Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unique names in INSTALLED_APPS Django limitation

Django docs says:

the final dotted part of the path to the module defined in INSTALLED_APPS must be unique

I'm developing a CMS based on Django. And here comes the problem: the moment will come when two 3rd-party developers create two different apps with the same name.

Why is it so? Is there any possibility to overcome this limitation?

like image 351
kolypto Avatar asked Nov 28 '25 21:11

kolypto


2 Answers

For the time being, the only solution is to use unique application names. This is a known limitation which is currently being worked on.

For reference, it was one of the accepted projects during the 2010 Google Summer of Code by Arthur Koziel, and you can see some of the background and design considerations on Django's 2010 GSOC wiki page.

My current understanding is that Arthur's work was largely successful, but due to concerns about making the 1.3 release a feature-light/bugfix-heavy release it was decided to delay merging the app loading refactor branch into trunk until the 1.4 development cycle.

like image 77
Gabriel Hurley Avatar answered Dec 01 '25 12:12

Gabriel Hurley


That is mainly because Django uses the last part as "app_label" property in some places.

For example, someModel._meta.app_label can be used in a multi-database scenario in order to decide to which database a model instance is stored. It's also used for the management commands (you must type "manage.py sqlall sites" instead of "django.contrib.sites").

How to work around this limitation? Well, I think app renaming should work if the app doesn't depend on its name in any way. But most apps actually use the app name in URLconf, for example (patterns("appname.views", ...)), so that would have to be changed, too.

But seriously, why would one install two apps with the same name? If they really have the same name, they usually have the same functionality (e.g. apps called "pagination"), so there's no need to use more than one.

like image 38
AndiDog Avatar answered Dec 01 '25 10:12

AndiDog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!