Thanks a lot for your help, but my problem is that i want to  pass an 
additional parameter to ShopDetalview. I want to pass the datetimelst in 
order to handle it in ShopDetailView

On Tuesday, November 5, 2019 at 5:28:17 PM UTC+2, Bruckner de Villiers 
wrote:
>
> I assume that you want to access the DetailView form the ListView??
>
> To do that your List View template (which should be shop_list.html) should 
> contain <a href=”{{shop.id}}/”>{{field}} – {{field}}</a>
>
> I don’t see your models.py so don’t know what the fields are, but here is 
> an example of my code for a model called Organisation:
>
>  
>
> {% extends 'pbs1/pbs1_base.html' %}
>
> {% block body_block %}
>
> <div class = "jumbotron">
>
>     <h4 id='pers'>Available Organisations - </h4>
>
>     <h5><i>Click for further details</i></h5>
>
>     <p></p>
>
>     <ol>
>
>         {% for org in organisation_list %}
>
>             <h6><li><a href="{{org.id}}/">{{org.org_Name}} - {{org.
> org_HQ_Location}}</a></li></h6>
>
>         {% endfor %}
>
>     </ol>
>
> </div>
>
> <div class="container">
>
>     <p><a class="btn btn-light" href="{% url 'pbs1:home' %}">Back</a></p>
>
> </div>
>
> {% endblock %}
>
>  
>
> So, when the user clicks on an organisation in the list it takes her to 
> the DetailView of that organisation, by virtue of the line in the urls.py:
>
> path('<int:pk>/', views.Org_DetailView.as_view(), name='detail'),
>
>  
>
> Caveat – I am still an novice, but this works for me.
>
>  
>
> Bruckner de Villiers
>
> 083 625 1086
>
>  
>
> *From: *<[email protected] <javascript:>> on behalf of sotiris 
> moustogiannis <[email protected] <javascript:>>
> *Reply to: *<[email protected] <javascript:>>
> *Date: *Monday, 04 November 2019 at 02:09
> *To: *Django users <[email protected] <javascript:>>
> *Subject: *pass parameter from one class view to another
>
>  
>
> 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
>
> -- 
> 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 [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/5c011fa8-daa1-41ad-b4e8-b4bb7e8aa5d2%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/5c011fa8-daa1-41ad-b4e8-b4bb7e8aa5d2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a637196-2727-448a-ae80-cb97a4160600%40googlegroups.com.

Reply via email to