Questions tagged [urlconf]
116 questions
                    
                    104
                    
            votes
                
                9 answers
            
        How to get the current url name using Django?
I have to build an url dynamically according to the current url. Using the {% url %} tag is the easiest way to do it, but I need the current url name to generate the new one dynamically. 
How can I get the url name attached to the urlconf that leads…
         
    
    
        Bite code
        
- 578,959
- 113
- 301
- 329
                    81
                    
            votes
                
                6 answers
            
        Including a querystring in a django.core.urlresolvers reverse() call
I'm trying to reverse a named URL and include a querystring in it. Basically, I've modified the login function, and I want to send ?next= in it.
Here's what I'm doing now: reverse(name) + "?next=" + reverse(redirect)
Here's what I'd like to do:…
         
    
    
        Brian Hicks
        
- 6,213
- 8
- 51
- 77
                    47
                    
            votes
                
                1 answer
            
        Django, name parameter in urlpatterns
I'm following a tutorial where my urlpatterns are:
urlpatterns = patterns('',
    url(r'^passwords/$', PasswordListView.as_view(), name='passwords_api_root'),
    url(r'^passwords/(?P[0-9]+)$', PasswordInstanceView.as_view(),… 
         
    
    
        Leonardo
        
- 4,046
- 5
- 44
- 85
                    23
                    
            votes
                
                2 answers
            
        Defining nested namespaces in a URLConf, for reversing Django URLs -- does anyone have a cogent example?
I have been trying to to figure out how to define a nested URL namespace (which look:like:this) in a Django URLConf. 
Before this, I figured out how to do a basic URL namespace and came up with this simple example snippet, containing what you might…
         
    
    
        fish2000
        
- 4,289
- 2
- 37
- 76
                    16
                    
            votes
                
                5 answers
            
        What is difference between instance namespace and application namespace in django urls?
I am referring https://www.webforefront.com/django/namedjangourls.html to understand django urlconfs. I have encountered terms instance namespace and application namespace. I know about namespaces in urlsconfs. But I don't know the difference…
         
    
    
        Mangu Singh Rajpurohit
        
- 10,806
- 4
- 68
- 97
                    13
                    
            votes
                
                4 answers
            
        Registering API in apps
With django-rest-framework I'm using the DefaultRouter
I want to provide APIs to several apps, so my question is can I do this in a django manner and put my router registrations in each app URLconf and have them appear either as one aggregate api or…
         
    
    
        rayjay
        
- 359
- 3
- 16
                    13
                    
            votes
                
                2 answers
            
        Django Url, Slug for Detail Page
I'm having trouble configuring my url to display a detail view. Clicking on this link: {{ blog.name }} shows blog.html, when I thought it would show blog-detail.html. There are no errors and the browser…
         
    
    
        Nick B
        
- 9,267
- 17
- 64
- 105
                    11
                    
            votes
                
                1 answer
            
        Using Django's new i18n_patterns: How to fall back to the default language specified in the settings module?
I'm using the new i18n_patterns of Django 1.4:
from django.conf.urls import patterns, include, url
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
admin.autodiscover()
urlpatterns += i18n_patterns('',
   …
         
    
    
        Armando Pérez Marqués
        
- 5,661
- 4
- 28
- 45
                    10
                    
            votes
                
                5 answers
            
        Why do some includes in Django need strings, and others variable names?
Referring to the Django Book, chapter 3:
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
    # Examples:
 …
         
    
    
        codyc4321
        
- 9,014
- 22
- 92
- 165
                    9
                    
            votes
                
                3 answers
            
        Django Pytest Test URL Based on Settings
I have an endpoint /docs in django that I only want to be visible when DEBUG = True in settings - otherwise, it should throw a 404. My setup looks like this
urls.py
urlpatterns = ...
if settings.DEBUG:
    urlpatterns += [
           …
         
    
    
        mjkaufer
        
- 4,047
- 5
- 27
- 55
                    8
                    
            votes
                
                1 answer
            
        Django: How to access URL regex parameters inside a middleware class?
I am working on a Django project on Google App Engine. I have a URL like:
http://localhost:8080/[company]/projects/project
Note that [company] is a URL parameter defined in my urls.py like:
(r'(^[a-zA-Z0-9-_.]*)/projects/project/(\d*)',…
         
    
    
        Muhammad Towfique Imam
        
- 1,351
- 10
- 16
                    8
                    
            votes
                
                1 answer
            
        Django, dynamic urlconfs, thread-safety
I need to dynamically generate urlpatterns based on data in the session in a thread-safe way.
I implemented this via a custom URLResolver that defers url resolving until later.  I do know about setting request.urlconf from a middleware; but there…
         
    
    
        Alydis
        
- 160
- 5
                    7
                    
            votes
                
                4 answers
            
        django - regex for optional url parameters
I have a view in django that can accept a number of different filter parameters, but they are all optional.  If I have 6 optional filters, do I really have to write urls for every combination of the 6 or is there a way to define what parts of the…
         
    
    
        imns
        
- 4,996
- 11
- 57
- 80
                    7
                    
            votes
                
                3 answers
            
        Django URLS, using a ? in the URL
I am trying to do some Django URL matching.
i want a few urls where i have http://mysite.com/base?sort=type1/, http://mysite.com/base?sort=type2/, etc.
I can't figure out how to URL match these expressions:  I'm very new to Django and never used Reg…
         
    
    
        codesw1tch
        
- 720
- 10
- 29
                    5
                    
            votes
                
                1 answer
            
        Serving different urlconfs in a single Django project
My question is about how to serve multiple urls.py (like urls1.py, urls2.py and so on)   files in a single Django project.   
I am using Win7 x64, django 1.4.1, python 2.7.3 and as a server django dev-server tool.
I have decided to use a method…
         
    
    
        Sergey Makhonin
        
- 350
- 3
- 13