Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ImportError: cannot import name 'BoundField' from 'django.forms.forms'
I am having ImportError: cannot import name 'BoundField' from 'django.forms.forms'. I was facing ImportError: cannot import name 'pretty_name' from 'django.forms.forms' error, then I changed 'from django.forms.forms import pretty_name' to 'from django.forms.utils'. Now the error changed. Anyone having a solution for this? -
Query a queryset from a django Foreign key connected model
I have a model like the following: class Flow(models.Model): flow_type_choices = (('Static', 'Static'), ('Transit', 'Transit'), ('Circuit', 'Circuit'), ('Close', 'Close')) flow_name = models.CharField(max_length=500, default=0) flow_info = models.CharField(max_length=500, default=0) flow_type = models.CharField(max_length=500, default=0, choices=flow_type_choices) flow_days = models.IntegerField(default=0) sender_client = models.ForeignKey(Client, on_delete=models.CASCADE) receiver_client = models.ForeignKey(ReceiverClient, on_delete=models.CASCADE) I am trying to get the queryset of receiver_client attached to a particular sender client For this I have tried the following: items = Flow.objects.filter(sender_client=request.user.pk).values_list('receiver_client', flat=True).distinct() and I am getting : items <QuerySet [11, 8, 7, 18, 4, 6, 3]> How can I get the queryset of the receiver clients instead of the pk ? -
learing django project in that process of having some error [ model = Models.Todo NameError: name 'Models' is not defined ] [closed]
this is my serializers.py file from rest_framework import serializers from todos import models class TodoSerializer(serializers.ModelSerializer): class Meta: fields =( 'id', 'title', 'description', ) model = Models.Todo here is i am getting error File "D:\---\api\demo_project\api\serializers.py", line 12, in Meta model = Models.Todo NameError: name 'Models' is not defined -
I am unable to create object for a model using django-celery-beat periodic task
These are my files app/tasks.py from celery import shared_task from .models import news @shared_task def add_title(): new = news.object.create() new.title = "got it" new.save() app/models.py from django.db import models # Create your models here. class news(models.Model): title = models.CharField(max_length=10) app/views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def Save(request): return HttpResponse('<h1>ok</h1>') /celery.py import os from celery import Celery # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smallproject.settings') app = Celery('smallproject') # Using a string here means the worker doesn't have to serialize # the configuration object to child processes. # - namespace='CELERY' means all celery-related configuration keys # should have a `CELERY_` prefix. app.config_from_object('django.conf:settings', namespace='CELERY') app.conf.beat_schedule ={ 'add-data-to-db':{ 'task': 'app.tasks.add_title', 'schedule':20, } } # Load task modules from all registered Django app configs. app.autodiscover_tasks() @app.task(bind=True) def debug_task(self): print(f'Request: {self.request!r}') In /settings.py these were modified/updated things INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app', 'django_celery_beat', ] CELERY_BROKER_URL='redis://127.0.0.1:6379' CELERY_RESULT_BACKEND='redis://127.0.0.1:6379' CELERY_ACCEPT_CONTENT=['application/json'] CELERY_RESULT_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json' I have used this command to run the periodic task(worker) celery -A smallproject beat -l INFO. The problem is when I check the news table there are no records with title "got it"(it is … -
Heroku Error: No application module specified. Django
When I deploy my Django app on Heroku I got following error Error: No application module specified. I cleary see that Heroku see wsgi file Starting process with command `gunicorn --pythonpath application.george_paintings.george_paintings.wsgi --log-file - --log-level debug` But then I got this error. My Procfile looks like this web: gunicorn --pythonpath application.george_paintings.george_paintings.wsgi --log-file - --log-level debug The WSGI import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'george_paintings.settings') application = get_wsgi_application() I tried to see logs with heroku run rails console -a george-paintings but got an error bash: rails: command not found -
django - how to create a chart table in a django admin dashboard?
I have installed the django-jet. [https://jet.readthedocs.io] I want to make a chart with the data in my database. (membership registration, withdrawal of membership...) I want to show the statistics as a chart, what should I do? -
can't able to acess static path which is placed inside root folder in ssh in digital ocean (13: Permission denied) error showing
Static file permission is denied.It shows (13: Permission denied) error. Iam using digital ocean for ssh. My path is root/home/wc-learnclicks in this static file,myapp,manage.py and learnclicks placed. learnclicks contain settings.py otherproject files and myapp is the app and in nginx my path is given asenter image description here -
Export dataframe to csv with django
def convert(fuzz): # if "POST" == request.method: df1 = pd.DataFrame(fuzz) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename=export.csv' print (df1) df1.to_csv(path_or_buf=response, sep='\t', encoding='utf-8') # logger.error('dddddd') return response def fuzzy(excel): df=pd.DataFrame(excel) NameTests = [name for name in df["NameTest"] if isinstance(name, str)] data = {'Matching': [], 'Score': []} for Name in df["Name"]: if isinstance(Name, str): match = process.extractOne( Name, NameTests, scorer=fuzz.ratio, processor=None, score_cutoff=50) if match: data['Matching'].append(match[0]) data['Score'].append(match[1]) df1 = pd.DataFrame(data) return df1 i want my dataframe export as a csv file. but my csv. file got b'csrfmiddlewaretoken=OoNaLz1PC9bYDGBnw9UNxm0RYAGIC3OnsCib7ZjI4UsbhAWI56XRUB95suip8xYz' -
Make whole django project installable including apps
We have microservice architecture and each Django project acts as a small microservice. every Django project has at least one app running, we are trying to make our Django project installable so we can ship these microservices anywhere. I am able to make my Django service as installable but when I am adding app path in INSTALLED_APPS it's not allowing it. My project structure is like project directory contains settings, urls etc files setup file looks like import setuptools setuptools.setup( name="project", # Replace with your own username version="0.0.1", author="Example Author", author_email="author@example.com", description="A small example package", long_description="this is test", long_description_content_type="text/markdown", url="https://github.com/pypa/sampleproject", project_urls={"Bug Tracker": "https://github.com/pypa/sampleproject/issues",}, classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], package_dir={"": "src"}, packages=setuptools.find_packages(where="src"), python_requires=">=3.6", entry_points={ "mysite.plugin.1": [], "console_scripts": ["manage-framework=mysite.manage:main"], }, ) now when I install this and try to run a server with manage-framework runserver its throwing below error. django.core.exceptions.ImproperlyConfigured: Cannot import 'polls'. Check that 'mysite.polls.apps.PollsConfig.name' is correct. I have added mysite.polls.apps.PollsConfig in INSTALLED_APPS Note: I am following the packaging structure from here Packaging -
Is there anyway to stop printing specific columns multiple times in scatter plot with django
enter image description here I created a dropdown to select column from csv and wanting that column to scatter on y axis with my x axis fixed.The dropdown created and working successfully.I have my django file to refresh the plot after every 10 seconds.When it refreshes, the scatter plot is occuring again and again.I want that my plots as shown in image should not display again and again.Kindly suggest any solution for this. -
simple redirect with Django REST framework
I want to do simple redirect processing. From /api/v1/piyo/piyopiyo/<id>/ to /api/v1/hoge/huga/<id>/ I thought it was possible with RedirectView, but it loops as follows. Please tell me how to set urls.py. urls.py from rest_framework import routers from apiv1.views import hoge from django.urls import include, path router = routers.SimpleRouter() router.register('hoge/huga', hoge.HugaViewSet, basename='Huga') urlpatterns = [ path('', include(router.urls)), # target redirect settings re_path( 'piyo/piyopiyo/.*$', RedirectView.as_view( url='hoge/huga')), ] accessed url 1. /api/v1/piyo/piyopiyo/346c7932-e9e3-4735-9729-eb50fa29c466/ 2. /api/v1/piyo/piyopiyo/346c7932-e9e3-4735-9729-eb50fa29c466/hoge/huga 3. /api/v1/piyo/piyopiyo/346c7932-e9e3-4735-9729-eb50fa29c466/hoge/hoge/huga ... 10. /api/v1/piyo/piyopiyo/346c7932-e9e3-4735-9729-eb50fa29c466/hoge/hoge/hoge/hoge/hoge/hoge/hoge/hoge/hoge/hoge/huga redurected 10 times. aborting. -
Django admin use form pk to send push notification
I'm trying to send a push notification of an article with its id.pk value from django admin form. I've searched on how to get id.pk from admin.py I've also added the below to the model but I can't seem to get the value from admin. Here is my model. class Notice(models.Model, HitCountMixin): id = models.AutoField(primary_key=True) title = models.CharField(max_length=20, verbose_name='제목') category = models.CharField(choices=NOTICE_CATEGORY_CHOICES, max_length=18, verbose_name='분류', default='뉴스') I can see this in the list but not from the django admin edit form. I need the id in order send within json data the push notification. Is there way to make this happen. admin.py readonly_field = ('id' , 'file_link') def save_model(self, request, instance, form, change): instance = form.save(commit=False) print(form.cleaned_data.get('category')) print(form.cleaned_data) # PUSH # ------------------------------------------------------------------ if(form.cleaned_data.get('is_push')): title = form.cleaned_data.get('title') body = form.cleaned_data.get('content') message = strip_tags(body)[:100] try: job = django_rq.get_queue('default', default_timeout=3000) job = django_rq.enqueue(send_to_all, title, message, extra) except: pass # ------------------------------------------------------------------ form.save() Things I've tried or considered : Set id as integer to autoincrement Send id value as hidden from admin list to detail. But I can't find the location to pass this to fieldset.html. Please have a look. Thanks. -
Get all posts by Tags
I am trying to implement a feature in my Social Media WebApp . I am trying to get all tags posts according to user's liked posts For Example ( In Brief ) :- Suppose, user_1 liked a post and that post contains tags of #tag1 , #tag2 , #tag3. AND i am trying to show all the posts in a page that contains one of these tags which is liked by user. models.py class Post(models.Model): post_owner = models.ForeignKey(User,default='',null=True,on_delete = models.CASCADE) likes = models.ManyToManyField(User, related_name='post_like', blank=True) tags = TaggableManager() views.py def get_post(request,user_id): tags = Tag.objects.filter(post=id) posts = Post.objects.filter(likes__in=[user_id]) context = {'posts':posts,'tagss':tagss} return render(request,'like_post.html', context) like_post.html {% for post in posts %} {% for tag in post.tags.all %} {{ tag }} {% endfor %} {% endfor %} When i try to run this in browser then it only shows the posts done by me and its tags. What have i tried :- I tried also by i_contains=tags but this didn't worked for me. I noticed a question yesterday about it BUT that question is deleted too. When i try to get it by posts = Post.objects.filter(tags__likes__in=[user_id]) then it keep showing me. Related Field got invalid lookup: likes I am new in Django … -
django RQ / rq scheduler - Possible to disable job timeout?
Once in a while, I have a job that requires much longer processing than anticipated so i'd like to disable timeout if possible. -
How to send Null Value instead of an empty string to Django Model regarding Date field?
I want to make a DateField not mandatory in a form using Django. To maintain the code consistency, I am not using Django Forms as my colleagues who worked on this project before didn't use it. Here's how my HTML looks like for the form <label class="required" for="eol_date">EOL Date</label> <input type="date" class="form-control form-control-sm" id = "eol_date" name="eol_date"> And my Django Model looks like this eol_date = models.DateField(null=True, blank=True) eos_date = models.DateField(null=True, blank=True) Now, Whenever I submit the form, it uses JQuery and JS to POST the data using an API. The Problem is that Whenever I submit the form, the DateField throws in an exception that says the following ['“” value has an invalid date format. It must be in YYYY-MM-DD format.'] I have tried using JS to fetch that value and pass in null as well. The same thing repeats again: ['“null” value has an invalid date format. It must be in YYYY-MM-DD format.'] It would be great if I could fix this -
Plz help me in resolving internal server error 500 for django project on heroku
2021-04-14T01:52:56.741091+00:00 app[web.1]: LINE 1: SELECT COUNT(*) AS "__count" FROM "academic_programme" 2021-04-14T01:52:56.741092+00:00 app[web.1]: ^ 2021-04-14T01:52:56.741092+00:00 app[web.1]: 2021-04-14T01:52:56.748513+00:00 heroku[router]: at=info method=GET path="/home/" host=naacgrade.herokuapp.com request_id=dfd30f65-200b-4735-b33d-c183ab2d7603 fwd="47.29.104.163" dyno=web.1 connect=1ms service=310ms status=500 bytes=403 protocol=https 2021-04-14T01:52:57.212243+00:00 app[web.1]: WARNING:django.request:Not Found: /favicon.ico 2021-04-14T01:52:57.214224+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=naacgrade.herokuapp.com request_id=3948b02a-24b7-441f-afc7-a09154592c1d fwd="47.29.104.163" dyno=web.1 connect=1ms service=10ms status=404 bytes=411 protocol=https 2021-04-14T02:28:41.689333+00:00 heroku[web.1]: Idling 2021-04-14T02:28:41.695614+00:00 heroku[web.1]: State changed from up to down 2021-04-14T02:28:43.150997+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2021-04-14T02:28:43.334286+00:00 heroku[web.1]: Process exited with status 143 -
ModuleNotFoundError, when I try to import models into another custom folder
Inside the app I created a scrapers folder and there are two files in it: __init__.py and asana.py. In asana.py I am trying to import models when I try to run the asana.py imported models gicing the following error ModuleNotFoundError, Django structure --- projects --- models.py --- scrapers ---__init__.py asana.py asana.py import requests from projects.models import Project class Asana: def __init__(self, url, team, keyword=None): self.url = url self.projectKeyWord = keyword self.team = team self.rawData = [] self.projects = [] def setAsanaData(self): res = requests.get(self.url, headers={"Authorization": "Bearer 0/"}).json() self.rawData = res["data"] def setProjects(self): if self.projectKeyWord: for project in self.rawData: if project["name"].startswith(self.projectKeyWord): project["team"] = self.team self.projects.append(project) def getProjects(self): self.setAsanaData() self.setProjects() return self.projects def setProjectsIntoDatabase(self): self.getProjects() for project in self.projects: defaults = {"name": project["name"]} Project.objects.update_or_create(pid=project["gid"], defaults=defaults) URL = "https://app.asana.com/aprojecturl" projects = Asana(URL, "23123123", "keyw") projects.setProjectsIntoDatabase() why can't I import the models? -
How to create the flow for a Django App authorization token process
I am building a Django app. When people fill out a form and click send, i would like to send an email to them for confirmation. When they receive the email, they should have a link where when they click on it they are sent to their application form. I want to use an authorization token to handle the authentication when they click on the link; so that if someone else would be to receive the email they would not be able to open to the application form. I was thinking that when the person fills out the form, when they click send the following happens: the client makes a request for token sending some token_data like name, password, etc.. the authorization engine gets the request and send back the token where does the token get stored in the backend? Is it into a view? does it have to be in LocalStorage? The email then gets sent. Where does this email gets generated from ? When the email is received; it leads back to the application form view I have questions about #3 and #4 -
How to show fields from different table through foreign key and natural key in django query statement
In mysql if you want to get some fields in different tables the query qould be like this `select tab1.field, tab2.field1, tab3.fieldA from CustomerOrder tab1, Food tab2, table3 tab3, table4 tab4 where tab1.id=tab2.tab1_id and tab2.id=tab4.tab3_id and tab3.id=tab4.tab3_idx` This query would help you get the field stated above. I have tried to do the same thing in django but it is giving me the number instead of the field_name it e.g. instead of Burrito for tab2.field1 it is sending me id number 15 CustomerOrder is table1 Food is table2 CustomerAddress is table3 CustomerOrder is my entry point CustomerOrder.objects.filter(customer=customername) These are my models class CustomerOrderManager(models.Manager): def get_by_natural_key(self, customer, food, customeraddress): return self.get( customer=customer, food=food, customeraddress=customeraddress, ) #this contains the subject a students registered for in a specific customeraddress class CustomerOrder(models.Model): customer = models.ForeignKey(User, on_delete=models.CASCADE) food = models.ForeignKey(Food, on_delete=models.CASCADE, null=True) customeraddress = models.ForeignKey(CustomerAddress, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) objects = CustomerOrderManager() class Meta: unique_together = [['customer','food','customeraddress']] #**** when i use this it prevents the pk or id from showing when i save a customerorder def natural_key(self): return (self.customer, self.food, self.customeraddress) class FoodManager(models.Manager): def get_by_natural_key(self, food_type, food_name, description): return self.get(food_type=food_type, food_name=food_name, description=description) class Food(models.Model): food_type = models.CharField(max_length=100, null=True) food_name = models.CharField(max_length=100, null=True) … -
Reverse for 'edit' with arguments '('',)' not found. 1 pattern(s) tried: ['edit/(?P<page>[^/]+)$']
I know this is just like the Reverse for 'edit' with no arguments not found. 1 pattern(s) tried: ['edit/(?P<page>[^/]+)$'] page but I looked for answers there and couldn't find any. I got the same error once and fixed it easily using the link above. But when I coded the field data handling, the same error as before showed up again Here is how I processed the data: def editpage(request, page): if request.method == "POST": form = newPageForm(initial={"title": page, "content" : util.get_entry(page)}) if form.is_valid(): title = form.cleaned_data["title"] content = form.cleaned_data["content"] util.save_entry(title, content) return HttpResponseRedirect(reverse("index")) else: return render(request, "encyclopedia/editentry.html", { "form": form }) return render(request, "encyclopedia/editentry.html", { "form": newPageForm(initial={"title": page, "content" : util.get_entry(page)}), "title": page }) Does any one have a clue whats wrong or where the bad arguments are? -
Django model: Generate series number for each identifier upon saving the model
Good day! I am very new in Django python web development. I have a scenario where I need to automatically generate a property number and a set of series number per location_code as part of a property tag. The format is 0000-00-00-0001-000000000, the format definition is 'year' - 'gl_account' - 'sub_account' - 'series_number' - 'location_code' Example: for location code: 000000001 - office 2021-10-10-0001-000000001 - table 2021-10-10-0002-000000001 - chair 2021-10-10-0003-000000001 - computer set for location code: 000000002 - warehouse office 2021-10-10-0001-000000002 - table 2021-10-10-0002-000000002 - long table 2021-10-10-0003-000000002 - coffee maker and so forth I can already save the model with some part of the property number except the series_number. I see that you can generate random numbers or string, but it is not what I need. below is what I have, so far. class Item(models.Model): # ... # This is where I override the save function to save the format in the 'property_number' field # def save(self, *args, **kwargs): self.property_number = '{}-{}-{}-{}'.format(self.date_acquired.year, self.sub_major_group_and_gl_account.sub_major_group_and_gl_account, 'series_number', self.location.location_code) super(Item, self).save(*args, **kwargs) Admin Site: -
how to make react and django work with aws fargate
Im trying to connect the backend django port:8000 to the frontend react port:3000, which works perfectly on local using AWS Fargate. I really dont understand because i am able to see the app when i only deploy the backend on the URI of the load balancer, EG: http://someelb-xxxx.us-east-3.elb.amazonaws.com/ but nothing is being served when i try with docker-compose that include a backend + frontend images (they have separetaly pushed to ECR repo) From the image above, when i create a task definition i select 8000 for backend and 3000 for frontend since thats the way it is configured in the docker-compose file. If anyone could help -
decoding uidb64 with urlsafe_base64_decode(uidb64).decode() returns <property object at 0x7fc13bd2aea0>
Basically what i am trying to do is to send a link containing a token to the users's email address after registration, so that they can verify their email address and activate their account. After the user receives the email and they click on it, i want to decode the uidb64 i encoded so that i can get the pk and then perform a user query in the database but any time i try to use urlsafe_base64_decode(uidb64).decode() It returns the result <property object at 0x7fc13bd2aea0> Below Is My Urls.py Code from Auth.Api.views import RegisterView, ObtainLoginTokenView, DestroyLoginTokenView from django.urls import path from .views import * app_name = 'users' urlpatterns = [ path('register/', RegisterView.as_view()), path('activate/<uidb64>/<token>/',AccountActivation.as_view(), name='activate'), path('login/', ObtainLoginTokenView.as_view()), path('logout/', DestroyLoginTokenView.as_view()), ] Below Is mail.py code This file contains functions responsible for sending mails. Specifically registerationMail from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.shortcuts import get_current_site from django.core.mail import EmailMessage from django.template.loader import render_to_string from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from .token import account_activation_token from django.conf import settings from django.contrib.auth import get_user_model class SendMail: def registerationMail(self,*args,**kwargs): subject = 'Account Activation.' message = render_to_string('mail/acc_active_email.html', { 'domain':get_current_site(self.kwargs.get('request')), 'uid': urlsafe_base64_encode(force_bytes(get_user_model().pk)), 'token': self.kwargs.get('token') }) receipient = self.kwargs.get('receipient') email = EmailMessage( subject, message, settings.EMAIL_HOST_USER, to=[receipient] ) if … -
Dnago HTML email Gmail not rendering
Hi, I'm sending an email template and gmail is not rendering, see image This is the HTML Code that I have: <html> <head> <style> .banner-color { background-color: #eb681f; } .title-color { color: #0066cc; } .button-color { background-color: #0066cc; } @media screen and (min-width: 500px) { .banner-color { background-color: #0066cc; } .title-color { color: #eb681f; } .button-color { background-color: #eb681f; } } </style> </head> <body> <div style="background-color:#ececec;padding:0;margin:0 auto;font-weight:200;width:100%!important"> <table align="center" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed;font-weight:200;font-family:Helvetica,Arial,sans-serif" width="100%"> <tbody> <tr> <td align="center"> <center style="width:100%"> <table bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="0" style="margin:0 auto;max-width:512px;font-weight:200;width:inherit;font-family:Helvetica,Arial,sans-serif" width="512"> <tbody> <tr> <td bgcolor="#F3F3F3" width="100%" style="background-color:#f3f3f3;padding:12px;border-bottom:1px solid #ececec"> <table border="0" cellspacing="0" cellpadding="0" style="font-weight:200;width:100%!important;font-family:Helvetica,Arial,sans-serif;min-width:100%!important" width="100%"> <tbody> <tr> <td align="left" valign="middle" width="50%"><span style="margin:0;color:#4c4c4c;white-space:normal;display:inline-block;text-decoration:none;font-size:12px;line-height:20px">Webinars</span></td> <td valign="middle" width="50%" align="right" style="padding:0 0 0 10px"><span style="margin:0;color:#4c4c4c;white-space:normal;display:inline-block;text-decoration:none;font-size:12px;line-height:20px">Tuesday 14, February 2017</span></td> <td width="1">&nbsp;</td> </tr> </tbody> </table> </td> </tr> <tr> <td align="left"> <table border="0" cellspacing="0" cellpadding="0" style="font-weight:200;font-family:Helvetica,Arial,sans-serif" width="100%"> <tbody> <tr> <td width="100%"> <table border="0" cellspacing="0" cellpadding="0" style="font-weight:200;font-family:Helvetica,Arial,sans-serif" width="100%"> <tbody> <tr> <td align="center" bgcolor="#8BC34A" style="padding:20px 48px;color:#ffffff" class="banner-color"> <table border="0" cellspacing="0" cellpadding="0" style="font-weight:200;font-family:Helvetica,Arial,sans-serif" width="100%"> <tbody> <tr> <td align="center" width="100%"> <h1 style="padding:0;margin:0;color:#ffffff;font-weight:500;font-size:20px;line-height:24px">Invitation to Revevol webinar</h1> </td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" style="padding:20px 0 10px 0"> <table border="0" cellspacing="0" cellpadding="0" style="font-weight:200;font-family:Helvetica,Arial,sans-serif" width="100%"> <tbody> <tr> <td align="center" width="100%" style="padding: 0 15px;text-align: justify;color: rgb(76, … -
Multiple Django app with uwsgi and nginx with sub domains at 80 not working
I've been trying to deploy two Django projects on a single server using uWSGI and Unix socket Nginx, I've cross-checked the configuration it seems fine, but it behaves oddly. Let me give the project names A for first and B for second for better understanding and referencing. For both projects, I've set up uWSGI and Nginx setup as per this amazing article How To Serve Multiple Django Applications with uWSGI and Nginx in Ubuntu 20.04 Everything is working right emperor.uwsgi.service shows two uwsgi processes for each project A and B there are socket files at the correct path, but when I tried to serve both with the different subdomain let's say for A subdomain A.example.com and for B subdomain B.example.com at port 80 using Nginx then A.example.com works fine but B.example.com returns default Nginx page but if I change the B.example.com's config and use port 8000 then it works fine at B.example.com:8000. A.conf symlinked to /etc/nginx/sites-enabled/A from /home/ubuntu/ProjA/nginx/A.conf upstream A_uwsgi { server unix:///run/uwsgi/A.sock fail_timeout=0; } # configuration of the server server { # the port your site will be served on listen 80; # the domain name it will serve for server_name A.example.com; # charset utf-8; # max upload size …