#22351: New django migrations and places where lambdas are supposed
--------------------------------------+------------------------------------
Reporter: dimyur27@… | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: migrations lambdas | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by niwi):
* cc: niwi@… (added)
Comment:
It also happens with simple charfield and "default" keyword argument like
this:
{{{#!python
token = models.CharField(max_length=255, blank=True, unique=True,
db_index=True,
default=lambda: str(uuid.uuid1()))
}}}
This is a traceback:
{{{
Traceback (most recent call last):
File "manage.py", line 8, in <module>
execute_from_command_line(sys.argv)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/core/management/__init__.py", line
385, in execute_from_command_line
utility.execute()
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/core/management/__init__.py", line
377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/core/management/base.py", line 288,
in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/core/management/base.py", line 337,
in execute
output = self.handle(*args, **options)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/core/management/commands/makemigrations.py",
line 115, in handle
self.write_migration_files(changes)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/core/management/commands/makemigrations.py",
line 143, in write_migration_files
migration_string = writer.as_string()
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/db/migrations/writer.py", line 124,
in as_string
operation_string, operation_imports =
OperationWriter(operation).serialize()
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/db/migrations/writer.py", line 76,
in serialize
arg_string, arg_imports = MigrationWriter.serialize(item)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/db/migrations/writer.py", line 229,
in serialize
item_string, item_imports = cls.serialize(item)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/db/migrations/writer.py", line 290,
in serialize
return cls.serialize_deconstructed(path, args, kwargs)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/db/migrations/writer.py", line 205,
in serialize_deconstructed
arg_string, arg_imports = cls.serialize(arg)
File "/home/niwi/.virtualenvs/table/lib/python3.4/site-
packages/Django-1.7b4-py3.4.egg/django/db/migrations/writer.py", line 303,
in serialize
raise ValueError("Cannot serialize function: lambda")
ValueError: Cannot serialize function: lambda
}}}
Django version: 0cabf3a (2014-06-21) revision from git repository.
Without default keyword with lambda, everything works ok.
--
Ticket URL: <https://code.djangoproject.com/ticket/22351#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/076.762c90cc708eb7acde24dbab99dc7426%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.