Re: curious about model classes

2011-03-04 Thread kost BebiX
On Thursday, March 3, 2011 5:33:56 PM UTC+2, bruno desthuilliers wrote: > > On 3 mar, 15:16, kost BebiX wrote: > > Yes, that's more a Python problem, not specifically django. > > > > You would normally do: > > > > class User(models.Model): > > def __init__(self): > >

Re: curious about model classes

2011-03-03 Thread bruno desthuilliers
On 3 mar, 19:05, Lorenzo Franceschini wrote: > On 03/03/2011 04:33 PM, bruno desthuilliers wrote: > I have a question about this point. > In one Django application I'm writing, I would like to programatically > add some attributes to a model instance when it's

Re: curious about model classes

2011-03-03 Thread Lorenzo Franceschini
On 03/03/2011 04:33 PM, bruno desthuilliers wrote: It has nothing to do with "looking cool" or anything like that. Using models.fields as class attributes in models class statement's body allow for the ORM to know what db fields and relations your table has - not what instance attributes a model

Re: curious about model classes

2011-03-03 Thread bruno desthuilliers
On 3 mar, 15:16, kost BebiX wrote: > Yes, that's more a Python problem, not specifically django. > > You would normally do: > > class User(models.Model): >     def __init__(self): >         name = ... > > but this looks not cool) That's why most of python libraries use >

Re: curious about model classes

2011-03-03 Thread kost BebiX
Yes, that's more a Python problem, not specifically django. You would normally do: class User(models.Model): def __init__(self): name = ... but this looks not cool) That's why most of python libraries use "declarative" syntax to describe models: class User(models.Model): name

Re: curious about model classes

2011-03-03 Thread Alex Hall
Thanks everyone. Looks like I have reading to do... On 3/3/11, bruno desthuilliers wrote: > > On 2 mar, 22:02, Alex Hall wrote: >> Hi all, >> Still working through that tutorial. I am just curious: why are none >> of the class variables called

Re: curious about model classes

2011-03-03 Thread bruno desthuilliers
On 2 mar, 22:02, Alex Hall wrote: > Hi all, > Still working through that tutorial. I am just curious: why are none > of the class variables called self.var, but rather just var? For > example: > import models > class Poll(models.Model): >  

Re: curious about model classes

2011-03-03 Thread Stefano
self in not a keyword in python, is only a convention for the first parameter for bound method. It refers to the instance of the class so you cannot use in the class definition. You should read something about "bound" and "unbound" methods in python. Hope this help S. 2011/3/2 Alex Hall

Re: curious about model classes

2011-03-03 Thread Sam Lai
On 3 March 2011 08:02, Alex Hall wrote: > Hi all, > Still working through that tutorial. I am just curious: why are none > of the class variables called self.var, but rather just var? For > example: > import models > class Poll(models.Model): >  

curious about model classes

2011-03-02 Thread Alex Hall
Hi all, Still working through that tutorial. I am just curious: why are none of the class variables called self.var, but rather just var? For example: import models class Poll(models.Model): question=models.CharField(max_length=200) Should that not be self.question=... instead? Otherwise, saying