Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
SSL verification is failed while authenticating with google-oauth2
I have implemented google Oauth2 authentication in a django project which is throwing an error when I choose the gmail account to get logged in. The error is "Authentication failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)". I have gone through a number of links and analyse it; but couldn't found any solution. Please suggest if you have one. I have followed this Link to setup the implement the authentication. When I hit the url for login i.e. http://localhost:8000/soc/login/google-oauth2,it is working fine but redirect uri is throwing the error after I select the account to get authenticated. -
mod_wsgi takes minutes on first page load after Apache restart
I have an outlier of a Django project with thousands of models. It serves as a RESTful API to data we have using Django REST Framework. When I start Django's runserver, it takes several minutes to come up, due to validating the data models in the project. Once loaded, it works as expected. mod_wsgi exhibits a similar behavior. After a publish or when we restart Apache, the first time we bring up the page in a browser takes several minutes. After that first page load, the entire site is pretty much instantly responsive. From reading the documentation, this seems to be when mod_wsgi is loading the application into the GLOBAL application group. I've been trying to find a way to start this loading process immediately after a deployment (which touches wsgi.py), or an Apache restart, to avoid having to bring the website up in a browser after a deployment, which is problematic in production as we have several web servers behind a round-robin proxy, on a private network. I have tried both adding the GLOBAL application group to the WSGIScriptAlias and adding WSGIImportScript, but neither seems to work. Here is my .conf file for the VirtualHost in question. I'm clearly … -
How to properly use mysql 5.7 and Django using docker-compose?
I had perflecty running docker-compose setup with mysql 5.6 Unfortunately I needed to use JSONField, so I wanted to switch to MySQL 5.7 All I did was change the image version in docker-compose file and add charset & collation options to 'DATABASES' setting. I also wiped all docker-related stuff (removed all containers, images and volumes to ensure clean setup). So no legacy db is in place. Now the tests do not work (I use pytest). On mysql 5.6 everything worked fine, on 5.7 I get errors like Got an error creating the test database: (1044, "Access denied for user 'dbuser'@'%' to database 'test_myproject'") The docker-compose.yml file has db set like this (version 2): db: image: mysql:5.7.17 volumes: - myproject_db_data:/var/lib/mysql env_file: - local.env ports: - "3306:3306" restart: always command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci local.env has nothing special: MYSQL_ROOT_PASSWORD=supersecretpwd123 MYSQL_DATABASE=myproject MYSQL_PASSWORD=dbpass MYSQL_USER=dbuser What did I miss? -
Django Migrations failing to apply
I have removed one Foreign Key field from a model and added another, so from: class MyModel(models.Model): fk_a = models.ForeignKey(ModelA) to class MyModel(models.Model): fk_b = models.ForeignKey(ModelB) I autogenerated the migration, which includes this: migrations.AddField( model_name='mymodel', name='fk_b', field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='myapp.modelb'), ), migrations.RemoveField( model_name='mymodel', name='fk_a', ), If I open up MySQL and describe the table, before applying the migration, it looks like: mysql> describe myapp_mymodel; +---------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | fk_a_id | int(11) | NO | MUL | NULL | | +---------------+---------+------+-----+---------+----------------+ When I run the migration, I get the following error: raise django.core.exceptions.FieldDoesNotExist: MyModel has no field named u'fk_a' What on earth is going on? I've reset, carefully checked the migration and database state, regenerated and rerun the migration and the same error occurs. -
How to implement search with part of the term in haystack and django
I need to get the results of search with part of the term provided in the search field like entering "tes" should get results for "test,tester,testing". I need the search to work for primary field (where we put document=True) in searchindexes.I am using django 1.7.5 and haystack 2.3.1 What I already tried. text = indexes.CharField(document=True, use_template=True) in search_indexes.py and sqs.filter(text__contains=escape(q), global_search=True, is_active=True) text = indexes.EdgeNgramField(document=True, use_template=True) in search_indexes.py and sqs.filter(text__contains=escape(q), global_search=True, is_active=True) or sqs.filter(text=escape(q), global_search=True, is_active=True) it didn't worked even with NgramField. what am I doing wrong. When I used EdgeNgramField(model_attr="title") ,it worked. But I need to use it with primary one where we provide document=True. Please help -
How to understand the setup.cfg file in the python?
There is some code I copy from the nova-master's setup.cfg: console_scripts = nova-api = nova.cmd.api:main nova-api-metadata = nova.cmd.api_metadata:main nova-api-os-compute = nova.cmd.api_os_compute:main nova-cells = nova.cmd.cells:main nova-compute = nova.cmd.compute:main nova-conductor = nova.cmd.conductor:main nova-console = nova.cmd.console:main nova-consoleauth = nova.cmd.consoleauth:main nova-dhcpbridge = nova.cmd.dhcpbridge:main nova-idmapshift = nova.cmd.idmapshift:main wsgi_scripts = nova-placement-api = nova.api.openstack.placement.wsgi:init_application nova-api-wsgi = nova.api.openstack.compute.wsgi:init_application nova-metadata-wsgi = nova.api.metadata.wsgi:init_application You can see the upper code, such as the console_scripts = nova-api = nova.cmd.api:main How to understand that? can I comprehend it to: console_scripts:{ nova-api=nova.cmd.api:main } or like this: console_scripts=nova-api=nova.cmd.api:main -
Create new application in django
When i create application inside the django project by using startapp, the application is created as read only. I cannot add any new files inside the application. What should I do for that? I am using Linux mint operating syst Please help. -
models.FileField(blank=False): form is valid even if I don't choose file during update
Django 1.11.2 This view is called via AJAX. It may be important. In the model I used blank=False. In DeleteOldFileMixin I have put a breakpoint (please the comment in the code below where it is). I run Django, try to update an existing UserFile object. The update form appears. But i don't select any file, I just press "Submit". And I occur at breakpoint. The breakpoint is inside form_valid method. This means that form is already cleaned. My code works incorrectly: it deletes an old file without substituting it with a new one. But if I use blank=False, why the form should be valid? If the form could intercept this empty field, I'd be glad. Could you give me a kick here? class UserFile(models.Model): item = models.ForeignKey(Item, on_delete=models.PROTECT) user_file = models.FileField(blank=False, verbose_name=_("file"), max_length=255, upload_to=get_file_path) class FileForm(ModelForm): class Meta: model = UserFile exclude = [] class DeleteOldFileMixin(ModelFormMixin): def form_valid(self, form): old_file_name = form.initial.get('user_file').name # Breakpoint try: os.remove("{}/{}".format(settings.MEDIA_ROOT, old_file_name)) except FileNotFoundError: pass # Do nothing. return super(DeleteOldFileMixin, self).form_valid(form) class FileUpdate(DeleteOldFileMixin, UpdateView): model = UserFile form_class = FileForm -
How to use tags in django charfield?
I'm making a blog with Django. When the admin creates an article, how can he use tags for text formating or import an image? thanks. -
Running python manage.py test gives "Max Recursion Depth reached error"
So I have a django project which was built on 1.6.5 and now I'm migrating it to 1.9.5. I successfully migrated it to 1.7.0 and then to 1.8.0. When doing so from 1.8.0 to 1.9.0, I had to replace SortedDict by collections.OrderedDict. Now I'm encountering this error when I do python manage.py test: File "forum/models/base.py", line 134, in iterator key_list = [v[0] for v in self.values_list(*values_list)] File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__ self._fetch_all() File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all self._result_cache = list(self.iterator()) File "forum/models/base.py", line 134, in iterator key_list = [v[0] for v in self.values_list(*values_list)] File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__ self._fetch_all() File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all self._result_cache = list(self.iterator()) File "forum/models/base.py", line 134, in iterator key_list = [v[0] for v in self.values_list(*values_list)] File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 725, in values_list clone = self._values(*fields) File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 671, in _values clone = self._clone() File "venv/mystuff/lib/python2.7/site-packages/django/db/models/query.py", line 1059, in _clone query = self.query.clone() File "venv/mystuff/lib/python2.7/site-packages/django/db/models/sql/query.py", line 298, in clone obj._annotations = self._annotations.copy() if self._annotations is not None else None File "/opt/python/python-2.7/lib64/python2.7/collections.py", line 194, in copy return self.__class__(self) File "/opt/python/python-2.7/lib64/python2.7/collections.py", line 57, in __init__ self.__update(*args, **kwds) File "venv/mystuff/lib64/python2.7/abc.py", line 151, in __subclasscheck__ if subclass in cls._abc_cache: File "venv/mystuff/lib64/python2.7/_weakrefset.py", line 72, in __contains__ wr … -
Redirect after post in views.py django rest framework
I'm trying to figure out how to redirect to a simple html response page after post in Django rest framework application. this is how model looks like in web: Form for file upload: And after click on post button I have code in views.py that should redirect it on simple html but instead it stays on same page with empty queryset results and I don't know what I'm I doing wrong? from rest_framework import viewsets from api.models import UploadImage from api.serializers import UploadedImageSerializer from rest_framework import permissions from rest_framework.parsers import MultiPartParser,FormParser from sqlite_queries import user_ips class FileUploadViewSet(viewsets.ModelViewSet): #create queryset view permission_classes = (permissions.IsAuthenticated,) queryset = UploadImage.objects.all() serializer_class = UploadedImageSerializer parser_classes = (MultiPartParser, FormParser,) #after post action get this def perform_create(self, serializer): #grab request image_name = self.request.data['image'] meta_data = self.request.META username = self.request.user REMOTE_ADDR = meta_data['REMOTE_ADDR'] #check user status, how many ip's he had over last 24 hours user_status = user_ips(username) #if user has more than allowed redirect to html page if user_status == 400: print ("how to redirect here?") #return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) #return HttpResponseRedirect("limit.html") #if user iz valid continue with upload serializer.save(user = username, meta_data= meta_data,remote_ip=REMOTE_ADDR) -
How to create a django-cms multilanguage Page from the code
I'm quite new to Django CMS, and I couldn't find in the official documentation nor in SO how to solve the following situation: I have a custom Django app with a couple of models, hooked to Django CMS. I have also created a page that uses that application and the instance. This is all working correctly. For the sake of simplicity, I want to automatically create a new Page object (that inherits from the Page working with the AppHook) every time I create an object of the custom app, let's call it "Project", so this Page object will be associated with the Project object, will execute the Django view and so on. After digging in the docs, the code, and the objects created in the database, I understand I need to create some Page objects, and some related Title objects, but this is where the confusion begins. I'm working with 2 languages. So after checking the database, I see that Django CMS creates an unpublished Page object with two Title objects, obviously, but then, if I publish the page, it will be duplicated in the database. I guess that is using a pair of them for the drafts, and the … -
windows python manage.py collectstatic --noinput error when deploying Django project to Heroku
This is my project files This is error message This is my settings.py """ Django settings for studyingLog project. Generated by 'django-admin startproject' using Django 1.11.2. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '_=ih5m_%sfwfr4k8$6^e3zo#=8xa73prn^+w$d6+%+cu*&=wxi' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #Thirt-part apps 'bootstrap3', #My program 'studyingLogs', 'users', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'studyingLog.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'studyingLog.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, {enter code … -
Fields clash in case of inheritance
I' ve the following simplified model structure: #common/models.py class CLDate(models.Model): active = models.BooleanField(default=True) last_modified = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) #br/models.py class Dokument(CLDate): user = models.ForeignKey(User) class Entity(CLDate): dokument = models.ForeignKey(Dokument) . Both class inherits from CLDate, and i' ve a OneToMany relation between them. When i try to migrate, i got the following error: python manage.py makemigrations SystemCheckError: System check identified some issues: ERRORS: br.Entity.dokument: (models.E006) The field 'dokument' clashes with the field 'dokument' from model 'common.cldate'. I can' t really get why is this structure a problem for Django hence the Entity is a totally different object than the Dokument. Could anyone explain me why, and how could i solve it with this structure? So both should inherit from CLDate and there should be this kind of relation between the 2 models from the br application. I also tried to delete all the migration files, and solve it that way, but the same. Runserver gives also this error. Django: 1.11.2 Python: 3.4.2 Debian: 8.8 . Thanks. If i rename the dokument property name in the Entity model, it works fine. I' m also almost pretty the same layout was working previously (in previous Django versions). -
Delete identical row in many MySQL tables
I'm looking for delete some identical rows present in 4 databases. Each database has a table named Identity_Individu. Don't worry about this process, it's the only way found in order to share data between databases because Data Cross Relation are not allowed with Django. I have this part : #settings.py file BDD = ('default', 'DS_Douane', 'DS_Impots', 'DS_Finance') #views.py file @login_required def Identity_Deleting(request) : query_number = request.GET.get('q6') if query_number : query_number_list = Individu.objects.filter(NumeroIdentification__iexact=query_number) else : query_number_list = Individu.objects.none() form = IndividuFormulaire(request.POST or None, instance = query_number_list.first()) if "Delete" in request.POST : for element in settings.BDD : form = Individu.objects.filter(pk=query_number_list).delete().using(element) return HttpResponseRedirect(reverse('Home')) I'm getting an issue : (1093, "Table 'Identity_individu' is specified twice, both as a target for 'DELETE' and as a separate source for data") How I have to use .delete() with using() in order to delete all rows respecting the condition in each table ? I tried .delete(using=element) but I got : delete() got an unexpected keyword argument 'using' -
Nested imports vs two separate import statements
Consider these two styles of code that accomplish the same thing. NESTED IMPORTS common.models from django.db.models import * class SmallAutoField(fields.AutoField): def db_type(self, connection): return "small serial" myapp.models from common import models class Test(models.Model): id = models.SmallAutoField() test = models.IntegerField() SEPARATE IMPORTS common.models from django.db import models class SmallAutoField(models.fields.AutoField): def db_type(self, connection): return "smallserial" myapp.models from django.db import models from common import models as my_models class Test(models.Model): id = my_models.SmallAutoField() test = models.IntegerField() I know which version I prefer stylistically, but which version is the proper way to do it and why? As for performance: I tried to timeit the Nested version, but that's not possible because SyntaxError: import * only allowed at module level. So, is there another way to benchmark this method? Bytecode for reference, but doesn't look like it tells much: >>> dis.dis('from django.db.models import *') 1 0 LOAD_CONST 0 (0) 3 LOAD_CONST 1 (('*',)) 6 IMPORT_NAME 0 (django.db.models) 9 IMPORT_STAR 10 LOAD_CONST 2 (None) 13 RETURN_VALUE >>> dis.dis('from django.db import models') 1 0 LOAD_CONST 0 (0) 3 LOAD_CONST 1 (('models',)) 6 IMPORT_NAME 0 (django.db) 9 IMPORT_FROM 1 (models) 12 STORE_NAME 1 (models) 15 POP_TOP 16 LOAD_CONST 2 (None) 19 RETURN_VALUE -
Add new custom view in django_chroniker package
I need to create the simple view with some code and add it into cron jobs. From admin side, user just allow to select the custom commands from "command" drop down Can anybody, please help me? For adding custom view and displaying it on admin side. Thanks in advance. -
Django - how to stringify JSON object when passing it as payload to request.post()
I have the following code in my Django view: headers = {'Authorization': "key=AAAA7oE3Mj...", 'Content-type': 'application/json'} token = "dJahuaU2p68:A..." payload = {"data": {}, "to": user_web_tokens} url = "https://..." r = requests.post(url, data=payload, headers=headers) The problem is that the response terminates with 400 error with the error message being: JSON_PARSING_ERROR: Unexpected character (t) at position 0 If I pass a string instead of JSON: payload = {"data": {}, "to": user_web_tokens} ...I get a slightly different error: JSON_PARSING_ERROR: Unexpected character (u) at position 19. I have come across a post where they say that a json object should be stringified before being passed on as a payload. But I have no idea how to this in Django. Does it have something to with serialization ? Help me please ! -
How to add cron job in windows task scheduler, created by django_chroniker package on localhost with virtual environment
I need to set the cron jon in task scheduler on windows 7, cron job created by django_chroniker package on localhost with virtual environment. I have followed the steps mention in below links https://github.com/chrisspen/django-chroniker Properly installed "django_chroniker" package, added job from admin side. After activating the virtual environment and executing the command "python manage.py cron" on command prompt, cron job properly run and stop and log entry is added into log table. But I need to add this job in cron tab, by setting it into cron tab as like Linux server on local (windows task scheduler). I have copied "chroniker" file from Lib/script into project directory. I have tried to execute command python D:\project-folder\chroniker -e D:\virtualenv-path\Scripts\activate_this.py -p D:\project-folder\ without activating the virtual environment, but above command started the job but not stops. python command not access proper project virtual env path. Can anybody tell me how I can do this? Also I need to set this cron job, in task scheduler with proper arguments -
how to generate embed codes for integrating chatbots to other web application
I build a chatbot tool using django application where by clicking in some functions it will generate some intents and entities. Now I want to build a chat box where these req and response comes from the tool and also integrate the chatbot to other webapps. for ex in api.ai or bot framework, once intents and entities are created then we can use embed code(like: src="https://bot.api.ai/2db9077b-d425-4b27-9ad3-8c63467c580f" or https://webchat.botframework.com/embed/sample_questions?s=YOUR_SECRET_HERE' for testing it and also integrate with other web app. Is anyone know how to do this pls help me.. -
Django, Queue and Thread - don't free memory
User visit http://example.com/url/ and invoke page_parser from views.py. page_parser create instance of class Foo from script.py. Each time http://example.com/url/ is visited I see that memory usage goes up and up. I guess Garbage Collector don't collect instantiated class Foo. Any ideas why is it so? Here is the code: views.py: from django.http import HttpResponse from script import Foo from script import urls # When user visits http://example.com/url/ I run `page_parser` def page_parser(request): Foo(urls) return HttpResponse("alldone") script.py: import requests from queue import Queue from threading import Thread class Newthread(Thread): def __init__(self, queue, result): Thread.__init__(self) self.queue = queue self.result = result def run(self): while True: url = self.queue.get() data = requests.get(url) # Download image at url self.result.append(data) self.queue.task_done() class Foo: def __init__(self, urls): self.result = list() self.queue = Queue() self.startthreads() for url in urls: self.queue.put(url) self.queue.join() def startthreads(self): for x in range(3): worker = Newthread(queue=self.queue, result=self.result) worker.daemon = True worker.start() urls = [ "https://static.pexels.com/photos/106399/pexels-photo-106399.jpeg", "https://static.pexels.com/photos/164516/pexels-photo-164516.jpeg", "https://static.pexels.com/photos/206172/pexels-photo-206172.jpeg", "https://static.pexels.com/photos/32870/pexels-photo.jpg", "https://static.pexels.com/photos/106399/pexels-photo-106399.jpeg", "https://static.pexels.com/photos/164516/pexels-photo-164516.jpeg", "https://static.pexels.com/photos/206172/pexels-photo-206172.jpeg", "https://static.pexels.com/photos/32870/pexels-photo.jpg", "https://static.pexels.com/photos/32870/pexels-photo.jpg", "https://static.pexels.com/photos/106399/pexels-photo-106399.jpeg", "https://static.pexels.com/photos/164516/pexels-photo-164516.jpeg", "https://static.pexels.com/photos/206172/pexels-photo-206172.jpeg", "https://static.pexels.com/photos/32870/pexels-photo.jpg"] -
Django - redirect list of users (other than the current user) from view
I am building a web application with Django that will allow teachers to send out multiple choice questions to students. For now, I would like to redirect all logged-in students to the question page (containing the question form) when the teacher clicks on the question. However, this requires redirecting users OTHER THAN the current user from the view which is what I am struggling with. I have looked into every form of redirect (render, HttpResponseRedirect etc) to see if I could input a user parameter but this doesn't seem to be possible. Below is the view where I would like to redirect all users to the question page. @login_required @user_is_on_course def pushquestion(request, course_code, profquestion_id): course = Course.objects.get(code=course_code) choices = Choice.objects.filter(question=profquestion_id) users = get_current_users(request, course) #gets list of students for u in users: #This is where I want to redirect all users to the question page return render(request, 'thesis/professorquestion.html' {'profquestion':profquestion_id, 'course': course, 'choices':choices}) def get_current_users(request,course): active_sessions = Session.objects.filter(expire_date__gte=timezone.now()) user_id_list = [] for session in active_sessions: data = session.get_decoded() user_id_list.append(data.get('_auth_user_id', None)) return UserProfile.objects.filter(id__in=user_id_list, courseID=course) I have researched the Django messages feature however this doesn't seem suitable for sending question forms to all users (seems to operate as more of an alert box). … -
Django how to use variable into src tag
i am making a website.I have a table in my db which is named Adds.Every record has one field and the field contains an url to a image.Everytime the add box has to contain different add.I made the script who gets random add from the db.I have to display it in my html.How can i do this?Something like this <img src = "{{myvariable}}"/> -
AttributeError: 'ModelFormOptions' object has no attribute 'private_fields'
I created a modelform for one model i've made, but the thing is: this error: AttributeError: 'ModelFormOptions' object has no attribute 'private_fields' I don't know where it is coming from, and i don't know how to solve it. What I already tried: Deleted the modelform, and created a regular form instead. (define the fields as they are in the object This is my forms.py: class OpnameBanenForm(forms.ModelForm): class Meta: model = OpnameBanen fields='__all__' Models.py class OpnameBanen(models.Model): id = models.AutoField(primary_key=True, null=False) baan_nr = models.CharField(max_length=23, null=False) ruimte = models.CharField(max_length=45, blank=True, null=True) kleur = models.CharField(max_length=45, blank=True, null=True) banen_baanlengte = models.CharField(max_length=45, blank=True, null=True) project = models.ForeignKey('Project', on_delete=models.CASCADE, blank=True) Edit: The full Traceback: Unhandled exception in thread started by <function wrapper at 0x7fc727a1b5f0> Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 227, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 125, in inner_run self.check(display_num_errors=True) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 359, in check include_deployment_checks=include_deployment_checks, File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 16, in check_url_config return check_resolver(resolver) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 26, in check_resolver return check_method() File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py", line 254, in check for pattern in self.url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py", … -
Django - ListView, multiple-valued queryset, but want to have pagination on just one?
As title. In my ListView I have a queryset comprised of more than one set of values, such as: queryset = {"albums": songs, "liked": likedSongs} and in my page I only want to paginate the objects in "albums". I would still like to be able to reference the variable "liked" on my page. Is there a way to achieve this through ListView? Any response would be greatly appreciated.