Ahmad Ajmi
Ahmad Ajmi

Reputation: 7281

Django url conflict

I want to set the url for a user to be example.com/user not example.com/u/user but when I try to open example.com/admin it conflict.

So I don't want to add extra pattern to the url, just the username after /. Is that possible

So

url(r'^u/', include('profiles.urls')),
url(r'^admin/', include(admin.site.urls)),

will be

url(r'', include('profiles.urls')),
url(r'^admin/', include(admin.site.urls)),

Upvotes: 0

Views: 852

Answers (1)

Robert
Robert

Reputation: 6540

Posting this as the answer since it apparently worked (see comment to question)... urls are pattern-matched in order, so if admin/ is first, it matches and you go to the admin page. Only if the pattern doesn't match 'admin/' does it match the users.

Upvotes: 1

Related Questions