I have a model that looks something like this.
class Post(models.Model): id = models.IntegerField(unique=True, primary_key=True) title = models.CharField(max_length=150, blank=True) created = models.DateTimeField(blank=True) ...
I need to populate a database with pieces of data. I get the data as a flat json string (without nesting), so my work is pretty simple. Ie
mydict = json.loads(jsonstr) mypost = Post(**mydict) mypost.save()
there is only one problem when the date-time is expressed in the format "YYYY-MM-DDThh: mm: ss + zzzz" (for example, "created" : "2011-11-17T09:21:31+0000" ), which splits the above code.
I know forms.DateTimeField has input_formats . Is there a way to get DateTimeField to accept the format above?
source share