Saturday, August 4, 2012

Re: How to override an attribute?

> But assuming you just want to set up a default, and  be able to override it at will, you can always do:
> class Foo:
>    def default_name(self):
>       return 'Foo'
>    name = CharField(default=default_name)

> Class Bar(Foo):
>    def default_name(self):
>      return "Bar"

This looks right but I can't check it.

There is a class (let's call it Foo) which is a subclass of User.
Foo has the following line in its Meta:
proxy = True

When I try to validate my models this error appears:
django.core.exceptions.FieldError: Proxy model 'Foo' contains model fields.

I will get another error if I remove "proxy = True":

Error: One or more models did not validate:
app.foo: Accessor for field 'user_ptr' clashes with related field
'User.foo'. Add a related_name argument to the definition for
'user_ptr'.

I've read a doc page on inheritance but I don't know how to fix these errors.


Thanks

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate