8👍
You must have a
__init__.py
file inside your “myproject” directory. When you say:
(r'^myapp1/', include('myproject.myapp1.urls'))
you are saying “myproject” (as well as myapp1) is a python packege.
5👍
In myproject.settings make following changes :
INSTALLED_APPS = (
[..]
'myapp1',
'myapp2',
'myapp3',
)
1👍
Try:
urlpatterns = [
...
url(r'^app_name/', include('app_name.urls', namespace='project_name'))
...
]
- How to specify long url patterns using Regex so that they follow PEP8 guidelines
- How to properly runserver on different settings for Django?
- How to unit test Django-CMS extensions?
- Web visitor statistics for Django?
0👍
Does ROOT_URLCONF
need to point to myproject.urls
?
If you place your apps inside of myproject
you need to use the proper view prefix.
urlpatterns = patterns('myproject.myapp1',
...
- How to pass data between django views
- Moving django apps into subfolder and url.py error
- Django – Template objects access verbose name
0👍
To solve this issue just select “myproject” directory in PyCharm and set this as a source root.
Your project don’t know from which root it has to search for given app.
It fixed the issue for me.
Thank you.
- Request.FILES always empty on file upload
- Django's "dumpdata" or Postgres' "pg_dump"?
- How to avoid n+1 select in Django?
- Django, Apache2 on Google Kubernetes Engine writing Opencensus Traces to Stackdriver Trace
- Django form with fields from two different models
0👍
Recently, In new versions of Django introduces path(route, view, kwargs=None, name=None)
instead of old url()
regular expression pattern.
You must have __init__.py
file in app folders to recognize it as a package by django project i.e myproject
Django project i.e. myproject urls.py file must be updated to include examples like:
path('', include('django_app.urls'))
path('url_extension/', include('django_another_app.urls'))
Above example includes two apps urls in it. One is without adding any extension to path in url and another is with extension to path in current url.
Also, Do not forget to add django apps in INSTALLED_APPS
in settings.py
file to recognise it as app by django project something like this.
ROOT_URLCONF = 'myproject.urls'
INSTALLED_APPS = [
...
django_app,
django_another_app
...
]
For more information look at documentation.