--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7D0D33A0-8A01-48F7-9928-A8465CC40066%40stacktrace.dk.
On Sun, Jul 12, 2020, 6:37 PM Kasper Laudrup <lau...@stacktrace.dk> wrote:
On July 12, 2020 3:02:00 PM GMT+02:00, Chander shekhar <best...@gmail.com> wrote:
>starttime=datetimefield()
>
>i want to take datetimefield from my template but i am not able to do
>it.
>i have created the form and passed the widget of datetime-local but it
>is
>not acceptable ,it is giving me error .
>Help me to resolve it .
>It's important
It will be a lot easier for people to help you if you share which kind of error you are getting.
Kind regards,
Kasper Laudrup
--
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...@googlegroups.com.
#forms.py
class eventform(forms.ModelForm):
class Meta:
model = Event
fields = [, 'end_time',]
widgets = {
'start_time': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
Models.py
class Event(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
start_time = models.DateTimeField()
views.py
def add(request):
if request.method=='POST':
form=eventform(request.POST)
if form.is_valid():
form.save()
return redirect('calendar')
else:
messages.error(request, "Error")
return render(request,'event/add.html',{'form':form})
template
<form method='POST' method={% url 'add' %}>
{% csrf_token %}
{{form.as_p}}
<button class='btn btn-outline-info' type="submit">ADD</button>
</form>
</div>
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a485f092-32df-42c4-a25b-dc6f1696bbdbo%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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d907af69-2973-e383-497c-4af6a0e15277%40stacktrace.dk.