1

My Form:

date = forms.DateField(widget=forms.DateInput(attrs={'class': 'form-control'}))

My HTML:

<div class="col-md-3">
    <label class="form-label">Date</label>
        {{ form.date }}
            <div class="invalid-feedback">
                Enter Date
            </div>
    </label>
</div>

Also, I don't want to add the type "date" in my forms.

Issue picture:
enter image description here

ZygD
  • 22,092
  • 39
  • 79
  • 102
  • 1
    This answer could help you : https://stackoverflow.com/questions/3367091/whats-the-cleanest-simplest-to-get-running-datepicker-in-django – smart-developer Aug 07 '21 at 15:03
  • Are you using this package? https://pypi.org/project/django-jalali/ – allexiusw Aug 07 '21 at 16:54
  • Yes I am. but I guess the problem is with my front-end part. because I used the same thing in models and it works fine in admin templates. also I checked normal datefileds that django has but the problem was the same. – Enigma Beyond Aug 07 '21 at 17:01

1 Answers1

1

The way how I handle it is the following:

date = forms.DateField(widget=forms.TextInput(attrs={'class': 'form-control', 'type':'date'}))

Other ways more elegant is to use a javascript widget like DatetimeUI but it is the easiest way I think.

allexiusw
  • 1,533
  • 2
  • 16
  • 23