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(.*)\w+)/$','tracks.views.trackList'),
url(r'^Track
List/(?P(.*)\w+)/(?P)/$','tracks.views.track'),
the views
def trackList(request, countryList_countryName):
trackList=Track.objects.filter(country__startswith=countryList_countryName).order_by('name')
t=loader.get_template('trackList.html')
c=Context({'tracks':trackList})
return HttpResponse(t.render(c))
def track(request, track_name):
track=Track.objects.get(name=track_name)
t=loader.get_template('track.html')
c=Context({'track':track})
return HttpResponse(t.render(c))
I'd like to know what should I put on the url pattern to maintain the
current url and seek for the next part, the (?P) fragment.
Any help is welcome, thanks to all the community!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/kO2OolPX7YAJ.
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.