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.
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>
* 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>
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>
* 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>
* 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>
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>
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>
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>
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>