Opened 9 years ago

Closed 9 years ago

Last modified 9 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 by Tim Graham, 9 years ago

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 by Tim Graham, 9 years ago

Resolution: wontfix
Status: newclosed

comment:3 by Alex Rothberg, 9 years ago

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