[Django] #21275: Cannot use migrations if model field specifies validators

15 views
Skip to first unread message

Django

unread,
Oct 16, 2013, 9:20:20 AM10/16/13
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
--------------------------------------+------------------------
Reporter: timo | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
My assumption is that we shouldn't try to serialize the `validators`
attribute.

Traceback:
{{{
File "/home/tim/.virtualenvs/foo/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 185, in serialize
raise ValueError("Cannot serialize: %r" % value)
ValueError: Cannot serialize: <django.core.validators.RegexValidator
object at 0x1bacc10>
}}}

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

Django

unread,
Oct 16, 2013, 10:13:35 AM10/16/13
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
----------------------------+--------------------------------------

Reporter: timo | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
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 timo):

After discussion with loic84 in #django-developers, it appears that
validators should be serializable and that this error is due to the regex
used by the username field of `contrib.auth.models.AbstractUser` not being
serializable. Loic says validators may be useful for data migrations,
hence a possible reason not to exclude them entirely.

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

Django

unread,
Oct 16, 2013, 12:04:08 PM10/16/13
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
----------------------------+--------------------------------------

Reporter: timo | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by loic84):

* cc: loic@… (added)
* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

POC https://github.com/loic/django/compare/ticket21275.

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

Django

unread,
Oct 17, 2013, 3:53:26 AM10/17/13
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
----------------------------+--------------------------------------

Reporter: timo | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------

Comment (by loic84):

Another POC around the concept of a `deconstructible` decorator.

https://github.com/loic/django/tree/ticket21275_take2.

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

Django

unread,
Oct 20, 2013, 3:05:34 PM10/20/13
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
----------------------------+--------------------------------------

Reporter: timo | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

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

* needs_tests: 1 => 0


Comment:

PR https://github.com/django/django/pull/1783.

Note that this will be needed if/when #21295 is merged.

--
Ticket URL: <https://code.djangoproject.com/ticket/21275#comment:4>

Django

unread,
Oct 21, 2013, 2:57:19 PM10/21/13
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
-------------------------------------+-------------------------------------
Reporter: timo | Owner: Tim
Type: Bug | Graham <timograham@…>
Component: Migrations | Status: closed
Severity: Normal | Version: master
Keywords: | Resolution: fixed
Has patch: 1 | Triage Stage:
Needs tests: 0 | Unreviewed
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* owner: => Tim Graham <timograham@…>
* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"e565e1332ddfbb44fe7e6139375e3c243af7398d"]:
{{{
#!CommitTicketReference repository=""
revision="e565e1332ddfbb44fe7e6139375e3c243af7398d"
Fixed #21275 -- Fixed a serializer error when generating migrations for
contrib.auth.

The migration serializer now looks for a deconstruct method on any object.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21275#comment:5>

Django

unread,
Mar 19, 2014, 3:53:05 AM3/19/14
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
-------------------------------------+-------------------------------------
Reporter: timo | Owner: Tim
Type: Bug | Graham <timograham@…>
Component: Migrations | Status: closed
Severity: Normal | Version: master
Keywords: | Resolution: fixed
Has patch: 1 | Triage Stage:
Needs tests: 0 | Unreviewed
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by erikr):

Shouldn't this also be added to the release notes? If anyone has their own
model with a custom RegexValidator where they currently pass a compiled
regex, they'll need to pass a string now, or they will also hit this
issue, right?

--
Ticket URL: <https://code.djangoproject.com/ticket/21275#comment:6>

Django

unread,
Mar 19, 2014, 4:35:45 PM3/19/14
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
-------------------------------------+-------------------------------------
Reporter: timo | Owner: Tim
Type: Bug | Graham <timograham@…>
Component: Migrations | Status: closed
Severity: Normal | Version: master
Keywords: | Resolution: fixed
Has patch: 1 | Triage Stage:
Needs tests: 0 | Unreviewed
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by blueyed):

Please note that there is #22255, which is about adding a new `flags`
kwarg.

--
Ticket URL: <https://code.djangoproject.com/ticket/21275#comment:7>

Django

unread,
Mar 21, 2014, 6:27:48 AM3/21/14
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
-------------------------------------+-------------------------------------
Reporter: timo | Owner: Tim
Type: Bug | Graham <timograham@…>
Component: Migrations | Status: closed
Severity: Normal | Version: master
Keywords: | Resolution: fixed
Has patch: 1 | Triage Stage:
Needs tests: 0 | Unreviewed
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by erikr):

I've included this in the release notes with
https://github.com/django/django/commit/4d0c5f61427a8e67552ee2d777fffbadc7aff3b2

--
Ticket URL: <https://code.djangoproject.com/ticket/21275#comment:8>

Django

unread,
Jan 4, 2022, 2:11:17 PM1/4/22
to django-...@googlegroups.com
#21275: Cannot use migrations if model field specifies validators
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
| Graham <timograham@…>
Type: Bug | Status: closed
Component: Migrations | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

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

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"194ca77092a2507a57c288c35b279eb2cb4a64fb" 194ca770]:
{{{
#!CommitTicketReference repository=""
revision="194ca77092a2507a57c288c35b279eb2cb4a64fb"
Refs #21275 -- Added more tests for @deconstructible decorator.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21275#comment:9>

Reply all
Reply to author
Forward
0 new messages