Reputation: 11
i have this model:
class CalendarEvent(models.Model):
"""
Calendar Events
"""
CSS_CLASS_CHOICES = (
('', _('Normal')),
('event-warning', _('Warning')),
('event-info', _('Info')),
('event-success', _('Success')),
('event-inverse', _('Inverse')),
('event-special', _('Special')),
('event-important', _('Important')),
)
title = models.CharField(max_length=255, verbose_name=_('Título'))
comentario = models.TextField('Comentario', blank=True, null=True)
cliente = models.ForeignKey(Cliente, blank=True, verbose_name='Cliente' ,null=True)
empleado = models.ForeignKey(Empleado, blank=True, verbose_name='Empleado' ,null=True)
url = models.URLField(verbose_name=_('URL'), null=True, blank=True)
css_class = models.CharField(max_length=20, verbose_name=_('Tipo'),null=True, blank=True,choices=CSS_CLASS_CHOICES)
start = models.DateTimeField(verbose_name=_('Inicio'))
end = models.DateTimeField(verbose_name=_('Término'), null=True, blank=True)
Im working on Mac os x with MySQL 5.6.21 and everything is ok, when i get a query asking for the start or end time the response its ok.
from Artico.models import CalendarEvent
q = CalendarEvent.objects.get(id=90)
print q.start
2015-09-14 01:50:08+00:00
Then i upload my app to an instance with ubuntu on amazon. This instance have Mysql 5.6.19 and Django 1.8.3
I have the same data on Mysql and get this on the query:
from Artico.models import CalendarEvent
q = CalendarEvent.objects.get(id=90)
print q.start
none
print q.title
El titulo
then my question is why is occurring this issue? what i have bad if i have the same code on my pc and the amazon instance? is the version of mysql?
Thanks
Upvotes: 1
Views: 1024
Reputation: 159
I think because django creating the column in the DB as datetime(6) instead of datetime. you can alter the column to datetime.
ALTER TABLE `my_table`
MODIFY COLUMN `created` datetime NOT NULL
see this: DateTimeField queryset returning None in Django
Upvotes: 1
Reputation: 1
Remove you database schema, recreate it. And re-migrate it from WINDOWS machine instead of mac.
Upvotes: 0