Reputation: 1
suppose I have this model:
id = models.AutoField(primary_key=True)
datetime_from = models.DateTimeField('time')
model = MyModel
def read(self, request, id=0):
if not id:
id = 0
MyModel.object
mmodel = MyModel.objects.filter(id__gt=id)
return mmodel
My question is, how do I possible get the model fields individually, because I need to validate the datetime_from before I have to output the data on json format
Upvotes: 0
Views: 78
Reputation: 29913
You don't need to create an id
column yourself. The read
method is not necessary, either. Just say
from django.db import models
class MyModel(models.Model):
datetime_from = models.DateTimeField('time')
You can then query the table like so
>>> obj = MyModel.objects.get(id=<target id here>)
>>> date = obj.datetime_from
etc.
Upvotes: 1