开发者

django app with a generic name

开发者 https://www.devze.com 2022-12-24 16:21 出处:网络
Django tutorials everywhere use constant-set application name all around - in urls file, in HTML templates, in views. But if I want to distribute an开发者_StackOverflow中文版 application and let the u

Django tutorials everywhere use constant-set application name all around - in urls file, in HTML templates, in views. But if I want to distribute an开发者_StackOverflow中文版 application and let the user sets it name (i.e. its URL postfix on http://server.com/appname) - how can I do?

I must have some common name setting then in configuration, but how to work it for template files, etc?


The only thing that matters with reference to the URL is the app's urlconf. As long as you do your imports via the app's package, e.g. appname.models, appname.views, etc., all consumers of your app will have to do after installation is add it to their INSTALLED_APPS and include() it in their urlconf. Everything else will be found by Django provided they are in their default locations.

0

精彩评论

暂无评论...
验证码 换一张
取 消