I'm running the following command to fix the error I've encountered with the Datefield() in my django model.
django.db.utils.ProgrammingError: column "end_date" cannot be cast
automatically to type timestamp with time zone
HINT: Specify a USING expression to perform the conversion.
Here is the line I'm running which doesn't seem to fix the problem:
ALTER TABLE merged_subscription ALTER COLUMN end_date TYPE timestamp USING to_timestamp(col, 'DD-MON-YYY');
I'm not very familiar with postresql. Is there something wrong with the logic here?
Here is my Django model for reference:
class Subscription(models.Model):
start_date = models.DateField()
end_date = models.DateField()
date = models.DateTimeField(auto_now_add=True, blank=True)
issue_one = models.ForeignKey(Issue, blank=True, null=True, related_name='issue_one')
issue_two = models.ForeignKey(Issue, blank=True, null=True, related_name='issue_two')
issue_three = models.ForeignKey(Issue, blank=True, null=True, related_name='issue_three')
def __unicode__(self):
return unicode(self.start_date)