# Declare a model field the same as Django's password

**URL:** <https://forum.djangoproject.com/t/declare-a-model-field-the-same-as-djangos-password/5326>\
**Category:** Using Django\
**Created:** [November 20, 2020, 10:20pm UTC](https://forum.djangoproject.com/t/declare-a-model-field-the-same-as-djangos-password/5326 "2020-11-20T22:20:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![codecresta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codecresta/32/2381_2.png) [@codecresta](https://forum.djangoproject.com/u/codecresta)\
**Post date:** [November 20, 2020, 10:20pm UTC](https://forum.djangoproject.com/t/declare-a-model-field-the-same-as-djangos-password/5326/1 "2020-11-20T22:20:45Z")

</div>

Looking at my Db schema it says it is a varchar(128). How do I declare the same in my model?

```
password = models.?(?)

```

This is for an API not a user, but something long will do for passwords.

I know that you can use a TextField for long strings, but can you specify a max length with that?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 21, 2020, 12:01am UTC](https://forum.djangoproject.com/t/declare-a-model-field-the-same-as-djangos-password/5326/2 "2020-11-21T00:01:31Z")

</div>

If you look at the source for the password field in the AbstractBaseUser model (django.contrib.auth.base\_user) , you’ll see the password field defined as:

> password = models.CharField(\_(‘password’), max\_length=128)

A [TextField](https://docs.djangoproject.com/en/3.1/ref/models/fields/#textfield) does not enforce the max\_length parameter.

A [CharField](https://docs.djangoproject.com/en/3.1/ref/models/fields/#charfield) does enforce max\_length, but the actual max value depends upon the database being used. (For Postgresql, the limit is 1GB, which is also the limit for a TextField, and according to the docs, there are no performance differences between the two.)
