Hello, I have the task of convert the project from django version 1.8.2 to 
version 1.11. Faced a problem with which I can not cope. That model of 
tables, which worked excellently in 1.8.2, stopped working in version 1.11, 
and falls out with an error:


    core.CarModel.manufacture: (models.E006) The field 'manufacture' 
clashes with the field 'manufacture' from model 'core.page'.


Apparently this is due to the inheritance of models, since the project is 
old I can not fundamentally change the scheme of tables, please tell me how 
to get out of this situation.

Thank you in advance for your help.


I have reproduced the scheme of models, which works fine on 1.8.2 and stops 
working on 1.11:



    # -*- coding:utf-8 -*-

    from django.db import models

    from django.contrib.contenttypes.models import ContentType



    class InheritanceCastModel(models.Model):


        real_type = models.ForeignKey(ContentType, editable=False)


        def save(self, *args, **kwargs):

            if not self.id:

                self.real_type = self._get_real_type()

            super(InheritanceCastModel, self).save(*args, **kwargs)


        def _get_real_type(self):

            return ContentType.objects.get_for_model(type(self))


        def cast(self):

            return self.real_type.get_object_for_this_type(pk=self.pk)


        class Meta:

            abstract = True



    class Page(InheritanceCastModel):

        title = models.CharField(max_length=512, verbose_name=u'Title', 
blank=True)



    class Manufacture(Page):

        ru_title = models.CharField(max_length=128, verbose_name=u'RU 
Title')



    class CarModel(Page):

        manufacture = models.ForeignKey(Manufacture, 
verbose_name=u'Manufacture')

        ru_title = models.CharField(max_length=64, verbose_name=u'RU Title')


this question on 
stackoverflow: 
http://stackoverflow.com/questions/43327543/inheritance-models-from-django-1-8-2-to-django-1-11

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c9da822-cfda-4934-b653-9630b5ed2867%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to