Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does changing a django models related_name attribute require a south migration?

I have a simple django model with a ForeignKey

class FooModel(models.Model):
    foo = models.ForeignKey('Foo', related_name="foo_choices")
    bar = models.CharField(max_length=50)

The related_name attribute exists already, but I'd like to change it. Will this change require a migration of any kind? When I run the schemamigration management command after modifying the related_name I get the "Nothing seems to have changed" but I wanted to verify.

like image 619
Toran Billups Avatar asked Nov 05 '13 22:11

Toran Billups


1 Answers

No You do not need a migration.

Related name is the name to use for the relation from the related object back to this one (the reverse relationship).

related_name has nothing to do with the database. It is consumed by the Django's ORM to fetch queryset results, so you dont need a migration if you change the related_name attribute on a models' field.

Some additional documentation here on the usage of related_name

like image 163
karthikr Avatar answered Oct 11 '22 02:10

karthikr