On Thu, Jul 26, 2012 at 12:20 AM, Felipe Sitta <musicpl...@gmail.com> wrote:

> I'm new to programming and I'm designing an demo website to get used to
> django, web and database stuff. It's about racetracks.
>
> The structure is the following:
> There's a menu with a link "Track List", it leads to a page with an
> country list each one as a link.
> Each link leads to an list with the racetracks from the respective
> country, and then clicking on a track name leads to a page with
> informations.
>
> So the links will be looking, for example, like this:
>
> localhost/Track List/United States/Indianapolis Motor Speedway
>
>
> Everything's fine until "United States" when I click the track name it
> ignores the view function that creates the track information layout,
> instead of this, it recalls the country list view (which pops an error
> since data is different on the layout)
>
> I messed up with the code and figured that the problem is with the urls
> patterns. Here are the codes:
>
> the url patterns from urls.py
>     url(r'^Track List/(?P<countryList_countryName>(.*)\w+)/$'
> ,'tracks.views.trackList'),
>     url(r'^Track
> List/(?P<countryList_countryName>(.*)\w+)/(?P<track_name>)/$'
> ,'tracks.views.track'),
>

Get rid of the (.*) in those url regular expressions. That's matching
anything at all, including '/Indianapolis Motor Speedwa', then the y
matches \w and presumably the url ends with a slash at the end of the
string. urlpatterns are processed in order with first match begin taken, so
anything that that starts with 'Track List' and ends with an alphnumeric
(\w+) and a slash is matching the first url pattern and being routed to
the trackList view.

(Once you get to the point where the 2nd pattern is matched you'll have a
problem since that url captures two parameters for the view but the view
itself is only defined to expect one.)

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to