#35019: GeneratedField save error
-------------------------------------+-------------------------------------
     Reporter:  Deb Kumar Das        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  GeneratedField save  |             Triage Stage:
  error                              |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Deb Kumar Das:

Old description:

> When using GeneratedField column along with a ForeignKey column, getting
> error while saving.
> The below model throws error while saving data from admin panel.
> {{{
> #!python
> class Square(models.Model):
>     id = models.BigAutoField(primary_key=True)
>     side = models.IntegerField()
>     area = models.GeneratedField(
>         expression=F("side") * F("side"),
>         output_field=models.BigIntegerField(),
>         db_persist=True,
>     )
>     user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
> }}}
>
> Throws the below error
>
> {{{
> Cannot force an update in save() with no primary key.
> }}}

New description:

 When using GeneratedField column along with a ForeignKey column, getting
 error while saving.
 The below model throws error while saving data from admin panel.
 {{{
 #!python
 class Square(models.Model):
     side = models.IntegerField()
     area = models.GeneratedField(
         expression=F("side") * F("side"),
         output_field=models.BigIntegerField(),
         db_persist=True,
     )
     user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
 }}}

 Throws the below error

 {{{
 Cannot force an update in save() with no primary key.
 }}}

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35019#comment:2>
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/0107018c3ea78714-f0308667-b470-451f-be98-4d5c15862375-000000%40eu-central-1.amazonses.com.

Reply via email to