Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Permission issue in custom user model in django
I am trying to create a custom user model in my Django application. In my app user_app i have added the below code in my models.py : from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin class RestrauntManager(BaseUserManager): def create_user(self, username, email, phone, restraunt_name, is_staff=False, is_admin=False, is_active=True, password=None): if not email: raise ValueError('User must have an email address') if not username: raise ValueError('User must have a username') if not password: raise ValueError('User must have a password') if not phone: raise ValueError('User must have a phone number') if not restraunt_name: raise ValueError('User must have a restraunt name') user = self.model( email = self.normalize_email(email), username = username, phone = phone, restraunt_name = restraunt_name ) user.set_password(password) user.staff = is_staff user.active = is_active user.admin = is_admin user.save(using=self._db) return user def create_staffuser(self, email, username, phone, restraunt_name, password=None): user = self.create_user( email = self.normalize_email(email), username = username, phone = phone, restraunt_name = restraunt_name, is_staff = True ) return user def create_superuser(self, email, username, phone, restraunt_name, password=None): user = self.create_user( email = self.normalize_email(email), username = username, phone = phone, restraunt_name = restraunt_name, password = password, is_staff = True, is_admin = True ) user.save(using=self._db) return user class Restraunt(PermissionsMixin, AbstractBaseUser): email = models.EmailField(verbose_name = 'email', max_length=60, unique=True) username … -
Read a select option on Django
I am attempting to get the value of the data from the select option which will actively decide what will be displayed on the same page. I need to get the child.id value and was wondering if there is a way to find this data without having to create a whole new page. <select id="child"> {% for cl in children %} {% if cl.parent == user %} <option value="{{child.id}}">{{ cl.first_name }} {{ cl.last_name }}</option> {% endif %} {% endfor %} </select> -
ajax call to submit data form in django RESTFRAMEWORK
I am trying to make a POST request to Mayan EDMS(a Django app to store documents), through an API to upload a document, but each time I try to submit the form I get a permission denied error. here is an HTML form with a file field and other fields, HTML form <form method="POST" id="DocForm" enctype="multipart/form-data"> {% csrf_token %} <textarea name="description"></textarea> <input type="file" /> <select class="form-control" name="document_type"> <option value="1">Default</option> </select> <button>POST</button> </form> this function get csrf token from a form ajax/js code to get csrf token ////getting crsf token /////////////////////////////////// // function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); } function sameOrigin(url) { // test that a given url is a same-origin URL // url could be relative or scheme relative or absolute var host = document.location.host; // host … -
Django rest framework, imitate the Django admin behavior when using Foreign Key
I have a Django rest framework API model that contains a foreign key field. I want to show the user In the browsable API a kind of dropdown menu to choose existing objects or create a new one just like in the admin interface, Is there something like this existing? The models: class Mission(models.Model): id = models.UUIDField(primary_key=False, default=uuid.uuid4, editable=False) mission_name = models.CharField(name='MissionName', verbose_name="Mission Name", unique=True, max_length=255, blank=False, help_text="Enter the mission's name", primary_key=True ) uav_lat = models.FloatField(name="UavLatitude", verbose_name="UAV Latitude", unique=False, max_length=255, blank=False, help_text="Enter the location's Latitude, first when extracting from Google Maps.", default=DEFAULT_VALUE) uav_lon = models.FloatField(name="UavLongitude", verbose_name="UAV Longitude", unique=False, max_length=255, blank=False, help_text="Enter the location's Latitude, first when extracting from Google Maps.", default=DEFAULT_VALUE) uav_elevation = models.FloatField(name="UavElevation", verbose_name="UAV Elevation", max_length=100, default=1, blank=False, help_text="Enter the above ~Sea Level~ planned uav Elevation. " ) area = models.CharField( name='Area', max_length=8, choices=AREAS, ) date_added = models.DateTimeField(verbose_name="Date Added", default=now()) gdt = models.ForeignKey(KnownLocation, on_delete=models.PROTECT) class Meta: get_latest_by = 'date_added' KnownLocation model: class KnownLocation(models.Model): name = models.CharField(name="Name", unique=False, primary_key=True, max_length=150, blank=False, help_text="Enter the name of the location's name") area = models.CharField(name='Area', max_length=8, choices=AREAS, ) date_added = models.DateTimeField(default=timezone.now) latitude = models.FloatField(name="Latitude", unique=True, max_length=255, blank=False, help_text="Enter the location's Latitude, first when extracting from Google Maps.", default=DEFAULT_VALUE) longitude = models.FloatField(name="Longitude", unique=True, max_length=255, blank=False, … -
Django REST serializer with multiple foreign keys
Hi everybody and good morning. My application is a sort of 'repository manager', able to list, search and create datasets of files. I have a models.py like the following: class Author(models.Model): name = models.CharField(max_length=50) surname = models.CharField(max_length=50) email = models.EmailField() phone = models.CharField(max_length=20, blank=True) # optional def __str__(self): return self.name class Dataset(models.Model): name = models.CharField(max_length=150) # dataset title description = models.TextField(blank=True) # dataset description --> optional slug = models.SlugField(max_length=200, unique=True) author = models.ForeignKey(Author, on_delete=models.CASCADE) remote = models.URLField(max_length=300) def __str__(self): return self.name def save(self, *args, **kwargs): self.slug = slugify(str(self.author.pk) + "-" + str(self.name)) super(Dataset, self).save(*args, **kwargs) class File(models.Model): creator = models.ForeignKey(Author, related_name='author', on_delete=models.CASCADE) # the original creator of the file dataset = models.ForeignKey(Dataset, related_name='dataset', on_delete=models.CASCADE) # dataset to which belongs name = models.CharField(max_length=100) # file name with path description = models.CharField(max_length=300, blank=True) # file description --> optional url = models.URLField(max_length=300) # hot link to file def __str__(self): return self.name So I am working with nested serializers. The creation of an object Dataset is working in this way: class AuthorSerializer(serializers.ModelSerializer): class Meta: model = Author fields = ('name', 'surname', 'email', 'phone') class FileSerializer(serializers.ModelSerializer): creator = AuthorSerializer(required=False) class Meta: model = File fields = ('name', 'description', 'url', 'creator') class DatasetSerializer(serializers.ModelSerializer): author = AuthorSerializer() … -
How to chain custom methods of subclass of Django QuerySet so that types match
Consider following example code: class MyQuerySet(models.QuerySet): def my_method(self): return self.annotate(_something=47) def my_method_2(self): return self.annotate(_something2=42) def second_method(self): return self.my_method().my_method2() Problem is that PyCharms type checker highlights my_method2() call ("Unresolved attribute reference 'my_method2' for class 'QuerySet'"). I could disable warning inside IDE on case-by-case basis, but type-checker is right, types do not match. (I don't even understand why such code works, I suppose methods like filter and annotate preserve these attributes.) Is there some clean way to change returned values to MyQuerySet? Or are there any type hints that would make type-checker happy? (Setting return type of my_method to MyQuerySet only moves the problem.) -
Importing external library (say pytube) in Django
Fairly new to Django. I am trying to import Pytube to my django project. I am on my virtual environment and installed pytube va Pip. How to I import it. not working the way like 'from Pytube import Youtube' -
How to filter queryset data with exact matching word?
I am creating one Django project, here I define some fields like: class Data1(models.Model): message = models.TextField() and making input word in msg variable msg = "hello" I want to filter all message field strings in which the msg variable exists. when I am using list_data = Data1.objects.filter(message__icontains=msg).all() it's not giving me desire output is there any way to filter query objects with exact word match in strings. -
App linking to root instead of actual application on redirect
I'm having some trouble working with paths in Django. I have python experience but not Django experience at all. Here is what I have templates/AppName/base.html <header id="header"> <div id="logo"> <div id="top_menu"> Home | Calendar | About | <a href="/contactus">Contact Us</a> </div> </div> </header> template/AppName/contact_us.html {% extends 'Orchestrator/base.html' %} {% block content %} <h2>New post</h2> <form method="POST" class="post-form">{% csrf_token %} {{ form.as_p }} <button type="submit" class="save btn btn-default">Save</button> </form> {% endblock %} AppName/urls.py from django.urls import path from . import views app_name = 'AppName' urlpatterns = [ path('', views.index, name='index'), path('contactus/', views.contact_us, name='contactus') ] AppName/views.py from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render from .forms import ContactUs def index(request): return render(request, 'AppName/base.html') # Forms # def contact_us(request): form = ContactUs() return render(request, 'AppName/contact_us.html', {'form': form}) AppName/forms.py from django import forms class ContactUs(forms.Form): firstname = forms.CharField(max_length=100) lastname = forms.CharField(max_length=100) So, the rendering of the starting page, meaning 127.0.0.1:8000/AppName Works just fine, but when I want to make the Contact Us button redirect to AppName/contactus, Django is actually redirecting to 127.0.0.1/contactus. Any idea on how to solve this? -
How do I filter query objects (DecimalFIeld) by value range in Django?
I've a Django model with a DecimalField. class SomeModel(models.Model): decimal_field = models.DecimalField() I'd like to get all model instances which have a field value in the range of e.g. 5.0 and 10.0. I've read the Django docs section about queries but I did not find a solution. How do I have to write the query SomeModel.objects.filter(?) ? -
Django Compare ManyToMany fields
Let's say I have a model: patients = models.ManyToManyField(Patient) patients_tracker = models.ManyToManyField(Patient, blank=True, editable=False, related_name="patient_tracker") ... Now, in my overridden save function, I set both of them equal to each other. By doing: self.patients_tracker.set(self.patients.all()) #----Statement a but in my post_save function, this statement if instance.patients_tracker.all() != instance.patients.all(): #----Statement b for some reason returns False even though I checked manually and print(instance.patients_tracker.all()) & print("Here's the patients: ", instance.patients.all()) return the same Patients in them which only tells me that "Statement a" worked perfectly. But why doesn't "Statement b" work and return true? What am I doing wrong? Thank you for reading this. -
Receive django error debug report by email :
Here is my configuration in django settings : MAILER_LIST = ['toto@toto.com'] EMAIL_HOST = 'toto.smtp.com' EMAIL_HOST_USER = 'toto@toto.com' EMAIL_HOST_PASSWORD = 'tata' EMAIL_PORT = 587 EMAIL_USE_TLS = True DEFAULT_FROM_EMAIL = 'toto@toto.com' LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'mail_admins': { 'level': 'DEBUG', 'class': 'django.utils.log.AdminEmailHandler', 'filters': [], } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'DEBUG', 'propagate': True, }, } } i've try to debug with : from django.core.mail import EmailMessage email = EmailMessage('Hello', 'World', to=['toto@toto.com']) email.send() And i get the test email if i put this in my settings. i would like to receive this error report by email : What am i missing to get the debug log by email ? The test is sending the email so it's not an email configuration problem ... Thanks and regards -
django datatables | filter the queryset python 3
I am trying to query on jquery datatables list. Right now I can fetch all records from the table, but i want to fetch records to whom their parent id matches. e-g users have posts, so in my case it would be fetch posts where user id is lets say 1. So I am trying to implement same thing for jquery datatables. I can see data is being posted but I cant figure out how to query along with datatables, so that datatables filters are not affected by this change. My current code: class PartRequestViewSet(CommonViewset, generics.RetrieveAPIView): queryset = PartRequest.objects.filter(deleted_at=None) serializer_class = PartRequestSerializer def list(self, request, *args, **kwargs): records = request.GET.get('records', None) # ID of the part part_number_id = request.GET.get('part_number_id', None) queryset = self.get_queryset() queryset = self.filter_queryset(queryset) page = self.paginate_queryset(queryset) if page is not None and records is None: serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = self.get_serializer(queryset, many=True) return Response(serializer.data) Now in above code I can get the part_number_id from request, but how can I filter records using filter_queryset(), so that only parts_requests are given back in datatables where part_number_id is 1 Update: current helper function filter_queryset that is used in above code. def filter_queryset(self, queryset): format = self.request.GET.get('format', None) … -
testing stripe on-boarding django with mock
i am having trouble trying to mock test the on-boarding process of stripe connect. I am just learning how to use mock and i am struggling with the StripeAuthorizeCallbackView. the process is as follows: A user reaches the StripeAuthorizeView which sends them to the stripe api to sign up for an account. Once they successfully sign up for an account their redirected back to my platform and stripe sends a temporary code which i then send back to stripe with my api keys. Once i have sent the information back to stripe they then return me credentials for the user being the stripe_user_id. Here is the two views in question: import urllib import requests class StripeAuthorizeView(LoginRequiredMixin, View): def get(self, request): url = 'https://connect.stripe.com/express/oauth/authorize?' user = self.request.user if user.account_type == 'Business': business_type = 'company' else: business_type = 'individual' params = { 'response_type': 'code', 'scope': 'read_write', 'client_id': settings.STRIPE_CONNECT_CLIENT_ID, 'redirect_uri': f'http://127.0.0.1:8000/accounts/stripe/oauth/callback', 'stripe_user[email]' : user.email, 'stripe_user[business_type]' : business_type, 'stripe_user[url]' : 'http://127.0.0.1:8000/accounts/user/%s/' %user.pk, } url = f'{url}?{urllib.parse.urlencode(params)}' return redirect(url) lass StripeAuthorizeCallbackView(LoginRequiredMixin, View): def get(self, request): code = request.GET.get('code') if code: data = { 'client_secret': settings.STRIPE_SECRET_KEY, 'grant_type': 'authorization_code', 'client_id': settings.STRIPE_CONNECT_CLIENT_ID, 'code': code } url = 'https://connect.stripe.com/oauth/token' resp = requests.post(url, params=data) stripe_user_id = resp.json()['stripe_user_id'] stripe_access_token = resp.json()['access_token'] … -
Generate div in django template according to logic in template tag
I would like to generate different types of html code according to logic/conditions I check in template tags. E.g. if a text from a Model contains a '!' in front of a word, the word should be bold. What is the best way to do something like this in django? I want to avoid to create too much conditional html code in the templates. -
How to do a form with a list of check items in Django, with the check box on the left?
I am converting a simple checkbox list to a Django form. Here is a the checkbox survey: <input type="checkbox"><label>I like bourbon.</label><br> <input type="checkbox"><label>I like whisky.</label><br> <input type="checkbox"><label>I like beer.</label><br> Of course George Thorogood would chose all three. My grandma would chose none of them. Django doesn't have a checkbox field, and I read that I should use a BooleanField. This is the form code: class Form_BoissonSurvey(forms.Form): c0 = forms.BooleanField(required=False, label='I like bourbon.'); c1 = forms.BooleanField(required=False, label='I like whisky.'); c2 = forms.BooleanField(required=False, label='I like beer.'); And rendered it in a template.html form as: {{ form_boisson_survey.as_p }} But it looks like this: I have spent beaucoup time trying to get the check boxes to the left side, and to get it to separate without the big spaces inbetween. How can I get the check boxes on the left and get the lines to be separated by br instead of p ?? I.e. to get this to look like a normal list of three things of which any number of them may be selected? -
django OperationalError
i start to learn django and i want to crate models the first one work and then i want to make another and i go to the admin panel and this happen[https://i.stack.imgur.com/rg8oO.png] can somone help me with that[https://i.stack.imgur.com/7Da01.png] [https://i.stack.imgur.com/SGEiX.png] -
Guzzle http and Laravel Http post method replace with get method
I create guzzle client using post method but it replaced to get method. I try to use Illuminate\Support\Facades\Http on Laravel 7.x but get the same error. The API server is Django Rest Framework. see Illuminate\Support\Facades\Http doc at : https://laravel.com/docs/7.x/http-client#request-data Http::withHeaders([ 'Authorization' => "" ])->post('http://domain.id/api/v1/test', [ "parameter" => "value", ]); Result using Laravel Illuminate\Support\Facades\Http The method is GET instead of POST -
Obtain the last "n" values from my model from all my devices
I want to obtain the last values of my different devices from my data model. If I want the last one I'm using, dev_data = DevData.objects.order_by('dev_id','-data_timestamp').distinct('dev_id') But I don't know how to obtain the last "n" values of each one (not just the last one). I tried this, but is wrong. dev_data = DevData.objects.order_by('dev_id','-data_timestamp').distinct('dev_id')[:n] Can somebody help me? Thank you very much! -
Django Exception
i have a question. Im working on a Web-app and i included the Google API. Everything works fine and now i want to add some stuff for good Messages for the users. The Problem now is, that i build a try - except with the request inside: try: results = service.users().list(customer='my_customer', maxResults=10, orderBy='email').execute() response = HttpResponse.status_code except Exception: return "error" In this case, response is 200, thats good. But when i make a bad reqeust like: try: results = service.users().list(customer='my_customer', maxResults=10, orderBy='wdadwadwa').execute() response = HttpResponse.status_code except Exception: return "error" #I want to return the error code here Or i change Scope to a wrong scope whatever i recieve a code 200. And this is right because we have the try-except block there. But i need the original code. Like 404, 403 or whatever. I want to return the Code to create Messages for users. Like 403 - better contact the admin etc. How can i get the original http response from the error? The HttpRespone.status_code doesnt work in this case. Any ideas? -
Autocomplete does nothing. What is wrong?
Guys i am learning how to make autocomplete. Explored many resources and watched tutorials but it seemed i miss something and my code does nothing. I would be very happy to get your help as i am struglling with it for over week for now. What i did so far: In models.py i have: class Coordinate(models.Model): code = models.CharField(max_length=150) class Profiles(models.Model): geocode=models.CharField(max_length=200) country=models.CharField(max_length=500) class Meta: managed=False db_table='profiles_country' def __str__(self): return '{}'.format(self.geocode) in forms.py: from dal import autocomplete class CoordinateForm(forms.ModelForm): code= forms.CharField(max_length=150, label='',widget= forms.TextInput) class Meta: model = Coordinate fields = ('__all__') widgets = { 'code': autocomplete.ModelSelect2(url='coordinate-autocomplete', attrs={ 'theme': 'bootstrap'})} def clean_code(self): code=self.cleaned_data.get("code") if not Profiles.objects.filter(geocode=code).exists(): raise forms.ValidationError ( "Not true") return code in views.py: from dal import autocomplete def geoview(request): form = CoordinateForm(request.POST or None) if request.method == "POST": if form.is_valid(): form1 = form.save(commit=False) code = form1.code dataview=Profiles.objects.get(geocode=code) context={'geodata':dataview ,} return render(request, 'cgeo/result.html', context) return render(request, 'cgeo/search.html', context={'form':form}) class CoordinateAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): if not self.request.user.is_authenticated(): return Profiles.objects.none() qs = Profiles.objects.all() if self.q: qs = qs.filter(name__istartswith=self.q) return qs in main urls.py: urlpatterns = [ path('admin/', admin.site.urls), path('geo/', geoview, name='geo'), path('coordinate-autocomplete/', CoordinateAutocomplete.as_view(create_field='name'), name='coordinate-autocomplete'),] in geo.html : {% extends "base.html" %} {% block content %} {% if user.is_authenticated %} <form enctype="multipart/form-data" method="POST" > … -
Headers not visible in ModelAdmin get_form()
My model is such that each website has an associated email address. An administrator would select a set of websites on the website list view and use an admin action to pass the email addresses of the selected websites to recipient field of a new email_message object. From here, the administrator should be able to customize an email that is sent to each of those email addresses. The problem is that I can't pass headers to the get_form() method in the new email_message view. When I run the code, the print function that you see included here prints <QueryDict: {}>. How can I pass header data from an admin action to another model's get_form method? admin.py: def email_selected(modeladmin, request, queryset): response = HttpResponseRedirect('/admin/websites/email_message/add/') response['queryset'] = queryset return response class WebsiteAdmin(admin.ModelAdmin): actions = [email_selected] class Email_messageAdmin(admin.ModelAdmin): def get_form(self, request, obj, **kwargs): print(request.GET) form = super(Email_messageAdmin, self).get_form(request, obj, **kwargs) return form Thank you in advance for your time. -
How to use a DatePicker in a ModelForm in django 3.0?
I am using django 3.0 and I am trying to display a datepicker widget in my ModelForm, but I can't figure out how (all I can get is text field). I have tried looking for some solutions, but couldn't find any. This is how my Model and my ModelForm look like: class Membership(models.Model): start_date = models.DateField(default=datetime.today, null=True) owner = models.ForeignKey(Client, on_delete=models.CASCADE, null=True) type = models.ForeignKey(MembershipType, on_delete=models.CASCADE, null=True) class MembershipForm(ModelForm): class Meta: model = Membership fields = ['owner', 'start_date', 'type'] widgets = { 'start_date': forms.DateInput } And this is my html: <form class="container" action="" method="POST"> {% csrf_token %} {{ form|crispy }} <button type="submit" class="btn btn-primary">Submit</button> </form> -
Django Channel 2 with Daphne on Heroku crash on starting
I created a django app using Channels 2 on heroku but it crash on starting with 503 error code. 2020-04-07T10:05:35.226253+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.mysite.com request_id=317bfbe6-9055-4957-9fbb-8190616c3964 fwd="" dyno= connect= service= status=503 bytes= protocol=https Procfile : release: python manage.py migrate web : daphne myproject.asgi:application --port $PORT --bind 0.0.0.0 -v2 worker: python manage.py runworker channels -v2 settings.py ASGI_APPLICATION = 'myproject.routing.application' # Channels CHANNEL_LAYERS = { "default": { 'BACKEND': 'channels_redis.core.RedisChannelLayer', "CONFIG": { "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')], }, }, } asgi.py import os import django from channels.routing import get_default_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") django.setup() application = get_default_application() -
Hello i am trying to run my django app in pythonanywhere and i get this error .does by any chance anyone experienced something similar isues?
error log 2020-04-07 09:50:50,115: *************************************************** 2020-04-07 09:50:50,115: If you're seeing an import error and don't know why, 2020-04-07 09:50:50,115: we have a dedicated help page to help you debug: 2020-04-07 09:50:50,115: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2020-04-07 09:50:50,115: *************************************************** 2020-04-07 09:50:53,872: Error running WSGI application 2020-04-07 09:50:53,873: ModuleNotFoundError: No module named 'psych_test_demo' 2020-04-07 09:50:53,873: File "/var/www/evaldasmencinskas_pythonanywhere_com_wsgi.py", line 14, in <module> 2020-04-07 09:50:53,873: application = get_wsgi_application() 2020-04-07 09:50:53,873: 2020-04-07 09:50:53,874: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2020-04-07 09:50:53,874: django.setup(set_prefix=False) 2020-04-07 09:50:53,874: 2020-04-07 09:50:53,874: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/__init__.py", line 19, in setup 2020-04-07 09:50:53,874: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 2020-04-07 09:50:53,874: 2020-04-07 09:50:53,875: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__ 2020-04-07 09:50:53,875: self._setup(name) 2020-04-07 09:50:53,875: 2020-04-07 09:50:53,875: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup 2020-04-07 09:50:53,875: self._wrapped = Settings(settings_module) 2020-04-07 09:50:53,875: 2020-04-07 09:50:53,875: File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__ 2020-04-07 09:50:53,875: mod = importlib.import_module(self.SETTINGS_MODULE) 2020-04-07 09:50:53,875: *************************************************** 2020-04-07 09:50:53,875: If you're seeing an import error and don't know why, 2020-04-07 09:50:53,875: we have a dedicated help page to help you debug: 2020-04-07 09:50:53,876: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2020-04-07 09:50:53,876: *************************************************** i tried using diferent names for virtualenv like mysite-virtualenv and psych_test_demo-master i got installed everything required for app to work like django and xlsxwriter this is how my wsgi.py file looks like.i got python 3.8 here. …