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):
> > name = ...
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 retrieved from the
> database.
>
> I
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
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
> "declarative" syntax to d
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 =
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 self.var, but rather just var? For
>> example:
>> im
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):
> question=models.CharField(max_length=200)
What you defi
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 :
> Hi
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):
> question=models.CharField(max_length=200)
>
> Should
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
10 matches
Mail list logo