Re: m2m admin relationship selector with filter_horizontal and large datasets
Thanks Collin, I looked at raw field ids, but feels too basic. I'm attempting to implement autocomplete_light which seems to offer m2m selection. IT would seem that this would be a common problem: select from a large list without displaying that entire list. filter_horizontal would work if I could turn off the left hand side list and still get the search and select functions. I wish I had time to extend that. On Thursday, December 11, 2014 5:25:51 AM UTC-10, Collin Anderson wrote: > > Hi, > > Check out raw_id_fields if you haven't. > > Either on ArticleAdmin: > raw_id_fields = ['categories'] > > Or as an inline: > class CategoryInline(models.TabularInline): > model = Article.categories.through > extra = 0 > raw_id_fields = ['category'] > > Collin > > On Wednesday, December 10, 2014 2:32:20 AM UTC-5, James Y wrote: >> >> I have a Category model that is m2m with an Article model and need to >> make categories selectable in my article admin. So I'm using >> a filter_horizontal and the problem is that I have thousands of categories >> and do not want to load them all into the left hand side (lhs) of >> filter_horizontal. >> >> Is there a way to limit the lhs to just a search functionality instead of >> a category browse? >> >> Is there another widget I should use just for searching categories to >> make m2m relationships? >> >> Thanks >> > -- 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 post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3d5d3d35-723d-4670-8801-97bed32e3284%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
m2m admin relationship selector with filter_horizontal and large datasets
I have a Category model that is m2m with an Article model and need to make categories selectable in my article admin. So I'm using a filter_horizontal and the problem is that I have thousands of categories and do not want to load them all into the left hand side (lhs) of filter_horizontal. Is there a way to limit the lhs to just a search functionality instead of a category browse? Is there another widget I should use just for searching categories to make m2m relationships? Thanks -- 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 post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e38e12cd-b643-4617-b3ae-f83fc9b76425%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Return to paginated ListView page after update
There's probably better solution, but this works: 1) added a page_number to the view 2) subclass dispatch and in get page from request: self.page_number = request.REQUEST['page'] 3) subclass get_context_data and put the page number in a hidden files on the form: context['hidden_field'] = self.page_number #20 in the form: {% for hidden_field in form.hidden_fields %} {{ hidden_field }} {% endfor %} 4) subclass form_valid and set the page_number: self.page_number = context['hidden_field'] 5) and finally: get_success_url(self, **kwargs): return reverse('articleeditor_list', kwargs={'page': self.page_number}) class ArticleEditView(UpdateView): model = Article template_name = 'edit_template.html' page_number = 1 def dispatch(self, request, *args, **kwargs): self.page_number = request.REQUEST['page'] return super(ArticleEditView, self).dispatch(request, *args, **kwargs) def get_context_data(self, **kwargs): context = super(ArticleEditView, self).get_context_data(**kwargs) context['hidden_field'] = self.page_number return context def form_valid(self, form, **kwargs): context = self.get_context_data(**kwargs) self.page_number = context['hidden_field'] return super(ArticleEditView, self).form_valid(form) def get_success_url(self, **kwargs): return reverse('editor_listview', kwargs={'page': self.page_number}) On Friday, September 12, 2014 12:23:52 PM UTC-10, James Y wrote: > > It must be more simple than the nothingness that searching google is > showing me... how can I to get back to the last page (say page 2: > http://127.0.0.1:8000/articlelist/2, which works) in a ListView after an > UpdateView. > > I can go to a random page - 10 in the below UpdateView - but how do I > capture the referring ListView's current page and then feed that back in > get_success_url after the update? > > class ArticleEditView(UpdateView): > model = Article > template_name = 'edit_template.html' > form_class = ArticleForm > > def get_success_url(self): > return reverse('editor_listview', kwargs={'page': 10}) > > > Thank you > -- 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 post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/95758a18-4b00-41f0-adff-5b9d383f882d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Return to paginated ListView page after update
It must be more simple than the nothingness that searching google is showing me... how can I to get back to the last page (say page 2: http://127.0.0.1:8000/articlelist/2, which works) in a ListView after an UpdateView. I can go to a random page - 10 in the below UpdateView - but how do I capture the referring ListView's current page and then feed that back in get_success_url after the update? class ArticleEditView(UpdateView): model = Article template_name = 'edit_template.html' form_class = ArticleForm def get_success_url(self): return reverse('editor_listview', kwargs={'page': 10}) Thank you -- 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 post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/646c8295-a5c5-42b4-b3a9-e9a477c1341b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.