#34288: Using queryset manager methods as default value breaks makemigrations
----------------------------------------------+----------------------------
               Reporter:  Mikhail Podgurskiy  |          Owner:  nobody
                   Type:  Bug                 |         Status:  new
              Component:  Migrations          |        Version:  4.1
               Severity:  Normal              |       Keywords:  migrations
           Triage Stage:  Unreviewed          |      Has patch:  0
    Needs documentation:  0                   |    Needs tests:  0
Patch needs improvement:  0                   |  Easy pickings:  0
                  UI/UX:  0                   |
----------------------------------------------+----------------------------
 When I'm using  a manager method as default value for a model field,
 migrations can't be generated

 {{{
 class Company(models.Model):
     name = models.CharField(max_length=250)


 class Client(models.Model):
     name = models.CharField(max_length=250)
     company = models.ForeignKey(
         Company,
         on_delete=models.DO_NOTHING,
         default=Company.objects.last
     )

 }}}

 {{{
 django/db/migrations/serializer.py", line 169, in serialize
     raise ValueError(
 ValueError: Could not find function last in django.db.models.manager.

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34288>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070185e2410142-f36b90f8-e956-4db6-93ed-62acc86c50fa-000000%40eu-central-1.amazonses.com.

Reply via email to