#32464: Enable "detaching" of file from FileField and ImageField
-------------------------------------+-------------------------------------
     Reporter:  Samuli-Petrus        |                    Owner:  nobody
  Korhonen                           |
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 Hi.

 > ...cloning an instance by setting primarykey to None and saving object
 leads to problems. It seems that the resulting objects refer to same file
 which is not the desired behaviour as this leads to invalid objects.

 This strikes me as a special case of a much harder problem — you're going
 to get the same issue come up for any reference the model might hold. The
 [https://docs.djangoproject.com/en/3.1/topics/db/queries#copying-model-
 instances copying model instances] docs already hint at the issue: more-
 or-less you need to reset (or provide your own logic for) any fields for
 which the naive **Use the same value** isn't appropriate.

 See #4027 for discussion about **not** including such more complex logic
 in Django.

 I think there have been various takes on this issue over the years.
 [https://github.com/tj-django/django-clone django-clone] looks to be one
 that is currently maintained.

 I'm closing as `wontfix` but if you wanted to see if anyone on the
 DevelopersMailingList thinks this could be do-able, that would be OK. The
 conclusion from #4027 was roughly that per-project logic is relatively
 simple, but that a generic solution is almost impossible, so that it's not
 worth the complexity in core, but maybe that can be reviewed.

 Thanks.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32464#comment:1>
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/068.beb8ad27d29cab120080c6a9fa9d1430%40djangoproject.com.

Reply via email to