Skip to content

Commit 47cc44b

Browse files
committed
Add Question and Choice model
1 parent b30c349 commit 47cc44b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

polls/admin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from django.contrib import admin
2+
from polls.models import Question, Choice
23

3-
# Register your models here.
4+
admin.site.register(Question)
5+
admin.site.register(Choice)

polls/models.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
from django.db import models
22

3-
# Create your models here.
3+
4+
class Question(models.Model):
5+
question_text = models.CharField(max_length=200)
6+
pub_date = models.DateTimeField('date published')
7+
8+
def __unicode__(self): # __str__ on Python 3
9+
return self.question_text
10+
11+
12+
class Choice(models.Model):
13+
question = models.ForeignKey(Question)
14+
choice_text = models.CharField(max_length=200)
15+
votes = models.IntegerField(default=0)
16+
17+
def __unicode__(self):
18+
return self.choice_text

0 commit comments

Comments
 (0)