Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Check Data Availability with 0 % when data is not received on the date
I've created Data Availability (Which means if you select dates from_date to to_date, you'll get a table on that date on how much % of data will be received). If data is available on that selected date then I got that data in %. but if data is not received on a selected date then I want to add 0% data received. In the above Image, I've selected from date (03-09-2022) and to date (06-09-2022) but received only those dates for which data is available. In the table, I want to add 03-09-2022, and 04-09-2022 dates with 0% data. I've written this code in views.py final_data = dict() for key, values in data.items(): final_data[key]= dict() for key1, value in values.items(): total_data_count = len(value) percentage_data = (total_data_count * 100)/1440 available_data = str(percentage_data)[:5] final_data[key].setdefault(key1,available_data) Here key1 is the date and available_data is the calculated data in %. How can I get the selected date if data is not available? -
Print all values from dictionary in python [duplicate]
I have a dictionary a = {'a': 1, 'b': [2,3,[5,6]]} I need to get an output : [1,2,3,5,6] a['b'] : has a nested list contains both integer value and list -
how to get library steganography spread spectrum method DSSS
So i was searching library for encryption audio, using steganography spread spectrum. i want hide password to audio. the method spread spectrum i want to use is DSSS. i will implementation it using django (python). anyone know the library? i was searching for long but not get the library. i was tried searching but what i always found just paper, not the library. i need fast as can. i don't know how to search it again i was try with keywords: library spread spectrum audio, library spread spectrum "audio", library spread spectrum "audio" django -
Django permission_required decorator doesn't redirect back after login
My request handlers have a permission_required decorator to force the user to login. Like so: @permission_required("main.view_things", login_url="admin/login") def homepage(request): # ... This works fine. But if a login is required, the login page doesn't redirect back to the original page (here: homepage), but to some page in admin. Is there an easy fix, since this seems to be a pretty standard situation? -
Django MultiValueField and MultiWidget ChoiceField custom choices
I am trying to create a form that allows students to request courses, and I have been working on the time selection field, I would like the field to select a day of the week and a time of the day, but the hours of each course is different, so I would like to provide the available times in the form of the course instead of the field definition, this is what I tried: class ClassTimeWidgit(forms.MultiWidget): def __init__(self, time, attrs=None) -> None: widgets = [ forms.Select(choices=[ ('Monday', 'Monday'), ('Tuesday', 'Tuesday'), ('Wednesday', 'Wednesday'), ('Thursday', 'Thursday'), ('Friday', 'Friday'), ('Saturday', 'Saturday'), ('Sunday', 'Sunday'), ], attrs={'style':'width:130px'}), forms.Select(choices=time, attrs={'style':'width:130px'}) ] super(ClassTimeWidgit, self).__init__(widgets, attrs) def decompress(self, value): if value: return value.split(' ') return ['', ''] class ClassTimeField(forms.MultiValueField): widget = ClassTimeWidgit def __init__(self, time, **kwargs) -> None: f = ( forms.ChoiceField(choices=[ ('Monday', 'Monday'), ('Tuesday', 'Tuesday'), ('Wednesday', 'Wednesday'), ('Thursday', 'Thursday'), ('Friday', 'Friday'), ('Saturday', 'Saturday'), ('Sunday', 'Sunday'), ] ), forms.ChoiceField(choices=time) ) super().__init__(fields=f, require_all_fields=True, **kwargs) def compress(self, data_list): return ' '.join(data_list) class RequestCourseForm(forms.ModelForm): teacher = forms.ModelChoiceField(queryset=User.objects.filter(profile__teacher_status=True)) class_count = forms.IntegerField(widget=forms.Select(choices=[(10,10), (20,20)])) class_time = ClassTimeField(time=[(f'{i}:00', f'{i}:00') for i in range(8,21)]) class Meta: model = Request fields = ['teacher', 'class_count', 'class_time'] I am trying to make it so I can set the available … -
How to append a list inside of a dict from a JSONFeild in django
I want to use get_or_create() to search for an object. If it doesn't exist, it gets created. If it does exist, I want to update its metadata which is stored as a JSONFeild. Lets say we have this class and object: Class Customer(models.Model): first_name = models.CharField(max_length=32, blank=True, db_index=True) last_name = models.CharField(max_length=32, blank=True, db_index=True) metadata = models.JSONField(default=dict, blank=True) Customer.objects.create( first_name="John", last_name="Doe", metadata ={ "customer_created":"2022_08_06", "address_list":["123 Street"], }, ) Now we want to add another customer, but if it already exists, we just want to append the list in metadata["address_list"] obj, created = Customer.objects.get_or_create( first_name="John", last_name="Doe", defaults={ 'metadata':{ "customer_created": "2022_09_26", "adress_list": ["321 Avenue"], } ) Would obj.medata["address_list"].append(["321 Avenue"]) work or do I need to copy the list, append it, then update metadata? Which is correct? if not created: obj.medata["address_list"].append(["321 Avenue"]) or if not created: addresses = obj.medata["address_list"] addresses.append(["321 Avenue"]) obj.medata["address_list"] = addresses I'm new to django; is there a better way to do this? I am not allowed to change the Customer class but I can change how I structure the metadata dict -
Django Rest Framework - admin email has empty traceback
Getting empty stack trace from Admin Emails for 500 errors in Django Rest Framework (DRF): Exception Location: , line , in From DRF source code I can see: {% if lastframe %} <tr> <th>Exception Location:</th> <td><span class="fname">{{ lastframe.filename }}</span>, line {{ lastframe.lineno }}, in {{ lastframe.function }}</td> </tr>{% endif %} So this must have something to do with our custom exception handler where we shape the JSON response data to match a legacy system? def custom_exception_handler(exc, context): """ https://github.com/HackSoftware/Django-Styleguide#errors--exception-handling Format the error before passing to CustomJSONRenderer """ if isinstance(exc, DjangoValidationError): exc = exceptions.ValidationError(as_serializer_error(exc)) if isinstance(exc, Http404): exc = exceptions.NotFound() if isinstance(exc, PermissionDenied): exc = exceptions.PermissionDenied() # Call REST framework's default exception handler first, # to get the standard error response. response = exception_handler(exc, context) # Unknown error occured! if response is None: if exc: response.data = { "error": { "client_message": "Whoops, something went wrong", "developer_message": "".join( traceback.TracebackException.from_exception(exc).format() ), # "developer_message": str(exc), } } response.status_code = 500 return response response.data = { "error": { "client_message": "Whoops, something went awry", "developer_message": "unknown exception handling error - response is None", } } response.status_code = 500 return response errors = [] message = response.data.get("detail") if not message: for field, value in response.data.items(): errors.append(f"{field} : … -
In Python how to plot pie chart using plotly
I am trying to plot using plotly. I am using the go command. I can design bar charts, but when I am trying pie using the go command. i got error I am sharing here my code and bar graph image. I want to convert bar graph into a pie. df2 = df.groupby(pd.to_datetime(df.MeterReading_DateTime).dt.hour).agg({'ACT_IMP_TOT': 'sum'}).reset_index() print(df2) #x = df2['MeterReading_DateTime'] #y = df2['ACT_IMP_TOT'] data_plots = go.Bar(x=df2['MeterReading_DateTime'], y= df2['ACT_IMP_TOT'],marker = {'color' : '#0f4054'}) #data_plots = px.pie(values=random_x, names=names) layout = {'title': '','xaxis': {'title': 'Date and time'},'yaxis': {'title': 'Total Import(KWH)'},'plot_bgcolor':'#E8E8E8'} fig = {'data': data_plots, 'layout': layout} plot_div = offline.plot(fig, output_type='div') return plot_div -
Django REST Framework (AttributeError : Got AttributeError when attempting to get a value for field " " on serializer " ")
Got AttributeError : when attempting to get a value for field Firstname serializer NameSerializer. The serializer field might be named incorrectly and not match any attribute or key on the QuerySet instance. Original exception text was: 'QuerySet' object has no attribute Firstname. serializers.py from rest_framework import serializers from .models import Name, ForeName class NameSerializer(serializers.ModelSerializer): class Meta: model = Name fields = '__all__' class ForeNameSerializer(serializers.ModelSerializer): forenames = NameSerializer(many=True, read_only=True) class Meta: model = ForeName fields= '__all__' models.py from django.db import models import uuid # create your models here class ForeName(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) Forename = models.CharField(max_length=30) def __str__(self): return self.Forename class Name(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) Firstname = models.ForeignKey(ForeName, on_delete=models.PROTECT, related_name="forenames") views.py from rest_framework.decorators import api_view from rest_framework.response import Response from .serializers import NameSerializer from .models import Name # Create your views here. @api_view(['GET']) def names_list(request): names = Name.objects.all() myname = NameSerializer(names) return Response({"restult": { "Forename" : myname.data, } -
Can data stored in memory on a website be hacked? [closed]
I'm currently making a website in Django and I intend to eventually host it with Digital Ocean. Basically, what the website does is have a user upload a file that is hard to read, and then the website parses the content of the uploaded file and displays it in an easy to read format for the user. The file the user uploads may have some personal data in it. The way I have it set up is that all the data from the uploaded file is stored in memory. I don't upload the file's data to a database or locally on the website because I don't want any of the data, and I don't want the user's uploaded data to be seen anywhere but on the user's computer. So this means that when the user refreshes the page or goes to a different page and comes back, they have to upload their file again because the data from the user's uploaded file would have been deleted from memory when the page loads again. My question: The whole point of doing it this way is to keep the user's data safe (inaccessible) from everyone, including myself. Is this a good method … -
Django not updated inside the docker cookiecutters template
My Django project that is created based on Cookiecutters is not updated in local development environment after I changed the source code, I need to stop and start the docker again. I checked the volume and it seems ok but still no auto-update. The files and their contents are as follow: version: '3' volumes: one_sell_local_postgres_data: {} one_sell_local_postgres_data_backups: {} services: django: &django build: context: . dockerfile: ./compose/local/django/Dockerfile image: one_sell_local_django container_name: one_sell_local_django platform: linux/x86_64 depends_on: - postgres - redis volumes: - .:/app env_file: - ./.envs/.local/.django - ./.envs/.local/.postgres ports: - "8000:8000" command: /start postgres: build: context: . dockerfile: ./compose/production/postgres/Dockerfile image: one_sell_production_postgres container_name: one_sell_local_postgres volumes: - one_sell_local_postgres_data:/var/lib/postgresql/data:Z - one_sell_local_postgres_data_backups:/backups:z env_file: - ./.envs/.local/.postgres redis: image: redis:6 container_name: one_sell_local_redis The Dockerfile for Django: ARG PYTHON_VERSION=3.9-slim-bullseye # define an alias for the specfic python version used in this file. FROM python:${PYTHON_VERSION} as python # Python build stage FROM python as python-build-stage ARG BUILD_ENVIRONMENT=local # Install apt packages RUN apt-get update && apt-get install --no-install-recommends -y \ # dependencies for building Python packages build-essential \ && apt-get install gdal-bin -y \ # psycopg2 dependencies libpq-dev # Requirements are installed here to ensure they will be cached. COPY ./requirements . # Create Python Dependency and Sub-Dependency Wheels. RUN pip … -
More elegant one-liner way for urls.py to recognize path that include / as well as no / in Django
I am using Django v4. This is my urls.py from django.urls import path from .views import UserList, UserDetail urlpatterns = [ path("users", UserList.as_view()), ] http://127.0.0.1:8000/users works fine. However, http://127.0.0.1:8000/users/ with the slash at the end fails to work. To solve this problem, here's the new urls.py. from django.urls import path from .views import UserList, UserDetail urlpatterns = [ path("users", UserList.as_view()), path("users/", UserList.as_view()), ] It looks kind of repetitive and goes against DRY principle behind Django. Is there a more elegant one-liner to fix this problem? Answer need not be a one-liner as long as it doesn't look repetitive. -
django how to save data to multiple tables
I have PostgreSQL function that saves data in both items and items_transactionlog, I deleted some rows so its easier to read. INSERT INTO public.items (remarks,resolution,record_date,resolve) VALUES (f_remarks,f_resolution,now(),false); INSERT INTO public.items_transactionlog (trans_desc,trans_recorded) VALUES ('Add Clearance Item',now()); I want to use this function thru my models.py, How can I customize my models.py so whenever I save an item it also saves on transactionlog I use inspectdb and add the following models on my app class Items(models.Model): itemid = models.CharField(primary_key=True, max_length=20) remarks = models.TextField(blank=True, null=True) resolution = models.TextField(blank=True, null=True) resolve = models.BooleanField(blank=True, null=True) resolve_date = models.DateField(blank=True, null=True) resolve_by = models.CharField(max_length=8, blank=True, null=True) recorded_by = models.CharField(max_length=8, blank=True, null=True) record_date = models.DateField(blank=True, null=True) class Meta: managed = False db_table = 'items' class ItemsTransactionLog(models.Model): log_id = models.AutoField(primary_key=True) trans_desc = models.TextField(blank=True, null=True) trans_recorded = models.DateField(blank=True, null=True) class Meta: managed = False db_table = 'items_transactionlog' -
Django: to loop field while creating another instance
if i want to create another instance it doesnt pick the initial value. this is my model.py class Transaction(models.Model): student= models.ForeignKey(Student,blank=True,null=True, on_delete=models.CASCADE) schoollevy= models.ForeignKey(Schoollevy,blank=True,null=True, on_delete=models.CASCADE) inputt=models.IntegerField(blank=True,null=True) credit=models.IntegerField(blank=True,null=True) debit=models.IntegerField(blank=True,null=True) bal=models.IntegerField(blank=True,null=True) descrip=models.CharField(max_length=200, blank=True,null=True) date=models.DateField(auto_now_add=True, null=True, blank=True) def save(self): if self.schoollevy=="school fee": self.debit += self.inputt self.bal= self.credit-self.debit return super(Transaction, self).save() if i want to create a another instance it doesnt pick the first instance value -
Django TypeError: issubclass() arg 1 must be a class. Caused by from rest_framework.authtoken.views import ObtainAuthToken in views.py
I wrote the following view in Django to serialize the obtained token. However, I get error. I Could not get a similar issue on internet, most of the post were related to tests. from rest_framework import generics from rest_framework.authtoken.views import ObtainAuthToken from rest_framework.settings import api_settings from user.serializers import UserSerializer from user.serializers import ( UserSerializer, AuthTokenSerializer, ) class CreateUserView(generics.CreateAPIView): """Create a new user in the system.""" serializer_class = UserSerializer class CreateTokenView(ObtainAuthToken): """Create a new auth token for user.""" serializer_class = AuthTokenSerializer renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES After running docker-compose I get following error: eMenue_1 | File "/app/eMenue/user/urls.py", line 5, in <module> eMenue_1 | from user import views eMenue_1 | File "/app/eMenue/user/views.py", line 5, in <module> eMenue_1 | from rest_framework.authtoken.views import ObtainAuthToken eMenue_1 | File "/usr/local/lib/python3.10/site-packages/rest_framework/authtoken/views.py", line 11, in <module> eMenue_1 | class ObtainAuthToken(APIView): eMenue_1 | File "/usr/local/lib/python3.10/site-packages/rest_framework/authtoken/views.py", line 18, in ObtainAuthToken eMenue_1 | if coreapi_schema.is_enabled(): eMenue_1 | File "/usr/local/lib/python3.10/site-packages/rest_framework/schemas/coreapi.py", line 612, in is_enabled eMenue_1 | return issubclass(api_settings.DEFAULT_SCHEMA_CLASS, AutoSchema) eMenue_1 | TypeError: issubclass() arg 1 must be a class Any idea what can cause that plese? -
I have installed django-form-designer-ai as an app in my site but am unable to add fields
I have installed django-form-designer-ai as an app and it shows in my Admin page and Add form does not allow me to define my own fields. I had installed the package with PIP in my venv if that makes a difference. -
Using Ajax to change a Boolean in a Django Model using a Button
I am trying to send a post in a Django project to switch a boolean from False to True. The button is working fine but I want to click it without refreshing the page so I am trying to use Ajax but I keep getting {"status": "error"} for a bad request and not sure why. Here is the views: def change_status(request, id): if request.is_ajax() and request.method == 'POST': startsession = Workout.objects.get(id=id) startsession.active = True if request.POST.get('active') == 'true' else False startsession.save() data = {'status': 'success', 'active': startsession.active} return JsonResponse(data, status=200) else: data = {'status': 'error'} return JsonResponse(data, status=400) Here is the template: <div> {% if object.active %} <button disabled type="button">Start the workout</button> {% else %} <a href="{% url 'my_gym:bla' object.id %}"> <button id="customSwitches" onclick="start();" type="button">Start the workout</button> </a> {% endif %} </div> Here is the ajax script <script> $(document).ready(function() $("#customSwitches").on('click', function () { $.ajax({ url: "{% url 'my_gym:bla' object.id %}", data: { csrfmiddlewaretoken: "{{ csrf_token }}", active: this.disabled }, type: "POST", dataType: 'json', }); .done(function(data) { console.log(data); }) .always(function() { console.log('[Done]'); }) }) }); </script> -
Unable to access Bitnami Django web app using run server of mod_wsgi
I am not sure what I am missing here to get Django running on Google Compute Engine and access it publicly. I am starting with Django packaged by Bitnami since it seems like it would be easy... I have been following this Getting Started Guide to get a running instance of Django running on Google Compute Engine. Django Packaged By Bitnami For Google Cloud Platform It successfully deploys and I see the Bitnami page. I am unable to get pass this point even with the simple example of hello world in their guide. I have used both ./manage.py runserver and serving through Apache Web server with the module mod_wsgi for my project. Test Your Django Project The Django project can be started by using this command from the /opt/bitnami/projects/PROJECT directory, and it will run on port 8000: cd /opt/bitnami/projects/PROJECT python manage.py runserver To access the application, browse to http://SERVER-IP:8000/. To end the application, terminate the running Django process. I have completed a Django Project that I can test and run locally. Getting something basic on Google Compute Engine, is another story. -
Error in django template if statements about end block
I'm getting the following error for the django template below. Line 63 is the {% else %} statement on the line after "Age: {{bottom_age | safe}} to {{top_age | safe}} ". Thoughts on what is wrong? To me, this just looks like subsequent if statements. When I removed the below block, it worked fine but I don't know what is wrong with the below block. I tried putting the two variables on different lines (bottom_age and top_age), but that didn't help. {$ if age %} <p>Age: {{bottom_age | safe}} to {{top_age | safe}} </p> {% else %} <p>No age supplied, so all ages used</p> {% endif %} django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 63: 'else', expected 'endblock'. Did you forget to register or load this tag? {% if score %} <p>You are in the <b>{{percentile | safe}}</b> percentile compared to other people who self identify as:</p> {% endif %} {$ if age %} <p>Age: {{bottom_age | safe}} to {{top_age | safe}} </p> {% else %} <p>No age supplied, so all ages used</p> {% endif %} {% if gender %} <p>Gender: {{gender | safe}}</p> {% else %} <p>No gender supplied, so all genders used</p> {% endif %} {% if ethnicity %} … -
Celery task is not started
I have 2 celery tasks with two workers (worker for each task) docker-compose.yml -- https://pastebin.com/Ln9WgxTd Problem - don't see logs and results of the periodic_check_urls I am calling periodic_check_urls via POST request, but don't see result of the function I just see nginx_1_ef8ec258f1c4 | 10.37.15.246 - - [05/Sep/2022:23:59:02 +0000] "POST /check_all_urls/ HTTP/1.1" 200 34 "-" "PostmanRuntime/7.26.8" "-" settings.py CELERY_BROKER_URL = os.environ.get("CELERY_BROKER", "redis://redis:6379/0") CELERY_RESULT_BACKEND = os.environ.get("CELERY_BROKER", "redis://redis:6379/0") CELERY_IMPORTS = ("core_app.celery",) CELERY_ROUTES = { 'parser_app.views.periodic_exctract_urls': {'queue': 'priority_queue'}, 'parser_app.views.periodic_check_all_urls': {'queue': 'normal_queue'}, } CELERY_BEAT_SCHEDULE = { 'fetch_yandex_urls': { 'task': 'parser_app.views.periodic_exctract_urls', 'schedule': crontab(minute='*/15'), 'options': {'queue': 'priority_queue'} }, } views.py @shared_task(name="parser_app.views.periodic_check_urls") def periodic_check_urls(parsing_result_ids: List[int]): ... print("Log", flush=True) # don't see this log @api_view(['POST']) def periodic_check_all_urls(request): ... periodic_check_urls.delay(parsing_results_ids) # parsing_results_ids is a list of ints -
datetime mismatch between plain Python console and a Django shell
I can open a plain Python console and run: >>> from datetime import datetime >>> datetime.now().strftime('%H:%M') '01:21' When I do the same in ./manage.py shell, however, I get different results: >>> from datetime import datetime >>> datetime.now().strftime('%H:%M') '23:21' Why is that? I though it might be related to the timezone, so I checked date time.now().tzinfo, which, however, is None in both cases. I also tried setting USE_TZ = False in settings.py but it doesn't make a difference (it was on True by default). -
How can I do so that they cannot create a post with more than 300 digits?
Picture of the post What I want to do is that when you have more than 300 digits you can't touch the "Bloob" button or something like that. What is on the left is a counter with javascript. The models is this class Post(models.Model): timestamp = models.DateTimeField(default=timezone.now) content = models.TextField(max_length=300) user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='posts') This is the PostForm class PostForm(forms.ModelForm): content = forms.CharField(widget=forms.Textarea(attrs={'class':'form-control w-100', 'id':'contentsBox', 'rows':'3', 'placeholder':'¿Qué está pasando?'})) -
Limit queryset to foreignkey in django rest framework
i searched a lot about a solution for this problem and i tried many solutions but no one solve it some of solutions i tried: limit choices to foreignkey and using CurrentUserDefault the problem is i'm trying to limit the provider choices depending on the current user as each user has his own providers i tried this code but gives me TypeError: Field 'id' expected a number but got CurrentUserDefault(), class RideSerializer(serializers.ModelSerializer): invoice = InvoiceSerializer(required=False) duration = serializers.ReadOnlyField() riding_duration = serializers.ReadOnlyField() heading_duration = serializers.ReadOnlyField() earning_per_km = serializers.ReadOnlyField() earning_per_minute = serializers.ReadOnlyField() provider = serializers.PrimaryKeyRelatedField( queryset=User.objects.select_related( 'driver_profile__team', 'company_profile__team').filter( Q(driver_profile__team__user=serializers.CurrentUserDefault()) | Q(Company_profile__team__user=serializers.CurrentUserDefault())), default=serializers.CurrentUserDefault()) class Meta: model = Ride exclude = ['shift', ] read_only_fields = ['id', 'start_time', ] -
how raise ImproperlyConfigured("settings.DATABASES is improperly configured. when deploying on railway
hey guys so i'm follwing this guide https://dev.to/mr_destructive/django-postgresql-deployment-on-railway-app-d54 on how to deploy my django project on railway i have everything set locally, it working but once i deploy, the app crashes returning this err File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 55, in has_table with self.connection.cursor() as cursor: File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/db/backends/base/base.py", line 259, in cursor return self._cursor() File "/home/olaneat/Desktop/files/project/django/job/lib/python3.8/site-packages/django/db/backends/dummy/base.py", line 20, in complain raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. can someone pls help out -
Imports works in IDE and Idle but not in dokcer-compose and manage.py test
I have a strange problem with my Django project. The imports work fine in IDE and I can import when I import it in python CLI. However, when I run docker compose, I get error like: File "/app/eMenue/eMenueApp/admin.py", line 3, in <module> eMenue_1 | from eMenue.eMenueApp.models import models eMenue_1 | ModuleNotFoundError: No module named 'eMenue.eMenueApp' When I run python manage.py test I get similar output: ImportError: Failed to import test module: eMenue.eMenueApp Traceback (most recent call last): File "/usr/lib/python3.10/unittest/loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "/usr/lib/python3.10/unittest/loader.py", line 377, in _get_module_from_name __import__(name) ModuleNotFoundError: No module named 'eMenue.eMenueApp' The structure of my code looks like this: ├── eMenue │ ├── asgi.py │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── settings.cpython-310.pyc │ │ └── urls.cpython-310.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── eMenueApp │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── models.py │ ├── __pycache__ │ │ ├── admin.cpython-310.pyc │ │ ├── apps.cpython-310.pyc │ │ ├── __init__.cpython-310.pyc │ │ └── models.cpython-310.pyc │ ├── tests │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ └── test_models.cpython-310-pytest-7.1.3.pyc │ │ └── test_models.py │ └── views.py ├── __init__.py ├── manage.py └── __pycache__ …