diff --git a/matecnt/models.py b/matecnt/models.py index 66c27f4..49512ff 100644 --- a/matecnt/models.py +++ b/matecnt/models.py @@ -3,6 +3,9 @@ from django.db import models class Drinker(models.Model): + def __unicode__(self): + return unicode(self.name) + name = models.CharField(max_length=123) code = models.CharField(max_length=128) @@ -12,6 +15,9 @@ class Drinker(models.Model): class Drink(models.Model): + def __unicode__(self): + return unicode(self.name) + name = models.CharField(max_length=123) code = models.CharField(max_length=23) diff --git a/matecnt/templates/checkout.html b/matecnt/templates/checkout.html new file mode 100644 index 0000000..e3e1891 --- /dev/null +++ b/matecnt/templates/checkout.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block title %}{{ heading }}{% endblock %} + +{% block content %} +

{{ heading }}

+ +{% for drinker in drinkers %} +

+ + {{ drinker.name }} + +

+{% endfor %} +{% endblock %} diff --git a/matecnt/urls.py b/matecnt/urls.py new file mode 100644 index 0000000..0ee53cc --- /dev/null +++ b/matecnt/urls.py @@ -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'), +) diff --git a/matecnt/views.py b/matecnt/views.py index 9644c94..b8a3d2e 100644 --- a/matecnt/views.py +++ b/matecnt/views.py @@ -5,11 +5,13 @@ from django.template import RequestContext, loader from matecnt.models import Drinker, Drink -def index(request): +def checkout(request): + #drinkers = Drinker.objects.all() drinkers = Drinker.objects.order_by('credit')[:5] - template = loader.get_template('base.html') + template = loader.get_template('checkout.html') context = RequestContext(request, { + 'heading': 'It does work.', 'drinkers': drinkers, }) return HttpResponse(template.render(context)) diff --git a/matemat/urls.py b/matemat/urls.py index 14d3de1..11ae66e 100644 --- a/matemat/urls.py +++ b/matemat/urls.py @@ -1,12 +1,9 @@ from django.conf.urls import patterns, include, url from django.contrib import admin +from matecnt import urls as matecnt_urls + urlpatterns = patterns('', - # Examples: - # url(r'^$', 'matemat.views.home', name='home'), - # url(r'^blog/', include('blog.urls')), - + url(r'^checkout/', include(matecnt_urls)), url(r'^admin/', include(admin.site.urls)), - - (r'^index\.html$', 'matecnt.views.index'), )