Is there a naming convention for Django apps

Is there a preferred naming convention for creating a multi-word Django application? For example, which of the following options is preferable?

  • my_django_app
  • my-django-app Update: Not allowed syntactically
  • mydjangoapp Recommended Solution

While all of them may be , options 1 and 3 are syntactically resolved, is there any preference? Looking at how Django creates table names, combining the application name and the model name with underline, I am inclined to option No. 1.

Thoughts?

+62
django naming-conventions django-apps
Jun 23 2018-10-10T00:
source share
3 answers

They must be valid package names. This excludes 2 ("import my-django-app" will be a syntax error). PEP 8 says:

Modules must have short, all lowercase names. Underscores can be used in a module name if it improves readability. Python packages should also have short uppercase names, although using underscores is not recommended.

So 1 and 3 are valid, but 3 is the recommended approach.

+65
Jun 23 '10 at 13:12
source share

Application directory names must be a valid Python package name. This means that option 2 is completely invalid as the package name, although it can still be used for other purposes, such as documentation. In the end, it comes down to personal styles. If you prefer option 3, use it.

+3
Jun 23 2018-10-10T00:
source share

My votes are for 1 and 3, but you can check out several popular applications: http://www.django-cms.org/ http://geodjango.org/

-one
Jun 23 2018-10-10T00:
source share



All Articles