Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django model form mutiple selector can not save inti DB
I have a question as below. I stuck in this problem for a while. I build up an order in django model form which provide customer using shopping cart to fill their transaction info. Below is my code structure : ## models.py from django.db import models class Order(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField() address = models.CharField(max_length=250) postal_code = models.CharField(max_length=20) city = models.CharField(max_length=10) ## forms.py from django import forms from .models import Order from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout,Div,Field class OrderCreateForm(forms.ModelForm): class Meta: model = Order fields = ['first_name', 'last_name', 'email', 'address', 'postal_code','city'] def __init__(self,*args,**kwargs): super(OrderCreateForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper = Layout( Div(Field('city') , id="twzipcode_ADV"), ) ## views.py from .forms import OrderCreateForm from .models import OrderItem def order_create(request): cart = Cart(request) if request.method == 'POST': form = OrderCreateForm(request.POST) if form.is_valid(): order = form.save() ## .html <form action="." method="post"> {% csrf_token %} {% for field in form %} {% if field is form.city or field is form.county%} <div id="twzipcode_ADV"></div> {% else %} {{field.name}} {{field}} {% endif %} {% endfor %} {% buttons %} <button type="submit" class="btn btn-success btn-product"> <span class="glyphicon glyphicon-shopping-cart"></span> Place order </button> {% endbuttons %} </form> <script src='https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'></script> <script src='https://cdn.jsdelivr.net/npm/jquery-twzipcode@1.7.14/jquery.twzipcode.min.js'></script> <script src="{%static … -
Django CharField unique=True seems not working while unique=True is set
I'm using Django 3.0.2 and sqlite3 DB. I set following simple models: from django.db import models class Description(models.Model): IDENTIFIER_LENGTH = 30 identifier = models.CharField(max_length=IDENTIFIER_LENGTH, blank=False, unique=True, primary_key=True) Strangely, the unique=True seems not working. Following code run in shell mode from testunique.models import Description object = Description('first-object') object.save() object.save() doesn't raise any error. For the record, here is the SQL code of the migrations: BEGIN; -- -- Create model Description -- CREATE TABLE "testunique_description" ("identifier" varchar(30) NOT NULL PRIMARY KEY); COMMIT; What is wrong here? Thanks for the answer. -
How to add a unique name to a FileField that stores in aws s3?
I am having an issue with s3. When another user uploads a File which contains same name, the old one gets deleted and replaced with the new one. How can i add a unique name as a filename? Here is my settings.py AWS_ACCESS_KEY_ID = 'my access key' AWS_SECRET_ACCESS_KEY = 'my secret key here' AWS_STORAGE_BUCKET_NAME = 'my-media' AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' models.py from django.db import models # Create your models here. class Designer(models.Model): name = models.CharField(max_length=100, unique=True, blank=False, help_text='Designer Unique Name') email = models.EmailField(max_length=100, blank=True) mobileNumber = models.CharField(max_length=15, blank=True) logo = models.FileField(blank=True) # How to add a unique name?? -
Accessing information from extended modelform
I cannot access information from a modelform I extended. Since the model was saved as mentor I assume accessing information from it would be through something along the line of user.mentor.*informationname* This is what i have in my views.py class TeacherSignUpView(CreateView): model = User form_class = TeacherSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'teacher' return super().get_context_data(**kwargs) def form_valid(self, form): user = form.save() # user.set_password(form.cl) login(self.request, user) return redirect('teachers:app-instructor-dashboard') ... def payment_view(request): form = MentorPaymentForm() if request.method == 'POST': form = MentorPaymentForm(request.POST, request.FILES, instance=request.user) if form.is_valid(): user,mentor = form.save(commit=False) return redirect('teachers:payment_view') else: form = MentorPaymentForm(instance=request.user) return render(request, 'classroom/teachers/app-instructor-billing.html', {'form': form}) models.py: class Mentor(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='mentor') linkedin = models.URLField(max_length=200,null=True,blank=True) photo = models.ImageField(null=True, blank=True, upload_to='media', default='default.jpg') address = models.CharField(max_length=500, null=True, blank=True) invoice_name = models.CharField(max_length=200, null=False, blank=False) account_num = models.IntegerField(default=1234) bank_name = models.CharField(max_length=50, null=False) branch_code = models.IntegerField(default=1234) def __str__(self): return "Profile of user {}".format(self.user.username) and forms.py class TeacherSignUpForm(UserCreationForm): email = forms.EmailField(max_length=100) first_name = forms.CharField(max_length=100) last_name = forms.CharField(max_length=100) linkedin = forms.URLField(max_length=200) address = forms.CharField(max_length=500) invoice_name = forms.CharField(max_length=200) account_num = forms.IntegerField() bank_name = forms.CharField(max_length=50) branch_code = forms.IntegerField() class Meta(UserCreationForm.Meta): model = User fields = ('email', 'username', 'first_name', 'last_name') def save(self, commit=True): self.instance.is_teacher = True user = super(UserCreationForm, self).save(commit=False) user.email = self.cleaned_data['email'] … -
str(request.GET.get('code1')) always returning None
// I am downloading a CSV file from the page. Where i am extracting input parameters which are always getting returned None for all the fields even though they have value. Before downloading i am opening the page and searching with parameters with kitty_view(request) // Html Page {% extends 'base.html' %} {% load static %} {% block content %} <form class="form-signin" action="{% url 'kitty_view' %}" method="get"> {% csrf_token %} <div class="container"> <div class="customer"> <div class="form-row mb-3"> <td><a href="{% url 'kitty' %}" class="btn btn-primary btn-sm" role="button">Add Kitty</a> </td> <td><a style="margin-top:5px;margin-left:20px" href="{% url 'kitty_download' %}" ">CSV Download</a> </td> <!-- <td><a href=" {% url 'kitty_download' %}" class="btn btn-primary btn-sm" role="button">CSV Download</a> </td> --> </div> </div> <div class="form-row"> <div class="mb-3"> <select class="custom-select-sm center-block" name="code1" id="code1"> <!-- <option value="{{ code }}">Choose Kitty...</option> --> <option>{{ code }}</option> {% for j in kitty_code %} <option value="{{ j.code }}"> {{ j.code|add:' - '|add:j.name }} </option> {% endfor %} </select> </div> <div class="mb-3 ml-2"> <input type="text" value="{{ name }}" name="nam" id="nam" class="form-control-sm center-block" placeholder="Name" autofocus> </div> <div class="mb-3 ml-2"> <select class="custom-select-sm center-block" name="stat" id="stat" placeholder="Status"> <!-- <option value="{{ status }}">Choose Status...</option> --> <option>{{ status }}</option> <option>A</option> <option>I</option> </select> </div> <div class="mb-3 ml-2"> <!-- <a href="{% url 'kitty_view' %}" class="btn … -
PyCharm not running project via built-in run, but run in terminal
PyCharm perfectly run project, when starting from its Terminal, via command: py manage.py runserver 8000 But when I try to launch the same project via green button (Run), then I get this error: E:\work\wowzers-webapp\venv\Scripts\python.exe E:/work/wowzers-webapp/manage.py runserver 8000 Traceback (most recent call last): File "E:/work/wowzers-webapp/manage.py", line 21, in <module> main() File "E:/work/wowzers-webapp/manage.py", line 17, in main execute_from_command_line(sys.argv) File "E:\work\wowzers-webapp\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "E:\work\wowzers-webapp\venv\lib\site-packages\django\core\management\__init__.py", line 334, in execute parser = CommandParser(usage='%(prog)s subcommand [options] [args]', add_help=False, allow_abbrev=False) File "E:\work\wowzers-webapp\venv\lib\site-packages\django\core\management\base.py", line 48, in __init__ super().__init__(**kwargs) TypeError: __init__() got an unexpected keyword argument 'allow_abbrev' Process finished with exit code 1 This error started to appear after I updated project's django version from 2.2.7 to 3.0.2 I've checked Run configuration and it is the same python manage.py runserver 8000 I even copy-paste the same run command, that pycharm uses to launch project, into terminal: E:/work/wowzers-webapp/manage.py runserver and in terminal project starts normally. Both in terminal and in Run configuration the virtualenv python is being used, so they are the same. Could you please say, should I check? I already tried: Invalidate cache and restart Delete venv folder and install everything again Googling ~2 hours for this error didn't give me any help, so … -
Functionality for restoring dynamic data on webpage
I have a django web application (2.1.7) where I am storing data related to traveling groups. In order to get the desired results I am applying some filters through the web browser. So the application generates an HTML table on the fly , based on my criteria. Let's suppose I am navigating to another URL on the browser, www.google.com for example, is there any possible way to get the exact same html table when i press the browser's back button? I am new to web development and also stackoverflow, any guidance or reference to documentations would be much appreciated. -
requests==2.22.0 In my requirements.txt failed to pass travis
requests==2.22.0 In my requirements.txt failed to pass Travis CI. Can anyone suggest an alternative? I have already tried requests==2.20.0 -
Django AWS SES Shared Credential File, Environment Variables and Parameter Store
I have been trying to build a send_email feature into a website. In the long run, I was thinking of making this website code publicly available, so I didn't want passwords etc to be visible within the code. For this reason I was thinking of using AWS Parameter Store. This is fine and works for database connections etc. I wanted to send email using python and SES: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-using-sdk.html Within these doc's it says that you need to setup a shared credentials file, which I don't really fancy doing because that would make the key's publicly accessible, if ever I make the code available. It also mention's that you can use the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. I could stick these directly into elastic beanstalk, that would make them easy to see, but it would be nice to keep all of the sensitive information within one place such as the parameter store, so I tried setting the environment variables within settings.py, ie os.environ['AWS_ACCESS_KEY_ID'] = 'value from parameter store' os.environ['AWS_SECRET_ACCESS_KEY'] = 'value from parameter store' Unfortunately when I run the code from the views.py and use getenv, I cannot see the environment variables: os.getenv('AWS_ACCESS_KEY_ID') raises an error in views.py os.getenv('AWS_SECRET_ACCESS_KEY') raises an … -
ScrapyD with Django stops running after sometime
I have a whole django(2.2) application with scrapyd deployed on the production server. It seems to work fine but I noticed a trend recently that the crawler just stops running after some days. I run the scrapyD server using cronjobs. When the server restarts, a .sh file runs. Using nohup command: This script activates the venv and starts the scrapyd server using scrapyd command. Then using management controls, I run the crawler which scrapes the website and stores data in a MySQL database. The scraping works fine for 3 days as I can see the debug logs but then it doesn't run i.e there are no new logs generated in logs directory of scrapyd. I then ran the management control manually to see what is the issue. An exception is raised when scrapyd.schedule() is called: File "/var/www/venv/lib/python3.6/site-packages/scrapyd_api/wrapper.py", line 188, in schedule json = self.client.post(url, data=data, timeout=self.timeout) File "/var/www/venv/lib/python3.6/site-packages/requests/sessions.py", line 581, in post return self.request('POST', url, data=data, json=json, **kwargs) File "/var/www/venv/lib/python3.6/site-packages/scrapyd_api/client.py", line 38, in request return self._handle_response(response) File "/var/www/venv/lib/python3.6/site-packages/scrapyd_api/client.py", line 34, in _handle_response raise ScrapydResponseError(json['message']) scrapyd_api.exceptions.ScrapydResponseError: attempt to write a readonly database I have gone through some answers where people recommended to set the permissions. This is not that, the permissions … -
How to populate html input element with Ajax callback data
I am trying to populate an html field with some text being queried using jQuery Ajax. The data being sent to the function view is received back on page load. The callback data can be seen in the console. However the data value itself is not populated in the input field. Why my code below is failing: $('.clsSomeTxt input').val(data.recdValue); Whereas in the console it shows: console.log('The value received back is: ' + data.recdValue); I have tried using form's id also, without success. -
How to update template on Django view request post
I am doing some filtering. I have initial results on my page, then there is a form, that on select, I want to filter some data and update template. The template doesn't seem to be updated though. from .services import service # Home Page View def home_view(request, *args, **kwargs): update_list = service.get_updates() if request.method == 'POST': filter_string = request.POST.get('filter') update_list = [update for update in update_list if update['type'] == filter_string] print(len(update_list)) page = request.GET.get('page', 1) paginator = Paginator(update_list, 2) try: updates = paginator.page(page) except PageNotAnInteger: updates = paginator.page(1) except EmptyPage: updates = paginator.page(paginator.num_pages) context = { 'updates': updates } return render(request, "home.html", context) What would be the better way of doing this? -
Create Dashboard for CSV data
I have a csv file : each line having some inputs and some status. I need to read this csv file and present the data as a dashboard with some charts. I came across to use chart js plugin. Is there any better approach? -
Django REST Login error. I don't know what to do
Well Im trying to login with an API call. I got a model called User. I want make the login from this Model using email and password. This is my Model: class User(models.Model): name = models.CharField(max_length=30, null=False, blank=False) surnames = models.CharField(max_length=30, null=False, blank=False) email = models.EmailField(max_length=60) password = models.CharField(max_length=100, null=False, blank=False) country = CountryField() phonenumber = PhoneNumberField() postalCode = models.CharField(max_length=5) def __str__(self): return self.email I have this API call login User: class UserLogin(APIView): permission_classes = [] def post(self, request, *args, **kwargs): user = authenticate(email=request.data.get('email'), password=request.data.get('password')) if user is not None and user.is_active: login(request, user.email) return render(request, 'core/core_index.html') else: return HttpResponse('Error') With this backend to authenticate: class MyBackEnd(object): def authenticate(self, request, email, password): """ :param username: Username of the user :param password: Password of the user :return: """ #check is user is present in User DB. existing_user = None try: existing_user = User.objects.get(email=email) return existing_user except Exception as e: #Checking the user UserAPI Custom DB. user_data = UserAPI.objects.get(email=email) if email == user_data.email: user = User.objects.create_user(username=user_data.name ,email=email,password=password) user.save() return User.objects.get(email=email) else: return None def get_user(self, user_id): try: return User.objects.get(pk=user_id) except User.DoesNotExist: return None I have got the AUTHENTICATION_BACKENDS = ['apps.core.api.backends.MyBackEnd'] setted on settings.py. I tried a lot of things and all with … -
Django multiple User groups
Ok, so I have multiple users, and they belong to one, or more than one user group(I have 4 groups). Each group has its own bootstrap card which shows on the HTML page. How can I show 1,2,3 or more cards, depending on the user group? If a user is in group1, I want to render card1, but if user is in group1 AND group2, I want to render card1 and card2, etc. I tried {% if request.user.is_superuser %} and {%if 'group name' in user.groups.all.0.name %}, but that applies well only if a user is in one group. Thanks. -
Is there a way to produce a error or ask the user to change a name of an app object if the name is the same in django?
Hey guys im new to django. does anyone know how to give the user an error if he uses the same name. -
Change Stripe apy key on the fly Python SDK
I need to support transfers between multiple regions using Stripe. Since they don't allow it, my first option is to create multiple stripe accounts in these regions. Is it possible, using their SDK, to change the api_key on the fly? Is there any other solution that helps me to transfer money to different regions? -
View didn't return an HttpResponse Object
I would like users to be redirected to a form that would allow them to edit their billing details. However, when I try and click the link to go to the billing form I get this error message: ValueError: The view classroom.views.teachers.payment_view didn't return an HttpResponse object. It returned None instead. This is what I have in my views: def payment_view(request): user = request.user form = MentorProfileForm() if request.method == 'POST': form = MentorProfileForm(request.POST, request.FILES, instance=user) if form.is_valid(): form.save() return HttpResponseRedirect('%s' % (reverse('teachers:payment_view'))) else: form = MentorProfileForm(instance=user) return render(request, 'classroom/teachers/app-instructor-billing.html', {'form': form}) models.py class Mentor(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='mentor') linkedin = models.URLField(max_length=200,null=True,blank=True) photo = models.ImageField(null=True, blank=True, upload_to='media', default='default.jpg') address = models.CharField(max_length=500, null=True, blank=True) invoice_name = models.CharField(max_length=200, null=False, blank=False) account_num = models.IntegerField(default=1234) bank_name = models.CharField(max_length=50, null=False) branch_code = models.IntegerField(default=1234) def __str__(self): return "Profile of user {}".format(self.user.username) forms.py: These fields appear in the signup form class TeacherSignUpForm(UserCreationForm): email = forms.EmailField(max_length=100) first_name = forms.CharField(max_length=100) last_name = forms.CharField(max_length=100) linkedin = forms.URLField(max_length=200) address = forms.CharField(max_length=500) invoice_name = forms.CharField(max_length=200) account_num = forms.IntegerField() bank_name = forms.CharField(max_length=50) branch_code = forms.IntegerField() class Meta(UserCreationForm.Meta): model = User fields = ('email', 'username', 'first_name', 'last_name') def save(self, commit=True): self.instance.is_teacher = True user = super(UserCreationForm, self).save(commit=False) user.email = self.cleaned_data['email'] user.first_name = self.cleaned_data['first_name'] … -
How to use ColllectionField()?
I want to create model object to store multiple phone number. I am using CollectionField but getting error File "/home/shiv/.local/lib/python3.7/site-packages/collectionfield/models/fields.py", line 226, in contribute_to_class cls, name, virtual_only=virtual_only TypeError: contribute_to_class() got an unexpected keyword argument 'virtual_only' here is my models.py from django.db import models from multiselectfield import MultiSelectField from django.utils import timezone from collectionfield.models import CollectionField class Applications(models.Model): country = models.ForeignKey(Country, on_delete=models.SET_NULL, null= state = models.ForeignKey(State, on_delete=models.SET_NULL, null=True) city = models.ForeignKey(City, on_delete=models.SET_NULL, null=True) zone = models.CharField(max_length=10, choices=zone_choice, blank=True) name = models.CharField(max_length=20) phone_number = CollectionField() email_id = models.EmailField() home_address = models.CharField(max_length=255, blank=True, null=True) birthdate = models.DateField(null=True, blank=True) def __str__(self): return str(self.name) -
"NOT NULL constraint failed: small_small_hr_staffprofile.data"
Getting this error while trying to submit a modelForm . The problem appears to be with saving the form into the sqlite3 due to a contraints. If someone could help me pick it out, please. Thanks in advance Below is the code for my view and Model. IntegrityError at /admin/small_small_hr/staffprofile/add/ NOT NULL constraint failed: small_small_hr_staffprofile.data Request Method: POST Request URL: http://localhost:8000/admin/small_small_hr/staffprofile/add/ Django Version: 2.2 Exception Type: IntegrityError Exception Value: NOT NULL constraint failed: small_small_hr_staffprofile.data Exception Location: C:\Users\hp\Anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 383 Python Executable: C:\Users\hp\Anaconda3\python.exe Python Version: 3.7.4 View: @user_passes_test(lambda u: u.is_superuser) def CreateStaff(request): if request.method == 'POST': form = StaffProfileAdminCreateForm(request.POST) if form.is_valid(): form.save() messages.success(request, f'Staff created successfully') return redirect('home') else: form = StaffProfileAdminCreateForm() return render(request, 'small_small_hr/create-staff.html', {'form': form}) Model: class StaffProfile(TimeStampedModel, models.Model): """ StaffProfile model class Extends auth.User and adds more fields """ NOT_KNOWN = '0' MALE = '1' FEMALE = '2' NOT_APPLICABLE = '9' SEX_CHOICES = ( (NOT_KNOWN, _('Not Known')), (MALE, _('Male')), (FEMALE, _('Female')), (NOT_APPLICABLE, _('Not Applicable')) ) user = models.OneToOneField( USER, verbose_name=_('User'), on_delete=models.CASCADE) image = ImageField(upload_to="profile_pics", max_length=255, verbose_name=_("Profile Image"), help_text=_("A square image works best"), blank=True) sex = models.CharField(_('Gender'), choices=SEX_CHOICES, max_length=1, default=NOT_KNOWN, blank=True, db_index=True) role = models.ForeignKey(Role, verbose_name=_('Role'), blank=True, default=None, null=True, on_delete=models.SET_NULL) phone = PhoneNumberField(_('Phone'), blank=True, default='') address = … -
UndefinedValueError: SECRET_KEY - Deploying Docker to DigitalOcean
How do I declare my apps SECRET_KEY in Docker. Everything works fine locally but fails in my Digital Ocean droplet. The code runs on Heroku without issues. That could be because I declared the env variables directly into Heroku. Thanks in advance Here's the error: decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value. Here's my docker-compose file: version: "3" services: db: image: postgres web: build: . expose: - "8000" command: sh -c "python manage.py collectstatic --no-input && python manage.py makemigrations && python manage.py migrate && waitress-serve --port=${PORT} myapp.wsgi:application" environment: - DB_NAME=postgres - DB_USER=postgres - DB_PASS=postgres - DB_HOST=db - DB_PORT=5432 - DEBUG=${DEBUG} - SECRET_KEY=${SECRET_KEY} - ALLOWED_HOSTS=${ALLOWED_HOSTS} volumes: - ./myapp:/myapp ports: - "8000:8000" env_file: - ./.env.prod depends_on: - db nginx: build: ./nginx ports: - 1337:80 depends_on: - web Here's my Dockerfile: FROM python:3.7-alpine ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 COPY ./requirements.txt /requirements.txt RUN pip install -r /requirements.txt RUN apk update && apk add libpq RUN apk add --virtual .build-deps gcc python3-dev musl-dev postgresql-dev RUN pip install psycopg2 RUN apk del .build-deps # copy entrypoint.sh COPY ./entrypoint.sh /entrypoint.sh COPY ./.env.prod /.env.prod RUN mkdir /myapp WORKDIR /myapp COPY ./myapp /myapp RUN adduser -D user USER user EXPOSE 8000 # … -
django model can not create or save because of unexpected arguments
I want to insert the row by these parameters. but It failed because of the error wrote at Exception. this is the model of Mart. this is the form of Mart. -
Error when using docker-machine but not on ssh server: Are you trying to mount a directory onto a file (or vice-versa)?
I am running a dockerized django app with nginx on an ubuntu (ec2-instance) server. My idea is to deploy with docker-machine. When I ssh into my EC2 and copy my app there and then spin up my docker-compose file, everything works well and the app runs perfectly. But I would like to spin up my container without ssh'ing into the server but using docker machine. When I point my execution commands to my EC2 instance and run the same command (docker-compose -f production.yml up --build) I get the following error: Cannot start service production-nginx-container: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\"/Users/myuser/myfolder/myproject/compose/production/nginx/myconf.conf\\" to rootfs \\"/var/lib/docker/overlay2/44675a2cf4ac6e3052c9df3bd6fbb35b1ece33736d632199572c6a1c90965c12/merged\\" at \\"/var/lib/docker/overlay2/44675a2cf4ac6e3052c9df3bd6fbb35b1ece33736d632199572c6a1c90965c12/merged/etc/nginx/conf.d/default.conf\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type The line I think which docker is complaining about is this one: - ./compose/production/nginx/myconf.conf:/etc/nginx/conf.d/default.conf I am trying to map my config from my nginx file into the default conf of the nginx docker container. myconf.conf is there and it is a file. My guess is that there is a problem mounting the file from my local … -
Configure SSL in NGINX and Gunicorn in Django
I'm new to deploying applications. I have a requirement of hosting a Django application using NGINX and Gunicorn. I was able to successfully run the Django application using NGINX and Gunicorn. Now I have to configure the NGINX with HTTPS. I went through a few of the posts on configuring SSL with NGINX and Gunicorn. But still not able to configure HTTPS for my application. Below is the NGINX configuration file server { listen 80; listen 443 ssl; server_name domain_name; ssl_certificate /etc/ssl/https_certificate.cer; ssl_certificate_key /etc/ssl/https_key.key; location / { proxy_set_header X-Forwarded-Proto https; proxy_pass http://0.0.0.0:8000; } location /static/ { autoindex on; alias PROJECT_STATIC_FILES_DIR; } location = /favicon.ico { alias PATH_TO_FAVICON/favicon.ico; } } Still, my web application shows it as HTTP only not HTTPS. Can anyone please tell where I'm making the mistake. Kindly excuse, if it is a repeated question. -
I finished installing devstack on CentOS 7 and gave this error in the log: ... / wsgi.py' cannot be loaded as Python module
I installed devstack according to the documentation and when finished I was missing a django module as I understand it. I have already disabled SElinux, Firewalld and NetworkManager, I would like help to solve this problem, I have researched a lot and I have not found the solution. Here is the full log: 2020-01-20 10:55:42.036719 mod_wsgi (pid=25003): Target WSGI script '/opt/stack/horizon/openstack_dashboard/wsgi.py' cannot be loaded as Python module. 2020-01-20 10:55:42.036828 mod_wsgi (pid=25003): Exception occurred processing WSGI script '/opt/stack/horizon/openstack_dashboard/wsgi.py'. 2020-01-20 10:55:42.036953 Traceback (most recent call last): 2020-01-20 10:55:42.037045 File "/opt/stack/horizon/openstack_dashboard/wsgi.py", line 21, in <module> 2020-01-20 10:55:42.037299 from django.core.wsgi import get_wsgi_application 2020-01-20 10:55:42.037367 ImportError: No module named django.core.wsgi