You can use model forms and do something like this:
1) create your model. for instance
class DatePickerModel(models.Model):
    start_date = models.DateTimeField()
    end_date = models.DateTimeField()
2) create your form
  # setup date picker start
class DateInput(forms.DateInput):
    input_type = 'date'


class DatePickerForm(forms.ModelForm):
    class Meta:
        model = DatePickerModel
        widgets = {'date': forms.DateInput(attrs={'class': 'datepicker'})}
        fields = ['start_date', 'end_date']
        widgets = {
            'start_date': DateInput(), 'end_date': DateInput()
        }
        error_messages = {
            'start_date': {'required': ''},
            'end_date': {'required': ''}
        }

3) in your html
                 <form method="post">
                        {% csrf_token %}
                        {{ form.as_p }}
                        <button type="submit" class="btn
btn-primary">submit</button>
                    </form>

On Tue, May 30, 2023 at 4:20 AM Bhuvnesh Sharma <[email protected]>
wrote:

> You can also use
> https://github.com/monim67/django-bootstrap-datepicker-plus
>
> It is really good and easy to integrate.
>
> On Mon, May 29, 2023, 10:48 PM Larry Martell <[email protected]>
> wrote:
>
>> On Mon, May 29, 2023 at 1:14 PM Thomas Mutavi <[email protected]>
>> wrote:
>> >
>> > Hello, how  can i implement a form with several date fields which have
>> date and time picker in django?
>>
>> You can use the jQuery UI datetimepicker.
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CACwCsY72xpH90NiaJMQCWeziz%3DqPZcnDPZewBVt3BHMSjVcowQ%40mail.gmail.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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BZJHEoFJ%2Bgys1kEqO7bL%3D%2BxS-KiSnp_fdZzX79qGDi9ZND9hA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2BZJHEoFJ%2Bgys1kEqO7bL%3D%2BxS-KiSnp_fdZzX79qGDi9ZND9hA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y4_gx5vJ%2ByAyW232Fq-Y0-ZYhcCamNDDqc0AT-a5s16Kw%40mail.gmail.com.

Reply via email to