Q:

Django model alter duplicate column

I have two model classes having a foreign key relationship as below: Problem is by mistake I defined a foreign key relationship using a existing column name 'type'. How do I remove or alter the foreign key column 'type'
class LandmarkType(TimeStampedModel):
AIRPORT = 'AIRPORT'
RAILWAYSTATION = 'RAILWAYSTATION'
BUSSTOP = 'BUSSTOP'
OTHER = 'OTHER'
LANDMARK_TYPE_CHOICES = (
    (AIRPORT, 'Airport'),
    (RAILWAYSTATION, 'RailwayStation'),
    (BUSSTOP, 'BusStop'),
    (OTHER, 'Other'),
)
name = models.CharField(max_length=20,
                        choices=LANDMARK_TYPE_CHOICES,
                        default=OTHER)
def __str__(self):  # __unicode__ on Python 2
    return self.name

class Landmark(TimeStampedModel):
type = models.CharField(max_length=200, null=True, blank=True, default='')
name = models.CharField(max_length=200)
description = models.TextField(max_length=2000, null=True, blank=True)
city = models.ForeignKey(City)
latitude = models.DecimalField(max_digits=20, decimal_places=10,      null=True, blank=True, default='12.9667')
longitude = models.DecimalField(max_digits=20, decimal_places=10, null=True, blank=True, default='77.5667')
DISPLAY = const.DISPLAY
HIDE = const.HIDE
DISPLAY_CHOICES = const.DISPLAY_CHOICES
status = models.IntegerField(default=HIDE, choices=DISPLAY_CHOICES)
type = models.ForeignKey(LandmarkType, default=4)
popularity = models.PositiveIntegerField(default=0)

A:

Remove the duplicate field, then rerun makemigrations then migrate.
Depending on how many landmarks you have, you can write a migration to repopulate the new type field, or if there are not many, you could do it manually.

