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')
manufact = models.ForeignKey(Manufacture, verbose_name=u'Manufacture', db_column='manufacture')
https://docs.djangoproject.com/en/1.11/ref/models/fields/#db-column