All pastes #25552 Raw Edit

fawad

public text v1 · immutable
#25552 ·published 2005-10-15 04:45 UTC
rendered paste body
In [1]: from polls.models.polls import polls, choices

In [2]: p=polls.get_object(id__exact=1)

In [3]: p.add_choice(choice = 'Not much', votes = 0)
---------------------------------------------------------------------------
exceptions.AttributeError                            Traceback (most recent call last)

/home/fawad/code/python/django/apps/fawad/apps/<console>

AttributeError: 'Poll' object has no attribute 'add_choice'







from django.core import meta
import datetime

# Create your models here.
class Poll(meta.Model):
	question = meta.CharField(maxlength = 200)
	pub_date = meta.DateTimeField('date published')
	
	def __repr__ (self):
		return "Question: %s" % (self.question)
	
	def was_published_today(self):
		return self.pub_date == datetime.date.today()	

class Choice(meta.Model):
	poll = meta.ForeignKey(Poll)
	choice = meta.CharField(maxlength = 200)
	votes = meta.IntegerField()
	
	def __repr__(self):
		return "Choice: %s" % (self.choice)