getting templates to do something
This commit is contained in:
parent
4064634c61
commit
f281b4a54b
|
@ -3,6 +3,9 @@ from django.db import models
|
||||||
|
|
||||||
class Drinker(models.Model):
|
class Drinker(models.Model):
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return unicode(self.name)
|
||||||
|
|
||||||
name = models.CharField(max_length=123)
|
name = models.CharField(max_length=123)
|
||||||
|
|
||||||
code = models.CharField(max_length=128)
|
code = models.CharField(max_length=128)
|
||||||
|
@ -12,6 +15,9 @@ class Drinker(models.Model):
|
||||||
|
|
||||||
class Drink(models.Model):
|
class Drink(models.Model):
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return unicode(self.name)
|
||||||
|
|
||||||
name = models.CharField(max_length=123)
|
name = models.CharField(max_length=123)
|
||||||
|
|
||||||
code = models.CharField(max_length=23)
|
code = models.CharField(max_length=23)
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}{{ heading }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ heading }}</h1>
|
||||||
|
|
||||||
|
{% for drinker in drinkers %}
|
||||||
|
<h2>
|
||||||
|
<a href="/user/{{ drinker.code }}">
|
||||||
|
{{ drinker.name }}
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,9 @@
|
||||||
|
from django.conf.urls import patterns, include, url
|
||||||
|
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
# Examples:
|
||||||
|
# url(r'^$', 'matemat.views.home', name='home'),
|
||||||
|
# url(r'^blog/', include('blog.urls')),
|
||||||
|
|
||||||
|
(r'.*$', 'matecnt.views.checkout'),
|
||||||
|
)
|
|
@ -5,11 +5,13 @@ from django.template import RequestContext, loader
|
||||||
|
|
||||||
from matecnt.models import Drinker, Drink
|
from matecnt.models import Drinker, Drink
|
||||||
|
|
||||||
def index(request):
|
def checkout(request):
|
||||||
|
#drinkers = Drinker.objects.all()
|
||||||
drinkers = Drinker.objects.order_by('credit')[:5]
|
drinkers = Drinker.objects.order_by('credit')[:5]
|
||||||
template = loader.get_template('base.html')
|
template = loader.get_template('checkout.html')
|
||||||
|
|
||||||
context = RequestContext(request, {
|
context = RequestContext(request, {
|
||||||
|
'heading': 'It does work.',
|
||||||
'drinkers': drinkers,
|
'drinkers': drinkers,
|
||||||
})
|
})
|
||||||
return HttpResponse(template.render(context))
|
return HttpResponse(template.render(context))
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import patterns, include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from matecnt import urls as matecnt_urls
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
# Examples:
|
url(r'^checkout/', include(matecnt_urls)),
|
||||||
# url(r'^$', 'matemat.views.home', name='home'),
|
|
||||||
# url(r'^blog/', include('blog.urls')),
|
|
||||||
|
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
|
||||||
(r'^index\.html$', 'matecnt.views.index'),
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue