I think there is a restriction in using 'date' in MySQL as a field name as it's some sort of inbuilt function.
On Friday, July 4, 2014 5:01:15 PM UTC+8, William Granli wrote:I am trying to create a queryset for getting the values of a DateTimeField which is DATETIME in the DB.
The class in models.py:
class ChangeMetrics(models.Model): id = models.IntegerField(primary_key=True) file_id = models.ForeignKey(File, db_column = 'file_id') version_id = models.ForeignKey(Version, db_column = 'version_id') function_id = models.ForeignKey(Function, blank=True, db_column = 'function_id') date = models.DateTimeField(blank=True, null=True) user = models.TextField(blank=True) changed = models.IntegerField(blank=True, null=True)The field in the SQL DB:
date DATETIMEThe tuples are populated in the database and running SQL queries directly on the DB is working perfectly.
This is the queryset I am currently using in Django:
queryset = ChangeMetrics.objects.filter(~Q(changed=None), ~Q(date=None), ~Q(version_id=None))I have tried a raw query and also a version of the query that uses exclude(), but that still returns None for date.
I am accessing the entries in the queryset through a for loop and simply accessing date through entry.date inside the for loop.
I am using Django version 1.6.5. I have also tried getting the values through the Django shell, to no success.
Any ideas on what could be wrong? I have tried a multitude of queries, none of them change the returned value of date. I have tried resyncing the DB. I've looked over the models and everything seems to be correct. Everything except the date works fine.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20994464-f99b-40bf-a16e-aaff87ff9d5a%40googlegroups.com.--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq849kDAk_y%3DHzq3KWtPsbMN-OQrinb-vW0L-nAMq3Z8ttsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.