Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can I add taggit tags to a newly created Django model instance?
I'm unable to add Taggit tags to a newly created Django model instance from within a DRF serializer. When attempting to do use the new instance, the operation fails with list object has no attribute add. class ThingSerializer(serializers.ModelSerializer): def create(self, validated_data): # fails with `list object has no attribute add` thing = Thing.objects.create(**validated_data) custom_tags = validated_data.pop("custom_tags", []) for custom_tag in custom_tags: thing.custom_tags.add( custom_tag.pop("name"), tag_kwargs=custom_tag ) thing.save() def create_with_hack(self, validated_data): # works after fetching the record from DB thing = Thing.objects.create(**validated_data) thing_ = Thing.objects.get(pk=thing.id) custom_tags = validated_data.pop("custom_tags", []) for custom_tag in custom_tags: thing_.custom_tags.add( custom_tag.pop("name"), tag_kwargs=custom_tag ) thing_.save() As noted above, I'm able to work around this by first explicitly fetching record from the database but that is undesirable. Also, the refresh_from_db model method does not solve the problem. Python 3.8 Django 4.2.2 Taggit 4.0.0 -
How to use Django views variables in Google Maps API Javascript on HTML template?
For obvious reasons, I'll be referring to my API KEY by [GOOGLE_API_KEY]. I have the following view : def search_places(request): GOOGLE_API_KEY = os.getenv('google_api_key') search_keywords = request.POST.get('keywords') search_type = request.POST.get('type') top = request.POST.get('top') is_open = request.POST.get('open') w_duration = 1 - (int(request.POST.get('w-duration')) / 100) rating_filter = float(request.POST.get('btnradio-rtg')) price_filter = int(request.POST.get('btnradio-price')) # Converting is_open from string to bool if is_open: is_open = True else: is_open = False df_users = get_all_users_df() dict_users = format_df_users_for_map(df_users) barycenter = compute_barycenter(df_users) return render(request, "index.html", {'google_api_key': GOOGLE_API_KEY, 'dict_users': dict_users, 'barycenter': barycenter } ) Which return in dict_users and in barycenter the following : dict_users = [{'lat': 48.8501531, 'lng': 2.3897723, 'name': 'John'}, {'lat': 48.8490926, 'lng': 2.458714, 'name': 'Jack'}, {'lat': 48.8472106, 'lng': 2.3792469, 'name': 'James'}, {'lat': 48.8490926, 'lng': 2.458714, 'name': 'Jose'}] barycenter = (48.848887225, 2.4216118) In my 'index.html' template, I have : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="shortcut icon" href="{% static 'css/favicon.ico' %}" type="image/x-icon"> <link rel="stylesheet" href="{% static 'css/style.css' %}"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://maps.googleapis.com/maps/api/js?key=[GOOGLE_API_KEY]&libraries=places" defer></script> </head> With a script block : <html lang="en"> <body style="background-color: #f4f6f9;"> <script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))}) ({key: "[GOOGLE_API_KEY]", v: "beta"}); // … -
prevent closing of python app using windows CMD X button (by mistake)
I have a running Django app (localy) in "start.bat" file. CALL venv\Scripts\activate.bat manage.py runserver 0.0.0.0:8000 --insecure --noreload Someone on the PC sometimes close the window How can I prevent this? like: warning popup with prompet / hide X button / run in different app than CMD ? I did run it on TK gui but it was messing with my process manager inside the Django. -
Update the text entry widget in a django_jsonform JSONField
I'm using a JSONField from django_transform for a json column in my DB. On the admin page Django renders a nice form that allows users to add entries to the json according to the schema. I want to switch out the text entry input field (a Textinput, I think) for string inputs in the JSONField form with a rich text entry widget. I've tried overwriting the JSONField widget with a rich text widget (I'm using TinyMCE) but that replaces the whole thing and just prints the dumped json string in it. Is it possible to override internal widgets of the JSONField form? -
TypeError at /empinfo/add EmployeeInfoViewset.get_empinfo() got an unexpected keyword argument 'pk'
Here i was used Django Rest Framework to create simple API, But I was facing the Error on try to create new data model.py class EmpPersonalInfo(models.Model): emp_id = models.OneToOneField( 'Employees', models.PROTECT, primary_key=True, db_column='emp_id', verbose_name='Employee ID') dob = models.DateField(verbose_name='Date of Birth') mobile = models.CharField( max_length=10, unique=True, verbose_name='Mobile No.') email = models.CharField(max_length=45, unique=True, verbose_name='Email Address') aadhar = models.CharField(max_length=12, unique=True, verbose_name='Aadhar No.', help_text='Enter Aadhar no. without space') pan = models.CharField(max_length=20, unique=True, verbose_name='PAN No.') add1 = models.CharField(max_length=100, blank=True, null=True, verbose_name='Address line') city = models.CharField(max_length=25, blank=True, null=True, verbose_name='City') state = models.CharField(max_length=25, blank=True, null=True, verbose_name='State') pincode = models.IntegerField( blank=True, null=True, verbose_name='Pincode') class Meta: managed = False db_table = 'emp_personal_info' verbose_name_plural = "Personal Information" def __str__(self): return str(self.emp_id) in my Django app i was used without id field, but in my Mysql Db table i have extra id field Auto increment but not PK, emp_id only used FK and PK here. views.py class EmployeeInfoViewset(viewsets.ViewSet): queryset = EmpPersonalInfo.objects.all() serializer_class = EmpInfoSerializer lookup_field = 'emp_id' @api_view(['GET']) def get_empinfo(request, emp_id=None): with connection.cursor() as cursor: if emp_id is not None: cursor.execute("CALL sp_get_empInfo(%s)", [emp_id]) else: cursor.execute("CALL sp_get_empInfo('')") results = cursor.fetchall() employee_info = [] for result in results: employee_info.append({'emp_id': result[0], 'dob': result[1], 'mobile': result[2], 'email': result[3], 'aadhar': result[4], 'pan': result[5], 'address1': result[6], 'city': … -
Multiple processes spawned when running Django runserver
Sometimes, When I run Django (ver 4.1.6) runserver and monitor the usage memory usage using htop I see that there multiple processes or threads spawned (see the below image). The same thing doesn't happen when running another application's Django even though most of the code is almost identical. Any idea why this is happening? Is there any setting to determine the number of threads? and how do I figure out where the issue is? -
Sending Catalogue WhatsApp Business API
I am trying to ingrate integrate WhatsaApp Business API. I have setup the webhook and can now receive messages through the webhook but when when I send a catalogue, the webhook says Message type is currently not supported.Below is the full response { 'object': 'whatsapp_business_account', 'entry': [ { 'id': '**********************', 'changes': [ { 'value': { 'messaging_product': 'whatsapp', 'metadata': { 'display_phone_number': '***************', 'phone_number_id': ''***************' }, 'contacts': [ { 'profile': { 'name': 'Majesty' }, 'wa_id': 'Majesty' } ], 'messages': [ { 'from': ''***************', 'id': 'wamid.'***************==', 'timestamp': ''***************', 'errors': [ { 'code': ******, 'title': 'Message type unknown', 'message': 'Message type unknown', 'error_data': { 'details': 'Message type is currently not supported.' } } ], 'type': 'unsupported' } ] }, 'field': 'messages' } ] } ] } Is there a way to send catalogue receive it through the webhook -
Django - How to fix multiple pks in url?
I currently have a live search functionality built out mostly working how I want. Functionality works like this: A user searches a word on the search bar. Then the user gets a display of suggested searches that includes text and an image. The user clicks on the text/image from the suggested searches that they want and then the user goes to the template page that includes the primary key in the url. The Problem: When the user is on the template page that includes the primary key and another form submission is made. An additional pk gets added to the URL. Example: http://127.0.0.1:8000/1/2/ This results in Page Not Found 404. How do i fix this? After a user makes another submission I just need the url updated with the new primary key. So this: http://127.0.0.1:8000/1/2/ needs to be this http://127.0.0.1:8000/2/ Any help is gladly appreciated. Thanks! Code Below: urls.py: urlpatterns = [ path('', account_view_home, name='home'), # Below are the urls where the live search is enabled # path ('game_details/', search_results_view, name="game_details"), path ('<pk>/', search_detail_view, name="detail") ] views.py def search_detail_view(request,pk): obj = get_object_or_404(Game_Info, id=pk) user_prices = Shopping_Prices.objects.all() game_leaderboard = User_Info.objects.all() # return render(request, 'detail.html', {'obj':obj}) if request.user.is_authenticated: user_profile = User_Info.objects.filter(user=request.user) context … -
How to resolve the StaleElementReferenceException in selenium
I was trying to create an automation tool using selenium with python which searches google for a particular link and if the link is in the top results it will be marked as indexed and if it is not present it will be marked as not indexed. The first link gets searched with no problem but when I target the search bar to search the next link I'm getting this error. I'm looping over all my links in my database. Below given is the code I used for searching google. parser/parser.py from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException from indexer.models import Link from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys def main(): indexed = 0 not_indexed = 0 db_links = Link.objects.all() options = webdriver.FirefoxOptions() options.add_argument("-headless") driver = webdriver.Firefox(options=options) wait = WebDriverWait(driver, timeout=10) visited_google = False for link in db_links: try: if not visited_google: driver.get(f"https://www.google.com") visited_google = True wait.until(EC.element_to_be_clickable((By.XPATH, "//textarea[@id='APjFqb']"))) textarea = driver.find_element(By.XPATH, value="//textarea[@id='APjFqb']") textarea.send_keys(link.link) textarea.send_keys(Keys.ENTER) wait.until(EC.presence_of_element_located(locator=(By.XPATH, "//div[@id='search']"))) search = driver.find_element(By.XPATH, value="//div[@id='search']") anchor = search.find_element(By.XPATH, value=f"//a[@href='{link}']") if anchor: indexed += 1 else: not_indexed += 1 except NoSuchElementException: not_indexed += 1 driver.quit() print(indexed) print(not_indexed) I am using django. My view function … -
How to export in nextjs without regenerate the elements
I have a project with nextjs and I had to get output from it Now, if I want to make a change in the created html pages, I have to go to the chunks folder and edit the js file related to it, but I don't want this to happen because I want to set it with Django variables, and I don't want it to be related in any way. I can also use restful Thankful Also, I tried rendering on the server side and set webpack to false in the nextjs configuration, but no results were obtained. -
Is there a way to know what triggered the beforeunload?
I have a page on my Django app with a form. I would like to alert users if they try to exit the page without submitting their form. I implemented this with the beforeunload method, written below: window.addEventListener('beforeunload', function (e) { e.preventDefault(); e.returnValue = ''; }); However, this also raises an alert when a user submits a page. Is there a way to identify which event is triggering the beforeunload (either submit or exiting, refreshing,etc.)? -
Form Validation Errors Not Displayed in my HTML Template
I developed a login and registration system using Django on a single HTML page with a tabbing system. But, I encountered an error: upon registering, the page just refreshes. To troubleshoot, I debugged by printing errors to the console. It printed that the form is invalid. I intentionally provided invalid details to troubleshoot, like entering a password similar to the username or a password that isn't longer than 8 characters. It printed that in the console, but I want it to show the errors in the HTML template for each field. So, I wrote a login-register view. Everything seems to be okay in the view, but it still isn't showing the errors in the HTML template. Forms class CustomUserCreationForm(UserCreationForm): email = forms.EmailField(label="Email", max_length=255, required=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for field_name in self.fields: field = self.fields[field_name] field.widget.attrs.update({'class': 'u-full-width bg-light pb-2', 'placeholder': field.label}) class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] Views def login_register_view(request): if request.user.is_authenticated: return redirect('core:home') if request.method == 'POST': action = request.POST.get('action') if action == 'login': # login functionality elif action == 'register': registration_form = CustomUserCreationForm(request.POST) if registration_form.is_valid(): user = User.objects.create_user( username=registration_form.cleaned_data['username'], email=registration_form.cleaned_data['email'], password=registration_form.cleaned_data['password1'] ) user.save() return redirect('core:login_register') login_form = CustomAuthenticationForm() registration_form = CustomUserCreationForm() … -
Strapi filtering dose not work when I provide JWT token and returns every thing
I have this Strapi endpoint that return the products The problem is when I include the jwt token in the headers the filtering dose not work and it returns every thing but when I take the jwt suddenly the filtering work this is the function def get_products_by_supplier(jwt, supplier_id): url = f"{STRAPI_BASE_URL}/products?populate=*&filters[supplier][id][$eq]={supplier_id}" if jwt: headers = { "Authorization": f"Bearer {jwt}", "Content-Type": "application/json" } response = requests.request("GET", url, headers=headers) if response.status_code == 200: return response.json() else: return None else: return None how can I solve this issue because I need to use the jwt token in the headers -
no such table Django
I have a problem with Django. I got the Error Message: no such table: tablename. I already defined the model and now I want to safe Data in this model. But it cannot find the table. I hope you can help me. #my models.py class ImageUpload(models.Model): image = models.FileField(upload_to= user_directory_path) camera = models.CharField(max_length=100) ... #my view.py if request.method == 'POST': form = ImageUploadForm(request.POST, request.FILES) if form.is_valid(): image = form.cleaned_data['image'] camera = form.cleaned_data['camera'] uploaded_file = ImageUpload( image=image, camera=camera, ) uploaded_file.save() -
Please enter the correct email and password for a staff account
I created super user using python manage.py createsuperuser and i am sure that is_staff = True, is_superuser = True, is_active = True. I used custom user, here is models.py: from django.db import models from django.contrib.auth.hashers import make_password from django.contrib.auth.models import AbstractUser, Group, Permission, UserManager class CustomUserManager(UserManager): def create_superuser(self, email, password, **extra_fields): extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) extra_fields.setdefault('is_active', True) if extra_fields.get('is_staff') is not True: raise ValueError('Superuser must have is_staff=True.') if extra_fields.get('is_superuser') is not True: raise ValueError('Superuser must have is_superuser=True.') return self.create_user(email, password, **extra_fields) def _create_user(self, email, password, **extra_fields): email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.password = make_password(password) user.save(using=self._db) return user def create_user(self, email, password=None, **extra_fields): extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(email, password, **extra_fields) class User(AbstractUser): email = models.EmailField(max_length=254, unique=True) username = None USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() # use the custom manager def __str__(self): return self.email why can't login into the admin panal? -
Wagtail hook for richtext editor
I created a wagtail hook for adding a code block from the Richtext editor. The hook is working but I have the problem. The hook supposed to work like as follows, <div class="code"> content line one content line two </div> But when I apply the block from editor , it is applying each line with the code like, <div class="code">content line one </div> <div class="code">content line two </div> This was supposed to be one line, The wagtail editor is applying multiple divs for each of the lines instead of one div for the selected block My hook code is as follows, @hooks.register('register_rich_text_features') def register_py_code_block_feature(features): """ Registering for adding python code block """ feature_name = 'py-code-block' type_ = 'py-code-block' control = { 'type': type_, 'label': 'PY', 'description': 'Python Code Block', # Optionally, we can tell Draftail what element to use when displaying those blocks in the editor. 'element': 'div', 'style': { "display": "block", }, } db_conversion = { 'from_database_format': {'div': BlockElementHandler(type_)}, 'to_database_format': {'block_map': {type_: { 'element': 'div', 'props': { 'class': 'code blog_code language-python' } } } }, } features.register_editor_plugin('draftail', feature_name, draftail_features.BlockFeature(control)) features.register_converter_rule('contentstate', feature_name, db_conversion) features.default_features.append('py-code-block') Can some one point me the right direction -
How to connect local database with .env file?
I have a django docker container. And I have two .env files: one for local and one for production. And I am using Azure for the database service. So if I connect the env file with the Azure database it works. But when I try it the .env file for the local datbase. I get am error. so docker-compose file looks like: version: "3.9" services: app: build: context: . args: - DEV=true ports: - "8000:8000" volumes: - ./Welzijn:/app command: > sh -c "python ./manage.py migrate && python ./manage.py runserver 0:8000" environment: - DEBUG=1 env_file: - ./.env.sample and the local env file looks like: DEBUG=True SECRET_KEY="%@967xvpdnf7go%r#d%lgl^c9ah%!_08l@%x=s4e4&+(u" DATABASE_NAME="zijn" DATABASE_USER="zijn" DATABASE_PASSWORD="password" DATABASE_HOST="127.0.0.1" DATABASE_PORT="" So when I do a:docker-compose up --build I get this error: dwl_backend-app-1 | django.db.utils.OperationalError: could not connect to server: Connection refused dwl_backend-app-1 | Is the server running on host "127.0.0.1" and accepting dwl_backend-app-1 | TCP/IP connections on port 5432? But I also have a production env file: DEBUG=False SECRET_KEY="+)d)&d0^&0xda+s%1o(&r3+24)x#i^bk8p8r)@jl_q2=%usxw=" DATABASE_NAME="zijn" DATABASE_USER="zijn" DATABASE_PASSWORD="85jLGTj{v?s38_Jr" DATABASE_HOST="db-zijn.postgres.database.azure.com" DATABASE_PORT="" And that is working if I do a docker-compose up --build Question: How to connect with the local database with the .env file? -
How to create a REST API with Django and implement SSL, token authentication?
So, I need provide an API endpoint for my app. The one who requests this kinda link /api/thing/?thing_id=abc123 would get a JSON data. I am done with this part but cannot figure it out how make auth token implementation and I think I am mixing terms with SSL. So, it would be really appreciated, if someone explains! -
How does django manual user log in authentication works?
I am learning Django. I defined a database then signup and login views and templates accordingly. signup works fine but log in not working. Actually it does not do anything while entering email and password. Would you please help me? -
Django: Trouble importing updated form
learning Django for the first time and I'm getting my first error here. Saying it "cannot import 'UserRegisterForm' from 'users.forms'". I'm following a tutorial and I haven't skipped any steps. Not too sure what to try next...thanks for any suggestions. Tutorial Video (33:15): https://www.youtube.com/watch?v=q4jPR-M0TAQ&t=1959s views.py from django.shortcuts import render, redirect from django.contrib import messages from .forms import UserRegisterForm def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success(request, f'Account created for {username}!') return redirect('blog-home') else: form = UserRegisterForm() return render(request, 'users/register.html', {'form': form}) forms.py from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] Folder Directory -
Heroku H13 desc="Connection closed without response" for file (pdf) upload
I have a use case where the user can upload a pdf book and I process a summary for that book. For a 250-page book, for example, the summary process takes around 2-3 minutes and it works great on local. However, in Heroku, for that 250-page book, I get the error below. When I try the 20-page book, it's okay. I run Heroku using professional dynos. I have 3 dynos. I have also shared my views on how files are processed. There you will see libraries that I use as well. I read a bit that Heroku has a hard cap of 30 seconds, ie if 30 seconds passed and the summary is not done, boom, error. Is that true? How can I avoid that? Thank you in advance for your help. error: error in server: 2023-08-15T09:12:55.850512+00:00 app[web.1]: [2023-08-15 09:12:55 +0000] [98] [INFO] Worker exiting (pid: 98) 2023-08-15T09:12:55.848850+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/file_processing/upload/" host=someendpoint request_id=b8045e24-a33f-4446-869e-e22a27fbef32 fwd="109.245.202.232,141.101.96.16" dyno=web.1 connect=0ms service=30471ms status=503 bytes=0 protocol=https Procfile web: gunicorn backend.wsgi views.py from django.http import JsonResponse from rest_framework.views import APIView from rest_framework.parsers import MultiPartParser, FormParser from .serializers import DocumentSerializer from docx import Document as DocxDocument from pdfminer.high_level import extract_text import pytesseract … -
Trying to send HTML form field value in JSON POST call to API but getting syntax err showing that whole HTML page code is being sent as JSON
I am building a Single Page App using Django and JavaScript. In Django app in the views.py I have the following function acting as add-post API endpoint: def post_add(request): ''' API endpoint for creating a new post ''' # save data submitted by the user if request.method != "POST": return JsonResponse({"error": "POST request required."}, status=400) else: form = PostForm(request.POST) # check if form is valid server-side if form.is_valid(): post = form.save(commit=False) # save without commit as we have to associate some variables that were not in the form post.author = request.user post.save() return JsonResponse({"message": "Post added successfully."}, status=201) else: # return JsonResponse({"message": "Errors in the form."}, status=400) In JavaScript I have added event listener after the whole document has been loaded and within it an event listener on the submit button that removes the default submit action and triggers my add_post() function: document.addEventListener('DOMContentLoaded', function() { // add function call on add post form submission document.querySelector("#create-post").addEventListener('submit', function(event) { event.preventDefault(); // cancels default form submission action on clicking the submit button in the form add_post(); }); }); And here is the add_post() function in JavaScript that sends data for the new post (1 field in the form) and calls the API endpoint: … -
How can I see the body of the request that Django's test client makes
I am writing automated tests in Django and started writing tests for an API endpoint that supports the put method. I am making my put request like so: response = self.client.put(path, data=json.dumps({"key": "value"}) print(response.request) As you see, I'm trying to see the details of the request that is being sent. I am particularly interested in seeing what goes into the body of the request. But the object returned by response.request is a dictionary that does not contain the "body" key or anything similar. I think this is a weird feature for the testing framework not to have, seeing as how it could come in handy in many different scenarios. Is there any way I can access the body of the request that I have not yet discovered? Or does the feature really not exist? -
Performance issues with gunicorn + gevent Django
I'm encountering performance issues with gunicorn+genevent that is consuming a significant amount of RAM after conducting a high-load test. Even when I return an empty view with just a "hello world" message, the RAM usage continues to remain high, causing other requests to get stuck. I suspect that there might be a cache-related issue causing this behavior. Is there a way for gunicorn to clean up its cache automatically to return resources to normal levels after a high-load situation? I've configured gunicorn to use the formula NUM_WORKERS = NUM_CORES * 2 and performed tests with both 1 worker and more workers, but the results were the same. Here's the command I'm using to run gunicorn: gunicorn config.wsgi:application \ --workers $NUM_WORKERS \ --timeout $TIMEOUT \ --keep-alive 2 \ --bind 0.0.0.0:8000 \ --log-level=debug \ --log-file=- \ -k gevent Could this issue possibly be unrelated to gunicorn? If so, how can I go about testing for memory leaks? Your assistance is greatly appreciated. -
Why are emails sent successfully from my Django project using the Gmail SMTP server on localhost but not on AWS?
I use the Gmail SMTP server for my Django project, which I have deployed on AWS. The emails are sent and work locally on localhost, but they are not working from AWS. I have 2 step verification enabled on gmail and generated app password wich i use in two different .env files, one locally and one in the cloud. I use the same password (if that matters). Additionally, I have added port 587 to the inbound rules of the Security Groups but still not working. enter image description here