[Django] #33016: Cannot override choices error_messages in model

8 views
Skip to first unread message

Django

unread,
Aug 12, 2021, 1:15:00 AM8/12/21
to django-...@googlegroups.com
#33016: Cannot override choices error_messages in model
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
suneethdev |
Type: | Status: new
Uncategorized |
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have a model class (from django.db.model) and a char field with choices
attribute, my form is not created from django form and i am using a
serializer in the middle of the model and my static HTML form when
validating my choices field (dropdown) it shows the default validation
messages only, i couldn't override the error messages. Thanks in advance.

here is my code

class CustomUser(BaseModel, AbstractUser):
type = models.CharField(choices=TYPES, max_length=20,
default='super_admin',error_messages={"null":'Value is not a
valid.',"blank":'Value is not a valid.',"invalid_choice":'Value is not a
valid.'})

note: Base model inherited from models.Model

--
Ticket URL: <https://code.djangoproject.com/ticket/33016>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 12, 2021, 1:27:31 AM8/12/21
to django-...@googlegroups.com
#33016: Cannot override choices error_messages in model
-------------------------------------+-------------------------------------
Reporter: suneethdev | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by suneethdev):

Sorry, I have fixed the issue in serializer like this,
extra_kwargs = {"type": {"error_messages": {"null": "Value cannot be
null"}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33016#comment:1>

Django

unread,
Aug 12, 2021, 1:27:51 AM8/12/21
to django-...@googlegroups.com
#33016: Cannot override choices error_messages in model
-------------------------------------+-------------------------------------
Reporter: suneethdev | Owner: nobody
Type: Uncategorized | Status: closed

Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by suneethdev):

* status: new => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/33016#comment:2>

Django

unread,
Aug 12, 2021, 8:03:00 AM8/12/21
to django-...@googlegroups.com
#33016: Cannot override choices error_messages in model
-------------------------------------+-------------------------------------
Reporter: Suneeth S | Owner: nobody

Type: Uncategorized | Status: closed
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* resolution: fixed => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/33016#comment:3>

Reply all
Reply to author
Forward
0 new messages