I'm doing this inside Django. The DateTime string is passed into POST successfully. This is my code:
vk = Vk()
day1 = request.POST['day1']
vk.day1 = datetime.datetime.strptime(day1, '%m/%d/%Y %I:%M %p')
vk.save()
This is the format of the POST info:
'day1': 'MM/DD/YYYY HH:MM AM/PM' # AM/PM meaning either AM or PM
The problem is that the DateTimeField on the vk instance is None.
class Vk(models.Model):
day1 = models.DateTimeField(null=True, blank=True)
I see that it is None in my HTML file:
{% for vk in vk %}
{{ vk.day1 }}
{% endfor %}
which amounts to None.
This is the view that is responsible for rendering the template:
def list_verkefni(request):
vk = Vk.objects.all()
vm = Vm.objects.all()
return render(request, 'list_verkefni.html',
{'vk': vk, 'vm': vm}
)
day1is saved asNone?Vkvariable passed to the template? Could you show the view which is responsible for rendering the template?