shaping the urls

This commit is contained in:
Konstantin Martini 2015-01-03 00:24:57 +01:00
parent f281b4a54b
commit ff4093b61b
7 changed files with 47 additions and 11 deletions

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title %}{% endblock %}</title> <title>{{ heading }}</title>
</head> </head>
<body> <body>
{% block content %}{% endblock %} {% block content %}{% endblock %}

View File

@ -1,14 +1,12 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}{{ heading }}{% endblock %}
{% block content %} {% block content %}
<h1>{{ heading }}</h1> <h1>{{ heading }}</h1>
{% for drinker in drinkers %} {% for drink in drinks %}
<h2> <h2>
<a href="/user/{{ drinker.code }}"> <a href="/drink/{{ drink.code }}">
{{ drinker.name }} {{ drink.name }}
</a> </a>
</h2> </h2>
{% endfor %} {% endfor %}

View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ heading }}</h1>
{% for drink in drinks %}
<h2>
<a href="/drink/{{ drink.code }}">
{{ drink.name }}
</a>
</h2>
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ heading }}</h1>
{% for drinker in drinkers %}
<h2>
<a href="/drinker/{{ drinker.code }}">
{{ drinker.name }}
</a>
</h2>
{% endfor %}
{% endblock %}

View File

@ -5,5 +5,7 @@ urlpatterns = patterns('',
# url(r'^$', 'matemat.views.home', name='home'), # url(r'^$', 'matemat.views.home', name='home'),
# url(r'^blog/', include('blog.urls')), # url(r'^blog/', include('blog.urls')),
(r'.*$', 'matecnt.views.checkout'), #(r'.*$', 'matecnt.views.overview'),
(r'users/.*$', 'matecnt.views.users'),
(r'drinks/.*$', 'matecnt.views.drinks'),
) )

View File

@ -5,13 +5,23 @@ from django.template import RequestContext, loader
from matecnt.models import Drinker, Drink from matecnt.models import Drinker, Drink
def checkout(request): def users(request):
#drinkers = Drinker.objects.all() #drinkers = Drinker.objects.all()
drinkers = Drinker.objects.order_by('credit')[:5] drinkers = Drinker.objects.order_by('credit')[:5]
template = loader.get_template('checkout.html') template = loader.get_template('users.html')
context = RequestContext(request, { context = RequestContext(request, {
'heading': 'It does work.', 'heading': 'User list',
'drinkers': drinkers, 'drinkers': drinkers,
}) })
return HttpResponse(template.render(context)) return HttpResponse(template.render(context))
def drinks(request):
drinks = Drink.objects.order_by('prize')
template = loader.get_template('drinks.html')
context = RequestContext(request, {
'heading': 'Drink list',
'drinks': drinks,
})
return HttpResponse(template.render(context))

View File

@ -4,6 +4,6 @@ from django.contrib import admin
from matecnt import urls as matecnt_urls from matecnt import urls as matecnt_urls
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^checkout/', include(matecnt_urls)), url(r'^mate/', include(matecnt_urls)),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
) )