Created
January 27, 2012 03:36
-
-
Save krisys/1686842 to your computer and use it in GitHub Desktop.
MVC 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
# models.py | |
class Person(models.Model): | |
firstname = models.CharField(max_length=30) | |
lastname = models.CharField(max_length=30) | |
# views.py | |
def list_view(request): | |
person_list = Person.objects.all() | |
return HttpResponse('template.html', {'persons': person_list} ) | |
# template.html | |
''' | |
<html> | |
<table> | |
<tr><th>First Name</th><th>Last Name</th> | |
{% for person in persons %} | |
<tr><td>{{person.firstname}} </td><td> {{person.lastname}}</td></tr> | |
{% endfor %} | |
</table> | |
</html> | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment