Re: Match multiple URLs to the same pattern

2015-07-17 Thread Derek
Yes; Django says pretty much this same thing "on the tin": "A view function, or *view* for short, is simply a Python function that takes a Web request and returns a Web response." ( https://docs.djangoproject.com/en/dev/topics/http/views/ ) (I think there *is* magic in Django; but its in the i

Re: Match multiple URLs to the same pattern

2015-07-16 Thread Mathew Byrne
Thanks, yes this is *exactly* what I'm after. I'm coming from other web frameworks where there is more "magic" around controllers/views so I was unsure about this solution, but in django it appears that a view is explicity just a function that transforms a request into a response. Thanks again

Re: Match multiple URLs to the same pattern

2015-07-14 Thread Bill Freeman
You will want a routing view, or a fallback cascade. In either case, make that urlpattern r'^([\w-]+)$'. You don't need to escape the - because it's the last char in the class. You don want to restrict the urls to those in which the entire url matches (^ and $), and the parentheses capture the s

Re: Match multiple URLs to the same pattern

2015-07-14 Thread Avraham Serour
What do you mean by flat URL structure? In any case you may have a controller called by the URL dispatcher that decides which view to use to process the request. No need to complicate on writing you own dispatcher replacement On Tue, Jul 14, 2015, 4:20 PM Mathew Byrne wrote: > I have an applic

Match multiple URLs to the same pattern

2015-07-14 Thread Mathew Byrne
I have an application that requires a flat URL structure for multiple different views. The single route r"^[\w\-]+" should start by looking at slugs for one Model class, and move onto a Category Model class if no match is found, then a Vendor model class, and lastly down to the flatpages app.