# Set Format of DateField

**URL:** <https://forum.djangoproject.com/t/set-format-of-datefield/15169>\
**Category:** Templates & Frontend\
**Created:** [August 1, 2022, 9:03pm UTC](https://forum.djangoproject.com/t/set-format-of-datefield/15169 "2022-08-01T21:03:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FLYAX](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/flyax/32/3422_2.png) [@FLYAX](https://forum.djangoproject.com/u/FLYAX)\
**Post date:** [August 1, 2022, 9:03pm UTC](https://forum.djangoproject.com/t/set-format-of-datefield/15169/1 "2022-08-01T21:03:16Z")

</div>

Hello,

I tried setting the format of a DateField using the following code:

```auto
class SetUpForm_Personal(ModelForm):
    class Meta:
        model = Account
        fields = ['prename', 'surname', 'birthdate', 'punkte']
        widgets = {
            'prename': TextInput(attrs={"class": "form-control form-group", "required:": "", "placeholder": "Vorname*", "style": "max-width: 800px; margin-left: auto; margin-right: auto;"}),
            'surname': TextInput(attrs={"class": "form-control dragArea col-md col-sm-12 form-group mb-3", "required:": "", "placeholder": "Nachname*", "style": "max-width: 800px; margin-left: auto; margin-right: auto;"}),
            'punkte': TextInput(attrs={"class": "form-control dragArea col-md col-sm-12 form-group mb-3", "required:": "", "placeholder": "Aktien Anzahl*", "style": "max-width: 800px; margin-left: auto; margin-right: auto;"}),
            'birthdate': DateField(widget=forms.DateInput(format='%d/%m/%Y', attrs={'class': 'datepicker'}), input_formats=('%d/%m/%Y', )
       
        )
        
        }
        
        labels = {
            'prename': (),
            'surname': (),
            'birthdate': (),
            'punkte': (),

        }

```

But Im getting this error:

```auto
'DateField' object has no attribute 'is_hidden'

```

How can I prevent this, is there a better solution?

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [August 1, 2022, 11:45pm UTC](https://forum.djangoproject.com/t/set-format-of-datefield/15169/2 "2022-08-01T23:45:23Z")

</div>

It looks like the line of code for the DateField widget is incomplete, are you sure that this is precisely the code you have?

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [August 2, 2022, 12:03am UTC](https://forum.djangoproject.com/t/set-format-of-datefield/15169/3 "2022-08-02T00:03:56Z")

</div>

By default Django understands the date format like so: year-month-day. With hyphens and not forward slash between the numbers.

You would have to change this in settings to enable django to understand this date format.

This line needs to be added in settings.py (at the end of the script)

```auto

DATE_FORMAT = "d/m/Y"

```

USE\_L10N should then be set to false:

`USE_L10N = False`

I think you are also missing a parenthesis at the end of your line.

It is isn’t illustrated very well in the documentation but here is a link:

[https://docs.djangoproject.com/en/4.0/ref/settings/#date-format](https://docs.djangoproject.com/en/4.0/ref/settings/#date-format)
