Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Using When and Less then in Django DRF?
I am trying to check where a number is GreaterThan another number in the request.data and set the value if condition is true. ExampleModel.objects.filter( tic=request.data['tic']).update(last_high=When(GreaterThan(F('last_high'), request.data['high']), then=0)) Error: django.db.utils.OperationalError: near "WHEN": syntax error I am not sure how to proceed from here, trying to understand the documentation but I can't seem to find why it won't work. Documentation -
Django annotate multiple "Sum(Case(When()))" returns incorrect result
There is no problem with stock balls, but when you add currency, the stock totals are incorrect. My Models class Product(models.Model): stock_code = models.CharField(max_length=200, unique=True) product_name = models.CharField(max_length=255) class Price(models.Model): product = models.ForeignKey( 'product.Product', models.CASCADE, related_name='product_price_product' ) price = models.FloatField() class Transaction(models.Model): product = models.ForeignKey( 'product.Product', models.CASCADE, related_name='product_transaction' ) warehouse = models.ForeignKey( 'product.Warehouse', models.CASCADE, related_name='product_warehouse' ) type = models.BooleanField(_('Hareket Tipi'), choices=sorted([ (True, _('Stock In')), (False, _('Stock Out')) ])) quantity = models.FloatField() ModelViewSet class ProductView(ModelViewSet): queryset = Product.objects.prefetch_related( 'product_image_product', 'product_price_product', ).all() serializer_class = ProductSeriliazer def get_custom_queryset(self): warehouse = self.request.query_params.get('warehouse', 0) sale_price = self.request.query_params.get('sale_price', 0) purchase_price = self.request.query_params.get('purchase_price', 0) is_tax = self.request.query_params.get('is_tax', None) currency = self.request.query_params.get('currency', None) # Rate Calc if currency: currencies = Currency.objects.all().values('currency_code', 'currency_value') sale_price_when = [] purchase_price_when = [] for i in currencies: to_currency_val = list(filter(lambda x: x['currency_code'] == i['currency_code'], currencies))[0].get('currency_value') money_val = list(filter(lambda x: x['currency_code'] == currency, currencies))[0].get('currency_value') if is_tax == 'true': sale_price_when.append( When( product_price_product__definition_id=int(sale_price), product_price_product__definition__type=True, product_price_product__is_tax=True, product_price_product__currency=i['currency_code'], then=exchange_rate_calculator('product_price_product__price', money_val, to_currency_val) ) ) sale_price_when.append( When( product_price_product__definition_id=int(sale_price), product_price_product__definition__type=True, product_price_product__is_tax=False, product_price_product__currency=i['currency_code'], then=((exchange_rate_calculator('product_price_product__price', money_val, to_currency_val) * F('product_price_product__tax')) / 100) + exchange_rate_calculator('product_price_product__price', money_val, to_currency_val) ) ) purchase_price_when.append( When( product_price_product__definition_id=int(purchase_price), product_price_product__definition__type=False, product_price_product__is_tax=True, product_price_product__currency=i['currency_code'], then=exchange_rate_calculator('product_price_product__price', money_val, to_currency_val) ) ) purchase_price_when.append( When( product_price_product__definition_id=int(purchase_price), product_price_product__definition__type=False, product_price_product__is_tax=False, product_price_product__currency=i['currency_code'], then=((exchange_rate_calculator('product_price_product__price', money_val, to_currency_val) * F('product_price_product__tax')) / 100) + exchange_rate_calculator('product_price_product__price', … -
hello, I can’t solve this problem, I want to run this command, there is such an error?
python manage.py loaddata --settings definme.settings.dev django-dump.json wagtail.models.i18n.Locale.DoesNotExist: Problem installing fixture Locale matching query does not exist. -
Django - How to make multiple choice field in Admin Field?
I have the following Django model: class Level(models.Model): topics = # need to put option choice field here shortDescription = models.CharField(max_length = 50) I want my admins to be able to go into my application and for the topics, I want them to be select multiple values from a list in a user friendly way (dropdown) How can I make is so that admins using my app can go in and choose from a list of topics? They need to be able to choose multiple but they can select 1 if they choose to. -
Python Django update variable in template while function runs in background
I have this simple template which has a button: <a class="button" href="{% url 'function' %}"> <button> Settings </button> </a> And views.py in which I have function definition. def function(request): context = {} object = Runner() object.prepate_sth() context['tasks'] = runner.tasks.remaining try: thread = threading.Thread(target=runner.run_sth, args=()) thread.start() except Exception: raise Exception return render(request, 'home.html', context) I am creating separate thread in order to not to block the function execution and run some other function in the background. That task in the background changes the quantity of elements in runner.tasks.remaining list variable. I would want to have that variable shown in the template and being updated constantly when its value changes. How can I achieve that? -
How to use django-filters to filter a field by a list of inputs
I have a list of objects that have a country code associated with them, I would like to write a FilterSet class that can receive a list of codes ie. ['US', 'CA'] and will return a list of the objects that have the country code column set to either of those values. It doesn't seem like filtersets may be able to do this for me, but its seems like a relatively common requirement? I was thinking maybe it's something like __in for the filterset field. Any help is much appreciated -
Is there a way to sync a user from the code than running the ldap_sync_users <username> in django-python3-ldap?
To sync a user, I need to run ./manage.py ldap_sync_users . I wondered if the same can be achieved in Django without running manage.py. I was hoping to achieve this from the webpage, search for a user and do the sync. -
(staticfiles.W004) The directory in the STATICFILES_DIRS setting does not exist error in django
so i am working on a project where i want to use some css files. but i couldn't link them with my html page in django. i've used everything i knew but still static is not loading my error is: (staticfiles.W004) The directory 'C:\Users\ASUS\PycharmProjects\e-payment\epayment\static' in the STATICFILES_DIRS setting does not exist. my code snippets are given below: my setting is: settings.py Django settings for epayment project. Generated by 'django-admin startproject' using Django 4.1.1. For more information on this file, see https://docs.djangoproject.com/en/4.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.1/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-+)&^ze^f+g#k28j#(1&r8y@u)g4=9!g7c4ef-i07!5@yhq2dd3' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'epayapp', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'epayment.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', … -
Nextjs Error occurred prerendering page Error: connect ECONNREFUSED 127.0.0.1:8000 (Believe me this one is complicated)
Maybe this question was asked a hundred times, but I have an awkward one. All my pages load successfully with npm run dev. Whenever executing "npm run build" there are some errors. Do you guys have any idea? Console output info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules info - Linting and checking validity of types info - Creating an optimized production build info - Compiled successfully info - Collecting page data [ ] info - Generating static pages (0/333) Error occurred prerendering page "/r/sustainable-responsible-tourism". Read more: https://nextjs.org/docs/messages/prerender-error Error: connect ECONNREFUSED 127.0.0.1:8000 at Function.AxiosError.from (file:///C:/Users/aybas/Desktop/tto-frontend/node_modules/axios/lib/core/AxiosError.js:89:14) at RedirectableRequest.handleRequestError (file:///C:/Users/aybas/Desktop/tto-frontend/node_modules/axios/lib/adapters/http.js:516:25) at RedirectableRequest.emit (node:events:513:28) at ClientRequest.eventHandlers.<computed> (C:\Users\aybas\Desktop\tto-frontend\node_modules\follow-redirects\index.js:14:24) at ClientRequest.emit (node:events:513:28) at Socket.socketErrorListener (node:_http_client:481:9) at Socket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) [ ===] info - Generating static pages (2/333) Error occurred prerendering page "/how-to-roam/family-vacations". Read more: https://nextjs.org/docs/messages/prerender-error Error: connect ECONNREFUSED 127.0.0.1:8000 at Function.AxiosError.from (file:///C:/Users/aybas/Desktop/tto-frontend/node_modules/axios/lib/core/AxiosError.js:89:14) at RedirectableRequest.handleRequestError (file:///C:/Users/aybas/Desktop/tto-frontend/node_modules/axios/lib/adapters/http.js:516:25) at RedirectableRequest.emit (node:events:513:28) at ClientRequest.eventHandlers.<computed> (C:\Users\aybas\Desktop\tto-frontend\node_modules\follow-redirects\index.js:14:24) at ClientRequest.emit (node:events:513:28) at Socket.socketErrorListener (node:_http_client:481:9) at Socket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) info - Generating static pages (333/333) > Build error occurred Error: Export encountered errors on following paths: /how-to-roam/[category]: /how-to-roam/family-vacations /r/[slug]: /r/sustainable-responsible-tourism at C:\Users\aybas\Desktop\tto-frontend\node_modules\next\dist\export\index.js:404:19 at … -
How to automatically update a field when creating another record in different models?
I have two models that look like this: class TeamMember(models.Model): member = models.ForeignKey(User, on_delete=models.SET(get_default_team_member), verbose_name='Member Name', related_name="team_members") team = models.ManyToManyField('Team', verbose_name='Team Name', related_name="team_members", blank=False, default=team_id) shift = models.ForeignKey(Shift, on_delete=models.PROTECT) ... class Team(models.Model): name = models.CharField(max_length=50) members = models.ManyToManyField(TeamMember, blank=True, related_name="members") ` The users use the admin panel to add new members. When adding a new member, I want to automatically add the member to the associated team. For example, when adding John, it is required to assign a team to him(blank=False), and the team is from what we have in the Team model. Then how do I update the members in the Team model to add John to one of the teams accordingly? Please help, thanks! -
slug related Feilds are not parsed in json parsing
I am trying to import with codenames it takes as a string while doing json parsing with slug feilds class ImportFinanceSaleSerializerField(serializers.JSONField): def to_representation(self, obj): user_serializer = ImportFinanceSaleSerializer(obj, many=False, ) return user_serializer.data def to_internal_value(self, data): return data' class ImportFinanceSaleSerializer(serializers.ModelSerializer): interestpercentage = serializers.SlugRelatedField( required=False, allow_null = True, slug_field="code", queryset=PercentageInterest.objects.filter(status=1,)) guarantor = serializers.SlugRelatedField( required=False, allow_null = True, slug_field='code', queryset=Person.objects.filter(status=1,)) emi_date = serializers.IntegerField(required=False, min_value=1, max_value=30) -
Doing polymorphic model, what's the best approach?
I'm trying to upscale a project that originally was used by an area to assign reports to their respective departments. Those reports I want them to be tasks, to broaden the spectrum of use to all of the organization. Originally, I was using separate models for reports, updates, report files, update files. (Those tables, had almost the same fields) Now, I'm trying to have a polymorphic model, as shown below: #### TASK TYPE (TASK, UPDATE) class TipoTarea(models.Model): nombre = models.CharField(max_length=50, unique=True) def __str__(self): return self.nombre ###### TASK CATEGORY (TOPIC AND THE AREA WHO IS BEING DIRECTED TO) class CategoriaTarea(models.Model): nombre = models.CharField(max_length=50, unique=True) area = models.ForeignKey(Area, on_delete=models.CASCADE) tiempo_atencion = models.IntegerField(default=2) def __str__(self): return self.nombre ##### TASK STATE (CREATED, IN PROCESS, COMPLETED, REASIGNED) ##### REASIGNED STATE, CREATES A NEW TASK WITH A DIFFERENT CATEGORY class EstadoTarea(models.Model): nombre = models.CharField(max_length=50) def __str__(self): return self.nombre ###### TASK ###### TASK PARENT WOULD BE USED FOR UPDATES, BUT HOW CAN REASIGNMENTS BE CLASSIFIED class Tarea(models.Model): tipo = models.ForeignKey(TipoTarea, on_delete=models.CASCADE, related_name = 'tarea') categoria = models.ForeignKey(CategoriaTarea, on_delete=models.CASCADE, related_name = 'tarea') descripcion = models.CharField(max_length=500) fecha = models.DateField(default=datetime.date.today) estado = models.ForeignKey(EstadoTarea, default= 1, on_delete=models.CASCADE) creado_por = models.ForeignKey(User, on_delete=models.CASCADE, related_name='creador') creado = models.DateTimeField(auto_now_add=True) parent = models.ForeignKey('self', on_delete=models.CASCADE, related_name="actualizaciones", null=True, … -
how to run tasks in parallel with django async
i'm using daphne as a asgi server, with django. turning my view from sync to async was relatively simple, since i could use @sync_to_async at the ORM part. the problem is, some service of mine is like this: async def service_of_mine(p1, p2, p3): r1 = await foo1(p1) r2 = await foo2(p2) r3 = await foo3(p3) return r1, r2, r3 i wanted to run all three calls in parallel, using return await asyncio.gather(foo1(p1), foo2(p2), foo3(p3)) but my api hangs with Application instance <Task pending name='Task-1' coro=<ASGIStaticFilesHandler.__call__() running at /mypath/python3.10/site-packages/django/contrib/staticfiles/handlers.py:101> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /home/rado/.pyenv/versions/3.10.6/lib/python3.10/asyncio/futures.py:385, Task.task_wakeup()]>> for connection <WebRequest at 0x7f8274b98340 method=GET uri=/myApiPath clientproto=HTTP/1.1> took too long to shut down and was killed. how can i achieve this? -
How to fetch a boolean value from models for a specific user in Django?
I have an extended user model and I want to check it to see if the logged-in user has completed_application as per the model: Models.py: class Completed(models.Model): class Meta: verbose_name_plural = 'Completed Application' user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) completed_application = models.BooleanField(default=False) def __str__(self): return f'{self.completed_application}' Views.py: @login_required def dashboard(request): if Completed.objects.get(completed_application = True): completed = True else: completed = False return render(request, 'dashboard.html', {'section': 'dashboard', 'completed' : completed}) HTML: {% if completed %} <!-- You already completed an application! --> <h1> Already completed </h1> {% else %} <!-- Show the application form --> <h1> Render model form here </h1> {% endif %} The code above is not working for me as it returns True every time. I read quite a few posts on here but they don't seem to be user specific such as: How to show data from django models whose boolean field is true? -
How do I make sure a model field is and incremental number for my model?
I have the following model in django: class Page(models.Model): page_number = models.IntegerField() ... and I would like to make sure that this page number keeps being a sequence of integers without gaps, even if I delete some pages in the middle of the existing pages in the data base. For example, I have pages 1, 2 and 3, delete page 2, and ensure page 3 becomes page 2. At the moment, I am not updating the page_number, but rather reconstructing an increasing sequence without gaps in my front end by: querying the pages sorting them according to page_number assigning a new page_order which is incremental and without gaps But this does not seem to the be best way to go... -
MultipleObjectsReturned: get() returned more than one items -- it returned 3
I am getting the following error in my traceback, I am currently running tests for my new website and when I try to create more than one blog post I get returned a MultipleObjectsReturned error, how would I fix this? I am guessing the issue lies with get_object_or_404 as other questions on Stack Overflow have suggested that I use primary keys but I don't want just one object to filter, I need to show all the objects in my Post model traceback: https://dpaste.com/6J3C7MLSU views.py ```python3 class PostDetail(LoginRequiredMixin, DetailView): model = Post form_class = CommentForm template_name = "cubs/post_detail.html" def get_form(self): form = self.form_class(instance=self.object) return form def post(self, request, slug): new_comment = None post = get_object_or_404(Post) form = CommentForm(request.POST) if form.is_valid(): # Create new_comment object but don't save to the database yet new_comment = form.save(commit=False) # Assign the current post to the comment new_comment.post = post # Save the comment to the database new_comment.save() messages.warning(request, "Your comment is awaiting moderation, once moderated it will be published") return redirect('cubs_blog_post_detail', slug=slug) else: return render(request, self.template_name, {'form': form}) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) post = get_object_or_404(Post) comments = post.cubs_blog_comments.filter(active=True).order_by('-date_posted') articles = Article.objects.filter(status=1).order_by('-date_posted')[:2] post_likes = get_object_or_404(Post, slug=self.kwargs['slug']) total_likes = post_likes.total_likes() if post_likes.likes.filter(id=self.request.user.id).exists(): liked = True … -
django query to count boolean values using annotate and values
So, what I am trying to do is count how many absents, tardy, and left early's an employee has. What I am using right now is results = Attendance.objects.values('emp_name__username').annotate(abs_count=Count('absent'),tardy_count=Count('tardy'), early_count=Count('left_early')) What this query is doing here is for every field i have specified to count, it's just giving me the count of every time an emp_name object has been made. -
How can I return a hex value of a dominant color from an image?
I'm making a backend django photo viewing app, and I'm tasked with extracting the hex value of the most dominant color from an image, and push it into a local database. I can't wrap my head around it, and I've been stuck at this for a whole day, looked everywhere and just couldn't find a proper solution. Anyone mind helping? -
systemctl enable gunicorn fails with error "/etc/systemd/system/gunicorn.service:8: Missing '='."
I am deploying Django application working on web server using gunicorn locally on WSL. I need to enable needed systemd files. When I run command systemctl enable gunicorn I get error "/etc/systemd/system/gunicorn.service:8: Missing '='. Failed to enable unit, file gunicorn.service: Invalid argument. gunicorn.service looking like that: [Service] User=root Group=www-data WorkingDirectory=<base_app_path> Environment="PATH=<base_app_path>/env/bin" EnvironmentFile=<base_app_path>/.env ExecStart=<base_app_path>/env/bin/gunicorn \ --workers 4 \ --bind 0.0.0.0:8080 \ meeting.wsgi:application RestartSec=10 Restart=always [Install] WantedBy=multi-user.target What can be the problem here? -
Get sum of nested JSON
I have this JSON data where "logs" is called as another serializer. { "id": 1, "logs": [ { "work_hours": 7, "user": "admin" }, { "work_hours": 8, "user": "admin" }, { "work_hours": 6, "user": "admin" }, { "work_hours": 4, "user": "admin" }, { "work_hours": 5, "user": "admin" } ] } Is it possible to get the total work_hours from logs? Tried the annotate(Sum) but I can only get the Sum of logs.id as default Here is my serializer.py class UserLogsSerializer(serializers.ModelSerializer): user = serializers.StringRelatedField() class Meta: model=UserLogs fields=['work_hours','user'] class UserSerializer(serializers.ModelSerializer): logs = UserLogsSerializer(read_only=True,many=True) class Meta: model=User fields='__all__' -
What is the simplest way to store a list of numbers in Django model without using third party databases
I want to store a list of numbers in Django model without using third party databases like MySQL, PostgreSQL etc. I want a simple approach. I don't think that there is any built-in field like PositiveSmallIntegerField, CharField etc but please do correct me if I am wrong. Is there a way I can use the built-in fields in order to achieve the result or is there a different approach? Please note that I need to add / remove / extract those numbers also. Can someone help me with it? -
Returning two arrays from a python script in Django and utilizing in Ajax simultaneously
I have a python script running in views.py within Django which returns two very large arrays, x and y. It currently is able to run off a button press within my index.html. def python_file(request): final() return HttpResponse("ran") The ajax code I have running to do the button press. <script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script> function gotoPython(){ $.ajax({ url: "/python_file", context: document.body }).done(function() { alert('finished python script'); }); } </script> It's also attached to the URLS.py. I know there's no array being returned right now, because I am unsure how to run the script, get the data simultaneously, then add it to the page without refreshing the page. So, I am asking what would be the best practice to do what I described. Any help would be appreciated. -
Django dump data got module not found error from Allauth and other package
After run python manage.py dumpdata > data.json I get this ModuleNotFoundError: No module named 'allauth' and if i comment the allauth in the installed apps i still get another error on another package that might have a data -
Django - mix two annotated values into one with a Case/When make the performance getting slow on many elements
In get_queryset function inside a viewset I buid a queryset that needs to list a big amount of "Course" but with annotating some counts of a children model "CoursePerson". It could have like 10000 "Course" objects with in total ~5 millions of "CoursePerson" objects. I would like to annotate "interact_count" by taking another annotated value depending of the Course type. If I remove then "interact_count" annotation django + postgresql taking ~20-50ms to answer. But when I put back that annotation, it takes like 600-800ms. I am pretty sure the Case/When is the cause of this latency. But I don't know how to do other way cause I need only one count. (And not 2) I don't wanna do that with python because I would lose the ordering or pagination. This part is the problem: How can I do the same but more performantly ? interact_count=Case( When( Q(type=models.Course.TypeChoices.PHISHING) | Q(type=models.Course.TypeChoices.SMS), then=course_person_open_subquery, ), default=course_person_extra_subquery, ) full queryset: course_person_open_subquery = Subquery( CoursePerson.objects.filter( course_id=OuterRef('uid'), status__gte=models.CoursePerson.StatusChoices.OPEN, is_in_analytics=True ) .annotate(count=Func(F('uid'), function="Count")) .values('count'), output_field=IntegerField() ) course_person_extra_subquery = Subquery( CoursePerson.objects.filter( course_id=OuterRef('uid'), status__gt=models.CoursePerson.StatusChoices.OPEN, is_in_analytics=True ) .annotate(count=Func(F('uid'), function="Count")) .values('count'), output_field=IntegerField() ) return models.Course.objects.annotate( account_count=Count("accounts", distinct=True), groups_count=Count("groups", distinct=True), domain_name=F("domain__name"), interact_count=Case( When( Q(type=models.Course.TypeChoices.PHISHING) | Q(type=models.Course.TypeChoices.SMS), then=course_person_open_subquery, ), default=course_person_extra_subquery, ), ).all() -
django.core.exceptions.AppRegistryNotReady: When I run docker
I have a chat application so I need to use both gunicorn and uvicorn in order to have websockets working. When I build the image only for the wsgi with gunicorn it's working and when I add the uvicorn for handling asgi I run into this error asgi.py from django.core.asgi import get_asgi_application from channels.routing import ProtocolTypeRouter, URLRouter from chat import urls import os import django os.environ.setdefault("DJANGO_CONFIGURATION", "Local") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "friendly_enigma.settings") django.setup() application = get_asgi_application() application = ProtocolTypeRouter( { "http": application, "websocket": URLRouter(websocket_urls.websocket_urlpatterns) } ) dockerfile command CMD gunicorn friendly_enigma.wsgi:application --bind 0.0.0.0:8000 & gunicorn friendly_enigma.routing:application -k uvicorn.workers.UvicornWorker --bind=0.0.0.0:8001 logs [2022-10-20 14:10:31 +0000] [7] [INFO] Starting gunicorn 20.1.0 [2022-10-20 14:10:31 +0000] [7] [INFO] Listening at: http://0.0.0.0:8000 (7) [2022-10-20 14:10:31 +0000] [7] [INFO] Using worker: sync [2022-10-20 14:10:31 +0000] [10] [INFO] Booting worker with pid: 10 [2022-10-20 14:10:31 +0000] [8] [INFO] Starting gunicorn 20.1.0 [2022-10-20 14:10:31 +0000] [8] [INFO] Listening at: http://0.0.0.0:8001 (8) [2022-10-20 14:10:31 +0000] [8] [INFO] Using worker: uvicorn.workers.UvicornWorker [2022-10-20 14:10:31 +0000] [12] [INFO] Booting worker with pid: 12 [2022-10-20 14:10:32 +0000] [12] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker worker.init_process() File "/usr/local/lib/python3.8/dist-packages/uvicorn/workers.py", line 66, in init_process super(UvicornWorker, self).init_process() File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/base.py", line 134, …