Django Admin Custom Inline Model - django

My question is about django admin inline model,
in Django admin site the inline model looks like this:
the many to many objects appear in a dropdown.
is there anyway (or a library) to show all the objects in a table and each row with a checkbox so the user could select each object they want?
thank you for helping
sorry about the image quality

I found the answer myself, I change tabular.html template showed all records and added extra js to only send selected rows

Related

Django: How to create an tabular inline like the one in admin panel with "+ Add another"?

I currently rely on the admin panel to create or edit a new/existing order (i.e. Order with its children model OrderItem in the tabular inline).
But this time I need to create a view with the same function for non-admin users. More specifically, I need the + Add another button in the tabular inline for users to add more Order Items themselves when necessary.
I have looked into a few stackoverflows (one of them) and books. So far they at most only mentioned about inlineformset_factory, but not how to create the + Add another. Any ideas please? Thank you!

Django save model and its children with ModelForm

I have such models: Article, Link & ArticleLink. Article can have many links attached to it and I need to save them from one form.
I have created all the relations and a ModelForm for Article, but the trick part is that links have two fields: Name and URL. I can't figure out what kind of form structure must be used, I tried hidden inputs with name "links[name]" and "links[url]" but did not work.
Where should I look? Is there any working example for this? Django docs does not help with this particular situation.
You should take a look at inline formsets.

Adding an hyperlink to another Model inside Django Admin

I have something which sounds trivial but I cant find a way to implement in django admin.
I have a Model which I am showing in my admin. I am using a TabularInline to show another model which refer to the first one.
All I want is a link to click on my current view so I'll go into the TabularInline view only.
The reason I need it is simple. My second model admin registertion also contains another TabularInline to a third model. so I cant see the Inline from the first model.
The Models are pretty simple. I am implementing a Voting system over several cretirias. So I want my Item model admin to show all the users which votes and the final score. But the Vote model breaks down the cretirias that the user votes for.
This answer discusses this in some detail:
Django InlineModelAdmin: Show partially an inline model and link to the complete model
But this is what I use:
https://gist.github.com/3013072

Django admin customization with non-related models

I am a django noob and am trying to figure out how to get the admin module to do something slightly different than the normal operation on a single model. Essentially what I need is to run a query and display the results of the query as a view page and then allow the link to the edit page take the user to an existing model's edit view. 2 of the 3 tables in my query are related, but not all 3.
Example:
select a.foo, a.second_field, b.bar, c.unrelated_field
from a, b, c
where a.primary_key = b.foreign_key
and a.some_value = c.some_value
Note that a and c are not defined as related tables.
I would like to have a view of this query output and have a link to the edit view of the b model as a whole when selected.
I have created a view in the DB for this query and simply created a new model which makes it easy to get the view, but I'm not sure this is even the right approach to start with...but from there I can't seem to figure out how to make this link to the edit page for the B table.
Any pointers or advice on how best to accomplish something like this with django admin would be appreciated!
Using Django 1.3.1 by the way.
Cheers!
You can override change_view in your ModelAdmin so it will construct a list of dicts with all your needed data. Then override change_list.html template to display this data correctly and link it with change_form view for correct model. So it will flawlessly integrate in Django's admin site.
And I don't like DB views as long as it's possible to solve the problem without it. If data can be constructed in Python without massive performance gaps and lots of magic code, it should be processed in Python.

Django Admin Template Overriding: Displaying checkboxselectmultiple widget

Have 2 tables Domain and Group having one to many relationship.
These tables have many to many relationship with User table
On the User admin interface I am rendering the Group and Domain as CheckboxSelectMultiple
widgets.
Is it possible to present this in a table form with 2 columns: Domain in one column and the list of groups belonging to the domain in the other column.
I want to override the fieldset template of the admin. However I am having difficulties knowing which methods/properties I can use with an AdminField.
Thanks
I'm not quite sure I 100% follow what you are trying to display.
AdminField is not documented unfortunately but its a short class, only 18 lines long so you can read it here.
I have a feeling you might be trying to step beyond what the admin allows you to do easily, once you are trying to combine more than two different models on the same page things can get a bit messy and you are soon in the business of customizing the admin by writing custom views and templates.
Am I correct in thinking you want to change the list of the objects? Rather than changing the editing/creating page?
I had similar problem and what I did is that I created new html pages and copied the same code from the Admin Template directory HTML pages to my template directory which will be overridden automatically, and then changed the HTML code to what I wanted to be. hope this is useful.