Created
March 14, 2012 18:07
-
-
Save debuggerpk/2038296 to your computer and use it in GitHub Desktop.
cascaded id passing in django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#url.py | |
urlpatterns = patterns('', | |
# Examples: | |
url(r'^$', 'djangocricket.Cricket.views.index', name='default'), | |
url(r'^user/(\w+)/$', 'djangocricket.Cricket.views.user_home', name='user home'), | |
url(r'^login/$', 'django.contrib.auth.views.login'), | |
url(r'^dashboard/$', 'djangocricket.Cricket.views.dashboard'), | |
url(r'^team/(\w+)/$', 'djangocricket.Cricket.views.team'), | |
url(r'^team/(<team_id>\d+)/player/(<player_id>\d+)', 'djangocricket.Cricket.views.player'), | |
# url(r'^djangocricket/', include('djangocricket.foo.urls')), | |
# Uncomment the admin/doc line below to enable admin documentation: | |
#url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | |
# Uncomment the next line to enable the admin: | |
url(r'^news/', 'djangocricket.cms.views.index', name='index'), | |
#url(r'^news/(?P<slug>[^\.]+).html', 'djangocricket.cms.views.detail', name='get_single_news_item'), | |
url(r'^admin/', include(admin.site.urls)), | |
) | |
#views.py | |
def player(request, team_id, player_id): | |
template = get_template('cricket/player.html') | |
loggedinuser = request.user | |
team = Team.objects.get(id=team_id) | |
player = Player.objects.get(id=player_id) | |
page_vars = Context({ | |
'loggedinuser': loggedinuser, | |
'team': team, | |
'player': player, | |
}) | |
output = template.render(page_vars) | |
return HttpResponse(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment