On Tue, Feb 19, 2013 at 11:34 AM, psychok7 <nun...@gmail.com> wrote:
> hi, i am trying to call a class based view and i am able to do it, but for
> some reason i am not getting the context of the new class
>
> class ShowAppsView(LoginRequiredMixin, CurrentUserIdMixin, TemplateView):
> template_name = "accounts/thing.html"
>
> def compute_context(self, request, username):
> u = get_object_or_404(User, pk=self.current_user_id(request))
> if u.username == username:
> cities_list=City.objects.filter(user_id__exact=self.current_user_id(request)).order_by('-kms')
> allcategories = Category.objects.all()
> allcities = City.objects.all()
> rating_list = Rating.objects.filter(user=u)
> totalMiles = 0
> for city in cities_list:
> totalMiles = totalMiles + city.kms
> return {'totalMiles': totalMiles ,
> 'cities_list':cities_list,'rating_list':rating_list,'allcities' : allcities,
> 'allcategories':allcategories}
>
> @method_decorator(csrf_exempt)
> def dispatch(self, *args, **kwargs):
> return super(ShowAppsView, self).dispatch(*args, **kwargs)
>
> def get(self, request, username, **kwargs):
> return self.render_to_response(self.compute_context(request,username))
>
> class ManageAppView(LoginRequiredMixin, CheckTokenMixin,
> CurrentUserIdMixin,TemplateView):
> template_name = "accounts/smarturbia.html"
>
> def compute_context(self, request, username):
> action = request.GET.get('action')
> city_id = request.GET.get('id')
> u = get_object_or_404(User, pk=self.current_user_id(request))
> if u.username == username:
> if request.GET.get('action') == 'delete':
> #some logic here and then:
> ShowAppsView.as_view()(self.request)
>
> What am i doing wrong guys?
>

You're not returning the response created by calling the ShowAppsView
CBV, you just discard it. After that, control flows back in to the
ManageAppView CBV.

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to