How do I replicate Django Admin-like CRUD for related objects? - django

I was able to add a PLUS button to a select widget in a CreateView like in Django Admin. I would like to add objects to the related model using the related model's CreateView by opening a new window using the PLUS button in the CreateView of the child model. After saving the related object, I should be able to go back to the previous CreateView to finish my entry. Any tutorials or guides on how to this like in Django Admin?

Related

How to make a drop-down that show images in Django Admin?

I spent two hours trying to find out how to customize select2 widget in Django admin to implement this simple feature.
I have a model (Article) that contains many other objects (Pictures). Every Picture has a set of FileFields representing the original image file, the thumbnail, post-processed (using Pillow) preview and some meta stuff.
What I'm going to achieve is to be able to upload new images on the Article change page, and select/deselect them in the fancy Select2 dropdown widget.
How can I do that? Should I use ImageField instead of FileField? Should I use inlines and through for ManyToMany relation between Article and Pictures? Should I make my own widget? How do Django admin uses Select2 and how could I pass parameters like "templateResult" to be able to change the look of dropdown items?
Thank you in advance.

Registering a dummy model in Django admin to control multiple models data

Is it possible to register a dummy model (Does not exist in db) that will display data from multiple models in one page?
Maybe just list all objects and when use click on one, a new webpage is opened with details of the clicked on objects? Which is usually this view:
admin:{app_name}/{model_name}/{object_id}/change
The closest standard solution to what you want are Django inlines:
https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#using-generic-relations-as-an-inline
I fail to see how you could create a model not present in the db.

Adding multiple items using the raw_id_field popup

I am using the Django admin site and I have a m2m relation which uses raw_id_fields in the admin panel. A user can add an item to the m2m model using the popup window but I would like to be able to select multiple items at once and add them all.
Is this at possible with the current framework or would customisation be needed. If customisations are needed, how would I go about doing that.
django-bulk-admin will do the trick, and it supports other bulk actions in admin.

Creating Views like Django Admin Panel

is there any way to create views like the ones shown on Admin Panel without any effort, I mean, generic views that display all the fields and have the ability to add foreign key items and such, just like admin panel?
I've tried using
django.views.generic.edit.FormView
django.views.generic.edit.CreateView
django.views.generic.edit.UpdateView
django.views.generic.edit.DeleteView
But I am forced to specify fields, and I have quite a lot. It also doesn't allow me to create objects for the foreignkey fields if there's any.
Thanks in advance.

Django admin: two change lists on the same page

I am trying to make an overview page for one of my models I have read through all of http://www.djangobook.com/en/1.0/.chapter17/ and understand how I can add my own custom views for a model to the django admin.
What I am currently trying to do is add multiple filtered change lists (presenting some child models) onto my "overview" page for the model. In these I would like to be able to make use of some of the admin features such as editable fields or actions.
Does anyone have some pointers on how I can best get started with this.
Check this out
He created a proxy model for the original model to avoid the conflict. You can create a new model admin or inherit the old ModelAdmin(as shown in the link)