Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Subtraction of two columns on two different models by its ID
I have Two Models 1)Invoice 2)Recieved Amount class Party: party_name = models.CharField(max_length=200) class Invoice(models.Model): party = models.ForeignKey(Party,on_delete = models.CASCADE) invoice_amount = models.FloatField(default=0.0) class RecievedAmount(models.Model): party = models.ForeignKey(Party,on_delete = models.CASCADE) recieved_amount = models.FloatField(default=0.0) I want to subtract (invoice_amount) from Invoice Model - (recieved_amount) from RecievedAmount Model based on the PartyId (ForignKey) and return output as [{'party':1,'total_difference':2000},{'party':2,'total_difference':5000}] total_difference = invoice_amount - recieved_amount And also parties can be more than 100. Can you please tell me the query that performs this operation. Thanks -
Web architecture for "sharing" API calls between users
I recently posted a question: How to dynamically create and close infinitely running Celery tasks using Django Channels . But Django channels seems to be a fairly niche area of development so I'd like to open up the question as a question about general architecture patterns. I would ultimately like users of my application to tap into the same data streams dynamically. I am creating a cryptocurrency application where users are accessing the same live price data. It seems ridiculous that every user should have to request an API for the same information. Scenario: Multiple users are receiving BTC/USD data by API request. How can I get this data and share it between users? This problem must have been solved countless times but I'm finding it very difficult to find the correct method for setting up a scalable solution. -
How to customize non_field_errors key using the NON_FIELD_ERRORS_KEY in Django REST framework setting?
In the docs, it was mentioned: Each key in the dictionary will be the field name, and the values will be lists of strings of any error messages corresponding to that field. The non_field_errors key may also be present, and will list any general validation errors. The name of the non_field_errors key may be customized using the NON_FIELD_ERRORS_KEY REST framework setting. How exactly do I do that? Can someone give me a code example of what it would look like in the settings.py file? -
Django: Error implementig ComputedTextField (Cannot force an update in save() with no primary key)
The idea To make the code a bit more understandable, I will first explain what my code (from which the problem probably comes) is supposed to do in the first place: I save reports in my model. I give these reports their own ID or numbering, because this is absolutely necessary.This ID shall be structured as follows: <year><ascending number with leading zeros> Example: 2021001, 2021002, ..., 2022001 The code I have developed the following modellfor this purpose. Since the value is to be calculated automatically, I use the @property decorator. To be able to use the ID (name: einsatznummer) later more easily as a field and simply for my REST Api, I use the computed_property package. class EinsatzPublic(models.Model): STATUS = ( (0,"Entwurf"), (1,"Öffentlich"), (2,"Archiv"), (3,"Papierkorb"), ) author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, verbose_name="Autor") created = models.DateTimeField(default=timezone.now, editable=False, verbose_name="Erstellt") updated = models.DateTimeField(auto_now= True, editable=False, verbose_name="Aktualisiert") status = models.IntegerField(choices=STATUS, default=0, verbose_name="Status") #(some more fields...) einsatznummer = ComputedTextField(blank=True, compute_from="einsatznummer_calc") alarmzeit = ComputedTextField(blank=True,compute_from="alarmzeit_calc") alarmdatum = ComputedTextField(blank=True, compute_from="alarmdatum_calc") @property def alarmdatum_calc(self): date = self.einsatz_start.date() return date.strftime("%d.%m.%y") @property def alarmzeit_calc(self): date = self.einsatz_start.date() return date.strftime("%H:%M") @property def einsatznummer_calc(self): year_einsatz = self.einsatz_start.strftime('%Y') last_number = EinsatzPublic.objects.filter(einsatznummer__isnull=False, einsatz_start__year=year_einsatz).values_list('einsatznummer', flat=True) if last_number: if last_number[:-1] != year_einsatz: last_number = '0' einsatznummer_gen = … -
Javascript not loading in Django html
I'm trying to include JavaScript in my html design in Django. I'm getting 304 response but the javascript is not showing on the page. GET /static/js/app.js HTTP/1.1" 304 0 I'm loading it in the head tag in html like this <script src="{% static 'js/app.js' %}" type="text/javascript" ></script> Can someone help me figure out what I'm doing wrong? -
Multiple user sign up with django-allauth. Two signup forms not render
I am trying to implement two user types with allauth. I have read so many tutorials, documentations, and so on. Still can't render my custom two forms for registrations. When i add in settings ACCOUNT_FORMS = { 'signup': ...} which form to be used is ok. But for both is not rendered. Models.py from django.contrib.auth.models import AbstractUser from django.db import models class User(AbstractUser): is_worker = models.BooleanField(default=False) is_company = models.BooleanField(default=False) class Worker(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) image = models.ImageField(default="default.jpg", upload_to='profile_pics') first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) phone = models.IntegerField() def __str__(self): return f'{self.user.username}' class Company(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) image = models.ImageField(default="default.jpg", upload_to='profile_pics') adrress = models.CharField(max_length=300) phone = models.IntegerField() def __str__(self): return f'{self.user.username}' forms.py from . models import User, Worker, Company from django import forms from allauth.account.forms import SignupForm class WorkerSignupForm(SignupForm): first_name = forms.CharField(label='First Name', max_length=50, required=True, strip=True) last_name = forms.CharField(label='Last Name', max_length=50, required=True, strip=True) phone = forms.CharField(label='Mobile phone', max_length=15, required=True, strip=True) def save(self, request): user = super(WorkerSignupForm, self).save(request) user.first_name = self.cleaned_data.get('first_name') user.last_name = self.cleaned_data.get('last_name') user.phone = self.cleaned_data.get('phone') user.is_worker = True user.save() return user class CompanySignupForm(SignupForm): company_name = forms.CharField(label='Comapny name', max_length=100) adrress = forms.CharField(label='Adrress', max_length=250) phone = forms.CharField(label='Mobile phone', max_length=15) def save(self, request): user = super(CompanySignupForm, self).save(request) user.company_name = … -
Is there a way to store the metadata in sqlite?
hi am doing a Django app and I got some metadata. I want to store them in SQLite but I have no idea if it is possible? because some tags are the same like "contributor" and some have "dc" before the tag name and some don't: the data looks like: <?xml version="1.0" encoding="UTF-8"?> <dataset xmlns="urn:pangaea.de:dataportals" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:pangaea.de:dataportals http://ws.pangaea.de/schemas/pansimple/pansimple.xsd"> <dc:title>Sorex araneus Linnaeus, 1758, a preserved specimen record of the Mammals (recent) dataset [ID: ZMB_Mam_050329 ]</dc:title> <dc:description>The Animal Sound Archive at the Museum fuer Naturkunde Berlin (German: Tierstimmenarchiv) is one of the oldest and largest worldwide. Founded in 1951 by Professor Guenter Tembrock the collection consists now of around 130 000 records of animal voices.</dc:description> <dc:contributor>Christiane Funk</dc:contributor> <dc:contributor>MfN</dc:contributor> <dc:contributor>Museum für Naturkunde Berlin – Leibniz Institute for Research on Evolution and Biodiversity, Berlin</dc:contributor> <dc:contributor>Zenker, R</dc:contributor> <dc:contributor>Kulicke</dc:contributor> <dc:contributor>Zenker, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:contributor>Kulicke, R</dc:contributor> <dc:publisher>Data Center MfN</dc:publisher> <dataCenter>Data Center MfN</dataCenter> <dc:type>ABCD_Unit</dc:type> <dc:type>preserved specimen</dc:type> <dc:format>text/html</dc:format> <dc:identifier>ZMB_Mam_050329</dc:identifier> <dc:source>MfN Custodians (2017). MfN Zoological Collections - Mammals (recent). [Dataset]. Data Publisher: Museum für Naturkunde Berlin (MfN) - Leibniz Institute for Research on Evolution and Biodiversity.</dc:source> <linkage type="metadata">http://biocase.naturkundemuseum-berlin.de/current?dsa=mfn_Mammalia&amp;detail=unit&amp;schema=http://www.tdwg.org/schemas/abcd/2.06&amp;cat=ZMB_Mam_050329</linkage> <dc:coverage xsi:type="CoverageType"> <northBoundLatitude>52.4256800000</northBoundLatitude> <westBoundLongitude>14.2540400000</westBoundLongitude> <southBoundLatitude>52.4256800000</southBoundLatitude> <eastBoundLongitude>14.2540400000</eastBoundLongitude> <startDate>1961-08-03T00:00:00</startDate> … -
Django connect to a remote database
How do I query a remote database particularly an Oracle (or any database really) database, do I have to create a model for the database? Also why would I need to create a model for the tables in that database if the tables already exist? -
html input value turns to placeholder
I' m working with Django project with Python. I have a example input area like this; <form method="GET"> <input type="text" name="product_code" placeholder="Please enter product code"> <button type="submit" class="btn btn-success">Search</button> </form> When I send the form with "Search" button, I want to see inputted value but I see placeholder again "Please enter product code". I changed the placeholder with {{variable}} but it doesn't work. -
Uncaught TypeError: Cannot read property 'send' of null
document.getElementById('id_chat_message_input').focus(); document.getElementById('id_chat_message_input').onkeyup = function(e) { if (e.keyCode === 13 && e.shiftKey) { // enter + return // Handled automatically by textarea } else if(e.keyCode === 13 && !e.shiftKey){ // enter + !return document.getElementById('id_chat_message_submit').click(); } console.log("received message"); }; document.getElementById('id_chat_message_submit').onclick = function(e) { const messageInputDom = document.getElementById('id_chat_message_input'); const message = document.getElementById('id_chat_message_input').value; console.log(message); chatSocket.send(JSON.stringify({ "command": "send", "message": message, "room": roomId })); messageInputDom.value = ''; }; <div class="card-body p-1"> <div class="d-flex flex-column" id="id_chat_log_container"> <div class="d-flex flex-row justify-content-center" id="id_chatroom_loading_spinner_container"> <div class="spinner-border text-primary" id="id_chatroom_loading_spinner" role="status" style="display: none; "> <span class="sr-only">Loading...</span> </div> </div> <div class="d-flex chat-log" id="id_chat_log"> </div> <span class="{% if not debug %}d-none{% endif %} page-number" id="id_page_number">1</span> <div class="d-flex flex-row chat-message-input-container"> <textarea class="flex-grow-1 chat-message-input" id="id_chat_message_input"></textarea> <button class="btn btn-primary chat-message-submit-button"> <span id="id_chat_message_submit" class="material-icons">send </span> </button> </div> </div> </div> Error: Uncaught TypeError: Cannot read property 'send' of null at HTMLSpanElement.document.getElementById.onclick Iam doing chatapplication using django. When i typed a message and click send iam getting this error, it is not sending. very thankful to you :) -
Is There A Way That Client Can Add Language Specific Inputs?
I want to take language inputs from my clients. For example : <input type="text" name="title" class="form-control" required="" id="en"> # For English Input <input type="text" name="title" class="form-control" required="" id="fr"> # For French Input <input type="text" name="title" class="form-control" required="" id="es"> # For Spanish Input I want to store them as dictionary as the { 'lang' : 'title', 'lang2' : 'title2', 'lang3' : 'title3 } pairs . I use Django as my backend. Is there a way that I can do that with Django forms? -
Only approved users should post blogs in django
I have build a blog based web-application using Django , Where users can login and wrote articles and those articles are being posted after admin approval. But right now all users can post articles. I want only those users to post the articles which are approved . I am using default Django user model . From users I only create a profile model. My users models.py is: from django.db import models from django.contrib.auth.models import User from PIL import Image # Create your models here. class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='default.jpg', upload_to='profile_pic') posting_post = models.BooleanField(default=False) def __str__(self): return f'{self.user.username} Profile' def save(self , *args, **kwargs): super().save() My postcreate view is: class PostCreateView(TagMixin, LoginRequiredMixin, CreateView): model = Post fields = ['title', 'content', 'image',] def form_valid(self, form): form.instance.author = self.request.user form.save() return HttpResponseRedirect('admin-approval') and my html for create post is: {% if user.is_authenticated %} <li class="nav-item"> <a class="nav-link" href="{% url 'post-create'%}">New Post</a> </li> <li class="nav-item"> -
django howto include urls from app into an existant namespace
My project has a namespace 'dashboard' and I'd like to include an app (django-calendar) into it, so my urls would be like /dashboard/calendar-list. So in dashboard urls.py I added: (...) path("avoirs/", include(avoirs_urls)), path("vouchers/", include(vouchers_urls)), path("logs/", include(log_urls)), path('schedule', include('schedule.urls', namespace='schedule')), (...) So I can reverse my urls using for example: reverse("dashboard:schedule:calendar_list") It's where I came accross a pitfall: All the app code uses urls like calendar_list and not schedule:calendar_list. Same for templates using code like {% url 'calendar_list' %}. It doesn't seem reasonable to refactor all the calendar app to fit my project. Is there a way to include it in the existing namespace? What's the guideline here? Thanks to share knowledge... -
Adding Data to ManytoMany Field Django
I am creating a dynamic form using javascript. Here are the models which I am using to store the data. one_label_fields = ['text','color','date','number','email','password'] class InputFieldNames(models.Model): name= models.CharField(max_length=40) #one field inputs :text,color,date,email,number,password def __str__(self): return self.name class OneLabelInputField(models.Model): label = models.CharField(max_length =40) value =models.CharField(max_length=40) def __str__(self): return "Label: "+self.label +"| Value: "+self.value class CheckBoxLabel(models.Model): label =models.CharField(max_length=40) def __str__(self): return self.label class CheckBoxField(models.Model): group_name = models.CharField(max_length=40) labels = models.ManyToManyField(CheckBoxLabel) def __str__(self): return self.group_name class DynamicForm(models.Model): single_label_fields =models.ManyToManyField() checkboxes = models.ManyToManyField(CheckBoxField) Here is my View function def form_creation(request): if request.method == 'POST': input_types = InputFieldNames.objects.all() form = DynamicForm.objects.create() print("form cretaetd ->",form) for x in input_types: #print(x.name) input_fields = request.POST.getlist(x.name) print("INPUT FIELDS:",input_fields) label_name = 'hidden_'+x.name #print(label_name) input_field_labels = request.POST.getlist(label_name) print("LABELS OF THE RESPECTIVD FIELDS",input_field_labels) length = len(input_fields) if length: for i in range(length): field = OneLabelInputField.objects.create(label = input_field_labels[i], value=input_fields[i]) form.single_label_fields.add(OneLabelInputField.objects.get(id= field.id)) print(">>>",form) # if input_fields: # print(input_fields) # print(input_field_labels) inputs = InputFieldNames.objects.all() context={} context['inputs'] = inputs #context['one_label_fields'] = json.dumps(one_label_fields) return render(request,"dynamic_form.html",context) I have declared many to many field in the Dynamic form model,because I want to store multiple objects of SingleLabelInputField and connect its relation with Dynamic Form. Whenever I create a Dynamic form ,and submit the data, the data is saved without any … -
Uanble to connect to remote mysql phpmyadmin
I'm trying to connect to remote phpmyadmin through my Django application. 'client4': { 'ENGINE': 'django.db.backends.mysql', 'NAME': config('DATABASE_NAME_5'), 'USER': 'username', 'PASSWORD': config('DATABASE_PASSWORD_PHPMYADMIN'), 'HOST': 'xxx.xx.xxx.xxx', 'PORT': '3306', }, When I run makemigrations, django.db.utils.OperationalError: (1045, "Access denied for user 'username'@'yyy.yy.yyy.yyy' (using password: YES)") This error pops. But the IP address shown here is different and unknown to me. I tried connecting to 2 different IP addresses but the same IP address keeps popping in the error. I tried to connect to a remote server using the terminal command, mysql -u root -h xxx.xxx.xx.xxx -p Led to the same error, ERROR 1045 (28000): Access denied for user 'root'@'yyy.yy.yyy.yyy' (using password: YES) with the same IP popping up again. I am unable to figure out what where this IP is coming from. I also checked my local IPs using ifconfig But this IP was not seen anywhere. Please help me out here. Thanks. -
Heroku application error logs, cannot run heroku open
I just made my first application. when I run Heroku open I get an error "Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail" what could possibly be the problem?Can a problem with DJANGO_SECRET_KEY cause such problem ? this is my logs 2021-06-11T05:06:11.906892+00:00 app[api]: Initial release by user a 2021-06-11T05:06:11.906892+00:00 app[api]: Release v1 created by user a 2021-06-11T05:06:12.046032+00:00 app[api]: Enable Logplex by user a 2021-06-11T05:06:12.046032+00:00 app[api]: Release v2 created by user a 2021-06-11T06:24:58.000000+00:00 app[api]: Build started by user 2021-06-11T06:25:45.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/67a0bf8e-56f4-41bd-b9de-b02c9ca20f13/activity/builds/b4469f36-8883-468b-95a2-aadaa03ff662 2021-06-11T06:36:08.000000+00:00 app[api]: Build started by user a 2021-06-11T06:36:39.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/67a0bf8e-56f4-41bd-b9de-b02c9ca20f13/activity/builds/254007fa-69b7-45d7-9490-5bd0643ec3cf 2021-06-11T06:37:40.559478+00:00 app[api]: Set DISABLE_COLLECTSTATIC config vars by user a 2021-06-11T06:37:40.559478+00:00 app[api]: Release v3 created by user a 2021-06-11T06:38:00.000000+00:00 app[api]: Build started by user a 2021-06-11T06:38:41.947391+00:00 app[api]: Running release v4 commands by user a 2021-06-11T06:38:41.947391+00:00 app[api]: Attach DATABASE (@ref:postgresql-fitted-13790) by user a 2021-06-11T06:38:41.960986+00:00 app[api]: @ref:postgresql-fitted-13790 completed provisioning, setting DATABASE_URL. by user a 2021-06-11T06:38:41.960986+00:00 app[api]: Release v5 created by user a 2021-06-11T06:38:42.248836+00:00 app[api]: Release v6 created … -
in django Mongodb Like (in mysql keyword) same in mongo db not working
Questions.objects.find({ps_tags: "/"+request.POST['txtTag']+"/"}).values() this is the code where I am using to search related words from the database but I am getting the following error. ERROR AttributeError: 'Manager' object has no attribute 'find' I want to implement code search (in MySQL if we want to search then we will use LIKE key word for matching rows from multiple rows) same like in Django MongoDB I want to implement but I am getting the above error, any solution for this? -
How does Huey call task?
I have this code here # it's not every five mins but let's overlook that for now @periodic_task(crontab(minute='*/1')) def every_five_mins(): # ... But I couldn't find where Huey calls the function. The only other place that I've used Huey is in settings.py but still I only included HUEY = { 'huey_class': 'huey.RedisHuey', 'name': DATABASES['default']['NAME'], 'results': True, 'store_none': False, 'immediate': False, 'utc': True, 'blocking': True, 'connection': { 'host': 'localhost', 'port': 6379, 'db': 0, 'connection_pool': None, 'read_timeout': 1, 'url': None, }, 'consumer': { 'workers': 1, 'worker_type': 'thread', 'initial_delay': 0.1, 'backoff': 1.15, 'max_delay': 10.0, 'scheduler_interval': 1, 'periodic': True, 'check_worker_health': True, 'health_check_interval': 1, }, } Can anyone please tell me how a task is executed? I want to know this because I want to pass in parameters into every_five_mins(), e.g., every_five_mins(argument1=argument1) but I can't do that without knowing where the function is called (otherwise argument1 is going to raise an undefined error). Thanks in advance. -
Django rest framework group objects by date
I have a Django model like below: from django.models import Model class Post(models.Model): headline = models.CharField(max_length=100) content = models.TextField() published_at = models.DateField() Requirement is to make API that group post objects by publish date (daily) and with pagination. Expected response is: { "publish_date": "2020-05-03", "posts": [ { "id": 1, "headline": "headline1", "content": "post body" }, ... ], "publish_date": "2020-05-16", "posts": [ { "id": 4, "headline": "headline2", "content": "post body" }, ... ], ... } How to make this done efficiently with Django? I don't want to iterate over dates and filter posts by that date. I tried queryset's dates and annotate methods with no successful result: from django.db.models import Subquery, OuterRef from blog.models import Post post_subquery = Post.objects.filter(published_at=OuterRef('published_at')).values('published_at') Post.objects.dates('published_at', 'day').annotate(publish_day=F('published_at'), posts=Subquery(post_subquery)).values('publish_day', 'posts') It says Cannot resolve keyword 'publish_day' into field. How should I do this via Django's ORM? -
How to create database automatically in django using settings.py or models.py
1) Pgadmin -> Create -> Database -> db_name 2) change database connection details in settings.py 3) python manage.py makemigrations (assuming we have ready-made models) 4) python manage.py migrate Is there any way to skip step 1? -
Django input CSV file to create a new table. (CSV file convert into a table in the database)
I wanted some help with a project I'm working on: So I have to take a CSV as input from the user and convert the CSV save it as a Table in the Database. So I was able to take the input from the user and save it in the MEDIA_ROOT. But now I'm unsure how to create a model without knowing the columns and so on. (I know I can get the columns from pandas(in views.py) but how to send that column details to models.py) I'm new to Django and very much confused with so many files. Please help. Note: I don't want to save the CSV file I want to convert it into a table in the database. views.py import pandas as pd from django.shortcuts import render from django.http import HttpResponse from django.views.generic import TemplateView, ListView, CreateView from django.core.files.storage import FileSystemStorage def home(request): return render(request, 'index.html') def upload(request): if request.method == 'POST': upload_file = request.FILES['csvfile'] fs = FileSystemStorage() fs.save(upload_file.name, upload_file) dataset = pd.read_csv('media/'+upload_file.name) colums = list(dataset.columns) return render(request, 'upload.html') models.py from assignment.settings import MEDIA_ROOT from django.db import models from django.db.models.fields import CharField class CSV(models.Model): csvfile = models.FileField(upload_to='CSV') -
How connect my admin panel (native django admin) to firebase
I'm new in django and firebase. in my project, i need to connect my admin panel (native django administration) to firebase. Please can i have a solution for this? Regards. -
Why qlite3.OperationalError: no such column: loginsignup_customusers.password While creating CustomUser and CustomUserManager?
I have just started learning Django and stuck my self in very strange condition. I have created my own CustomUser instead of available in django.contrib.auth.models for authentication purpose. I am getting some error or problems all together ,while running the program,i am trying to post all of them bellow. I know all of them are occurred due to some silly mistake which i am unable to figure out on my own 1) When ever i am trying to run python manage.py make migrations i am getting error as bellow:- You are trying to add a non-nullable field 'password' to customusers without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows with a null value for this column) 2) Quit, and let me add a default in models.py Select an option: 2) When using python manage.py runserver is worked fine and run a emulated server on my local computer. Now when i am trying to access admin/ it shows me the following error**:-** Internal Server Error: /admin/ Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\utils.py", line 84, in _execute return … -
Mocking model.User using mixer through error
Im trying to add unit test for my Django project. Im using mixer to mock the models. The model looks as below from django.contrib.auth.models import User class Mytable(Model): username = models.OneToOneField(User, on_delete=models.CASCADE, db_column='username') ... ... My testcase looks like class MyTest: def test_test1(self): mock_user = mixer.blend('django.contrib.auth.models.User') stock_mock = mixer.blend('app.Mytable', username=mock_user) But im hitting "too many values to unpack" while mocking User model Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/kketan/Documents/projects/Extractor/.venv/lib/python3.8/site-packages/mixer/main.py", line 566, in blend type_mixer = self.get_typemixer(scheme) File "/Users/kketan/Documents/projects/Extractor/.venv/lib/python3.8/site-packages/mixer/main.py", line 583, in get_typemixer return self.type_mixer_cls( File "/Users/kketan/Documents/projects/Extractor/.venv/lib/python3.8/site-packages/mixer/main.py", line 47, in __call__ cls_type = cls.__load_cls(cls_type) File "/Users/kketan/Documents/projects/Extractor/.venv/lib/python3.8/site-packages/mixer/backend/django.py", line 137, in __load_cls app_label, model_name = cls_type.split(".") ValueError: too many values to unpack (expected 2) Am I mocking the models right way ? If yes is this error known ? If no can you please suggest better way ? -
Main page with host name is not opening in Django app on live server
I am hosting a Django app on managed server with passenger_wsgi.py file. Lets say my domain name is food.menu , when i visit 'https://food.menu' browser shows me Not Allowed but when i visit 'https://food.menu/Menu' then these links are accessible. foodsample> urls.py file looks like this urlpatterns = [ path('admin/', admin.site.urls), path('', include('food.Urls.WebsiteUrls'))] food> urls.py file looks like this urlpatterns = [ path('', WebsiteViews.Home, name='HomePage'), path('menusearch', WebsiteViews.Search_Menu, name='menusearch'), path('MenuQR', WebsiteViews.MenuQRCode, name='MenuQR'), path('Menu', WebsiteViews.Menu, name='Menu'), path('QRScanner', WebsiteViews.Scanner_View, name='QRScanner')] on localhost its working fine but on live server main url path('', WebsiteViews.Home, name='HomePage') with domain name is not opening. Cpanel Application Manager Setting: 1.Application Manager>Deployment Domain, i have selected my domain 'food.menu'. 2.Base Application URL Enter the application’s base URL. After you register the application, you can use this URL to access it. i wrote nothing by default its giving the domain name and a '/' after domain name, like 'food.menu/'. Any kind of help would be great. Thanks..!!