Django admin does something like this with raw_id_fields[1]. I think it works 
by just swapping out the form widget. But you could take a look at the admin 
code to see for sure.

[1] 
https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

On April 1, 2021 10:23:03 PM CDT, Clive Bruton <cl...@indx.co.uk> wrote:
>I have a ManyToMany model set, that on the edit uses a formset to add/ 
>edit rows. I have this working, but the unfortunate part of it is  
>that the select that results from the ManyToMany relationship  
>populates with 16,000 records.
>
>What I would like to do is, once the records are added, just have the  
>delete checkbox and show the 'description' field (uneditable) next to  
>it), and, rather than add records through a huge select list, add the  
>records by id.
>
>To sketch it out, this is how it is:
>
>
>     <'Profile.directory-optin' checkbox>
>
>     <'Profile.directory-desc'>
>
>     <'Class.description' huge select>
>
>     <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <'Class.description' huge select>
>
>     <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <'Class.description' huge select>
>
>     <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <!--add new item-->
>
>     <'Class.description' huge select>
>
>     <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <save button>
>
>
>
>And I'd rather it was something like:
>
>
>     <'Profile.directory-optin' checkbox>
>
>     <'Profile.directory-desc'>
>
>     <text of 'Class.description' field> <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <text of 'Class.description' field> <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <text of 'Class.description' field> <delete checkbox>
>
>     <!--hidden formset elements-->
>
>     <!--add new item-->
>
>     <new 'Class.id' text input field>
>
>     <!--does not need a 'delete' checkbox-->
>
>     <!--hidden formset elements-->
>
>     <save button>
>
>
>The database tables look something like:
>
>
>Profile              Join table       Class
>=======              ==========       =====
>
>id                   id               id
>directory-optin      profile-id       description
>directory-desc       class-id
>
>
>
>Hope someone can help me out!
>
>
>-- Clive
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/E30F44E6-07DA-4703-BAB1-BE295C72EF22%40indx.co.uk.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75F0A15E-150A-4F74-BC98-2AE067B843AB%40fattuba.com.

Reply via email to