Hi,

I have the following two models:

class AcceptedRoleAbstract(models.Model):
    '''
    Represents a User that should accept a role

    E.g.: Discussant, Reviewer
    '''
    user = models.ForeignKey(User)
    accepted = models.NullBooleanField(help_text=_("The reviewer
agreed to make the review"))
    updated = models.DateTimeField(auto_now=True)
    created = models.DateTimeField(auto_now_add=True)

class Discussant(AcceptedRoleAbstract):
    '''
    Represents a discussant
    '''
    submission = models.OneToOneField(Submission)

    class Meta:
        verbose_name = _('discussant')
        verbose_name_plural = _('discussants')

class Submission(models.Model):
    '''
    Represents a submitted paper with its author.
    '''
    presenter = models.OneToOneField(Attendee) # ForeignKey(Attendee,
help_text=_('Choose the attendee who will present the paper'))
    coauthors = models.TextField(blank=True, help_text=_('Coauthors
separated by commas (,)'))
    title = models.CharField(max_length=255, help_text=_('Presentation
title'))
    abstract = models.TextField(help_text=_('Abstract'))
    document = models.FileField(upload_to=get_submission_upload_to,
help_text=_('Uploaded version'))
    accepted = models.NullBooleanField(help_text=_('Accepted /
Rejected'))
    topic = models.ForeignKey(Topic)
    section = models.ForeignKey(Section, null=True, blank=True)
    updated = models.DateTimeField(auto_now=True)
    created = models.DateTimeField(auto_now_add=True)

and run this code in my test

        submission = models.Submission.objects.create
(**self.submission_data.copy())
        discussant = models.Discussant.objects.create(
                               user=User.objects.get(pk=2),
accepted=True,
                               submission=submission)

what gives my an "IntegrityError: PRIMARY KEY must be unique"

could someone enlighten me please how to assign do what I want
correctly?

thanks, Viktor

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

Reply via email to