Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#24718 closed Uncategorized (wontfix)

Inconsistent Behavior by Admin when Creating vs Deleting Objects

Reported by: Alex Rothberg Owned by: nobody
Component: Uncategorized Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The Django Admin exhibits inconsistent behavior as far as how it uses the Model Manager / QuerySet for creating vs. deleting objects.

When an instance is deleted (whether one instance from the item view) or multiple instance from the list view, the admin uses the QuerySet's delete method.

On the other hand, when an instance is created, the admin bypasses using the model manager's create method requiring workarounds like (http://stackoverflow.com/questions/29114634/django-admin-not-using-modelmanagers-create-method).

I propose using the Model Manager's create method when creating a model.

Change History (3)

comment:1 Changed 6 years ago by Tim Graham

I'm not sure changing the behavior at this point is a good idea with respect to backwards compatibility. For example, if ModelAdmin.save_form() returns a customized model instance, if we start using create() it won't be possible to use that instance since create() requires kwargs of model attributes, not a model instance.

comment:2 Changed 6 years ago by Tim Graham

Resolution: wontfix
Status: newclosed

comment:3 Changed 6 years ago by Alex Rothberg

Is there an easy way to deserialize a model to a dict? i.e what is the best way to perform:

MyModel.objects.create(name=obj.name, ...)
Note: See TracTickets for help on using tickets.
Back to Top