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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:15:29+00:00 2026-05-10T19:15:29+00:00

I have a Django model with a large number of fields and 20000+ table

  • 0

I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:

/browse/<name1>/<value1>/<name2>/<value2>/ .... etc .... 

where ‘name’ maps to a model attribute and ‘value’ is the search criteria for that attribute. Each ‘name’ will be treated like a category to return subsets of the model instances where the categories match.

Now, this could be handled with GET parameters, but I prefer more readable URLs for both the user’s sake and the search engines. These URLs subsets will be embedded on each page that displays this model, so it seems worth the effort to make pretty URLs.

Ideally each name/value pair will be passed to the view function as a parameter named name1, name2, etc. However, I don’t believe it’s possible to defined named patterns via a regex’s matched text. Am I wrong there?

So, it seems I need to do something like this:

urlpatterns = patterns('',     url(r'^browse/(?:([\w]+)/([\w]+)/)+$', 'app.views.view', name='model_browse'), ) 

It seems this should match any sets of two name/value pairs. While it matches it successfully, it only passes the last name/value pair as parameters to the view function. My guess is that each match is overwriting the previous match. Under the guess that the containing (?:…)+ is causing it, I tried a simple repeating pattern instead:

urlpatterns = patterns('',     url(r'^browse/([\w]+/)+$', 'app.views.view', name='model_browse'), ) 

… and got the same problem, but this time *args only includes the last matched pattern.

Is this a limitation of Django’s url dispatcher, and/or Python’s regex support? It seems either of these methods should work. Is there a way to achieve this without hardcoding each possible model attribute in the URL as an optional (.*) pattern?

  • 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. 2026-05-10T19:15:30+00:00Added an answer on May 10, 2026 at 7:15 pm

    A possibility that you might consider is matching the entire string of possible values within the url pattern portion and pull out the specific pieces within your view. As an example:

    urlpatterns = patterns('',     url(r'^browse/(?P<match>.+)/$', 'app.views.view', name='model_browse'), )  def view(request, match):     pieces = match.split('/')     # even indexed pieces are the names, odd are values     ... 

    No promises about the regexp I used, but I think you understand what I mean.

    (Edited to try and fix the regexp.)

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Generally speaking, an entity is an abstract concept that's typically… May 11, 2026 at 11:22 am
  • added an answer You can use CSS or the :size option to control… May 11, 2026 at 11:22 am
  • added an answer It definitely looks like a bug in the view merging… May 11, 2026 at 11:22 am

Related Questions

I have a Django model with a large number of fields and 20000+ table
I have worked a bit with Django and I quite like its project/applications model
I stumbled over this passage in the Django tutorial : Django models have a
I'm working on a blog application in Django. Naturally, I have models set up
I have a web report that uses a Django form (new forms) for fields
If I have a Django form such as: class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message
I have written a Django app that makes use of Python threading to create
I have a pretty standard django app, and am wondering how to set the
I have a medium sized Django project, (running on AppEngine if it makes any
I have done a little Django development, but it has all been in a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.