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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:35:00+00:00 2026-05-13T11:35:00+00:00

I’m trying to use one app to satisfy multiple url paths. That is to

  • 0

I’m trying to use one app to satisfy multiple url paths. That is to say, I want the url /blog/ and /job/ to use the same app, but different views. There are a number of ways to do this I’m sure, but none of them seem very clean. Here’s what I’m doing right now

# /urls.py
urlpatterns = patterns("",
    (r"^(blog|job)/", include("myproject.myapp.urls")),
)

# /myapp/urls.py
urlpatterns = patterns("myproject.myapp.views",
    (r"^(?P<id>\d+)/edit/$",    "myproject.myapp.views.edit"),
    (r"^(?P<id>\d+)/delete/$",  "myproject.myapp.views.delete"),
    (r"^(?P<id>\d+)/update/$",  "myproject.myapp.views.update"),
    (r"^insert/$",              "myproject.myapp.views.insert"),
)

urlpatterns += patterns("",
    (r"^(?P<object_id>\d+)/$",  "django.views.generic.list_detail.object_detail", info_dict, "NOIDEA-detail"),
    (r"^/$",                    "django.views.generic.list_detail.object_list",   info_dict, "NOIDEA-community"),
)

# /myapp/views.py
def edit(request, type, id):
    if (type == "blog"):
        editBlog(request, id)
    else (type == "job")
        editJob(request, id)

def editBlog(request, id):
    # some code

def editJob(request, id):
    # some code

I’ve ended up breaking all of this into multiple model and view files to make the code cleaner but the above example doesn’t account for things like reverse url lookups which breaks all of my template {% url %} calls.

Originally, I had blogs, jobs, events, contests, etc all living in their own apps, but all of their functionality is so similar, that it didn’t make sense to leave it that way, so I attempted to combine them… and this happened. You see those “NOIDEA-detail” and “NOIDEA-community” url names on my generic views? Yeah, I don’t know what to use there 🙁

  • 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-13T11:35:00+00:00Added an answer on May 13, 2026 at 11:35 am

    You can have more than one modules defining URLs. You can have /blog/ URLs in myapp/urls.py and /job/ URLs in myapp/job_urls.py. Or you can have two modules within a urls subpackage.

    Alternatively you can manually prefix your url definitions:

    urlpatterns = patterns("myproject.myapp.views",
        (r"^jobs/(?P<id>\d+)/edit/$",    "myproject.myapp.views.edit"),
        (r"^jobs/(?P<id>\d+)/delete/$",  "myproject.myapp.views.delete"),
        (r"^jobs/(?P<id>\d+)/update/$",  "myproject.myapp.views.update"),
        (r"^jobs/insert/$",              "myproject.myapp.views.insert"),
    )
    
    urlpatterns += patterns("",
        (r"^blog/(?P<object_id>\d+)/$",  "django.views.generic.list_detail.object_detail", info_dict, "NOIDEA-detail"),
        (r"^blog/$",                    "django.views.generic.list_detail.object_list",   info_dict, "NOIDEA-community"),
    )
    

    And then mount them as:

    urlpatterns = patterns("",
        (r"", include("myapp.urls")),
    )
    

    Personally I would go for more RESTful URL definitions though. Such as blog/(?P<post_id>\d+)/edit/$.

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

Sidebar

Related Questions

i want to parse a xhtml file and display in UITableView. what is the
I need to clean up various Word 'smart' characters in user input, including but
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.