Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
SQL: Join information from two tables
I have three relational postgres tables (timescale hypertables) and need to get my data into a CSV file, but I am struggling to get it to the format I want. I am using django as frameworks, but I need to solve this with raw SQL. Imagine I have 2 tables: drinks and consumption_data. The drinks table looks like this: name | fieldx | fieldy ---------+--------+------ test-0 | | test-1 | | test-2 | | The consumption_data table looks like this: time | drink_id | consumption ------------------------+-------------+------------------------------ 2018-12-15 00:00:00+00 | 2 | 123 2018-12-15 00:01:00+00 | 2 | 122 2018-12-15 00:02:00+00 | 2 | 125 My target table should join these two tables and give me all consumption data with the drink names back. time | test-0 | test-1 | test-2 ------------------------+-------------+---------+------- 2018-12-15 00:00:00+00 | 123 | 123 | 22 2018-12-15 00:01:00+00 | 334 | 122 | 32 2018-12-15 00:02:00+00 | 204 | 125 | 24 I do have all the drink-ids and all the names, but those are hundreds or thousands. I tried this by first querying the consumption data for a single drink and renaming the column: SELECT time, drink_id, "consumption" AS test-0 FROM heatflowweb_timeseriestestperformance WHERE drink_id = 1; … -
Django REST framework - parse uploaded csv file
I have setup Django REST framework endpoint that allows me to upload a csv file. The serializers.py looks like this: from rest_framework import serializers class UploadSerializer(serializers.Serializer): file_uploaded = serializers.FileField() class Meta: fields = ['file_uploaded'] In my views.py file, I'm trying to read data from uploaded csv like this: class UploadViewSet(viewsets.ViewSet): serializer_class = UploadSerializer def create(self, request): file_uploaded = request.FILES.get('file_uploaded') with open(file_uploaded, mode ='r')as file: csvFile = csv.reader(file) for lines in csvFile: print(lines) I'm getting the following error: ... line 37, in create with open(file_uploaded, mode ='r') as file: TypeError: expected str, bytes or os.PathLike object, not InMemoryUploadedFile I have checked type() of file_uploaded and It is <class 'django.core.files.uploadedfile.InMemoryUploadedFile'> How can I read this file into dictionary or dataframe so I can extract the data I need from it? -
Django Models multiple foreign key relationship
say I have a model, e.g.,: class Topic(models.Model): date = models.DateField(null=False, blank=False) subject = models.ForeignKey(Subject, blank=False, null=False, on_delete=models.CASCADE) topic_id = models.PositiveIntegerField(null=False, blank=False) aggregate_difficulty = models.PositiveIntegerField(null=False, blank=False) class Meta: constraints = [models.UniqueConstraint(fields=["subject", "date", "topic_id"], name="topic_unique")] And we have another model, e.g.,: class Module(models.Model): date = models.DateField(null=False, blank=False) subject = models.ForeignKey(Subject, blank=False, null=False, on_delete=models.CASCADE) topic_id = models.PositiveIntegerField(null=False, blank=False) content = models.TextField() difficulty = models.PositiveIntegerField(null=False, blank=False) How can I create a foreign key relationship from module to topic using the three fields: date, subject and topic_id? I would like to have this format, so the person inserting into the database would not have to find out the auto-generated topic id before inserting into the module table. There are many modules to one topic and many topics to one subject. -
webpack main.js file size is 6.3 in "webpack --mode production"
I am using webpack to combine django & React js. but main.js bundle file is too large (6.3 MB) so the page to much time to load webpack.config.js const path = require("path"); const webpack = require("webpack"); const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); module.exports = { entry: "./src/index.js", output: { path: path.resolve(__dirname, "./static/frontend"), filename: "[name].js", }, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: "babel-loader", }, }, // Additional configuration to handle *.css files { test: /\.css$/i, use: ["style-loader", "css-loader"], }, { test: /\.svg$/, use: ["@svgr/webpack"], use: [ { loader: "svg-url-loader", options: { limit: 10000, }, }, ], }, { test: /\.(png|jpg)$/, type: "asset/resource", }, ], }, optimization: { minimize: true, }, performance: { hints: false, maxEntrypointSize: 512000, maxAssetSize: 512000, }, plugins: [ new NodePolyfillPlugin(), new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production"), }), ], }; babel.config.json { "presets": [ [ "@babel/preset-env", { "targets": { "node": "10" } } ], "@babel/preset-react" ], "plugins": ["@babel/plugin-proposal-class-properties"] } My pakage.json Installed is "webpack": "^5.75.0", "webpack-cli": "^5.0.0" I am unable to optimize with minimize = true Its show error when minimize = true ERROR in main.js main.js from Terser plugin -
ValueError at /borrow/
I am tryin to automatically populate a table B whenever a user fills out a form that populate tableA. Whenever i fill out the form to populate table A, i run into this error. Traceback (most recent call last): File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/dubsy/virtualenvs/djangoproject/libmain/books/views.py", line 21, in borrow borrower.save() File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/db/models/base.py", line 812, in save self.save_base( File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/db/models/base.py", line 878, in save_base post_save.send( File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 176, in send return [ File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp> (receiver, receiver(signal=self, sender=sender, **named)) File "/home/dubsy/virtualenvs/djangoproject/libmain/books/models.py", line 84, in create_lending ApprovedLending.objects.create(member=row["member_id"]) File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/db/models/query.py", line 669, in create obj = self.model(**kwargs) File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/db/models/base.py", line 541, in __init__ _setattr(self, field.name, rel_obj) File "/home/dubsy/virtualenvs/djangoproject/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py", line 235, in __set__ raise ValueError( Exception Type: ValueError at /borrow/ Exception Value: Cannot assign "1": "ApprovedLending.member" must be a "User" instance. Here is my models.py class A(models.Model): member = models.ForeignKey(User, on_delete=models.CASCADE, default="") book = models.ForeignKey(Books, on_delete=models.CASCADE, default="") library_no = models.CharField(default="", max_length=255, blank=True) staff_id = models.CharField(default="", max_length=255, blank=True) application_date = models.DateTimeField(auto_now_add=True) class B(models.Model): member = models.ForeignKey(User, on_delete=models.CASCADE, default="", null=True) book = models.ForeignKey(Books, on_delete=models.CASCADE, default="", null=True) … -
Problem with email sending when server status is on smtp
So I am making a website with account activation when registering and this works fine. But the part where I have to send email to reset password doesn't. If I turn the email backend to 'console', It works fine. In the console I get the message with the token link to reset the password. When I turn the email backend to 'smtp' it just doesnt work and I get a long error after I submit the email that the message has to be sent on. Also I don't have a pasword reset view. I don't know if that is the problem.email_SettingsPassword reset formspasswordreset_confirm_htmlpassword_reset_Form_htmlpassword_reset_urlserrorerror location I tried moddeling a Password reset view. I don't know if the view was right or this does not solve the problem. Also I googled this error but I didnt find something useful. Tried to change some urls. -
Django Dynamically Assign Model Object Field In For Loop
I want to dynamically pass the field name of a model in a for loop function. The code below is what I want to achieve, but obviously "object.model_field" won't work because it's looking for that specific name and not using the variable passed through the function. How can I lookup the field name of the variable passed through the function? query_objects = my_model.objects.all() def function(query_objects, model_field): object_list = [] for object in query_objects: object_list.append(object.model_field) return object_list -
Django & Django Rest Framework. Custom accounts app
I need help in creating a custom accounts app instead of using django_allauth or the built-in django user model. I'm stuck on LoginView, LogoutView, SignupView, and linking the created model to django rest framework auth model (using the created model to authenticate your api with token). Here is what i have wrote: models.py: from django.db import models class Account(models.Model): email = models.EmailField(unique=True, blank=True, null=True) phone = models.CharField(max_length=30, unique=True, blank=True, null=True) password = models.CharField(max_length=250) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) urls.py: from django.urls import path from accounts.views import ( AccountsView, AccountView, SignupView, LoginView, LogoutView ) app_name = 'accounts' urlpatterns = [ path('', AccountsView.as_view()), path('<int:pk>', AccountView.as_view()), path('signup/', SignupView.as_view()), path('login/', LoginView.as_view()), path('logout/', LogoutView.as_view()) ] serializers.py: from django.contrib.auth.hashers import make_password from rest_framework import serializers from accounts.models import Account class AccountSerializer(serializers.Serializer): id = serializers.IntegerField(read_only=True) email = serializers.EmailField() phone = serializers.CharField(max_length=30) password = serializers.CharField(max_length=250, write_only=True, required=True) created_at = serializers.DateTimeField(read_only=True) updated_at = serializers.DateTimeField(read_only=True) def create(self, validated_data): password = make_password(validated_data.get('password')) account = Account.objects.create( email=validated_data.get('email'), phone=validated_data.get('phone'), password=password ) return account def update(self, account, validated_data): password = make_password(validated_data.get('password')) if validated_data.get('password') is not None else account.password account.email = validated_data.get('email', account.email) account.phone = validated_data.get('phone', account.phone) account.password = password account.save() return account views.py: from django.http import Http404 from rest_framework import status from rest_framework.views … -
How to make an input field with prompts that will appear in the process of entering data
I am making a site on Django. And I faced a problem. I would like to create an input field in the form so that it is initially empty, but so that in the process of how the user enters data into it, a frame will appear next to it, with possible selection options based on data already entered by the user. In short, I want to make something like this field Help me please -
CPanel installing requirements.txt file problem
Getting error in cPanel while installing requirements.txt file in django project. note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> cffi note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. -
Import data containing title instead of ID in django
I am using django-import-export. It is an extension used to import tables of data to the admin panel using a csv file. I have a model with a foreign key : ProductModel, now if i want to import data i have to supply an ID of the ProductModel in the csv. I want a bypass so I can use title of an object instead of id in the csv class Item(models.Model): title = models.CharField(max_length=100) model = models.ForeignKey(ProductModel, ....) class ProductModel(models.Model): title = models.CharField(max_length=100) desc = models.Tex..... -
How to make factory use `objects.create_user` instead of `objects.create` when creating model
Is there a way to make instantiating instances from factories use Model.objects.create_user instead of Model.objects.create? It seems that user_factory.create uses the latter, which makes the below code succeed even though username is a required field and not passed. @register class UserFactory(factory.django.DjangoModelFactory): class Meta: model = User @pytest.fixture def new_user2(user_factory): return user_factory.create(first_name='abc') -
Debugging routing issue in Netbox plugin (Django)
I'm trying to debug a new plugin I'm writing for Netbox. But I'm currently stuck at the error. 'netbox_redfish' is not a registered namespace inside 'plugins' There is a stack trace but it isn't pointing to the line of code wich is causing the error. Error Code can be found here: https://github.com/accelleran/netbox_redfish Thanks -
Why Autocomplete form in django doesn't work
I have been trying several different kind of code for an autocomplte form with Django Im new on this but here are the code: Views.py def search_ifsc(request): try: q = request.GET.get('q', '').capitalize() search_qs = InfoTrabajadores.objects.filter(documento__startswith=q) results = [] print(q) for r in search_qs: dict_data = {'documento':r.documento,'nombres':r.nombres,'info':{ 'num_emergencia':r.num_emergencia, 'prov_salud':r.prov_salud, 'prov_salud_trabj':r.prov_salud_trabj, 'rh':r.rh}} results.append(dict_data) data = json.dumps(results) except Exception as e: data = 'fail'+ f'\n{e}' mimetype = 'application/json' return HttpResponse(data, mimetype) This in the endpoint to filter te data with the document Inside the document: <script type='text/javascript'> fetch('http://127.0.0.1:8000/ajax/search/') .then((response) => response.json()) .then((data) => { document.getElementById('nombre').value = data.nombres; document.getElementById('num_emergencia').value = data.num_emergencia; document.getElementById('prov_salud').value = data.prov_salud; document.getElementById('prov_salud_trabj').value = data.prov_salud_trabj; document.getElementById('rh').value = data.rh; } ) And the urls.py urlpatterns = [ path('ajax/search/' , search_ifsc, name='search_view'), ] This is how the site looks with the actual code I've been trying change de model and how the query works, but nothing change the response in the site -
how to add legend in django form
I am trying to add legend to the form field in my django project. But facing some issues unable to add the legend. Any kind of help will be appreciated. Form.py class MyForm3(ModelForm): class Meta: model = import fields = ['date_of_request', 'Number_of_units', 'Date_of_shipment', 'Required_doc',-------------- This should be the legend 'doc1', 'doc2', ] models.py class import(models.Model): date_of_request = models.DateField() Number_of_units = models.IntegerField() Date_of_shipment = models.IntegerField() Required_doc = models.CharField(max_length=200)---------- This should be the legend doc1 = models.BooleanField() doc2 = models.BooleanField() -
django how can i send data to def function in view.py when <a href is clicked
For example, I want to send data "1" when January is clicked January -
how to map data in column panda dataframe
Dataframe data I need to group each student/name by the teacher. Which I was able to do. Now I can't get the below desired output: Desired output Dataframe to map I want to output the data to this: { "name": "Roberto Firmino", "age": 31, "height": "2.1m" }, { "name": "Andrew Robertson", "age" : 28, "height": "2.1m" }, { "name": "Darwin Nunez", "age": 23, "height": "2.1m" } -
Broken migrations after implementing MultiSelectField with choices based on ForeingModel
I'm using MultiSelectField and it works perfect, the problem is when I need to do migrations after my models... class Title(models.Model): name = models.TextField(null = True) degree = models.TextField(null = True) class Person(models.Model): name = models.TextField(null = True) title = MultiSelectField(choices=Title.objects.values_list('name','degree'), max_choices=4, max_length=255, null = True, blank= True) The trick here is Person is trying to use Title before migrations happens, so it crashes. Instead of models.ForeignKey that actually take care about the dependent model. I've already tried to handle it with migration dependencies but it doesn't work. Any workaround? -
Django. I want it to be moved within that category list
I want it to be moved within that category list if I choose the previous and next text. Hi, everyone. English is not my first language. Therefore, please understand the poor expression in advance. But I dare you to understand this question and write it in anticipation of answering it. LOL (I used a translator for some content) I created a bulletin board app using DJango. These bulletins are categorized into categories. If you click on a text in the full list page, navigate to the detail page, and select Previous and Next, of course, it will move normally. What I've been struggling with for a few days is that when I click on a text in a particular category list and go to the detail page, I want it to be moved within that category list if I choose the previous and next text. ㅠ.ㅠ ** models.py ** from django.db import models from django.contrib.auth.models import User import os class Category(models.Model): name = models.CharField(max_length=20, unique=True) slug = models.SlugField(max_length=200, unique=True, allow_unicode=True) description = models.TextField(default='카테고리 설명') def __str__(self): return self.name def get_absolute_url(self): return f'/mytube/category/{self.slug}/' class Post(models.Model): title = models.CharField(max_length=100) hook_text = models.CharField(max_length=100, blank=True) content = models.TextField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) … -
Creating one object for multiple models in one form
This is a project support a vendor. I have three models, Item DeliveryOrderForm TableList Item defines what items is sold by the vendor. DeliveryOrderForm saves the details of the recipient/buyer. TableList saves the details of each order's row that is ordered by the buyer. models.py class Item(models.Model): itemID = models.AutoField(unique=True,primary_key=True) itemPrice = models.DecimalField(default=0,max_digits=19,decimal_places=2) itemDescription = models.CharField(max_length=30) #deliveryorder status class Status(models.IntegerChoices): pending = 1 disapproved = 2 approved = 3 class DeliveryOrderForm(models.Model): deliveryOrderID = models.AutoField(unique=True,primary_key=True) vendorName = models.CharField(max_length=30) vendorAddress = models.CharField(max_length=200) recipientName = models.CharField(max_length=30) recipientPhone = PhoneNumberField(blank=False) recipientAddress = models.CharField(max_length=200) deliveryOrderStatus = models.IntegerField(default=Status.pending,choices=Status.choices) deliveryOrderDate = models.DateTimeField(default=timezone.now) class TableList(models.Model): deliveryOrderID = models.ForeignKey(DeliveryOrderForm,on_delete = models.CASCADE) itemID = models.ForeignKey(Item,on_delete=models.PROTECT) itemQuantity = models.IntegerField(default=0) So, in the admin page, creating an object of DeliveryOrderForm is fine. I was also able to display the DeliveryOrderForm along with the TableList. The issue now trying to create a view that works to CREATE an object of DeliveryOrderForm. I've tried this : forms.py class DOForm(ModelForm): class Meta: model = DeliveryOrderForm fields = '__all__' views.py def createDeliveryOrder(request): model = DeliveryOrderForm template_name = 'deliveryorder/create.html' deliveryOrderID = get_object_or_404( model.objects.order_by('-deliveryOrderID')[:1] ) formset = inlineformset_factory(DeliveryOrderForm,TableList, fields = [ 'itemID', 'itemQuantity', ]) if request.method == 'POST': form = DOForm(request.POST,prefix = 'deliveryorder') if form.is_valid() and formset.has_changed(): form.save() … -
How to push reviews from 3rd party website to Google and Facebook reviews venue page? (Django)
I have a website that collects reviews for a group of venues from their customers. I am looking at the feasibility for a user to automatically share their reviews on the venue's Facebook or Google page without having to retype it. Let's say I am User_1. I connect to website and leave a review for Venue_A. I would then be able to press a button that would atomically push my review to the Facebook and Google review against Venue_A page, without the user having to retype it. Does any know if this is something Google or/and Facebook have already in place? I can see some API about pulling reviews, but not much about pushing them. -
To apply 'update_session_auth_hash' in UpdateView
error occured at the code below. class UserUpdate(LoginRequiredMixin, UpdateView): model = User form_class = ProfileUpdateForm template_name = 'single_pages/profile_update.html' success_url = reverse_lazy('single_pages:landing') login_url = '/login/' def form_valid(self, form): u = form.save() if u is not None: update_session_auth_hash(self.request, u) return super(UserUpdate, self).form_valid(form) with the error message IntegrityError at /update/8/ UNIQUE constraint failed: single_pages_profile.phoneNumber Request Method: POST Request URL: http://127.0.0.1:8000/update/8/ Django Version: 3.2.13 Exception Type: IntegrityError Exception Value: UNIQUE constraint failed: single_pages_profile.phoneNumber Exception Location: C:\github\project\venv\lib\site- packages\django\db\backends\sqlite3\base.py, line 423, in execute Seems like it's related to the model Profile, which is OnetoOne with the user like this: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) phoneNumberRegex = RegexValidator(regex = r'^01([0|1||6|7|8|9]-?([0-9]{3,4})-?([0-9]{4})$') phoneNumber = models.CharField(max_length=11, unique=True, validators=[phoneNumberRegex]) username = models.CharField(max_length=30) email = models.EmailField(max_length=50) address = models.CharField(max_length=200) Although I don't want Profile to be a ForeignKey of user, I tried that once but the same error occured. Lastly, this is forms.py class ProfileUpdateForm(UserCreationForm): phoneNumber = forms.CharField(required=False) address = forms.CharField(required=False) username = forms.CharField() email = forms.EmailField() password1 = forms.CharField() password2 = forms.CharField() class Meta(UserCreationForm.Meta): fields = UserCreationForm.Meta.fields + ('email',) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['username'].disabled = True def save(self): user = super().save() profile = Profile.objects.create( user=user, phoneNumber=self.cleaned_data['phoneNumber'], address=self.cleaned_data['address']) return user By the error message, problem is here: profile = … -
Dropdown are not working in Django , HTML
I am trying to display data from database throw drop-down list and Use filter query to filter data and display if i tried to select value of html and select but slot is not create. Debugging form and i see error. If i select anything but drop-down do't selected here is error Here is my code: slot/views.py def slot_create(request): form = SlotForm(request.POST) print(form) station = Station.objects.filter(user_id=request.user) print(station) if form.is_valid(): slot = form.save(commit=False) slot.user = request.user slot.save() messages.success(request, 'Your Slot is add successfully') return redirect('view_slot') return render(request, 'add_slot.html', { 'form': form, 'station': station }) here is my add_slot.html <form method="post" novalidate> {% csrf_token %} <div class="form-row"> <div class="form-group col-md-12 mb-0"> {{ form.slot_name|as_crispy_field }} </div> <div class="form-group col-md-12 mb-0"> {{ form.per_unit_price|as_crispy_field }} </div> <div class="form-group col-md-6 mb-0"> {{ form.current_status|as_crispy_field }} </div> {% comment %} <div class="form-group col-md-6 mb-0"> {{ form.station|as_crispy_field }} </div> {% endcomment %} <div class="form-group col-md-6 mb-0"> <label for="station" class="block font-semibold text-sm mb-1"> Choose Station </label> <select name="station_name" id = "station"> {% for station in station %} <option value="{{station}}"> {{station}} </option> {% endfor %} </select> </div> <button type="submit" class="w-full rounded-full bg-red-gradient p-3 text-white font-bold hover:ring"> Add Slot </button> </div> </form> -
Django admin site foreign key
I have created some classes like STATE, DISTRICT, TALUK, and VILLAGE. Admin needs to add details in the admin panel. If the admin needs to add TALUK, he must select provided STATE, DISTRICT.I used a foreign key in the TALUK class for calling states and districts. But in admin after selecting STATE, the DISTRICT dropdown shows all the DISTRICTS. I need to get only the districts of that particular state This is the code I wrote in models.py class STATE(models.Model): state_name=models.CharField(max_length=25) def __str__(self): return self.state_name class DISTRICT(models.Model): district_state=models.ForeignKey(STATE,on_delete=models.CASCADE) district_name=models.CharField(max_length=25) def __str__(self): return self.district_name class TALUK(models.Model): taluk_state=models.ForeignKey(STATE,default=1,verbose_name="state",on_delete=models.CASCADE) taluk_district=models.ForeignKey(DISTRICT,on_delete=models.CASCADE) taluk_name=models.CharField(max_length=25) def __str__(self): return self.taluk_name class VILLAGE(models.Model): taluk_vill=models.ForeignKey(TALUK,on_delete=models.CASCADE) vill_name=models.CharField(max_length=25) def __str__(self): return self.vill_name -
Deploying Django on Windows server 2019 using xampp gives ModuleNotFoundError: No module named '_socket'\r
I am trying to host a django application on Windows Server 2019 using XAMPP and after going through all the settings necessary for the app to run, I get an Internal Server Error. Here's my setup: Running on venv, doing a pip freeze gives: (envcrm) DECRM@CRM2 MINGW64 /c/xampp/htdocs/crm $ pip freeze asgiref==3.6.0 Django==4.1.5 mod-wsgi==4.9.4 mysqlclient==2.1.1 sqlparse==0.4.3 tzdata==2022.7 Django App is in C:\xampp\htdocs\crm\decrm Directory Structure: C:\xampp\htdocs\crm |--decrm -> python project |--envcrm -> virtual environment |--mydecrm -> app |--static -> static folder for the apps |--templates -> templates folder for the apps |--users -> app Also placed MOD_WSGI_APACHE_ROOTDIR in the environment variables to be able to do a successful pip install mod_wsgi As for the httpd.conf, here's my setting for WSGI: LoadFile "C:/Users/DECRM/AppData/Local/Programs/Python/Python311/python311.dll" LoadModule wsgi_module "C:/xampp/htdocs/crm/envcrm/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp311-win_amd64.pyd" WSGIPythonHome "C:/xampp/htdocs/crm/envcrm" WSGIScriptAlias / "c:/xampp/htdocs/crm/decrm/wsgi.py" WSGIPythonPath "c:/xampp/htdocs/crm" <Directory "c:/xampp/htdocs/crm/decrm/"> <Files wsgi.py> Require all granted </Files> </Directory> Alias /static "c:/xampp/htdocs/crm/static/" <Directory "c:/xampp/htdocs/crm/static/"> Require all granted </Directory> with this, I get an Internal Server Error with these on the error logs: [Wed Jan 25 19:18:33.645848 2023] [wsgi:error] [pid 6720:tid 2060] [client ::1:51675] ModuleNotFoundError: No module named '_socket'\r [Wed Jan 25 19:18:33.694850 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] mod_wsgi (pid=6720): Failed to exec Python script file 'C:/xampp/htdocs/crm/decrm/wsgi.py'., referer: …