Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with
something I thing should be easy but for some reason I can't find the
error.

I'm trying to define a model to manage shifts for volunteers. I have
three diferent models, Shifts, Users and Swaps. A User have many
Shifts and a Shift have many Swaps, while a Shift only have one User,
and a Swap only have one Shift. A Shift have two users. Well, then I
wrote something like this:


from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Shifts(models.Model):
    date = models.DateField()
    user_1 = models.ForeignKey(User)
    user_2 = models.ForeignKey(User)
    turno = models.IntegerField()

class Swaps(models.Model):
        origin_shift = models.ForeignKey(Shifts)
        origin_user = models.ForeignKey(User)
        destination_shift = models.ForeignKey(Shifts)
        state = models.CharField(maxlength=25)
        swap_user = models.ForeignKey(User)


Does anybody knows what I'm doing wrong? I get messages of validation
like this:

turno.shifts: Accessor for field 'user_1' clashes with related field
'User.shifts_set'. Add a related_name argument to the definition for
'user_1'.
turno.shifts: Accessor for field 'user_2' clashes with related field
'User.shifts_set'. Add a related_name argument to the definition for
'user_2'.
turno.swaps: Accessor for field 'origin_shift' clashes with related
field 'Shifts.swaps_set'. Add a related_name argument to the
definition for 'origin_shift'.
turno.swaps: Accessor for field 'origin_user' clashes with related
field 'User.swaps_set'. Add a related_name argument to the definition
for 'origin_user'.
turno.swaps: Accessor for field 'destination_shift' clashes with
related field 'Shifts.swaps_set'. Add a related_name argument to the
definition for 'destination_shift'.
turno.swaps: Accessor for field 'swap_user' clashes with related field
'User.swaps_set'. Add a related_name argument to the definition for
'swap_user'.

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to