This is a continuation from my last question. created_by = models.ForeignKey(User)
I want to automatically use current logged in user as value. Can I put the code inside def save(self) for this model? I can't find anything about getting current user value from model. Thanks in advance. --Tirta -----Original Message----- From: "Tirta K. Untario" <tkunta...@yahoo.com> Date: Wed, 24 Dec 2008 01:39:20 To: <django-users@googlegroups.com> Subject: Model with 2 foreignkey to User Hi all, I'm developing a simple todo list. I use Django Auth for handling authentication. This is my models.py from django.contrib.auth.models import User class Item(models.Model): project = models.ForeignKey(Project) category = models.ForeignKey(Category) title = models.CharField(max_length=250, unique=True) priority = models.IntegerField(choices=PRIORITY_CHOICES, default=2) completed = models.BooleanField(default=False) created_at = models.DateTimeField(default=datetime.datetime.now) created_by = models.ForeignKey(User) assigned_to = models.ForeignKey(User) I have 2 fields from Item model that I want to relate with User model: 'created_by' and 'assigned_to'. This is the error message when I try to syncdb: Error: One or more models did not validate: todo.item: Accessor for field 'created_by' clashes with related field 'User.item_set'. Add a related_name argument to the definition for 'created_by'. todo.item: Accessor for field 'assigned_to' clashes with related field 'User.item_set'. Add a related_name argument to the definition for 'assigned_to'. If I use only 1 foreignkey, it works without error, i.e: created_by = models.ForeignKey(User) without assigned_to = models.ForeignKey(User) Can anyone help me to solve this problem? TIA. --Tirta --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---