pass list parameter from one class view to another

48 views
Skip to first unread message

sotiris moustogiannis

unread,
Nov 4, 2019, 8:42:51 PM11/4/19
to Django developers (Contributions to Django itself)
I have this listview and the context['datetimelist'] which is a list into def get_context_data

class ShopListView(ListView):
  model = Shops
  context_object_name= 'shops'

        template_name = 'booking/search.html'

        def get_context_data(self, **kwargs):
          context = super(ShopListView, self).get_context_data(**kwargs)
         query = self.request.GET.get('q')
              query1 = self.request.GET.get('q1')
            query2 = self.request.GET.get('q2')
            query3 = self.request.GET.get('q3')
            context['datetimelist'] = [query,query1,query2,query3]
         return context


        def get_queryset(self):
        query = self.request.GET.get('q')
              query1 = self.request.GET.get('q1')
            query2 = self.request.GET.get('q2')
            query3 = self.request.GET.get('q3')
            result_list = Shops.objects.exclude(Q(appointments__time=query) & Q(appointments__date = query1))
              result_list2 = Shops.objects.filter(Q(city=query2) & Q(typesport=query3))
              context = list(chain(result_list & result_list2))
              return context



And i want to pass this list to ShopDetailView class based view 


class ShopDetailView(DetailView):

        model = Shops
 
        template_name = 'booking/results.html'


        context_object_name= 'shops'



Also, here are my urls that calls these classes

    path('search/', booking_views.ShopListView.as_view(template_name='booking/search.html'), name='search'),
    path('results/<int:pk>/', booking_views.ShopDetailView.as_view(template_name='booking/results.html'), name='results'),


How can i pass this list from one class based view to the other

Adam Johnson

unread,
Nov 5, 2019, 4:14:55 AM11/5/19
to django-d...@googlegroups.com
Hi!

I think you've found the wrong mailing list for this post. This mailing list is for the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy. Read more on the mailing lists at https://www.djangoproject.com/community/

For support, please use the NEW Django forum at https://forum.djangoproject.com , django-users mailing list, or IRC #django on Freenode, or a site like Stack Overflow. There are people out there willing to help on those channels, but they might not respond if you don't ask your question well. Stack Overflow's question guide can help you frame it well: https://stackoverflow.com/help/how-to-ask .

Also if you haven't read it, please take a look at Django's Code of Conduct: https://www.djangoproject.com/conduct/ . These are our "ground rules" for working well as a community, and will help you get the most out of Django and our fantastic community.

Thanks for your understanding,

Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3268ec4e-accf-49df-8578-aab18c69ce30%40googlegroups.com.


--
Adam
Reply all
Reply to author
Forward
0 new messages