Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sat, May 18, 2013 at 10:22 PM, Dave Angel da...@davea.name wrote: The pub_date is probably an instance attribute of either the Poll class or the models.Model class. It should probably be defined in the appropriate __init__ method. In any case it's not a method attribute. Django uses

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
Thanks guys i had no idea about these method attributes and also these underlying oop __objects__ @ eryksun i understand your explanation, im still having trouble figuring out how django is being used in the tutorial. class Poll(models.Model): # ... def was_published_recently(self):

Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 6:35 AM, Matthew Ngaha chigga...@gmail.com wrote: if you look at the diagram under that function, why is the value of was_published_recently.short_description the title of that field? replacing the old title? is a short_desccription attribute set somewhere in django

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
The default description is the name with underscores removed, unless you set a custom description in the function's short_description attribute. I'm not experienced with Django, so I can't ramble off lots of examples, but hopefully you get the gist. Thanks that does clear it up. Also thats a

Re: [Tutor] model methods in Django

2013-05-19 Thread John Steedman
For the benefit of others,I believe the full class (from the Django Tutorial) is class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def was_published_recently(self): return self.pub_date = timezone.now() -

Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 7:20 AM, Matthew Ngaha chigga...@gmail.com wrote: Thanks that does clear it up. Also thats a huge script you linked, can options.py is the biggest module in the admin package. The link I posted is to the get_actions method of ModelAdmin. In the tutorial, PollAdmin extends

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def was_published_recently(self): return self.pub_date = timezone.now() - datetime.timedelta(days=1) #

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
options.py is the biggest module in the admin package. The link I posted is to the get_actions method of ModelAdmin. In the tutorial, PollAdmin extends this class. oh ok thanks, yes i will definately look through it I'm not coming from any framework. My knowledge of web development is

Re: [Tutor] model methods in Django

2013-05-19 Thread Steven D'Aprano
Matthew, who are you quoting? Your email program should automatically insert an attribution line, such as the one just below. Without that attribution line, it is hard to follow the conversation, as we can't tell who you are quoting. On 20/05/13 00:23, Matthew Ngaha wrote: class

Re: [Tutor] model methods in Django

2013-05-19 Thread Matthew Ngaha
On Sun, May 19, 2013 at 3:34 PM, Steven D'Aprano st...@pearwood.info wrote: Matthew, who are you quoting? Your email program should automatically insert an attribution line, such as the one just below. Without that attribution line, it is hard to follow the conversation, as we can't tell who

Re: [Tutor] model methods in Django

2013-05-19 Thread eryksun
On Sun, May 19, 2013 at 10:49 AM, Matthew Ngaha chigga...@gmail.com wrote: On Sun, May 19, 2013 at 3:34 PM, Steven D'Aprano st...@pearwood.info wrote: Matthew, who are you quoting? Your email program should automatically insert an attribution line, such as the one just below. Without that

[Tutor] model methods in Django

2013-05-18 Thread Matthew Ngaha
im following the official docs and after learning Python im sure of how methods work, but the model example on the beginners guide has me really confused. The model definition is omitted but can anyone explain how this methed (was_published_recently) is given these attributes: class

Re: [Tutor] model methods in Django

2013-05-18 Thread Dave Angel
On 05/18/2013 03:16 PM, Matthew Ngaha wrote: im following the official docs and after learning Python im sure of how methods work, but the model example on the beginners guide which official docs? URLs please? which beginners guide? URL please? has me really confused. I don't know