Opened 4 years ago

Closed 4 years ago

#19330 closed Bug (needsinfo)

change model instance with unique_together using modelform

Reported by: molavy Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords: modelform, unique_together, instance, save, change
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Claude Paroz)

I have Problem on changing a model with modelform and instance
model form return form validate error:
user with this title already exist


class Tag(models.Model):
    user = models.ForeignKey(User)
    title = models.CharField(max_length=765)
    create_time = models.DateTimeField(null=True, blank=True)
    status = models.IntegerField(null=True, blank=True)
    color = models.CharField(max_length=765, blank=True)
    cnt_member = models.IntegerField(null=True, blank=True)
    cnt_items = models.IntegerField(null=True, blank=True)
    def __unicode__(self):
        return self.title+ " || "+self.user.username
    class Meta:
        db_table = u'tbl_tag'


class Tagform(forms.ModelForm):
    class Meta:
        exclude = ('status','create_time')


def change_tag_title(request):
    if request.POST and request.is_ajax():
        cur_form=Tagform(data=cur_req, instance=cur_tag)
        if cur_form.is_valid():

Change History (3)

comment:1 Changed 4 years ago by molavy

db :sqlite

comment:2 Changed 4 years ago by Claude Paroz

Description: modified (diff)

Please use preview and proper formatting.

comment:3 Changed 4 years ago by Claude Paroz

Resolution: needsinfo
Status: newclosed

I'm afraid we have not enough information in the ticket description to assume that there is a bug in Django. Please try to debug the problem a little further and tell us why you think the problem is in Django and not in your code.

Note: See TracTickets for help on using tickets.
Back to Top