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 683653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:43:51+00:00 2026-05-14T01:43:51+00:00

I am trying to refactor out my application a little bit to keep it

  • 0

I am trying to refactor out my application a little bit to keep it from getting too unwieldily. So I started to move some of the urlpatterns out to sub files as the documentation proposes.

Besides that fact that it just doesn’t seem to be working (the items are not being rerouted) but when I go to the admin, it says that ‘urlpatterns has not been defined’.

The urls.py I have at the root of my application is:

if settings.ENABLE_SSL:
urlpatterns = patterns('',
    (r'^checkout/orderform/onepage/(\w*)/$','checkout.views.one_page_orderform',{'SSL':True},'commerce.checkout.views.single_product_orderform'),
)
else:
    urlpatterns = patterns('',
    (r'^checkout/orderform/onepage/(\w*)/$','commerce.checkout.views.single_product_orderform'),
)

urlpatterns+= patterns('',
    (r'^$', 'alchemysites.views.route_to_home'),
    (r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')),
    (r'^/checkout/', include('commerce.urls')),
    (r'^/offers',include('commerce.urls')),
    (r'^/order/',include('commerce.urls')),
    (r'^admin/', include(admin.site.urls)),
    (r'^accounts/login/$',  login),
    (r'^accounts/logout/$', logout),
    (r'^(?P<path>.*)/$','alchemysites.views.get_path'),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),

The urls I have moved out so far are the checkout/offers/order which are all subapps of ‘commerce’ where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

order_info = {
'queryset': Order.objects.all(),
}


urlpatterns+= patterns('',


(r'^offers/$','offers.views.start_offers'),
(r'^offers/([a-zA-Z0-9-]*)/order/(\d*)/add/([a-zA-Z0-9-]*)/(\w*)/next/([a-zA-Z0-9-)/$','offers.views.show_offer'),
(r'^reports/orders/$', list_detail.object_list,order_info),
)

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I’m thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter http://www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering http://www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

  • 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-14T01:43:52+00:00Added an answer on May 14, 2026 at 1:43 am

    Have a look at the django docs for including other url confs. I think you might have misunderstood them. In particular

    Whenever Django encounters include(), it chops off whatever part of the URL matched up to that point and sends the remaining string to the included URLconf for further processing.

    As an example, you have

    (r'^/checkout/', include('commerce.urls')),
    (r'^/offers',include('commerce.urls')),
    (r'^/order/',include('commerce.urls')),
    

    This means that

    /checkout/offers/
    /offers/offers/
    /order/offers/
    

    will all match the url pattern (r'^offers/$','offers.views.start_offers') in commerce/urls.py.

    If you want to define a view for /checkout/ in commerce.py, you need to add the pattern

    (r'^$', 'path_to_your_view')
    

    because the /checkout/ part will be chopped off by the include()


    As, an aside:

    In /commerce/urls.py, use

    urlpatterns = patterns('',
        ...
    

    for the first patterns you define. You can then use urlpatterns += later in the same file.

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

Sidebar

Related Questions

For some time now I am trying to figure out how I can refactor
I am trying to refactor some delphi 7 code. One of the procedures I'd
I have the following code for adding to/extracting from Zip. I'm trying to refactor
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Never seen this before in ASP.NET development. I'm trying to refactor out 40 single-page
I am trying to refactor some code while leaving existing functionality in tact. I'm
I am trying to figure out how to refactor this LINQ code nicely. This
I'm trying to refactor a fairly hefty view function in Django. There are too
I'm trying to refactor a big tightly coupled application and trying to make it
I'm new to javascript and was trying to refactor some code, clearly there's something

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.