Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Blue footer in Gentelella Theme
I'm currently working with this fantastic theme. For context I'm using the django flavor django-gentelella. My problem is when I remove some elements from the side bar a blue footer appears, those elements are the following: Removing <div class="sidebar-footer hidden-small"> Blue Footer appears: Not removing the above class but if you remove some menu elements from the side bar when you click the hamburger to minimize the sidebar, blue footer again: I tried to replicate both scenarios on the demo: gentelella demo but only the first scenario can be reproduced, probably because the template is not being rendered. I'm not a CSS expert but if someone can help me I would really appreciate it. -
Using Django, how do I set a default value for a foreign key select when creating a new item
I've come to the end of the DjangoGirls tutorial and have been trying to add some extra functionality of my own I have a new model called Subject. Each blog post now has a subject such as cookery, gardening, astrophysics, general, etc. When a blogger writes a new post, I want to force the Subject dropdown to default to 'General', but my template (post_edit.html) doesn't give me access to the SELECT so I can't set a default value post_edit.html: {% extends 'blog/base.html' %} {% block content %} <div> <h1>New post</h1> <form method="POST" class="post-form">{% csrf_token %} {% if form.non_field_errors %} <ul> {% for error in form.non_field_errors %} <li>{{ error }}</li> {% endfor %} </ul> {% endif %} {% for field in form %} <div id="{{ field.auto_id }}_container"> {{ field.help_text }} <div> <span class="staticdata">{{ field.label_tag }}</span> <span class="staticdata">{{ field }}</span> </div> <div id="{{ field.auto_id }}_errors"> {{ field.errors }} </div> </div> {% endfor %} <button type="submit" class="save btn btn-default">Save</button> </form> </div> {% endblock %} forms.py from django import forms from .models import Post, Subject from django.contrib.auth.models import User class PostForm(forms.ModelForm): class Meta: model = Post fields = ('title', 'text', 'subject', 'author') models.py from django.db import models from django.utils import timezone class Post(models.Model): author … -
Authentication login in django (AbstractBaseUser model)
I have a problem at the moment of the authenticity of a user since I have a custom model which the primary key comes from a People table. views.py That's where the authentication is done It is not taking the user model from django.shortcuts import render, redirect from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth import authenticate, login from django.http import HttpResponse from django.template import loader def user_new(request): if request.method == "POST": form = AuthenticationForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.set_password(User.password) user.save() return redirect('index', User.User) else: return render(request, 'login.html', {'form': form}) else: form = NewUserForm() return render(request, 'login.html', {'form': form}) def index(request): if request.method == 'POST': form = AuthenticationForm(data=request.POST) if form.is_valid(): User = form.cleaned_data['username'] password = form.cleaned_data['password'] User = authenticate(username=User, password=password) if User is not None and User.is_active: login(request,user) return redirect('/privada') else: return HttpResponse('Algo salio mal') else: return HttpResponse('El formulario no es valido') else: form = AuthenticationForm() ctx={'form':form} return render(request, 'index.html', ctx) Model People In this model of people we create the person to whom a user will be assigned and the data that is sent to the user table is the id of the person model from django.db import models from apps.area.models import Area from apps.company_dependence.models import CompanyDependence from apps.position.models import … -
Highlight exact phrase with haystack/elasticsearch in Django
My web app uses Django Haystack with Elasticsearch as the search engine. My SearchForm child class filters for exact search (content__exact parameter) if the search query contains a token with quotes. class NepSearchForm(SearchForm): # ... def search(self): if not self.is_valid(): return self.no_query_found() if not self.cleaned_data.get('q'): return self.no_query_found() sqs = self._parse_query(self.cleaned_data['q']) if self.load_all: sqs = sqs.load_all() return sqs def no_query_found(self): return self.searchqueryset.all() def _parse_query(self, query): """ Parse query treating modifiers 'AND', 'OR', 'NOT' to make what they're supposed to. :param query: query entered in search input box in form :param sqs: SearchQuerySet until now :return: SearchQuerySet object """ words = iter(shlex.split(query)) result = self.searchqueryset for word in words: try: if word == 'AND': result = result.filter_and(content=words.__next__()) elif word == 'OR': # TODO: fail when changing order of the words. See # TODO: functional test: # TODO: test_search_with_OR_modifier_returns_correct_objects result = result.filter_or(content=words.__next__()) elif word == 'NOT': result = result.exclude(content=words.__next__()) # if "word" is compounded of more than one non blank word the # term is inside quotes elif len(word.split()) > 1: result = result.filter(content__exact=word) else: result = result.filter(content=word) except StopIteration: return result return result I'm using the Django template tag {% highlight %} to highlight the terms searched in my app, like in: … -
During tests, how to override a Django setting used in the urlconf?
In my Django project's urlconf I have something like this: from django.conf import settings from django.conf.urls import include, url urlpatterns = [ url(r'^{}/blog'.format(settings.MY_ROOT_DIR), include('weblogs.urls')), # ... ] In my settings.py I'll have something like: MY_ROOT_DIR = 'phil' This is so I can set the root directory, that's used in several places, in one place (the settings). When I come to test URLs, I use the @override_settings decorator: from django.test import TestCase, override_settings from django.urls import reverse @override_settings(MY_ROOT_DIR='terry') class WeblogUrlsTestCase(TestCase): def test_post_detail_url(self): self.assertEqual( reverse('post_detail', kwargs={'slug': 'my-post'}), '/terry/blog/my-post/' ) However, @override_settings doesn't appear to do anything - the MY_ROOT_DIR value used in urls.py is always "phil", never the overridden setting of "terry". I've also tried @modify_settings, and using it on the test method, rather than the class. I guess the urlconf is is loaded by Django before @override_settings takes effect? Is there a way around this? Or a better solution altogether? -
django + nginx + uwsgi + ssl giving post 403 forbidden error from react?
I run django + nginx + uwsgi with https in production, and the front end uses react. The react code requests the production site for the apis during development. When js code uses POST it causes a 403 forbidden. I think this occurs because the host and referer headers are different when posting from localhost to the production site with ssl. It was working fine when I was using gunicorn. I would like to find a workaround so that I can POST from the js code while developing the react app. This is my nignx conf. server { listen 80; server_name www.tratoli.com,tratoli.com; #return 301 https://$host$1; rewrite ^(.*) https://www.tratoli.com$1 permanent; } server { listen 443 ssl; ssl_certificate /etc/nginx/sites-available/tratoli_ssl.crt; ssl_certificate_key /etc/nginx/sites-available/tratoli_ssl.key; server_name www.tratoli.com; location = /favicon.ico { alias /home/ubuntu/django/new_backend/favicon.ico; } location /static/ { alias /home/ubuntu/django/new_backend/static/; } location / { include uwsgi_params; uwsgi_pass unix:///home/ubuntu/django/new_backend/tratoli/tratoli.sock; } location /chat/ { proxy_pass http://52.66.167.160:8000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Origin ''; proxy_read_timeout 300; } location ~* \.(?:jpg|jpe?g|png|gif|ico|css|js|eot|ttf|woff|otf)$ { root /home/ubuntu/django/new_backend/; expires 30d; add_header Pragma public; add_header Cache-Control "public"; } location =/sw.js { root /home/ubuntu/django/new_backend/static/react_mobile/js/; } } And this is my uwsgi ini file [uwsgi] socket = /home/ubuntu/django/new_backend/tratoli/tratoli.sock uid = 1000 gid = 33 … -
Unescaping characters with Python (Django)
I am trying to show a list of Objects from my Postgres DB like this: # -*- coding: utf-8 -*- @python_2_unicode_compatible @csrf_exempt def eventlist(request): esemenyek = Event.objects.all().values() esemenyek_list = list(esemenyek) return JsonResponse(esemenyek_list, safe=False) This would work great but I use characters like óüöűáéúő and instead of these I get their escaped version like \u0171\u00e1\u00e9\u00fa\u0151\u00f3\u00fc\n\r. I spent a couple of hours trying to figure it out without any luck. -
Get multiple values
fields = ['first_name', 'last_name', 'birth_date'] user__first_name, user__last_name, birth_date = self.fields.get(fields) As self.fields is a list, it is not possible to do such thing. How could it possible to modify it so that it works? -
Running some task every 5 mins Django
I wrote small django website that read the data from data base and show that data in a table. (Database will be filled by making the request to an external API. ) Now my problem is that I need to make the request every 5 minutes to API and get the last 5 mins data and store them in the data base and at the same time update my table to show last 5 mins data. I have read about job scheduler but I did not get how I can perform it. First of all is an scheduler such as celery is a good solution for this problem? and would be helpful for me if you can guide me how would be the approach to solve this? -
Django web analytics
I want have web analytics module in my website, where I can see -who has logged in at what time by user name -From which location -Duration I have added google analytics, but I want to have my own dashboard in my website itself. Is there any package is that allow achieve my result or is there way I can use any web analytics tool inside my Django project -
ImportError No module named request
C:\Users\james\Desktop\FaceRecognitionAPI-master\FaceRecognitionAPI-master>python manage.py runserver Performing system checks... Unhandled exception in thread started by Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run self.check(display_num_errors=True) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 426, in check include_deployment_checks=include_deployment_checks, File "C:\Python27\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks new_errors = check(app_configs=app_configs) File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config return check_resolver(resolver) File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver for pattern in resolver.url_patterns: File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in get res = instance.dict[self.name] = self.func(instance) File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in get res = instance.dict[self.name] = self.func(instance) File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module return import_module(self.urlconf_name) File "C:\Python27\lib\importlib__init__.py", line 37, in import_module import(name) File "C:\Users\james\Desktop\FaceRecognitionAPI-master\FaceRecognitionAPI-master\facerec\urls.py", line 6, in from api import views File "C:\Users\james\Desktop\FaceRecognitionAPI-master\FaceRecognitionAPI-master\api\views.py", line 9, in import urllib.request ImportError: No module named request -
Django `DateTimeRangeField` used with `date_hierarchy`
I have a DateTimeRangeField that I'd like to use with django's date_hierarchy but date_hierarchy needs a DateField or DateTimeField. I've written a function to convert the range into a datetime using range.lower, but this doesn't seem to work. eg. @admin.register(models.MyModel) class MyModelAdmin(AdvancedModelAdmin): date_hierarchy = 'date_range_to_datetime' def date_range_to_datetime(instance): """ Return a datetime from django date range. """ return instance.range.lower Is there a way to use a DateTimeRangeField with date_hierarchy? -
I cannot login from Dockered Django web application. What is wrong?
I successfully put my web application in a Docker container. Looking through... I can register users. When I tried to register the same user my web application says that the user is already registered. I cannot logged in as any users. I can go to admin login panel. I cannot logged in as an admin. Other than that everything went fine. I am using SQLite. And this is my docker-compose.yml. version: "3" services: nginx: image: nginx:latest container_name: nginx_airport ports: - "8080:8080" volumes: - ./:/app - ./nginx:/etc/nginx/conf.d - ./static:/app/static depends_on: - web rabbit: hostname: rabbit_airport image: rabbitmq:latest environment: - RABBITMQ_DEFAULT_USER=admin - RABBITMQ_DEFAULT_PASS=asdasdasd ports: - "5673:5672" web: build: ./ container_name: django_airport volumes: - ./:/app - ./static:/app/static expose: - "8080" links: - rabbit depends_on: - rabbit I don't think I need separate container for SQLite don't I? -
How to test if one element from list is in other list in django filter
I trying to make this for query work using the Django filter. Any help? tmp = TemporaryLesson.objects.filter(Q(expiration_date__gte=now()) | Q(expiration_date__isnull=True)) temporary_lessons = [] for t in tmp: # How to make this manual query works in the filter above? for c in t.related_courses: if c in student.my_courses: temporary_lessons.append(t) break -
Multiple Logics in filter
I'm implementing ModelManger for privacy. Basically, I want to exclude some queryset for this case if post(Cloth)'s field only_me is true and owner of post(Cloth) is not logged in user. class ClothManager(models.Manager): def all(self, *args, **kwargs): return super(ClothManager, self).filter(???) Use Case return qs if only_me=false return qs if only_me=true and user=self.request.user (Can we call self.request.user in Model?) DO NOT return qs if only_me=true and user is not self.request.user I can use Q if it's needed -
Defining more models in a decorator
I have a pattern that I'd like to make as reproducible as possible, it goes something like this: class TranslatedThing(models.Model): name = models.Charfield(max_length=100) class Thing(models.Model): translation = models.ForeignKey(TranslatedThing) name = models.Charfield(max_length=100) The idea being that in my raw data I have some Things, which map to a reduced set of translated Things. Across many different data sets I have many different types of Things. I already use an Abstract class to reduce the complexity of this pattern: class AbstractThing(models.Model): name = models.CharField(max_length=100) class Meta: abstract = True ------- class TranslatedThing(AbstractThing): pass class Thing(AbstractThing): translated = models.ForeignKey(TranslatedThing) But I'd like to automate the creation and linkage to TranslatedThing. Is this possible with a decorator? e.g. @translate class Thing(AbstractThing): pass ---- Thing.objects.filter(translation__name="foo") #works I've read through but it looks like maybe not. Is there any other way to reduce the repetition of code while using this pattern? -
How to escape single quote for a prop?
I have a Django context variable which is a jsonified list of strings but some of those strings might have a single quote ' import json list_of_strings = ["test", "hello", "I have a'single quote"] return render(request, 'template.html', { 'strings': json.dumps(list_of_strings) }) Then I insert it into a vue component through one of his props which, as you can see, must be wrapped between single quotes. :strings='{{ strings|safe }}' But it crashes, just insert the list until the first single quote and then writes everything else as text in the browser. How can I escape it? -
Sessions not getting created and deleted
i have made a login and logout form this way : http://blog.narenarya.in/right-way-django-authentication.html But now i am facing problem with sessions. As i have used the ways described in the above link, i have not made a login and logout view. Hence the login() and logout() function have not been used. Therefore the session is not getting created everytime i log in and not getting destroyed when i log out. //project/urls.py(the outer one) from django.contrib.auth import views from student.forms import LoginForm url(r'^login/$', views.login, {'template_name': 'login.html', 'authentication_form': LoginForm}, name='login'), url(r'^logout/$', views.logout, {'next_page': '/login'}), //forms.py from django.contrib.auth.forms import AuthenticationForm from django import forms class LoginForm(AuthenticationForm): username = forms.CharField(label="Username", max_length=30, widget=forms.TextInput(attrs={'class': 'form-control', 'name': 'username'})) password = forms.CharField(label="Password", max_length=30, widget=forms.TextInput(attrs={'class': 'form-control', 'name': 'password'})) How do i do that? -
The pointer got nothing?
OrderedDict([('first_name', <django.forms.fields.CharField object at 0x7f9b5bed4c50>), ('last_name', <django.forms.fields.CharField object at 0x7f9b3b7abf50>), ('email', <django.forms.fields.EmailField object at 0x7f9b3b7abf10>)]) I have this dict, when I call self.fields. I am trying to get access the value of email with email = self.fields.get('email', False), which is supposed to be something like test@test.com, but I got . Is it because the space is not used yet? Otherwise, how could I get the value of email? -
Unable to build Solr schema in Django project
I'm going to build a schema using command $ python manage.py build_solr_schema. I'm using Apache Solr 4.10.4 in my Django powered project. When I ran Apache Solr, I got error: SolrCore Initialization Failures blog: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core blog: Plugin Initializing failure for [schema.xml] fieldType. Schema file is solr/blog/conf/schema.xml Please check your logs for more information Solr logs: WARN - 2017-09-28 15:15:40.335; org.apache.solr.schema.FieldTypePluginLoader; TokenFilterFactory is using deprecated 3.6.0 emulation. You should at some point declare and reindex to at least 4.0, because 3.x emulation is deprecated and will be removed in 5.0 WARN - 2017-09-28 15:15:40.337; org.apache.solr.schema.FieldTypePluginLoader; TokenizerFactory is using deprecated 3.6.0 emulation. You should at some point declare and reindex to at least 4.0, because 3.x emulation is deprecated and will be removed in 5.0 WARN - 2017-09-28 15:15:40.338; org.apache.solr.schema.FieldTypePluginLoader; TokenFilterFactory is using deprecated 3.6.0 emulation. You should at some point declare and reindex to at least 4.0, because 3.x emulation is deprecated and will be removed in 5.0 WARN - 2017-09-28 15:15:40.338; org.apache.solr.schema.FieldTypePluginLoader; TokenFilterFactory is using deprecated 3.6.0 emulation. You should at some point declare and reindex to at least 4.0, because 3.x emulation is deprecated and will be removed in 5.0 WARN - 2017-09-28 … -
Getting a KeyError when edit profile
I am attempting to allow the user to edit user profile however I keep getting a KeyError. What am I doing wrong ? KeyError at /Identity/profile/edit/ 'password' Request Method: POST Request URL: http://127.0.0.1:8000/Identity/profile/edit/ Django Version: 1.10.5 Exception Type: KeyError Exception Value: 'password' Exception Location: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/contrib/auth/forms.py in clean_password, line 145 Python Executable: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3 Python Version: 3.5.3 Python Path: ['/Users/iivri.andre/Nesting/Identity', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages'] This is the code the cause the error : UpdateAccount form : I imported these models to enable creation of the updateaccount form : from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm, UserChangeForm I then created the UpdateAccoutnForm class which takes the UserChangeForm argument class UpdateAccountForm(UserChangeForm): class Meta: model = User fields = ( 'email', 'first_name', 'last_name', 'password' ) Code in views.py document from django.shortcuts import render, redirect from django.urls import reverse from django.contrib.auth.forms import UserChangeForm, PasswordChangeForm from django.contrib.auth.models import User from Identities.forms import CreateAccountForm, UpdateAccountForm This the function based view that will allow the editing the saving of the updated profile def edit_profile(request): if request.method == 'POST': form = UpdateAccountForm(request.POST) if form.is_valid(): form.save() return redirect('Identities:view_profile') else: return redirect('Identity/profile/edit') else: form =UpdateAccountForm(instance = request.user) var = {'form': form} return render(request, 'Identities/edit_profile.html',var) Tool versions … -
authentication login ( DJANGO )
I have an error in django authentication with a user model that extends from AbstracBaseUser and its id is a foreign key from another table. views.py enter image description here ModelsUser enter image description here ModelPeople from django.db import models from apps.area.models import Area from apps.company_dependence.models import CompanyDependence from apps.position.models import Position class People(models.Model): documentPeople = models.AutoField(primary_key=True, null=False) fullname = models.CharField(max_length=50) phone = models.IntegerField() address = models.CharField(max_length=50) email = models.CharField(max_length=50) codeArea = models.ForeignKey(Area, null=True, blank=True, on_delete=models.CASCADE) codePosition = models.ForeignKey(Position, null=True, blank=True, on_delete=models.CASCADE) codeCompaDepen = models.ForeignKey(CompanyDependence, null=True, blank=True, on_delete=models.CASCADE) def __str__(self): return '{}'.format(self.fullname) in the settings I put AUTH_USER_MODEL = 'user.User' -
Python/Django logging issues (syslog)
Hi, I am posting data to my REST-API, and get an HTTP 500 error. I have a fault in my models.py which I was able to fix already. The problem I have is with logging. I do get an e-mail of this error, but forwarding this error to syslog doesn't work. Syslog works otherwise. E.g. if I get HTTP 404 (Not found) this message is forwarded to syslog without problems. E-mail has this error-info: $ [Sep/28/2017 15:38:28] django.request ERROR Internal Server Error: /api/v1/organizations/ Traceback (most recent call last): File "..dev/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) psycopg2.IntegrityError: null value in column "some_code" violates not-null constraint DETAIL: Failing row contains (...). The above exception was the direct cause of the following exception: Traceback (most recent call last): ........ File "..dev/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) django.db.utils.IntegrityError: null value in column "some_code" violates not-null constraint DETAIL: Failing row contains (.....). [Sep/28/2017 15:38:28] django.server ERROR "POST /api/v1/organizations/ HTTP/1.1" 500 22033 Settings: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse', }, 'require_debug_true': { '()': 'django.utils.log.RequireDebugTrue', }, }, 'formatters': { 'verbose': { 'format': '%(process)-5d %(thread)d %(name)-50s %(levelname)-8s %(message)s' }, 'simple': { 'format': '[%(asctime)s] %(name)s %(levelname)s %(message)s', 'datefmt': … -
How to do an update method for a nested django rest framework APi Boolean ? [OnetoOneField]
So i have been researching about how to update the nested serializer with onetoonefield. However it has not been able to solve my problem. As i am still new to django rest framework, i am still inexperience about what is the problem as i never done an API before. models.py class Membership(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) membership = models.BooleanField(default=False) serializers.py class MembershipSerializer(serializers.ModelSerializer): class Meta: model = Membership fields = ('membership',) class UserSerializer(serializers.ModelSerializer): membership = MembershipSerializer(many=False) class Meta: model = User fields = ('id', 'username', 'email', 'password', 'first_name', 'last_name', 'is_staff', 'membership',) read_only_fields = ('id',) def create(self, validated_data): membership_data = validated_data.pop('membership') user = User.objects.create(**validated_data) Membership.objects.create(user=user, **membership_data) return user def update(self, instance, validated_data): instance.username = validated_data.get('username', instance.username) instance.email = validated_data.get('email', instance.email) instance.password = validated_data.get('password', instance.password) instance.first_name = validated_data.get('first_name', instance.first_name) instance.last_name = validated_data.get('last_name', instance.last_name) instance.is_staff = validated_data.get('is_staff', instance.is_staff) instance.save() membership_data = validated_data.get('membership') membership_id = membership_data.get('id', None) if membership_id: membership_item = Membership.objects.get(id=membership_id, membership=instance) membership_item.membership = membership_data.get('membership', membership_item.name) membership_item.user = membership_data.get('user', membership_item.user) membership_item.save() return instance views.py class UserViewSet(viewsets.ModelViewSet): queryset = User.objects.all().order_by('-date_joined') serializer_class = UserSerializer permission_classes = [IsAuthenticated] def get_permissions(self): # allow non-authenticated user to create return (AllowAny() if self.request.method == 'POST' else permissions.IsStaffOrTargetUser()), screenshot of api https://i.imgur.com/dDqthRu.png As you can see above, my membership is null, … -
Django-Haystack: How to pass extra context with FacetedSearchView
This is my current view. class FacetedSearchView(BaseFacetedSearchView): form_class = FacetedProductSearchForm facet_fields = ['TopCategory'] template_name = 'shop-grid-ls.html' paginate_by = 20 context_object_name = 'object_list' extra = TopCategory.objects.all() def extra_context(self): return { 'extra': self.extra, } I can't access the 'extra' objects within my templates. How can I pass context through a FacetedSearchView. Thanks.