Creating Views like Django Admin Panel - django

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.

Related

How do we change Field Names in our existing Users table in django

I am trying to Edit Users Table in Django. I am using Users Table to login or register a users. I have to add a new field name Role in that Table but i can't find any option to edit that existing table in admin section.
i just try to field some files to field out where the code of that existing Table is but did't get it.
is there any way to Edit the Table or I have to Create a New Table and have to create a new method of registration.
i am not expert so it's hard to me understand things.
Well first, the Django admin interface it's just for performing CRUD operations over already existing models, you are not able to change in any way the database tables (at lest not using the "out of the box features") using the admin interface.
Said that in order to do what you want to do, with any model (not just User), you should:
Add the field to the model.
Instruct the admin interface to list this fields along the others.
Now the user model is kind of a special model here so I'll recommend a couple of readings you should complete before go forward with the model User customization.
References (User customization): Substituting a custom User model, Extending the User model.
And for the admin interface ...
Reference (admin interface): ModelAdmin options, special attention here to list_display

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.

Django admin - how to store references to models in model field?

I'm making some big changes in Django Admin and need to make an application to group various models to groups and then show it in menu.
I have a function to generate list of all available admin models including permissions.
So I make 1 model to add group (id, name). Via Inlines I want to add specific models to groups.
What is the best way to store models references? Should I store it as string and during my menu is generated I should parse the name, find specific model and generate its url in admin?
Thanks for clues.
Sounds like contenttypes would help you.

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)

Django databrowse with custom queryset?

Django's databrowse is very different from the rest of django in that the docs literally don't exist. Has anyone tried to do more that databrowse.site.register on a model? Any code examples?
In particular, I've got a model that has a ForeignKey to an auth.Group and I want databrowse to use this queryset instead of .all():
qs = Model.objects.filter(group__in=request.user.groups.all())
Bonus points for making it possible to have a button that does stuff with the current object (edit/delete/clone/etc). I basically need a simple way to browse and edit rows without giving users access to the admin.
It'd be even better if there was a way to do that on the admin, but I don't want to give users the staff privilege.
There's no way to do this through databrowse. You could try writing a custom Manager for your Model and return the required query set by default.