Le 3 avr. 2010 à 23:37, Fredrik <frecarl...@gmail.com> a écrit :

What I want is to "automatic" add an owner to every object..

Is there another way to accomplish the same?

I see. I have had a similar problem. I have tried a similar solution with exactly the same effect. I could have add manualy a foreignkey to each class with a proper related_name. At this point, i realised that it will be an huge load for the database and I have simplified my authorization design. I have deeply look to an app called 'namespace' but it don't fit to my need (but perhaps it could fit yours ?). Now it work with a simple authorization function applied on the queryset when i populate my forms.

Thierry

Fredrik


On Apr 3, 10:48 pm, Thierry Chich <thierry.ch...@gmail.com> wrote:
I think that if you want make inheritance it is because you want to
have others subclasses. But then, your related name will be same for
all the subclasses.
There is no solution with the stable version. In the dev version, it
is possible to add the origin class name in the related_name. It is
documented, but i don't remember where exactly.

Thierry

Le 3 avr. 2010 à 20:38, Fredrik <frecarl...@gmail.com> a écrit :

Hi,
I want to use it like this:

"""
class PersistentModel(models.Model):
   deleted = models.BooleanField(default = False)
   date_created = models.DateTimeField(default=datetime.now)
   date_edited = models.DateTimeField(default=datetime.now)
   owner = models.ForeignKey(User)

class Contacts(PersistentModel):
       full_name = models.CharField("Fullt navn", max_length=20)
       address = models.CharField("Adresse", max_length=50)
       phone = models.CharField("Telefon", max_length=20)
       email = models.EmailField("Epost", max_length=50)

       def __unicode__ (self):
           return self.full_name
"""

But it creates errors,
" Reverse query name for field 'owner' clashes with field
'User.email'. Add a related_name argument to the definition for
'owner'.

But if I try to add related_name to owner, then I get a lot of errors
like this:

"""
contacts.contacts: Accessor for field 'owner' clashes with related
field 'User.Owner'. Add a related_name argument to the definition for
'owner'.
contacts.contacts: Reverse query name for field 'owner' clashes with
related field 'User.Owner'. Add a related_name argument to the
definition for 'owner'.
contacts.contacts: Accessor for field 'owner' clashes with related
field 'User.Owner'. Add a related_name argument to the definition for
'owner'.
contacts.contacts: Reverse query name for field 'owner' clashes with
related field 'User.Owner'. Add a related_name argument to the
definition for 'owner'.
contacts.contacts: Accessor for field 'owner' clashes with related
field 'User.Owner'. Add a related_name argument to the definition for
'owner'.
contacts.contacts: Reverse query name for field 'owner' clashes with
related field 'User.Owner'. Add a related_name argument to the
definition for 'owner'.
contacts.contacts: Accessor for field 'owner' clashes with related
field 'User.Owner'. Add a related_name argument to the definition for
'owner'.
"""

Hopefully, someone can help me out :)

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

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


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

Reply via email to