Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to implement update mechanism in my django/django rest framework project
I’m trying to do an app which is able to get data from other websites and get updated itself without handling from the user. For instance: when it is 2pm my script is launched in my app, it gets data, then my database is updated by using my model and serializers/forms. Do you have an idea that is it possible to do it on a django project? Thanks for all! -
Silk UI not loading: ERROR CODE 103 - Enable JavaScript to run this app
I'm experiencing an issue while trying to access the Silk statistics for my Django app. When I request the corresponding URL (http://localhost:8000/silk/), I'm getting the following response: ERROR CODE 103: You need to enable JavaScript to run this app. Interestingly, instead of showing the Silk UI, it displays the UI of my React app, which makes API calls to the Django app. In my Django Settings.py file, I have the Silk middleware configured as follows: MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', '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', 'silk.middleware.SilkyMiddleware', ] Furthermore, I can confirm that Silk operations are being logged in the console, indicating that data is being successfully recorded in the database. I think that this tool would be very useful for me to be able to do an analysis of the performance of my Django app, but until now I have not been able to make it work completely. Any help, thanks in advance! -
on_connect() missing 3 required positional arguments: 'userdata', 'flags', and 'rc'
I am writing a django application which should act as MQTT publisher and as a subscriber. but when i run it , it give me: TypeError at / on_connect() missing 3 required positional arguments: 'userdata', 'flags', and 'rc' this is my code : from django.shortcuts import render from .models import Video from .form import VideoForm import paho.mqtt.client as mqtt from django.http import HttpResponse import time def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) client.subscribe("a") #global result def on_message(client, userdata, msg): global result result = msg.payload.decode("") print("Received message:", result) client = mqtt.Client("p1") client.connect("127.0.0.1", 1883) client.publish("test", 'C:/Users/HP/Desktop/NV_4.mp4') client.on_connect = on_connect client.on_message = on_message -
Vue.Js Routing issues, when visiting product and Visit other links after that, links stack one on top of another
I am building an E-Commerce with Vue.js and Django Rest Framework. Everything is working fine, the only problem is that when I press and visit a product page, then open menu and press any other link it sends me to a blank page and then stacks slug on top of another slug or like link on top of another link which breaks the view. Lets imagine we visit "lechuga crespa" and then press in menu on "products" it will send you to a blank view and the link would be like that: :8000/lechuga-crespa-verde/productos when it should replace /lechuga-crespa/ by /productos/. How could I solve that? Thank you. Here is my router.js: import { createRouter, createWebHistory } from 'vue-router' import store from '../store' import axios from 'axios' import Home from '../views/Home.vue' import Products from '../views/shop/Products.vue' import Product from '../views/shop/Product.vue' import About from '../views/About.vue' import Corporate from '../views/Corporate.vue' import Contact from '../views/Contact.vue' import ContactThankYou from '../views/ContactThankYou.vue' import Login from '../views/auth/Login.vue' import SignUp from '../views/auth/SignUp.vue' import ResetPassword from '../views/auth/ResetPassword.vue' import ResetPasswordToken from '../views/auth/ResetPasswordToken.vue' import ResetPasswordMessage from '../views/auth/ResetPasswordMessage.vue' import ResetSetNewPassword from '../views/auth/ResetSetNewPassword.vue' import Account from '../views/auth/Account.vue' import ComplaintsBook from '../views/ComplaintsBook.vue' import PrivacyPolicy from '../views/PrivacyPolicy.vue' import Favorites from '../views/Favorites.vue' import Cart from '../views/shop/Cart.vue' import Checkout … -
Django validation (Django Rest Framework) doesn't work with parallel queries
In my DRF Film serializer I have general validate() method: def validate(self, data): request = self.context.get('request') existing_film = Film.objects.filter(title__iexact=data.get('title'), release_date=data.get('release_date'), director__iexact=data.get('director')) if request.method == 'POST': if existing_film: validation_error_message = 'Film with such parameters (title, director, release date) already exists' logger.warning(f'Validation error - {validation_error_message}') raise serializers.ValidationError(validation_error_message) return data As you can see, it makes request to the database and compares posted film with the existing one. Everything works well when queries are sequential. But if I try to make parallel queries (for example, from two terminal windows) validate() doesn't work properly and both identical films are being pushed to the database, which is definitely not what I expect. Should I use some sort of transactions or something? Thank you! -
React/Django/Redux 400 Bad Request when registering a new user
I've been struggling with this error for a while now. Pretty new to python, Django and Redux so trying to solve this has been a struggle. I've been trying to register a new user through my react frontend but the console gives me a 400 (Bad Request). I'm able to make new users through Django admin, but can't through my frontend register page. I have no idea if my frontend or backend is the issue. Any help would be appreciated RegisterPage.js import React, { useEffect, useState } from "react"; import { Link, useLocation, useNavigate } from "react-router-dom"; import { Form, Button, Row, Col } from "react-bootstrap"; import { useDispatch, useSelector } from "react-redux"; import Loading from "../components/Loading"; import ErrorMessage from "../components/Error"; import FormContainer from "../components/FormContainer"; import { login, register } from "../actions/userActions"; import axios from "axios"; function RegisterPage() { const [first_name, setFirst_name] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [errorMessage, setErrorMessage] = useState(""); const location = useLocation(); const navigate = useNavigate(); const dispatch = useDispatch(); const redirect = location.state ? Number(location.state) : "/"; const userRegister = useSelector((state) => state.userRegister); const { error, loading, userInfo } = userRegister; const submitHandler … -
Django how to get the values with an id as key and shows it in template
I have got a DICT like this: {4: {'26.00': "{'tac': {'4.99': '1.30'}}"}, 2: {'32.00': "{'tac': {'4.99': '1.60'}}"}} Where 4 and 2 are the respective user id. I send the DICT to template and I also have access to the user id in a for loop. Is it possible to get only the data to the respsctive user in the template: I would like to learn a workout to get the dict data for each user by user.id. Is it possible to do something like this? Remembering that the DICT isnt inside any model. So it is a static data generated before the tamplate renders. user_name: John user_email: j@j.com user_id = 2 amount = 32.00 tac = 4.99 : 1.60 user_name: Charles user_email: c@c.com user_id = 4 amount = 26.00 tac = 4.99 : 1.3 Thank you very much for any ideas os directions to solve it. -
Interval callback is interrupting download callback in Dash. Is there a way to stop this?
I have an app built using django-plotly-dash in a container. The app uses an interval callback to periodically check the container for new files that are added from a backend process and update the frontend with said files. There is also a callback to download the file from the container. I've noticed when downloading a file, the interval callback is hammering away and interrupting the download callback. When the interval callback is disabled, the download works fine. I've disabled the interval callback and replaced it with a manual refresh button for the time being. It's currently satisfying the client's needs, but they would like it to automatically update instead of pressing "Refresh" until the files appear. Can anyone point me in the right direction on how to go about this issue? -
No module named 'django' | Django installed | Python 3 | No virtual env
I am trying to use Django Models in another python script script.py. This is my script from os import environ environ['DJANGO_SETTINGS_MODULE'] = 'settings' import sys sys.path.append("C:/.../djangoproject/djangoproject") from settings import * sys.path.append("C:/.../djangoproject/myapp") from models import video vid = video(video_title='a title') vid.save() This is my folder structure: djangoproject _script.py _djangoproject: __settings.py __ ... _myapp __models.py __ ... This is the error Traceback (most recent call last): File "C:\...\djangoproject\script.py", line 11, in <module> from models import video File "C:\...\djangoproject/myapp\models.py", line 1, in <module> from django.db import models ModuleNotFoundError: No module named 'django' Django is installed I only have python 3 I am not using a virtual env Is there a fix to this problem? Thank you -
SMTP AUTH extension not supported by server - Outlook SMTP & smtplib
I am trying to get emails sent from my django server using Outlook SMTP but I am getting this error: SMTPNotSupportedError( smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server. I have tried: Set up 2FA on outlook and created app password for django to use, same error. Here is my configuration in settings: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.office365.com' EMAIL_PORT = 587 EMAIL_USE_STARTTLS = True EMAIL_HOST_USER = {removed} EMAIL_HOST_PASSWORD = {removed} Here is the view sending the email: def password_reset(request): if request.method == "POST": body_unicode = request.body.decode('utf-8') body_data = json.loads(body_unicode) email = body_data['email'] try: user = User.objects.get(email=email) token = default_token_generator.make_token(user) subject = 'x: Password Reset' body = f'Here is the link you requested to reset your password: http://localhost:3000/api/user/reset/{token}' sender = os.environ.get('EMAIL_NAME') recipient_list = [email] send_mail(subject, body, sender, recipient_list) return HttpResponse("Email sent") except User.DoesNotExist: return HttpResponse("User does not exist") else: return HttpResponse("Invalid HTTP method") Can anyone point me in the right direction? Thanks in advance! -
Django what is the logic behind creating in-app users the same way as admin users?
I was looking into how to create in-app users in Django by leveraging their auth system, and I founds this part of their docs: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model Personally, I do not like this approach because of three reasons: an in-app user will still have an empty permissions field. This is a bit scary, what if I misconfigure something? That could enable access to an in-app user to the admin panel. while both in-app user and admin panel users are similar in some aspects, they belong in two different worlds. To me, it would make more sense to have the auth system more flexible, and be able to use it with any kind of model, keeping the admin users separate from in-app users. having a separate model just to add more fields is an unnecessary overhead. But then, I am sure there are also some good reasons for this approach or maybe I am wrong and this is not the actual recommended approach. Any views on this? -
Why is my blacklisted token still allowing me to access an API in Django Rest Framework with Simple JWT?
In logout I blacklisted a token. But i can access a api using that blacklisted token. I used django restframework simple jwt and blacklist app for blacklisted token. In settings.py i have my jwt settings like this: REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ] } SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': datetime.timedelta(minutes=60), 'REFRESH_TOKEN_LIFETIME': datetime.timedelta(days=1), 'USER_ID_CLAIM': 'id', 'ROTATE_REFRESH_TOKENS': True, 'BLACKLIST_AFTER_ROTATION': True, 'TOKEN_BACKEND': 'rest_framework_simplejwt.token_blacklist.backends.BlacklistBackend', 'BLACKLIST_TOKEN_CHECKS': [ 'rest_framework_simplejwt.token_blacklist.check_blacklisted_token', ], } In my views.py I am sharing two apis logout and hello api: from rest_framework.permissions import IsAuthenticated from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework import status from rest_framework.views import APIView from rest_framework.response import Response from rest_framework_simplejwt.tokens import RefreshToken class LogoutAPIView(APIView): def post(self, request): # Retrieve the user's refresh token from the request or any other means refresh_token = request.data.get('refresh') if refresh_token: try: print(refresh_token) token = RefreshToken(refresh_token) token.blacklist() # Blacklist the refresh token return Response({'detail': 'Successfully logged out.'}, status=status.HTTP_200_OK) except Exception as e: return Response({'detail': 'Invalid refresh token.'}, status=status.HTTP_400_BAD_REQUEST) else: return Response({'detail': 'Refresh token not provided.'}, status=status.HTTP_400_BAD_REQUEST) class HelloView(APIView): authentication_classes = [JWTAuthentication] permission_classes = [IsAuthenticated] def get(self, request): user = self.request.user return Response(f"Hello, {user.username}!") When ever i hit the hello api with a token which is blacklisted and stored in DB, the api stills sends me the content. -
django can you filter for different value for each object in one query
how to filter for different value for each object and is there is a better way to validate that amount of sales items wont be bigger than purchases items here is what I think is wrong in SaleItemListSerializer I am making a for loop and for each item I get its medicine and expiry date then finding sum by making 2 subquery and a query so if I have 15 item there will be 15 query on the database the total response time is in average about 0.8 s in sqlite but in mysql it grows to 1.5 ( still i want to add retrived items and disposed items in the supquery so it will grow bigger ) so is there is a way to annotate all medicine that are in items each with its expiry date ( which is stored in sale items and purchase items ) in one database query ? I think I am making alot of mistakes I am still new to django any help will be appreciated class SaleAddSerializer(serializers.ModelSerializer): items = serializers.ListField(child=serializers.DictField(),write_only=True,min_length=1) class Meta: model = Sale fields = ['doctor_name','coustomer_name','items'] def validate_items(self,items): seen_items = {} for item in items: if set(item.keys()) != {'medicine', 'quantity', 'price', … -
How to check if a field can be left blank in Django templates?
I have simple ModelForm. Some of those fields can be left blank. In the template I'd like to let the user know which fields are required (not to be left blank) and which are not required (can be left blank). How to do that? This did not work: {% for field in form.visible_fields %} {% if field.blank %} * {% endif %} {% endfor %} -
Django Google Authentication - Login page unformatted
I have a web page built using Django and I just followed a tutorial (https://www.section.io/engineering-education/django-google-oauth/) to add Google Authentication for user registration. The functionality works fine, I added a button that users can click and go to the Google Sign-in Page. However, this page is completely unformatted, and doesn't look like what's in the tutorial (the Google choose your account page that we've probably all seen). I can't for the life of me figure out why my site isn't serving the same formatted page. I have 2 urls.py files, one in my main app page, and one in a users folder. users/urls.py looks like this: from django.contrib import admin from django.urls import path, include from users import views as user_views from django.contrib.auth.views import LogoutView urlpatterns = [ path('register/', user_views.register, name='register'), path('login/', user_views.login_user, name='user-login'), path('accounts/', include('allauth.urls')), path('logout', LogoutView.as_view()), ] In my settings.py file, I've added SOCIALACCOUNT_PROVIDERS , SITE_ID and LOGIN_REDIRECT_URL . What else could I be missing that would affect the format of this page? -
Page not found | Can't serve media files with Django
That's the bit of code that causes the problem: <video width="320" height="240" controls> <source src="{{ movie_path }}" type="video/mp4"> </video> The error message: Using the URLconf defined in fergana_api.urls, Django tried these URL patterns, in this order: admin/ api/schema/ [name='api-schema'] api/docs/ [name='api-docs'] api/ [name='all-runs'] tests/<slug:test_session_id> [name='single-run'] tests/<slug:test_session_id>/<slug:test_name> [name='single-test'] ^files/(?P<path>.*)$ ^static/(?P<path>.*)$ The current path, vol/web/media/36/movies/movie.mt4, didn’t match any of these. I'm trying to serve a mp4 file from a volume that's outside the project. I thought I could render the page by providing the absolute path to the file, since it's how I'd do it if I tried to open that page as an html file in browser. But this just doesn't seem to work out though I see that 'The current path' looks exactly as it should look. Not sure it's required in this case, but it's my urls.py for the app urlpatterns = [ path('', views.AllRunsView.as_view(), name='all-runs'), path('tests/<slug:test_session_id>', views.SingleRunView.as_view(), name='single-run'), path('tests/<slug:test_session_id>/<slug:test_name>', views.SingleTestView.as_view(), name='single-test'), ] views.py class SingleTestView(View): def get(self, request, test_session_id, test_name): run = Runner.objects.get(id=test_session_id) movies_dir_path = to_file(run.artifacts_dir_path, 'movies') movie_path = to_file(movies_dir_path, test_name.replace('-', '_') + '.mp4') context = { 'movie_path': movie_path } return render(request, "presenter/single_test.html", context) settings.py # under what url to serve static files in prod STATIC_URL = '/static/' … -
Removing Queryset <>tags from being displayed with my query
I am trying to display a query to a template and I am getting the correct data output but it is being displayed with Queryset<>tags, I believe the reason for this is using .all within my template to make the query but I am unable to figure out how I would display the information with out using .all models.py class SectionMeetingDate(models.Model): section_date = models.DateField() # time stamps when a cost center is created or updated updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) def __str__(self): return str(self.section_date) class SectionMeeting(models.Model): user = models.CharField(max_length=200) section_meeting_date = models.ManyToManyField(SectionMeetingDate, related_name='section_meeting_date') # time stamps when a cost center is created or updated updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) def __str__(self): return str(self.user) class CostCenterID(models.Model): name = models.CharField(max_length=200) dept_leader = models.CharField(max_length=200, null=True, blank=True) section_leader = models.ManyToManyField(SectionMeeting, related_name='section_leader') department_meeting = models.ManyToManyField(DepartmentMeeting, related_name='section_leader') # time stamps when a cost center is created or updated updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name views.py def cost_center_id(request, pk): # provides the name of the section leaders for each cost center ID names = CostCenterID.objects.get(id=pk) context = { 'names':names, } return render(request, 'DeptSummary/cost_center_id.html', context) cost_center_id.html {% for section_leaders in names.section_leader.all %} <h5> Section Leader -- <a href="{% url 'section_leader_date' section_leaders.id %}"> … -
Stop paypal access token from refreshing so frequently
Straight forward and simple question; What is the best way to stop PayPal access token from refreshing so frequently? I have tried to do curl command with extended 'expires_in': command. Doesn't work. Still refreshes after 24hr -
Why is my Django image not uploading in media/eventimg folder?
python class Events(models.Model): user_name = models.TextField() e_image = models.ImageField(upload_to='eventimg') e_poster = models.ImageField(upload_to='eventimg') e_end_date = models.DateTimeField() def __str__(self) -> str: return self.e_name def create_event(self, value): #value is send from view.py, below is its structure self.user_name = value['username'] self.e_image = value['image'] self.e_poster = value['poster'] self.e_start_date = value['startdate'] value dictionary structure which is been send as parameter value= { 'username': request.POST.get('userName'), 'image': request.POST.get('eventImage'), 'poster': request.POST.get('poster'), 'enddate': datetime.strptime(request.POST.get('endDate'), '%d-%m-%Y').strftime("%Y-%m-%d") } Image is not uploading in media/eventimg folder. When i upload it from admin panel it is working but when i try to do same from my webpage its not working. -
Changing Django admin template
I follow this video to change the Django admin templates, but it seems like the change doesn't go through. I am only changing "Welcome, username" to "Bello, username" to see if it works. Any suggestion? admin site file structure settings.py TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates/')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] -
ReactJS post request not sending values to Django backend
I have a React frontend component that is for Login/Account creation. The problem I'm facing is that when trying to register a new user I am getting a Bad Request error. After printing the request on the backend I see the request as <WSGIRequest: POST '/register/'> Here's my react function: const handleRegister = async (e) => { e.preventDefault(); try { const response = await axios.post("http://localhost:8000/register/", { method: "POST", mode: "cors", credentials: "include", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ username, password }), }); const data = await response.json(); setMessage(data.success || data.error); } catch (error) { setMessage("An error occurred. Please try again."); } }; And here's my Django function: def register(request): print(request) if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') if not username or not password: return JsonResponse({'error': 'Missing username or password'}, status=400) try: user = User.objects.create_user(username=username, password=password) login(request, user) return JsonResponse({'success': 'User registered and logged in'}) except Exception as e: return JsonResponse({'error': str(e)}, status=400) return JsonResponse({'error': 'Invalid request method'}, status=405) This is my request payload from the browser: { "method": "POST", "mode": "cors", "credentials": "include", "headers": { "Content-Type": "application/json" }, "body": "{\"username\":\"test\",\"password\":\"test\"}" } Response: {"error": "Missing username or password"} Not sure what I'm missing to make it so … -
Vue.js Build and Deploy to NGINX TypeError: Cannot use 'in' operator to search for 'path' in undefined
I am developing an E-Commerce. It is Vue.js with Django Rest Framework. It was working perfectly fine on my local machine. I had absolutely no errors. Now, once I did "npm run build" (I created the project by "vue create myproject") and uploaded it to my server, some pages stopped working, and on some pages there are tons of error codes. The APIs are working fine and can be accessed and the data served seen. The main problem is the Vue.js build that I get that doesn't work well. I hope you can help me. For example here I should have my products, but I get this: Here is what my broken homepage looks like (it should show the most sold products): Here is My router: import { createRouter, createWebHistory } from 'vue-router' import store from '../store' import axios from 'axios' import Home from '../views/Home.vue' import Products from '../views/shop/Products.vue' import Product from '../views/shop/Product.vue' import About from '../views/About.vue' import Corporate from '../views/Corporate.vue' import Contact from '../views/Contact.vue' import ContactThankYou from '../views/ContactThankYou.vue' import Login from '../views/auth/Login.vue' import SignUp from '../views/auth/SignUp.vue' import ResetPassword from '../views/auth/ResetPassword.vue' import ResetPasswordToken from '../views/auth/ResetPasswordToken.vue' import ResetPasswordMessage from '../views/auth/ResetPasswordMessage.vue' import ResetSetNewPassword from '../views/auth/ResetSetNewPassword.vue' import Account from '../views/auth/Account.vue' import ComplaintsBook from … -
Django models.FileField or serializer.FileField changes 2byte charactor file name
I am uploading 2byte charactor file name such as 木.pdf, When uploading, the file name is attached with randum alphabet,however this is OK. But, 2byte words are encoded automatically. Is it possible to suppress this? class DrawingViewSet(viewsets.ModelViewSet): queryset = m.Drawing.objects.all() serializer_class = s.DrawingSerializer def create(self, request, *args, **kwargs): // the name is kept here. print(request.FILES['myfile'])// <MultiValueDict: {'myfile': [<TemporaryUploadedFile: 木.pdf (application/pdf)>]}> if 'pdf' in request.FILES['myfile'].content_type: serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) print(serializer.data['myfile'])// it shows `http://localhost:8021/media/uploads/%E6%9C%A8_5R4Yjrw.pdf` file name is changed. my model and serializer is here below class Drawing(models.Model): myfile = models.FileField(upload_to='uploads/') detail = models.JSONField(default=dict) #detail = models.JSONField(default=default_value) user = models.ForeignKey(CustomUser,on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class DrawingSerializer(ModelSerializer): myfile = serializers.FileField() detail = serializers.JSONField() class Meta: model = m.Drawing fields = ('id','detail','myfile','user','created_at','updated_at') -
Is it possible to access both my Django project and Nginx Server on a single port forwarding?
My Django project is running on http://127.0.0.1:8000/ and Nginx Server is running on http://127.0.0.1:8080/ I want to access both on a single port forwarding (8081). Host Django and Nginx on the same port on the windows server. I've docker compose as: version: '3' services: web: build: . command: sh -c "echo 'Making migrations ' && python manage.py makemigrations && echo 'Migrating...' && python manage.py migrate && echo 'Running server...' && python manage.py runserver 0.0.0.0:8000" volumes: - .:/code ports: - "8000:8000" restart: always nginx-allure: image: nginx container_name: nginx-allure ports: - "8080:80" volumes: - type: bind source: ./allure-reports target: /usr/share/nginx/html read_only: true restart: always -
RabbitMQ creating idle queues having no consumers
Problems High Memory Usage Blocked Workers High Number of channels and Connections Blocked Connections Deployment Aws EKS I have a Django application and have long-running tasks implemented in celery with RabbitMQ as a Message broker and Result Backend. Over time it uses More memory and connections are getting blocked, when I inspected I found that celery workers are not able to get tasks from rabbitmq. I had logged in to the celery pod which was already running celery worker with the command: celery -A app_name worker -l info. I Logged in to pod and started workers with the same command and it started to consume tasks I understand connections are blocked if we have high memory usage. While debugging I checked I have a lot of random queues(1380 queues) without consumers ready to deliver messages and unpack messages, a large number of connections around 800, a large number of channels, and unused references(I had to clean up using rabbitmqctl force_gc then it started to work) but I am not able to replicate this scenario in my localhost. In my localhost when I start workers some temporary event queues are created and they destroy as soon as the worker stops, I …