Thursday, March 3, 2011

Re: curious about model classes

On 3 mar, 19:05, Lorenzo Franceschini
<lorenzo.franceschi...@gmail.com> 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 thought this would work:
>
> class Foo(models.Model):
>              bar = models.CharField(max_length=10)
>              def __init__(self, *args, **kwargs):
>                  super(Foo, self).__init__(self, *args, **kwargs)

You want:

super(Foo, self).__init__(*args, **kwargs)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment