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

  • Home
  • SEARCH
  • 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 7097817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T10:58:58+00:00 2026-05-28T10:58:58+00:00

I’m wondering if restructuring my apps’ urlconfs with several nested pattern groups will provide

  • 0

I’m wondering if restructuring my apps’ urlconfs with several nested pattern groups will provide a performance boost for when Django looks for a request-matching pattern. I’m not sure on how to test the performance, but I’ve tried it out and the new version works at least.

I know that if there is a performance boost, it may as well be negligible. I only started doing this to see if the patterns would be easier to look at as a tree; I’m more worried about screwing things up than boosting speed.

The following is an app’s urlconf that is included by the master urlconf at /appname/.

Old urlconf:

from django.contrib.auth.decorators import login_required
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to

from appname import views

urlpatterns = patterns('',
    # Actions on sets of reports
    url(r'^reports/page(?P<page>[0-9]+)/$', login_required(views.appnameListView.as_view())),
    url(r'^reports/bill/', views.bill),

    # Actions on individual reports
    url(r'^report/new/', views.new),
    url(r'^report/(?P<reportNumber>[^/]+)/$', views.detail),
    url(r'^report/(?P<reportNumber>[^/]+)/delete/$', views.delete),
    url(r'^report/(?P<reportNumber>[^/]+)/edit/$', views.edit),
    url(r'^report/(?P<reportNumber>[^/]+)/print/$', views.detail_print),
    # url(r'^report/(?P<reportNumber>[^/]+)/pdf/$', views.detail_pdf),

    # Configure app settings
    url(r'^config/$', views.configure),
    url(r'^config/reporttype/(?P<id>[^/]+)/$', views.configure_ReportType),
    url(r'^config/reporttype/(?P<id>[^/]+)/delete/$', views.configure_ReportType_delete),
    url(r'^config/avgmethod/(?P<name>[^/]+)/$', views.configure_AvgMethod),
    url(r'^config/avgmethod/(?P<name>[^/]+)/delete/$', views.configure_AvgMethod_delete),
    url(r'^config/datatransformer/(?P<name>[^/]+)/$', views.configure_DataTransformer),
    url(r'^config/datatransformer/(?P<name>[^/]+)/delete/$', views.configure_DataTransformer_delete),

    # Catch all; #TODO: 404
    url(r'^', redirect_to, {'url': '/appname/reports/page1/'}),
)

New urlconf:

from django.contrib.auth.decorators import login_required
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to

from appname import views

urlpatterns = patterns('',
    # Actions on sets of reports
    url(r'^reports/', include(patterns('',
        url(r'^page(?P<page>[0-9]+)/$', login_required(views.appnameListView.as_view())),
        url(r'^bill/', views.bill),
    ))),

    # Actions on individual reports
    url(r'^report/', include(patterns('',
        url(r'^new/', views.new),
        url(r'^(?P<reportNumber>[^/]+)/$', views.detail),
        url(r'^(?P<reportNumber>[^/]+)/delete/$', views.delete),
        url(r'^(?P<reportNumber>[^/]+)/edit/$', views.edit),
        url(r'^(?P<reportNumber>[^/]+)/print/$', views.detail_print),
        # url(r'^(?P<reportNumber>[^/]+)/pdf/$', views.detail_pdf),
    ))),

    # Configure app settings
    url(r'^config/', include(patterns('',
        url(r'^$', views.configure),
        url(r'^reporttype/(?P<id>[^/]+)/$', views.configure_ReportType),
        url(r'^reporttype/(?P<id>[^/]+)/delete/$', views.configure_ReportType_delete),
        url(r'^avgmethod/(?P<name>[^/]+)/$', views.configure_AvgMethod),
        url(r'^avgmethod/(?P<name>[^/]+)/delete/$', views.configure_AvgMethod_delete),
        url(r'^datatransformer/(?P<name>[^/]+)/$', views.configure_DataTransformer),
        url(r'^datatransformer/(?P<name>[^/]+)/delete/$', views.configure_DataTransformer_delete),
    ))),

    # Catch all; #TODO: 404
    url(r'^', redirect_to, {'url': '/appname/reports/page1/'}),
)

I could go even further (4 of the 5 variables checked for with regex are defined at least twice), but I worry about losing the original benefit of readability.

  • 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-05-28T10:58:58+00:00Added an answer on May 28, 2026 at 10:58 am

    If you do not want to reapeat yourself and follow the DRY-principle, which is sometimes incorporated a lot when developing django code, you should group your urls. So you will reduce the amount duplicate code and produce code that is much easier to maintain. Think for example about the fact, that later on you may want to change the report/ urls to something else, you would have to do it for every single url then!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.