Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template name for Class Based View. #57

Open
ghost opened this issue Jun 1, 2015 · 1 comment
Open

Template name for Class Based View. #57

ghost opened this issue Jun 1, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 1, 2015

Hey I've got it to work but when I created the 'mobile/directory/venue_index.html and venue_list.html it doesn't use the templates. Sure it's some small thing I just missed.

class VenueList(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView):
    model = Venue
    paginate_by = 20
    context_object_name = 'venues'
    category = None
    slug_level = ""
    area = None

    template_name = 'directory/venue_index.html'

    def get_queryset(self):
        if self.request.is_mobile:
            qs = Venue.objects.filter(visible=True,).order_by('-hot', '-created')
            if self.kwargs.get('category', None):
                self.template_name = 'directory/venue_list.html'
                slugs = self.kwargs['category'].strip('/').split('/')
                self.category = get_object_or_404(Category, slug=slugs[-1])
                qs = qs.filter(categories__in=self.category.get_descendants(include_self=True))
            if self.kwargs.get('area', None):
                self.template_name = 'directory/venue_list.html'

                self.template_name = 'directory/venue_list.html'
                slugs = self.kwargs['area'].strip('/').split('/')
                self.area = get_object_or_404(Area, slug=slugs[-1])
                qs = qs.filter(area__in=self.area.get_descendants(include_self=True))
            if self.request.META.get('HTTP_ACCEPT', None) == 'application/json':
                qs = qs.filter(longitude__isnull=False, latitude__isnull=False).exclude(longitude=0, latitude=0).order_by('name')
            self.queryset = qs.distinct()
            return self.queryset
@gregmuellegger
Copy link
Owner

Hey, have you added django_mobile.loader.Loader as first item to your TEMPLATE_LOADERS setting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant