Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: django.db.migrations.exceptions.NodeNotFoundError
I was making new project and app. Then when I have typed 'python3 manage.py runserver' django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_auto_20210902_0542 dependencies reference nonexistent parent node ('auth', '0012_alter_user_first_name_max_length') This error come to me. And even if I delete 'all' of my app's migrations forder It's still hapening This error is hapening to all of my projects and apps Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/home/kimhaju/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/home/kimhaju/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run self.check_migrations() File "/home/kimhaju/.local/lib/python3.6/site-packages/django/core/management/base.py", line 453, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 274, in build_graph raise exc File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 248, in build_graph self.graph.validate_consistency() File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/graph.py", line 195, in validate_consistency [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/graph.py", line 195, in <listcomp> [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] File "/home/kimhaju/.local/lib/python3.6/site-packages/django/db/migrations/graph.py", line 58, in raise_error raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_auto_20210902_0542 dependencies reference nonexistent parent node ('auth', '0012_alter_user_first_name_max_length') -
Django graphql auth not showing all user fields in mutation
I have followed below tutorial to introduce user authentication in my django app. https://django-graphql-auth.readthedocs.io/en/latest/quickstart/ It has created the user mutations as below, Graphql user mutation The mutation to update user shows only two fields, first name and last name. However my user model has other fields as well like is_staff, is_superuser, gender. I would like to get control on updating those fields as well. Please advise how can I get that done? -
having issued running python3 manage.py runserver
(venv) C:\Users\USER\PycharmProjects\pyshop\pycal> python3 manage.py runserver The system cannot execute the specified program. -
import and use views from views.py to django admin
I have the below view in the view.py file and I want to use this view in Django admin. How can I impoert this view and use in django admin? def index(request): context = { 'customer': Customer.objects.filter(count__gt=0), } return render(request, "view-customer/index.html", context=context) -
Improperly configured at . error in Django REST framework
When I access the base URL of http://127.0.0.1:8000/ I get the following error ImproperlyConfigured at / Could not resolve URL for hyperlinked relationship using view name "wallet-detail". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field. When I try to access the admin URL it works fine but when I access my data URL which is http://127.0.0.1:8000/wallets I get a 404 error page not found? This is my serializers.py file from rest_framework import serializers from .models import Wallet class WalletSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Wallet fields = ('__all__') My views.py file is the following from django.shortcuts import render from rest_framework import viewsets from rest_framework.response import Response from rest_framework.decorators import api_view from .serializers import WalletSerializer from .models import Wallet @api_view(['GET']) def getData(request): queryset = Wallet.objects.all() serializer = WalletSerializer(queryset, many=True, context={'request': request}) return Response(serializer.data) I was using a simple class in my views.py file instead of 'GET' functions which I am doing now and I was also using routers in my urls.py file but I removed all that so I could create CRUD functions but I face this problem now -
How to sort and filter queryset based on select_related in Django ORM
I have two tables in my models as show below: class Coin(models.Model): coin_id = models.CharField(max_length=100, primary_key=True, unique=True) name = models.CharField(max_length=100, null=True, blank=True) class Fundamental(models.Model): coin_id = models.OneToOneField(Coin, to_field="coin_id", db_column="coin_id", on_delete=models.CASCADE) market_cap = models.BigIntegerField(null=True, blank=True) price = models.FloatField(null=True, blank=True) Now I want to get the top 1000 coins sorted by market cap, or market cap range is between 1000-1000000. coins = Coin.objects.select_related('fundamental').order_by('ticker__market_cap')[:1000] I'm writing my query like this, but it is working for some of the coins, but if any coin doesnot exists, it shows the exception like screener.models.Coin.fundamental.RelatedObjectDoesNotExist: Coin has no fundamental. Does anyone will help me to filter a query in a good way -
Custom Django Allauth Forms Not Being Stored in Database
I'm trying to extend Django Allauth's signup form to contain additional fields. These fields show up fine in my form but they do not store the submitted data in the database. I have tried following solutions here and here to no avail. forms.py: from allauth.account.forms import SignupForm from django import forms from .models import User from django.forms.widgets import NumberInput import datetime class CustomSignupForm(SignupForm): age = forms.CharField(max_length=30, label='Age') date_of_birth = forms.DateField(widget = NumberInput(attrs={'type':'date'})) def save(self, request): user = super(CustomSignupForm, self).save(request) user.age = self.cleaned_data['age'] user.date_joined = datetime.datetime.now() user.date_of_birth = self.cleaned_data['date_of_birth'] user.save() return user models.py: from django.db import models # Create your models here. class User(models.Model): age = models.PositiveSmallIntegerField() date_of_birth = models.DateField() date_joined = models.DateField() def __str__(self): return self.name settings.py: AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ] SITE_ID = 1 ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_REQUIRED=True ACCOUNT_EMAIL_VERIFICATION='mandatory' ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = False ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 3 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' LOGIN_REDIRECT_URL = '/' ACCOUNT_FORMS = { 'signup': 'core.forms.CustomSignupForm', } Somewhere mentioned having: AUTH_USER_MODELS = 'myproject.User' however this throws up an error about User having no required fields. I don't understand where i'm going wrong. Surely I don't need to create a different user object and link it to the same authenticated user? There must be a simpler way. Any help … -
How to add datetime condition in django html file and how to use parentheses
I'm using Django, and there is an 'add' button inside the html file. I want to hide this button from users from Friday 1pm to Sunday. The condition is added as follows, but parentheses cannot be used in the if statement. Any other solution? Help me! [views.py] from datetime import datetime, timedelta, date def supporting(request): today = datetime.today() return render(request, 'supporting.html', {'today': today}) [supporting.html] {% if (today.weekday == 4 and today.hour > 13) or today.weekday >= 5 %} <button type="button">Add</button> {% endif %} -
download contents , such as Audios, files and pdf from the same page
pls am building a project which will have a part where any user can download contents from the Site , such as Audios, files and pdf from the same page but when a user loads the page , the download only happens once , when he/she tries to click another download button , nothing happens , pls what can be the issue this is models.py class FellowshipFile(models.Model): Fileupload1= models.FileField(upload_to = 'media' , blank = True) Title= models.CharField(max_length = 100, blank = True) def __str__(self): return str(self.Title) class EBook(models.Model): Fileupload2 = models.FileField(upload_to = 'media', blank = True ) ebook_Title = models.CharField(max_length = 100,blank = True ) eBook_image= models.ImageField(upload_to='assets', blank = True) def __str__(self): return str(self.ebook_Title) class AudioMessage(models.Model): title= models.CharField(max_length=200) Fileupload3= models.FileField(upload_to = 'media' ,blank = True) def __str__(self): return str(self.title) this is my views.py def resources_view(request): queryset_1= FellowshipFile.objects.all() queryset_2= AudioMessage.objects.all() queryset_3= EBook.objects.all() queryset_4= Header.objects.all() queryset_5= DailyGuide.objects.all() context = { "File_list": queryset_1, "Audio_list": queryset_2, "Ebook_list": queryset_3, "headers":queryset_4, "dailyguide":queryset_5, } return render(request, "Resources.html", context) and my template (resources.html) <ul class="list-group-flush p-0"> {% for Ebook in Ebook_list %} <li class="list-group-item d-flex justify-content-between align-items-center"> <div class="ms-2 "> <div class="fw-bold text-success"> {{Ebook.ebook_Title }}</div> <a href="{{ Ebook.Fileupload2.url }}" class=" text-decoration-none text-warning" download >download</a> </div> <div class="ms-auto w-25"> … -
Django Using TabularInline in Admin Panel
I'm making a django app. It has multiple tests with multiple quesiton each. every question has an answer. models.py class Test(models.Model): name = models.CharField(max_length=200) author = models.ForeignKey(User, on_delete=models.CASCADE, default=None, null=True, blank=True) date_posted = models.DateTimeField(auto_now_add = True) def get_questions(self): return self.question_set.all() def __str__(self): return self.name class Question(models.Model): text = models.CharField(max_length=200, null=True) test = models.ForeignKey(Test, on_delete=models.CASCADE) created = models.DateTimeField(auto_now_add = True) def get_answer(self): return self.answer_set.all() def __str__(self): return self.text class Answer(models.Model): text = models.CharField(max_length=200) question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='parent') def __str__(self): return self.text I'd like to be able to manage whole test (making/changing questions and answers) from one django admin "view". I tried to do this like that: admin.py class QuestionInline(admin.TabularInline): model = Question class TestAdmin(admin.ModelAdmin): inlines = [ QuestionInline, ] admin.site.register(Test, TestAdmin) but it only allows me to change/add test's questions. what should I change/add to be able to manage whole test - including answers managing system from one page ? ofc I can do it by making another admin page: class AnswerInline(admin.TabularInline): model = Answer class QuestionAdmin(admin.ModelAdmin): inlines = [ AnswerInline, ] admin.site.register(Question, QuestionAdmin) But i would like to do it from only one page -
Django - assign a single record from a queryset to a user and update it. Only releasing the record to another user if the transaction fails
I'm a Django beginner and I'm trying to create a warehouse management system in Django. The system keeps track of what products enters the warehouse and therefore knows what is in the warehouse and at which location. There are several users (order pickers) who are logged in simultaneously and who have to get the products from the warehouse. My model looks like this: class Product(models.Model): location = models.IntegerField(validators=[MinValueValidator(1),MaxValueValidator(5000)]) already_picked = models.BooleanField(default=False, blank=True) available_for_picking = models.DateField(blank=True, null=True) def __str__(self): return str(self.id) The products that have to be picked from the warehouse on a certain day must meet a number of conditions. For instance: available_for_picking = today or date in the past AND aldready_picked = False What I want to do: Every user goes to the url: www.mydomain.com/get_order_location_to_pick and gets a location of a product that he has to pick up from the warehouse. However, there are several products that meet the selection criteria and there are several users who use the software at the same time. So I want to avoid assigning the same product (and location) to more than 1 user. When the user has taken the product, boolean "already_picked" should be changed from False to True. If the user … -
Parse multipart/form-data in Python
I'm trying to parse an incoming multipart/form-data request sent to a Django python server. I WILL NOT use Django REST server - it shouldn't be necessary to import an entire library on top of another library to parse a multipart form. The request is coming in from a React post request on the front end like the following - const createUploadForm = () => { console.log('value of uploadFile: ', uploadfile) var formData = new FormData(); formData.append("image", uploadfile) const obj = {title: postcomment.title, content: postcomment.content} const json = JSON.stringify(obj); const blob = new Blob([json], { type: 'application/json' }); formData.append("document", blob); return formData } useEffect(()=>{ var formdata = createUploadForm() if(postcomment.submit){ // axios.post( // "http://localhost:8000/lightone/comment/1/", // {title: postcomment.title, content: postcomment.content} // ) axios({ method: 'post', url: "http://localhost:8000/lightone/comment/1/", data: formdata }) How do I parse this into a json object and a file that I can save? -
How to serialize an already existing image to save in a models.ImageField param?
I want to create Note object which one of the fields of the model is an ImageField using Django Rest Framework. I can already create objects and update all different fields using my API, except for images. My code: models.py class Note(OwnedModel): note_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # note_owner = models.ForeignKey(, null=True, blank=True, on_delete=models.SET_NULL) note_name = models.CharField(max_length=50) body = models.TextField() updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) qr_image = models.ImageField(upload_to='notes', null=True) def __str__(self): return self.note_name[0:50] class Meta: ordering = ['-updated'] views.py @api_view(['GET', 'POST']) def getNote(request, pk=None): if request.method == 'GET': note = Note.objects.get(note_id=pk) serializer = NoteSerializer(note, many=False) return Response(serializer.data) elif request.method == 'POST': _data = request.data.copy() owner = request.user.id _data["owner"] = owner # Generate QR code qr_image = generate_qr(_data["note_name"]) # HOW TO PASS THE IMAGE TO THE SERIALIZER? _data["qr_image"] = qr_image # _data["qr_image"] = qr_image[0] # _data["qr_image"] = qr_image[1] serializer = NoteSerializer(data=_data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(status=status.HTTP_400_BAD_REQUEST) serializers.py class NoteSerializer(ModelSerializer): class Meta: model = Note fields = '__all__' qr_code.py import qrcode def generate_qr(qr_file_name=None): qr = qrcode.QRCode( version=1, # error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=4, border=3, ) qr.add_data(qr_file_name) qr.make(fit=True) img = qr.make_image() # img = qr.make_image(fill_color="black", back_color="white") path='images/notes/'+str(qr_file_name)+'.jpg' img.save(path) return path, img The QR code is properly generated and saved in the upload … -
How to use Date Range Picker to filter dates and display a listing in Django?
I have a doubt, what happens is that I have a list in Django and I want to use daterange, what I need is to place two dates and that fecha_registro (it is in models.py) filter the information in the same template, I only used this: index.html <input type="text" name="daterange" value="12/01/2021 - 12/31/2021" class="form-control"/> base.html $(function() { $('input[name="daterange"]').daterangepicker({ opens: 'left' }, function(start, end, label) { console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); }); }); models.py class Clientes(models.Model): nombre = models.CharField(max_length=200) apellido = models.CharField(max_length=200) fecha_registro = models.DateTimeField(default=datetime.now) def __str__(self): return f'{self.nombre} {self.apellido}' views.py class list_clientes(ListView): model=Clientes template_name = 'Clientes/clientes-list.html' context_object_name='clientes' queryset=Clientes.objects.all() -
django - can't display images at admin
I have the following problem: When I'm trying to upload an image at the admin panel Fig. 1 and then try to see it I get this error Fig 2 Settings.py: DEBUG = True STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' portfolio/models.py: from django.db import models from django.db.models.fields import CharField, URLField from django.db.models.fields.files import ImageField class Project(models.Model): title = CharField(max_length=100) description = CharField(max_length=250) image = ImageField(upload_to="portfolio/images") url = URLField(blank=True) portfolio/admin.py: from django.contrib import admin from .models import Project admin.site.register(Project) my_app/urls.py from django.contrib import admin from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), ] Thanks :) and sorry for my cool english -
Django admin: redirect back to View site page on " save " button from upload file Module
I am newbie on Django Admin. I have Django Admin for login as well as file upload Module. I can able to redirect from my main page where I have costume button for "Upload File" to Django File add page. that looks like . now I want to redirect back to view site page where my "Upload File " button is on click on "Save" button on Django Admin. where to write my redirect code? My admin.py looks like. ''' @admin.register(RadioFile) class RadioFileAdmin(admin.ModelAdmin): list_display = [ 'id', 'audio_file', 'category', 'uploaded_by', 'uploaded_at', 'trending', ] list_filter = [ 'trending', 'uploaded_by', 'uploaded_at', ] search_fields = [ 'id', 'category', ] exclude = ['uploaded_by',] def save_model(self, request, obj, form, change): obj.uploaded_by = request.user super().save_model(request, obj, form, change) ''' and my Views.py ''' @login_required(login_url="/login/") def radio_files(request): context = { 'segment': 'radio', 'categories': Category.objects.all(), 'radio_files': RadioFile.objects.all(), } html_template = loader.get_template('radio_files.html') return HttpResponse(html_template.render(context, request)) ''' [1]: https://i.stack.imgur.com/pJFIa.png Thank you in advance. -
Filtering many2many django rest framework
I have an entity model, and i want to list all the instances of Entity based on the id of a category instance in it. So basically i'd like to list all the Entity instances with category id of 1 with /specialists/category/1 but for some reason i get Not Found: /api/v1/specialists/categories/1 Even though the code looks alright. class Entity(models.Model): entity_category = models.ManyToManyField(Category) class SpecialistSerializer(serializers.ModelSerializer): entity_category = SpecialistCategorySerializer(read_only=True, many=True) class Meta: model = Entity fields = (....., entity_category) class SpecialistsPerCategory(generics.ListAPIView): serializer_class = SpecialistSerializer def get_queryset(self): category_id = self.kwargs['pk'] return Entity.objects.filter(entity_category=category_id, lookup_type='in') path('specialists/category/<int:pk>', SpecialistsPerCategory.as_view()), Do you have any idea what's wrong? -
disable post button after clicked [duplicate]
(new to js) I am having an issue where the user can click the submit button multiple times and the post gets posted multiple times. To fix this I found this JavaScript that is supposed to disable the post button after it is clicked. However when the button is click the post request is not sent and nothing happens. How can I still submit the form but disable the button after the click <form method="post" enctype="multipart/form-data" id="PostForm" data-models-url="{% url 'ajax' %}" novalidate> <!--id="modelForm"--> {% csrf_token %} <fieldset class="django-ckeditor-widget"> <legend class="border-bottom mb-4">New Car</legend> {{ postForm.stuff}} ..... </fieldset> <div class="form-group"> <button id="submit-btn" class="action-btn" type="submit">Post</button> </div> </form> <script type="text/javascript"> document.getElementById("PostForm").addEventListener("submit", function (event) { event.preventDefault(); }); </script> -
Timer is stoping |Django
I've got problem 'cause I created site in django which has chatrooms and thoose chatrooms should be deleted after 300 seconds and my problem is that it sometimes work fine but sometimes timer is freezing and not working. views.py: from django.shortcuts import render, redirect from .models import ChatRoom, Message, Time import random, time from .forms import MessageForm from threading import Thread from django.core.mail import send_mail import datetime def Odliczanie(timer,c): t = int(timer.time) while t > 0: t -= 1 timer.time = str(t) timer.save() time.sleep(1) c.delete() def Create(request): if request.method == 'POST': code = random.randrange(1, 10_000_000_000) if request.POST.get("private") == "clicked": privatecheck = True else: privatecheck = False c = ChatRoom(name = str(code), isprivate = privatecheck) c.save() t = c.time_set.create(time = 300) Thread(target=Odliczanie, args=(t,c)).start() return HttpResponseRedirect('/%i' %int(c.name)) return render(request, 'main/create.html',{}) models.py: import random class ChatRoom(models.Model): name = models.CharField(max_length=10_000_000_000) isprivate = models.BooleanField(default = False) def __str__(self): return self.name class Message(models.Model): ChatRoom = models.ForeignKey(ChatRoom, on_delete=models.CASCADE) text = models.CharField(max_length=500) liked = models.BooleanField(default = False) author = models.CharField(max_length= 50, null=True) def __str__(self): return self.text class Time(models.Model): ChatRoom = models.ForeignKey(ChatRoom, on_delete=models.CASCADE) time = models.CharField(max_length = 4) I deleted some code in views.py which isn't related to problem -
How do I create a custom format in Django for the following: YYYY-NNNN, where YYYY represents the year and NNNN represents a 4 digit numeric value
I been trying to find ways to create a custom format for a value input for a model. I can't seem to find the adequate way to create a a year then 4 digit number after the slash. I would really appreciate if you could help. -
How would you add a crsf token inside the html
form="<form action='addAppointment/' method='POST' enctype='multipart/form-data'><button type='submit'>Book now</button></form>" I am currently adding the form element to a page through html the goal of this is to book an appointment. How would I go about adding the crsf_token into this or use button instead. {% csrf_token %} Traceback Forbidden (403) CSRF verification failed. Request aborted. Help Reason given for failure: CSRF token missing or incorrect. -
Filter data of a JavaScript chart by date range - Django Project
I want to create a Javascript chart with a date selector in my Django project like this example: https://plotlydash.com/pie-chart-with-drop-down-list-and-date-picker-range-in-plotly-dash/ I've already created a date selector input in my chart.html file, which allows me to append the input date value to URL when I click "generate report". (For example: it will append: ?start=2022-02-02&end=2022-02-24). I was also able to call these two dates by {{request.GET.start}} and {{request.GET.start}} in my HTML. My chart data is based on a list of dictionaries, which is defined in views.py: I count the number of records with Mike, Jane and Jack. mylist= [{'Date': '2021-10-02', 'ID': 11773, 'Receiver': Mike}, {'Date': '2021-10-02', 'ID': 15673, 'Receiver': Jane}, {'Date': '2021-10-03', 'ID': 11773, 'Receiver': Mike}, ... {'Date': '2021-12-25', 'ID': 34653, 'Receiver': Jack}] mike=len(tuple(d for d in mylist if d['Receiver'] == 'Mike')) jane=len(tuple(d for d in mylist if d['Receiver'] == 'Jane')) jack=len(tuple(d for d in mylist if d['Receiver'] == 'Jack')) count = [mike, jane, jack] My JavaScript chart: <!-- pie Chart --> <div class="col-xl-4 col-lg-4"> <div class="card shadow mb-4"> <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between"> <h6 class="m-0 font-weight-bold">Team Chart ({{request.GET.start}} - {{request.GET.end}} )</h6> </div> <!-- Card Body --> <div class="card-body"> <div class="chart-area"> <canvas id="myPieChart"></canvas> <script> var ctx = document.getElementById("myPieChart"); var startDate = … -
"<Post:>" needs to have a value for field "id" before this many-to-many relationship can be used
When i'm trying to add a Post through django admin i get an error that the Post im trying to add needs to have a value for field id. Do you have any idea why? now = datetime.now() class Category(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(unique=True) class Meta: verbose_name_plural = "categories" def __str__(self): return self.name class Post(models.Model): title = models.CharField(max_length=100) excerpt = models.CharField(max_length=200) main_image = models.ImageField() author = models.ForeignKey(users.models.CustomUser, on_delete=models.CASCADE, related_name='blog_posts', null=True) content = models.TextField(null=True) created_at = models.DateTimeField(editable=False) updated_at = models.DateTimeField(editable=False) category = models.ManyToManyField(Category, related_name='post_category') class Meta: ordering = ['-created_at'] def save(self, *args, **kwargs): if not self.id: self.created_at = now self.updated_at = now def __str__(self): return self.title -
Can't import google api modules in python (vs code)
i'm wondering why i can't import the following modules: I'm using django with a virtual environment to create a web app. I can access to venv with a command pipenv shell but even though the google-api files are in pip freeze folder i still can't manage to use them. I've installed google-api with this pip command: pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib -
Error running WSGI application: ModuleNotFoundError: No module named '_overlapped'
I stuck on this problem. I don't know what should I do. My error throws an error about WSGI. When I saw Error Log, it is working with my local server but getting problem on live 2022-02-23 18:47:32,893: Error running WSGI application 2022-02-23 18:47:32,910: ModuleNotFoundError: No module named '_overlapped' 2022-02-23 18:47:32,910: File "/var/www/lrnglobal_pythonanywhere_com_wsgi.py", line 17, in <module> 2022-02-23 18:47:32,910: application = get_wsgi_application() 2022-02-23 18:47:32,910: 2022-02-23 18:47:32,910: File "/home/lrnglobal/.virtualenvs/mysite-virtualenv/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2022-02-23 18:47:32,910: django.setup(set_prefix=False) 2022-02-23 18:47:32,910: 2022-02-23 18:47:32,910: File "/home/lrnglobal/.virtualenvs/mysite-virtualenv/lib/python3.9/site-packages/django/__init__.py", line 24, in setup 2022-02-23 18:47:32,910: apps.populate(settings.INSTALLED_APPS) 2022-02-23 18:47:32,911: 2022-02-23 18:47:32,911: File "/home/lrnglobal/.virtualenvs/mysite-virtualenv/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate 2022-02-23 18:47:32,911: app_config.import_models() 2022-02-23 18:47:32,911: 2022-02-23 18:47:32,911: File "/home/lrnglobal/.virtualenvs/mysite-virtualenv/lib/python3.9/site-packages/django/apps/config.py", line 301, in import_models 2022-02-23 18:47:32,911: self.models_module = import_module(models_module_name) 2022-02-23 18:47:32,911: 2022-02-23 18:47:32,911: File "/home/lrnglobal/portal/lrnadmin/models.py", line 1, in <module> 2022-02-23 18:47:32,911: from asyncio.windows_events import NULL 2022-02-23 18:47:32,911: 2022-02-23 18:47:32,911: File "/usr/local/lib/python3.9/asyncio/windows_events.py", line 3, in <module> 2022-02-23 18:47:32,911: import _overlapped 2022-02-23 18:47:32,911: *************************************************** 2022-02-23 18:47:32,912: If you're seeing an import error and don't know why, 2022-02-23 18:47:32,912: we have a dedicated help page to help you debug: 2022-02-23 18:47:32,912: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2022-02-23 18:47:32,912: this is my working directory and this is my wsgi file it seems correct import os import sys path = '/home/lrnglobal/portal' if …