Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to add my function to values parameters?
I have a function 'is_recently' that checks how long the item I added has been hanging, and if 30 minutes have not passed yet, then write that it is recently on sale. I decided to optimize queries in the database, and I cannot add this function to the parameters of the values function, is it possible to do this at all? Forgive me in advance if I wrote with errors, I'm not English speaking. def index(request): data = ( Product .objects.select_related('category') .filter(is_on_main=True) .values('name','price','pk','date') ) Maybe there are some other functions? Or I don't understand something -
How to improve Django's collectstatic command performance in Docker?
I'm working on a Django project that's containerized using Docker, and I've noticed that the collectstatic command has very poor performance during the Docker image build process. The collectstatic command in Django works by comparing the timestamps of files from the source and destination. Based on this comparison, it determines whether a file should be copied, deleted and copied, or skipped. This behavior significantly affects the performance of the collectstatic command. I realized that the issue was due to the timestamps of my static files not being preserved during the Docker build process, causing collectstatic to perform unnecessary operations. Is there a way to preserve the original timestamps of my static files when building a Docker image for a Django application, and thereby improve the performance of the collectstatic command? -
How to web scrape an svg of site(Hackerrank) using Django [closed]
I want to scrape and display or store svg of the hackerrank website. Hackerrank robots.txt: User-agent: * Disallow: /x/tests/ Disallow: /x/interviews/ Disallow: /x/settings/ Disallow: /*download_solution$ Disallow: /tests/ Disallow: /work/embedview/ User-agent: AhrefsBot Disallow: / User-agent: MauiBot Disallow: / User-agent: ia_archiver Disallow: / User-agent: DuckDuckBot Crawl-Delay: 3 User-agent: Bingbot Crawl-Delay: 3 User-agent: YandexBot Crawl-Delay: 3 User-agent: MJ12Bot Crawl-Delay: 3 Sitemap: https://cdn.hackerrank.com/s3_pub/hr-assets/sitemaps/sitemap.xml.gz I tried using beautifulsoup but it only extracts the svgs tags and not the styles or the resources. I am willing to use other scraping software -
in my code send_bulkledger call many time ,but i called it only once
if main1['res']['message']['module']=='bulk_ledger_save': ledger_list=await self.save_bulk_ledger(main1) # returns a list print('6000') msgdict= {"msg":"bulk_legder_return","ledger_list": ledger_list} await self.channel_layer.group_send( self.room_group_name, { "type":"send_bulkledger", 'msg':msgdict }) async def send_bulkledger(self, event): print(event,'7000') data=event['msg'] await self.send(text_data=json.dumps({ "msg":data })) This code belongs to Django Channels While running above code 6000 is printing only once but 7000 is printing multiple times because of this getting data in frontend many times -
[GSI_LOGGER]: The given origin is not allowed for the given client ID. && Failed to load resource: the server responded with a status of 400
[GSI_LOGGER]: The given origin is not allowed for the given client ID. I have added "javascript_origins": [ "http://localhost", "http://localhost:8000" ] I don't uderstand Why am i gettingthis The given origin is not allowed for the given client ID. <script src="https://accounts.google.com/gsi/client" async defer></script> {% load static %} <script type="text/javascript" src="{% static '/js/app.js' %}"></script> <h1>My Awesome App</h1> <div id="g_id_onload" data-client_id="873307876888-9ht3ph1vm7l62ugtmos36fddrrm6bj5n.apps.googleusercontent.com" data-context="signin" data-ux_mode="popup" data-callback="handleLogin" data-auto_select="true" data-itp_support="true"> </div> <div class="g_id_signin" data-type="standard" data-shape="rectangular" data-theme="outline" data-text="signin_with" data-size="large" data-logo_alignment="left"> </div> -
Custom field in django-filter causes an error
I have django-filter and i want to add new custom field in my model filter but it causes an error Cannot resolve keyword 'category_choice' into field. When i deleted self.filters.extra everything okay but i dont know how to fix that bcs i need to add choice in init def qsCategory(request): object = request.GET.get('open_point_object') if object: return OpenPointList.objects.filter(open_point_object_id=object).values_list('category', flat=True).distinct() return OpenPointList.objects.values_list('category', flat=True).distinct() class OpenPointFilter(django_filters.FilterSet): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if self.data.get('category_choice'): self.data._mutable = True category_choice = request.GET['category_choice'] if category_choice: self.data['category'] = self.data.get('category_choice') self.data._mutable = False self.filters['category_choice'].extra['choices'] = [ (category, category) for category in qsCategory(self.request) ] status = django_filters.ChoiceFilter(choices=CHOICES) category = django_filters.CharFilter(method='custom_category_filter') category_choice = django_filters.ChoiceFilter(label='Категория') class Meta: model = OpenPointList fields = ( 'open_point_object', 'status', 'category', 'category_choice', ) ) -
Django rest framework: Cascade activate/deactivate
I am working on an API using django and django rest framework, what I want to do is cascading with two action for related models Deleting an instance and that goes smothely with no problem using on_delete=modles.CASCADE on the models.ForeignKey. Activation and deactivation and here is the problem Each model I defined in my application there is a boolean field is_active which indicates if this instance is active or not, what I want to do here is to cascade activation and deactivation whenever the is_active field changes and I want to handle this in a dynamic way because my application is growing big and I don't want to change this service manually every time I create a new foreign key for any model. For example I have the following models class Company(AbstractNamingModel): name_en = models.CharField(_("English Name"), max_length=64, unique=True, null=True, blank=True) name_ar = models.CharField(_("Arabic Name"), max_length=64, unique=True, null=True, blank=True) is_active = models.BooleanField( _("Is Active"), blank=True, default=True, ) class Branch(AbstractNamingModel): company = models.ForeignKey( Company, on_delete=models.CASCADE, verbose_name=("Company branches"), related_name="company_branches", ) is_active = models.BooleanField(_("Is Active"), blank=True, default=True) class Department(AbstractNamingModel): branch = models.ForeignKey( Branch, on_delete=models.CASCADE, verbose_name="Branch Departments", related_name="branch_departments", ) is_active = models.BooleanField( _("Is Active"), blank=True, default=True, ) class Employee(AbstractUser, TimeStampedModel): id = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4) … -
Issue with creating different profiles in Django signals
I'm facing an issue in my Django application where I need to create different profiles, either Profile1 or Profile2, based on the value of user.is_manager. I'm utilizing signals to handle this logic. Here is a summary of the problem: I have two profile models: Profile1 and Profile2. Profile1 is intended for manager users, while Profile2 is for non-manager users. In my managers.py file, I set user.is_manager to True for manager users during the creation of a user. However, when I try to access instance.is_manager in my signals.py file, it consistently returns False, even though it should be True according to the value set in managers.py. I have already reviewed my code and verified that user.is_manager is correctly set to True in managers.py. I'm looking for guidance on why the value of instance.is_manager is not being captured accurately in the signals. Any suggestions or insights to resolve this issue would be greatly appreciated. # managers.py from django.contrib.auth.models import BaseUserManager class UserManager(BaseUserManager): def create_user(self, phone, username, email, password): user = self.model(phone=phone, username=username, email=email) user.set_password(password) user.save(using=self.db) return user def create_superuser(self, phone, username, email, password): user = self.create_user(phone, username, email, password) user.is_admin = True user.is_manager = True # when create a superuser it's a … -
Django Rest Framework Serializer Update Method
I have a serializer that I am using to make an update I however cannot seem to make it work. The view is a ModelViewSet, and the main Model is a User model which has a foreign key mapping to a Profile model. Below is the view code class RegisterPublicAPIView(viewsets.ModelViewSet): # serializer_class = RegisterPublicSerializer http_method_names = ['get', 'post', 'put', 'delete'] lookup_field = "public_id" permission_classes = (permissions.IsAuthenticated,) def get_serializer_class(self): if self.action in ['list', 'retrieve']: return RegisterListPublicSerializer if self.action == 'create': return RegisterManagePublicSerializer else: return RegisterUpdatePublicSerializer def get_queryset(self): return User.objects.all() def post(self, request): updateSerializers = self.get_serializer_class() serializer = updateSerializers(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() user_data = serializer.data return Response(user_data, status=status.HTTP_201_CREATED) Below is the serializer code with comments on what I have tried and the error response I am getting. class RegisterUpdatePublicSerializer(serializers.ModelSerializer): department = serializers.IntegerField(required=True) salutation = serializers.CharField(max_length=10, required=True) firstname = serializers.CharField(max_length=40, required=True) lastname = serializers.CharField(max_length=40, required=True) mobile = serializers.CharField(max_length=40, required=True) tel = serializers.CharField(max_length=40, required=True) class Meta: model = Profile exclude = ('id',) def update(self, instance, validated_data): profile = Profile.objects.get(id=instance.profile.id) profile.firstname = validated_data.get('firstname') profile.lastname = validated_data.get('lastname') profile.mobile = validated_data.get('mobile') profile.tel = validated_data.get('tel') profile.salutation = validated_data.get('salutation') profile.save() dept = Department.objects.get(id=validated_data.get('department')) # instance.department_id = (dept.id, instance.department_id) # Expected a number but got (2, 2) # instance.department_id = dept.id … -
Connecting to snowflake in django using proxy
I have deployed my django app on heroku and I want to connect to snowflake. But whenever I redeploy, IP changes and my app is not able to connect to snowflake(IP whitelisting issue). I have tried to use fixie as a proxy so that when I connect to snowflake, my IP doesnt change and I don't need to get it whitelisted. Below are two code snippets I have been using to connect to snowflake. But my app keeps trying to connect using my network IP and not the proxy. MY IMPORTS: from sqlalchemy import create_engine from sqlalchemy import text import requests import snowflake import snowflake.connector snippet 1: engine = create_engine( 'snowflake://{user}:{password}@{account}/{database}/{schema}'.format( user=connection_details["user"], password=connection_details["pw"], account=connection_details["account"], database=connection_details["database"], schema=connection_details["schema"], ), connect_args={ 'proxy': 'http://fixie:kT8kuyNpPbrbdx@velodroll.usefixie.com:80' }) snippet 2: engine = snowflake.connector.connect(user=connection_details["user"],password=connection_details["pw"],account=connection_details["account"],database=connection_details["database"],schema=connection_details["schema"],connect_args={'proxy': 'http://fixie:kT8djczxc14@velodsad.usefixie.com:80'}) and the error i keep getting : snowflake.connector.errors.DatabaseError: 250001 (08001): Failed to connect to DB: pv40812.east-us-2.azure.snowflakecomputing.com:443. IP address 169.169.169.69 is not allowed to access Snowflake. Contact your account administrator. For more information about this error, go to https://community.snowflake.com/s/ip-xxxxxxxxxxxx-is-not-allowed-to-access. I tried to connect to snowflake through fixie proxy but it keeps ignoring it -
Alternative Solutions for Syncing PostgreSQL Databases Across Machines
I possess two machines: My laptop, which operates on Ubuntu 22.04. OKD (Openshift container) that runs on CentOS 7. My objective is to synchronize a PostgreSQL database between these two machines. Initially, I planned to utilize Rsync to ensure that the PostgreSQL data directory remains consistent on both machines. However, this method is likely to fail due to the differences in configuration files between the two systems. An alternative approach involves using the psql_dump command to export the database from one machine and then importing it on the other. Are there any other solutions available for scenarios like this (Note that this database is used for a Django project)? -
Issue with creating different profiles in Django signals
I'm facing an issue in my Django application where I need to create different profiles, either Profile1 or Profile2, based on the value of user.is_manager. I'm utilizing signals to handle this logic. Here is a summary of the problem: I have two profile models: Profile1 and Profile2. Profile1 is intended for manager users, while Profile2 is for non-manager users. In my managers.py file, I set user.is_manager to True for manager users during the creation of a user. However, when I try to access instance.is_manager in my signals.py file, it consistently returns False, even though it should be True according to the value set in managers.py. Any suggestions or insights to resolve this issue would be greatly appreciated. # managers.py: from django.contrib.auth.models import BaseUserManager class UserManager(BaseUserManager): def create_user(self, phone, username, email, password): user = self.model(phone=phone, username=username, email=email) user.set_password(password) user.save(using=self.db) return user def create_superuser(self, phone, username, email, password): user = self.create_user(phone, username, email, password) user.is_admin = True user.is_manager = True user.save(using=self.db) return # apps.py: from django.apps import AppConfig class PanelConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'panel' def ready(self): import panel.signals # signals.py from django.db.models.signals import post_save from django.dispatch import receiver from django.conf import settings from .models import User, Profile1, Profile2 @receiver(post_save, sender=User, … -
Upload excel sheet and insert excel sheet data into database along with some custom fields from Django admin panel
I am at beginner level in django and trying to upload excel file from Django admin and want to insert it's data into the database with some other custom fields from Django Admin. However, I am able to create the final object with all data but on final insertion I am getting 'No reverse match error'. Actual Error Note : I didn't create any view or did any URL configurations as it is admin panel and whatever examples I saw didn't see any other configurations. I wrote the following code to achieve this. Thanks in advance for your help! # model.py from django.db import models from django.urls import reverse class tblform(models.Model): ALSName = models.CharField(max_length=100) Study = models.CharField(max_length=100) FormId = models.CharField(max_length=100,primary_key=True) DraftName = models.CharField(max_length=100) OID=models.CharField(max_length=100) Ordinal = models.IntegerField(blank=True,null=True) DraftFormName = models.CharField(max_length=100) DraftFormActive = models.BooleanField(default=False) HelpText = models.CharField(max_length=100,blank=True,null=True) IsTemplate = models.BooleanField(default=False) # forms.py from django import forms from .models import tblform class tblform_Form(forms.ModelForm): excel_file = forms.FileField(required=False) class Meta: model = tblform fields = ('ALSName','Study','DraftName') # admin.py from django.contrib import admin from .models import tblform from .forms1 import tblform_Form import openpyxl class ProductAdmin(admin.ModelAdmin): form = tblform_Form def save_model(self, request, obj, form, change): if 'excel_file' in request.FILES: excel_file = request.FILES['excel_file'] #form_data = self.get_form(request).cleaned_data field_names … -
Catch and send the Integrity error in the response in Django rest Framework
In the application I want to catch the Integrity error, format it and send to the user for which I am doing something like this: class ProductUploadAPIView(APIView): @transaction.atomic def post(self, request): owner = request.user.pk d = request.data.copy() d['owner'] = owner file_obj = request.FILES['document'] df = pd.read_excel(file_obj) df = df.reset_index() error_details = [] # List to store error details for index, row in df.iterrows(): try: product = Product.objects.create( name=row['name'], sku=row['sku'], product_unit_id=row['product_unit_id'], ..... rest of the code except IntegrityError as e: error_msg = str(e) print("error message", error_msg) detail = error_msg.split('DETAIL: ')[1] error_details.append({'row': index + 2, 'detail': detail}) except Exception as e: error_msg = str(e) error_details.append({'row': index + 2, 'detail': error_msg}) if error_details: return Response({'errors': error_details}, status=status.HTTP_400_BAD_REQUEST) return Response("File uploaded successfully") But it doesn't return any response and give the integrity error directly which is not very readable to the user What changes should be made to send the column and row of the origin of error? -
Custom DjangoModelPermissions not being applied
I have a Django app that allows a user to be a member of multiple Organizations. from django.conf import settings from app.shared.models import BaseModel class Organization(BaseModel): name = models.CharField(max_length=256) class OrganizationMember(BaseModel): ROLE_OPTIONS = ( (OrganizationMemberRole.admin.value, _('Admin')), (OrganizationMemberRole.editor.value, _('Editor')), (OrganizationMemberRole.view.value, _('View Only')), ) organization = models.ForeignKey( Organization, related_name='members', on_delete=models.DO_NOTHING, ) user = models.ForeignKey( settings.AUTH_USER_MODEL, related_name='user_role', on_delete=models.DO_NOTHING, ) I've also got a custom user model with a property that generates a list of Organization IDs for that user from django.contrib.auth.models import AbstractUser from django.db import models from .managers import CustomUserManager class User(AbstractUser): username = None email = models.EmailField(max_length=254, unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email @property def user_organization_ids(self): """ Returns a list of Organization IDs. Converts UUID to str """ user_orgs_qs = self.user_role.all().values_list('organization_id', flat=True) return [str(i) for i in user_orgs_qs] There are other models in the database that will have a relationship with an Organization. For example, Widget from app.shared.models import BaseModel class Widget(BaseModel): organization = models.ForeignKey(Organization, on_delete=models.DO_NOTHING) I want to restrict CRUD operations based on OrganizationMember relationships. So, a user should only be able to perform CRUD operations on Widget if they are a member of the Organization. I've created from rest_framework.permissions import DjangoModelPermissions … -
Fatal error in launcher : when using Django
When running the command "pip install openpyxl" in PowerShell on Windows, I encountered the following error: Fatal error in launcher: Unable to create process using '"C:\Python311\python.exe" "C:\Python311\Scripts\pip.exe" install openpyxl': The system cannot find the file specified. How can I resolve this issue and successfully install the "openpyxl" package using pip? enter image description here I'm working on a Django project and I want to integrate Excel functionality. I'm trying to display data from my database, but I'm encountering the following error: "Fatal error in launcher: Unable to create process using '"C:\Python311\python.exe" "C:\Python311\Scripts\pip.exe" install openpyxl': The system cannot find the file specified." I believe this error is related to installing the openpyxl package using pip. Can someone please provide guidance on how to resolve this issue and successfully work with Excel in Django? Thank you in advance! -
How to send email to specific subscriber from the topic in AWS SNS
I have created one topic in AWS SNS. This topic contains many subscribers whose Protocol is Email and whose Endpoint is their email address. I have one API in Django which will send the email to the current user. So for this, I will fetch all the subscribers from the topic and match the email. If a match is found, I want to send an email to that particular subscriber. If a match is not found, I will create a new subscriber with that email address and send an email to it. I want to know how can we do that. What should be written in self.sns_client.publish() method. -
How to create a mobile app with django, with the same codebase?
I am trying to build an ERP system, same as TRYTN, ERPNEXT, ODDO. For the web version, I decided to go with Django and React. What I want is to have a mobile app of the same system too. Now my problem is to choose what tech stack to use for it. My company donot want to go with React Native for it. They want a solution with python itself. So I would like to know what option do I have , with python. This erp is really a data heavy software, there will be tens of thousand of records to be fetched at each api request. I looked at FLET(Write flutter app with python) framework, but it is really new. So any suggestion will be appreciated? I have tried to look at the code base of odoo/ tryton, but could not get any insight, as to how are they doing it. -
Facing a Cors error but that is already enabled in Django rest framework and react
I am facing one issue in my app which is developed in react and Django rest framework. In DRF api i am uploading the video and playing in react app. But video player slider not working then i have enabled the byte range request in my django rest app. But when i am enabling that setting then it giving a cors error in vtt Caption file. and also getting a cors error while downloading a pdf file from react app but when i am disabled the byte range request the video player slider not working but pdf downloading and video caption file working fine. Here is the code of byte range request in django rest app. byte range request code Please share your suggestions thanks i have enabled the byte range request in my django rest app. But when i am enabling that setting then it giving a cors error in vtt Caption file. and also getting a cors error while downloading a pdf file from react app but when i am disabled the byte range request the video player slider not working but pdf downloading and video caption file working fine. -
Could not find config for 'static files' in settings.STORAGES
This error occurs when running Django 4.2.The Default: django.contrib.staticfiles.storage.StaticFilesStorage has been deprecated. -
Problems to install Django in Windows
Now I'm using Windows10 and Python in vscode, When I tried to install Django by %pip install Django, there's the following error: Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skippingNote: you may need to restart the kernel to use updated packages. Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping WARNING: Ignoring invalid distribution -orch (d:\program files\anaconda\lib\site-packages) WARNING: Ignoring invalid distribution -cipy (d:\program files\anaconda\lib\site-packages) WARNING: Ignoring invalid distribution -orch (d:\program files\anaconda\lib\site-packages) WARNING: Ignoring invalid distribution -cipy (d:\program files\anaconda\lib\site-packages) WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF … -
User sign-in process in Django not working properly
I'm encountering an issue with the user sign-in functionality in my Django application. When attempting to sign in a user, I'm consistently receiving an error message stating "email and/or password is not valid!" instead of successfully logging in the user. I have verified that the email and password inputs are correct. I've also checked my code and ensured that I'm using the authenticate() and login() functions correctly. here is the code i tried, keep in mind that i am able to regester new users but not able to sign them in: def signup(request): # Extract data from form and assign it to variables. if request.method =='POST': username = request.POST['username'] email = request.POST['email'] password = request.POST['password'] confirm_password = request.POST['confirm_password'] # Check if user exists. user_exsit = User.objects.filter(Q(username = username) | Q(email = email)).exists() if user_exsit: error_message= 'User name or email already exists!' return render(request, 'user_auth/signup.html', {'error_message': error_message}) # Check if the password match. ((JS)) if password != confirm_password: error_message = "Password does not match!" return render(request, 'user_auth/signup.html', {'error_message': error_message}) # Create new user. else: user = User.objects.create_user(username = username, email = email, password = password) user.set_password(password) user.save() return render(request, 'user_auth/signin.html') else: return render(request,'user_auth/signup.html') def signin(request): # Extract data from form. if … -
Trouble Getting Django to Access the Correct Static Directory
I'm having trouble getting Django/Wagtail to access the correct static directory. As a result, all static files are returning 404. This is in a local/dev environment. I currently have: PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(PROJECT_DIR) STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] STATICFILES_DIRS = [ os.path.join(PROJECT_DIR, "static"), ] STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" STATIC_ROOT = os.path.join(BASE_DIR, "static") STATIC_URL = "/static/" MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_URL = "/media/" I'm using the following structure: my-project ├── apps │ └── app_1 │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── myproject │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-35.pyc │ │ └── settings.cpython-35.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py ├── media ├── static └── templates Django is trying to access: my-project\myproject\static which doesn't exist. When I try to move it to the correct directory, I get the following error: ?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting. For example, I've tried: STATICFILES_DIRS = [ os.path.join(PROJECT_DIR, "..", "static"), ] To get it to move up a dirrectory, but that results in the error above. Also, I've run collectstatic. -
ModuleNotFoundError: No module named 'projectName' - wsgi Django reployment
I am trying to run my Django Project using Apache. When I launch Apache I receive an 'Internal Server Error', inspecting the logs I have found that it fails to execute the wsgi.py for my project and throws the errors below. mod_wsgi (pid=5128): Failed to exec Python script file 'C:/Env/localassets/localassets/wsgi.py'., referer: http://localhost/ mod_wsgi (pid=5128): Exception occurred processing WSGI script 'C:/Env/localassets/localassets/wsgi.py'., referer: http://localhost/ Traceback (most recent call last):\r, referer: http://localhost/ File "C:/Env/localassets/localassets/wsgi.py", line 16, in <module>\r, referer: http://localhost/ application = get_wsgi_application()\r, referer: http://localhost/ File "C:\\Env\\Lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r, referer: http://localhost/ django.setup(set_prefix=False)\r, referer: http://localhost/ File "C:\\Env\\Lib\\site-packages\\django\\__init__.py", line 19, in setup\r, referer: http://localhost/ configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost/ File "C:\\Env\\Lib\\site-packages\\django\\conf\\__init__.py", line 102, in __getattr__\r, referer: http://localhost/ self._setup(name)\r, referer: http://localhost/ File "C:\\Env\\Lib\\site-packages\\django\\conf\\__init__.py", line 89, in _setup\r, referer: http://localhost/ self._wrapped = Settings(settings_module)\r, referer: http://localhost/ File "C:\\Env\\Lib\\site-packages\\django\\conf\\__init__.py", line 217, in __init__\r, referer: http://localhost/ mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost/ File "C:\\Program Files\\Python310\\Lib\\importlib\\__init__.py", line 126, in import_module\r, referer: http://localhost/ return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost/ File "<frozen importlib._bootstrap>", line 1050, in _gcd_import\r, referer: http://localhost/ File "<frozen importlib._bootstrap>", line 1027, in _find_and_load\r, referer: http://localhost/ File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked\r, referer: http://localhost/ File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed\r, referer: http://localhost/ File "<frozen importlib._bootstrap>", line 1050, in _gcd_import\r, … -
Can't get rid of modulenotfounderrror after moving project dirs around
when I run python manage.py runserver on myenv, I get the "modulenotfounderror" "no module named Quicpull" - which is my project Dir. I've tried multiple syntaxes in my installed apps, and I've updated the system env paths.