Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9230757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:54:02+00:00 2026-06-18T05:54:02+00:00

I have a problem with my urls.py file in Django which allows me wherever

  • 0

I have a problem with my urls.py file in Django which allows me wherever to have access on my admin interface, wherever to load the images. If somebody could have a look over it, thanks in advance !

from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings

urlpatterns = patterns('',
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^admin/', include(admin.site.urls)),

    url(r'^admin/files/(?P<filepath>.*)$', 'my.app.admin.serv_backup_files', name='admin-file-serv'),


    (r'^(?P<restaurant_slug>[^(admin)][a-zA-B-_0-9]+)$', TemplateView.as_view(template_name=os.path.join(settings.G_DOC_ROOT, 'index.html'))),
    (r'^(?P<path>[^(admin)].*)$', 'django.views.static.serve', {'document_root': settings.G_DOC_ROOT}),
)

The problem is that with this configuration, I see on the console of the runserver, things like

“GET /img/field_bg.gif HTTP/1.1” 404

for all the images, that are supposed to be served statically.

I can remove the [^(admin)] from the last pattern and the site will be served well, except that it will try to reroute the admin interface to the static file.

Thanks in advance for helping me combining the static file, the subdomainless TemplateViewing and the admin normal access.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:54:03+00:00Added an answer on June 18, 2026 at 5:54 am

    I don’t know python regexes well, but in any other flavor I’ve ever used, [^(admin)] would match a single character which is anything except ‘(‘ OR ‘a‘ OR ‘d‘ OR ‘m‘ OR ‘i‘ OR ‘n‘ OR ‘)‘. A character class ([...]) matches a single character, not a phrase.

    If you are trying to NOT match “(admin)”, then you can use a negative lookahead like so:

    ^(?P<restaurant_slug>(?!\(admin\))[a-zA-B-_0-9]+)$
    

    Or, more likely, you are trying to not match “admin”:

    ^(?P<restaurant_slug>(?!admin)[a-zA-B-_0-9]+)$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple set of urls in a Django url conf file which
I'm using django on nginx with FastCGI and i have a problem with urls.py
I have this problem where all URLs like context/path/file/anything/that/follows becomes context/path/file.php/anything/that/follows or context/path/file.xml/anything/that/follows .
This is my problem now, have a Django project named 'personal' with an urls.py
We have a website made by Django. And there is no problem when access
I have a problem with long urls in the context of video streaming via
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
I have problem with UIWebView delay when the load image from url. In my
I am making a Django app which allows users to upload pictures via the
I have a django project in which a user will type in a url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.