wmorrell
wmorrell

Reputation: 5307

Namespace django app names

I have tried searching around for this, but searches including "django", "app", and "namespace" all bring up topics mostly relating to URLConf, not what I want to know.

In Django settings, apps included in a project are listed in the INSTALLED_APPS setting. Most community-released apps are not "namespaced" in that the app name consists of only letters, numbers, and underscores. There are official apps like "django.contrib.sites" that are "namespaced" with dot-syntax. What I cannot seem to find is: how do I do this? For example, if I want to create an app like "mycompany.app". The startapp command of manage.py does not allow naming like this if I try ./manage.py "mycompany.app", complaining of invalid characters.

So what Python and/or Django magic am I missing to create and use apps in this way? Or is there some reason why doing this is discouraged, and I should only make apps like "mycompany_app"?

Upvotes: 0

Views: 1003

Answers (1)

Andrew_Lvov
Andrew_Lvov

Reputation: 4668

Create a python package mycompany (i.e. folder with init.py file inside), inside create package app.

There is also namespace term in django urls, can be noticed in calls like reverse('namespace:view-name'), here is the doc for these: https://docs.djangoproject.com/en/1.7/topics/http/urls/#url-namespaces

Upvotes: 1

Related Questions