Vonfry
Vonfry

Reputation: 365

Django cannot redict some of urls with uwsgi

In project/urls.py which is the root urls.py .

urlpatterns = [
    url(r'^webadmin/', include('webadmin.urls')), # With templates and plain text for returning.
    url(r'^api/', include('restAPI.urls')), # Without templates. Only plain text for returning.
]

In webadmin/urls.py

urlpatterns = [
    url(r'^api/login/', views.login, name='login'),
    url(r'^api/search/', views.search, name='search'),
    url(r'^api/delProject/', views.delProject, name='delProject'),
    url(r'^api/addProject/', views.addProject, name='addProject'),
    url(r'^api/statistics/', views.statistics, name='statistics'),

    url(r'^(?P<action>(users|login|statistics|projects))/', views.index, name='webadmin'),
    url(r'^', views.index, name='index'),
]

All the url in restAPI are working correctly.

But in webadmin, all the url are redict to views.index.

For example, when I goto http://example.com/webadmin/api/login/, it will show http://example.com/webadmin/.

If I remove the last line url(r'^', views.index, name='index'), there is nothing changed.

If I use python3 manage.py runserver, it has rigth result.

My uwsgi ini is:

[uwsgi]
chdir=/var/www/project
wsgi-file=/var/www/project/project/wsgi.py
static-map = /static/=/var/www/project/static/
max-requests=5000
daemonize=/var/log/uwsgi/project.log
http = :8000
vacuum = true
master = true

Upvotes: 0

Views: 40

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

You need to add end of the line anchor $

url(r'^$', views.index, name='index'),

Upvotes: 1

Related Questions