#27933: FieldDoesNotExist if remove foreign key and remove unique constraint at 
the
same time
-----------------------------------------+------------------------
               Reporter:  Jindi Wu       |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  1.10
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Remove foreign key b and unique_togetehr constraint from model like
 following:
 {{{
 class A(models.Model):
     name = models.CharField(max_length=10)
     b = models.ForeignKey('B')

     class Meta:
         unique_together = (('b','name'),)

 class B(models.Model):
     text = models.CharField(max_length=10)
 }}}

 -->

 {{{
 class A(models.Model):
     name = models.CharField(max_length=10)

     class Meta:
         unique_together = (('name'),)

 class B(models.Model):
     text = models.CharField(max_length=10)
 }}}

 Such error will be thrown.

 {{{
 raise FieldDoesNotExist('%s has no field named %r' % (self.object_name,
 field_name))
 django.core.exceptions.FieldDoesNotExist: A has no field named 'b'
 }}}

 However if swap the order of generated two operations within the migration
 AlterUniqueTogether and RemoveField, it'll work.

 Is this a bug or am I using Django the wrong way?

--
Ticket URL: <https://code.djangoproject.com/ticket/27933>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.7c71476a032948a12ec36a0c89376df3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to