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.
* Attachment "bug.zip" added.
Old description:
> 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?
New description:
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?
Sample app that can reproduce the issue is attached.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27933#comment:1>
Old description:
> 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?
>
> Sample app that can reproduce the issue is attached.
New description:
Remove foreign key `b` and `unique_together` 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?
Sample app that can reproduce the issue is attached.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27933#comment:2>
* status: new => closed
* component: Uncategorized => Migrations
* resolution: => duplicate
* type: Uncategorized => Bug
Comment:
Looks like a duplicate of #26180.
--
Ticket URL: <https://code.djangoproject.com/ticket/27933#comment:3>