#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 , 9 years ago
comment:2 by , 9 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 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, ...)
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 usingcreate()
it won't be possible to use that instance sincecreate()
requireskwargs
of model attributes, not a model instance.