I learned Django following django book and the document. In the django book exmaple, the project is called mysite and there’s an app called book inside this project. So in this case, the app is called “book”. I’ve no problem with it.
My confusion arises in front of reusable apps. Reusable apps usually reside outside the project. For example, django-registration only has an independent folder “registration”. So what’s its app name? “Registration”, right?
If that’s the case, isn’t there some inconsistency regarding the app naming? In the first case, app name seems to be a folder name (or sub package name) under the project while in the 2nd case, the app name is the top package name.
I know most of you will say “Why are you obssessed with app name? Just make sure the package structure is correct and django can run without problems.” Yes, in most case, app name is nothing but a name. Except in one occasion: specify AUTH_PROFILE_MODULE. As the document explains,
To indicate that this model is the
user profile model for a given site,
fill in the setting
AUTH_PROFILE_MODULE with a string
consisting of the following items,
separated by a dot:
- The name of the application (case
sensitive) in which the user profile
model is defined (in other words, the
name which was passed to manage.py
startapp to create the application).- The name of the model (not case
sensitive) class.
If I have a model as a user profile in a resuable package, I have to know the app name to correctly specify AUTH_PROFILE_MODULE.
Does django use certain path searching order to decide the app name?
The name of the app is the name of the directory, capitalization and all, unless you go to the extra work to change the name in the appropriate
__init__.pyfile. Django apps are, after all, just Python modules, and all the same rules apply.If you ever see an app or module name with different capitalization or other modifications, that doesn’t reflect the actual app or module name. Instead, what you’re seeing is the result of some “pretty-printing” that the Django admin app is known to do in some cases. This is for display only.