4👍
Nothing particular happens when you add an app to INSTALLED_APPS, but the main thing that affects you is that its views are checked when you call reverse()
.
The way reverse works is to import all the views in the project, and see which ones match the URL name you have given. However, it is quite fragile, and if any of the views cause an error for some reason, or can’t be imported, the reverse
call will fail.
The fact that it is only failing once you include app2 indicates that there is an issue with the views in app2 somewhere. Try importing them individually from the shell and see what errors you get.
Edited after update Thanks for the extra detail. I have seen this before in my own code. It is probably because the admin files are being imported before the urlconf is processed, so this reverse gives an error. Try moving the admin.autodiscover()
line down to the very bottom of urls.py, so that it is the last line in that file.
0👍
Without seeing the code, it’s hard to say for sure, but I would guess that the urls.py
of app_1 and app_2 contain the same name for different urls, e.g.:
app_1/urls.py:
...
url(r'^app_1/foo/$', 'app_1.views.foo', name='foo')
...
app_2/urls.py:
...
url(r'^app_2/foo/$', 'app_2.views.foo', name='foo')
...
If you clean up those names (the most common convention I’ve seen is appname_viewname
) it should start working.
- [Django]-Django on Google App Engine: cannot upload images
- [Django]-Have a problem using Django 2.2 with PyMySQL
- [Django]-Converting only one entry of django model object to json
- [Django]-How merge two querysets from same model without ordering them
- [Django]-Adding many to many fields (M2M) manually in django?