#33307: Model got both positional and keyword arguments for field 'id'.
-------------------------------------+-------------------------------------
     Reporter:  אורי                 |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Database layer       |                  Version:  4.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     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 Mariusz Felisiak):

 Replying to [comment:5 אורי]:
 > What is the case of starting an instance with an id in args? Is it a
 real id or just `None`? I think we need the id to be set before calling
 `save()`, we use the id for generating the file name and if it's just
 `None` in args then we need to generate it.

 When calling `get()` an instance is initialize with `id` from the
 database, so previously `id` in `kwargs` was ignored, e.g.
 {{{
 >>> x = File.objects.create()
 >>> x.id
 98176428171628647286
 >>> x = File.objects.get() # <- Here your code generates another "id" that
 was ignored
 >>> # super().__init__() was called with File('98176428171628647286',
 id='some_other_id')
 >>> x.id
 98176428171628647286
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33307#comment:6>
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/069.fc03d49c66389a8c9d2ab6541502c0e7%40djangoproject.com.

Reply via email to