Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to connect local React app to local REST API for production
I have a system where I want several tablets to connect to a local server on a local network. It would be nice to use react native on the tablets and connect to a local Django REST API on an apache server. I don't want this system touching the web whatsoever (totally offline). Is there a way to do this given self-signed SSL certs are supposedly development only? This networking part of it is new to me. -
iframe pdf preview at change event
$(document).ready(function(){ $("#id_quotationFile").change(function(){ url=$("#id_quotationFile").attr(value); $("#pdf-view").attr("src",url); }); }); Trying to load pdf file browsed in input field using above jquery code but not working <input type=file id="id_quotationFile"> <iframe src="" id="pdf-view" frameborder="0px" title="Preview"></iframe> How to preview pdf file in iframe. -
Django, OOP question to deal with EAV and complex attributes tables/models for diverse products
I have this model and I want to run select_related query for the category related product's attributes. class auction_product(models.Model): title = models.CharField(max_length=64) date_added = models.DateField(default=timezone.now) user = models.ManyToManyField(User, through='product_ownership', related_name='product_user') category = models.ForeignKey(Categories, on_delete=models.CASCADE) condition = models.CharField(max_length=5, choices=[('N', 'New'), ('U', 'Used')]) description = models.CharField(max_length=4096) product_bid = models.ManyToManyField(User, through='bid', related_name='product_bid') product_comment = models.ManyToManyField(User, through='comment') album = models.OneToOneField(ImageAlbum, related_name='product_model', blank=True, null=True, on_delete=models.CASCADE) class extra_vehicle_attributes(auction_product): product = models.OneToOneField('auction_product', primary_key=True, parent_link=True, on_delete=models.CASCADE, related_name="vehicle_attributes") make = models.CharField(max_length=128) model = models.CharField(max_length=128) year = models.IntegerField() mileage = models.IntegerField() class extra_pc_attributes(auction_product): product = models.OneToOneField('auction_product', primary_key=True, parent_link=True, on_delete=models.CASCADE, related_name="pc_attributes") processor = models.CharField(max_length=264) ram = models.FloatField() brand = models.CharField(max_length=64) motherboard = models.CharField(max_length=264) case = models.CharField(max_length=264) screen_size = models.FloatField() weight = models.FloatField() Now in the views.py for instance I am running this code below, but it is getting really tedious to write because each time I have to write .vehicle_attributes or pc_attributes or whatever attributes I may have and write it after the object in python code. Is there a way where I can get all the select_related mentioned fields properties without having to write like .vehicle_attributes for each object? I just want python to spit out all the possible fields auction_product may belong to its attributes foreign table without having … -
Uploading duplicated files with Django when reloading page
I'm trying to upload some files and I'm having problems with duplication. To uploading the file I do the following: views.py: from django.core.files.storage import FileSystemStorage def contView(request): if request.method == 'POST' and request.FILES.get('myfile'): myfile = request.FILES['myfile'] fs = FileSystemStorage() filename = fs.save('uploads/'+myfile.name, myfile) uploaded_file_url = fs.url(filename) # Return template_name ='cont/mainCont.html' context = {} return render(request, template_name, context) Template: <form method="post" enctype="multipart/form-data">{% csrf_token %} <div class="input-group"> <input type="file" name="myfile" class="form-control"> <span class="input-group-btn"> <button class="btn btn-default" type="submit">Importar</button> </span> </div> </form> The upload works perfectly but when I refresh the page it upload the same file again. Why is this happening? I need to empty something? Thank you very much! -
Use Twitter API in Celery task - need to use access_key and access_secret from auth user
I have the following function in my views.py that will send me the authorised user's key tokens. I can then manually amend these tokens for my Twitter API function locally to run the program. def like(request): oauth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) access_key = request.session['access_key_tw'] access_secret = request.session['access_secret_tw'] send_mail( 'Auth Codes', # subject 'access key - ' + os.environ['oaccess_key'] + '\n' + 'access_secret - ' + os.environ['oaccess_secret'], # message DEFAULT_FROM_EMAIL, # from email [DEFAULT_FROM_EMAIL], ) return render(request, "home.html") However having to do this manually isn't great and for security reasons I'd rather not have them emailed. I want to push the function to a celery task so that I don't need the sendmail() at all. My celery task would look like this after liking.delay() being called within like() - @app.task(bind=True) def liking(self): oauth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) oauth.set_access_token(access_key, access_secret) api = tweepy.API(oauth) ** Rest of my code using the Twitter API ** I have tried setting the access_key and access_secret as environmental variables but they do not import to the celery.py. Is there any way that I'm missing that can enable this to work? -
How to pass the url from the datepicker to Chartjs URL
I need to pass the url from the datepicker to loadChart() var requestURL = 'http://127.0.0.1:8000/api/v1/rainfall/'; the date-picker have 2 urls. defaultUrl and url and everytime those urls been modified on the frontend. it automatically passes the url to the loadChart() url. How can I do it? Thanks! <script> (function rfChart(rainfall, amount, timestamp) { amount = loadChart().amount; timestamp = loadChart().timestamp; var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'line', data: { labels: timestamp, datasets: [{ label: 'Rainfall Graph', data: amount, lineTension: 0, backgroundColor: 'transparent', borderColor: '#c9c5c5', borderWidth: 2, pointRadius: 1, }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: false } }] }, legend: { display: false } } }) }()); </script> <script> var myVar = setInterval(loadChart, 60000); // updates chart every one minute function loadChart() { var rainfall, amount = [], timestamp = []; var requestURL = 'http://127.0.0.1:8000/api/v1/rainfall/'; //URL of the JSON data var request = new XMLHttpRequest(); // create http request request.onreadystatechange = function() { if(request.readyState == 4 && request.status == 200) { rainfall = JSON.parse(request.responseText); for (var i=0; i<rainfall.length;i++) { amount.push(rainfall[i].amount); timestamp.push(rainfall[i].timestamp); } console.log('amount', amount); console.log('timestamp', timestamp); console.log('rainfall', rainfall); return rainfall,amount,timestamp; rfChart(amount,timestamp); } } request.open('GET', requestURL); request.send(); // send the request } loadChart() … -
How to save a model form with two Models in Django
There is a model Listaflor linked to Estados with another model named Flora2Estado, i made a form with ModelMultipleChoiceField. It saves successfully into Listaflor but nothing into the Flora2Estado, what can i do about this? forms.py class FloForm(forms.ModelForm): familia = forms.ModelChoiceField(queryset=Familia.objects.all().order_by('familia_nome').filter(aprovado=1)) Especie = forms.CharField(label="Nome da espécie*") estados = forms.ModelMultipleChoiceField(queryset=EstadosM.objects.all().order_by('nome_abbr')) class Meta: model = Listaflor ordering = ["estados",] fields = ['Especie','estados'] views.py def CreateFlo(request): form = FloForm() if request.method == 'POST': form = FloForm(request.POST) if form.is_valid(): Listaflor = form.save(commit=False) Flora2Estado = form.save(commit=False) Listaflor.save() Flora2Estado.save() return render(request,'accounts/enviar_flora.html') models.py class Flora2Estado(models.Model): estado = models.ForeignKey(EstadosM, models.CASCADE) especie = models.ForeignKey(Listaflor, models.CASCADE) flora2estado = models.AutoField(primary_key=True) class Meta: managed = False db_table = 'flora2estado' unique_together = (('estado', 'especie'),) Any tips on helping me making a better post is welcome, have a good day! -
Run django and cron in docker-compose
I have two similar dockerfiles. They differ only in the entrypoint This is Dockerfile-cron FROM python:3.8 WORKDIR /src COPY requirements.txt ./ COPY requirements-dev.txt ./ RUN apt-get update -y RUN apt-get install libgl1-mesa-glx -y RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements-dev.txt CMD [ "chmod", "+x", "cron.sh" ] This is cron.sh #!/usr/bin/env bash * * * * * python manage.py check_subscriptions > /proc/1/fd/1 2>/proc/1/fd/2 I have cron service in docker-compose cron: build: dockerfile: deploy/Dockerfile-cron context: . volumes: - .:/src networks: - sortif-network When I up docker-compose I get error backend_cron_1 exited with code 0 sudo docker logs backend_cron_1 is empty. -
Django templates not loading without errors
I am trying to load my templates in Django but it does not load anything except the base.html and does not show any error as well. I have tried these solutions but did not see and changes: Templates not loading in Django Django Template not loading Django template doesn't load Here is my views: def all(request): lead_list = Lead.objects.all() print(lead_list) return render(request, "leads.html", {'leads': lead_list}) URLS: urlpatterns = [ path('leads/', views.leads, name="leads"), path('newlead/', views.newlead, name="newlead"), path('leads/<int:pk>', views.lead_details, name="lead-details"), path('leads/<int:pk>/update', views.lead_update, name="lead-update"), path('leads/<int:pk>/delete', views.lead_delete, name="lead-delete"), path('all/', views.all, name="all"), ] Here is the HTML: {% extends 'base.html' %} {% block content %} <h1>Hello World</h1> {% for lead in leads %} <div class="max-w-sm mx-auto bg-white dark:bg-gray-800 shadow-lg rounded-lg overflow-hidden"> <img class="w-full h-56 object-cover object-center" src="https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" alt="avatar"> <div class="flex items-center px-6 py-3 bg-gray-900"> <svg class="h-6 w-6 fill-current text-white" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M17 21C15.8954 21 15 20.1046 15 19V15C15 13.8954 15.8954 13 17 13H19V12C19 8.13401 15.866 5 12 5C8.13401 5 5 8.13401 5 12V13H7C8.10457 13 9 13.8954 9 15V19C9 20.1046 8.10457 21 7 21H3V12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12V21H17ZM19 15H17V19H19V15ZM7 15H5V19H7V15Z"/> </svg> <h1 class="mx-3 text-white font-semibold text-lg">{{lead.status}}</h1> </div> <div class="py-4 px-6"> <h1 class="text-xl font-semibold … -
Django - Group by Count of Foreign Key
I have two models like so: models.py class Subscription(...): is_active = models.BooleanField(...) class Order(...): subscription = models.ForeignKey('Subscription', related_name='orders', ...) ... I want to know: How many subscriptions have x number of orders (i.e. 7 subscriptions with 1 order, 5 subscriptions with 2 orders, etc.) The average number of orders across all of my subscriptions (i.e. 2.2 orders) I can susccesfully annotate the number of orders to a subscription queryset, but I am having trouble grouping the queryset by like 'number_of_orders' from there: views.py from django.db.models import Count queryset = Subscription.objects.filter(is_active=True).annotate(number_of_orders=Count('orders') queryset = queryset.values('number_of_orders') I've tried: queryset = queryset.order_by('number_of_orders').aggregate(count=Sum('number_of_orders')) which doesn't group my subscriptions correctly, and: queryset = queryset.order_by('number_of_orders').annotate(count=Sum('number_of_orders')) which fails with this error: Cannot compute Count('number_of_orders'): 'number_of_orders' is an aggregate Ideally, I am looking for the result to be in a form that I can pass to a bar chart in chart.js, something like: data = [ {"subscriptions_with_1_order" : 5}, {"subscriptions_with_2_orders" : 3}, {"subscriptions_with_3_orders" : 3}, ... ] or more preferably (where x is the number of orders and y is the count of subscriptions with that many orders): data = [ {"x" : 1, "y" : 5}, {"x" : 2, "y" : 3}, {"x" : 3, "y" : 3}, … -
<a> tag not opening popup
{% extends "base.html" %} {% block spotify %} <ul class="navbar-nav"> <li class="nav-item"> <a href="#" id="login" onclick= "openSignInWindow" class="nav-link">Login</a> </li> </ul> </nav> <script> let windowObjectReference = null; let previousUrl = null; var url = "{% url 'login' %}"; const openSignInWindow = (url, name) => { window.removeEventListener('message', receiveMessage); const strWindowFeatures = 'toolbar=no, menubar=no, width=600, height=700, top=100, left=100'; if (windowObjectReference === null || windowObjectReference.closed) { windowObjectReference = window.open(url, name, strWindowFeatures); } else if (previousUrl !== url) { windowObjectReference = window.open(url, name, strWindowFeatures); windowObjectReference.focus(); } else { windowObjectReference.focus(); } // add the listener for receiving a message from the popup window.addEventListener('message', receiveMessage, false); // assign the previous URL previousUrl = url; }; login = document.getElementById(login); login.addEventListener(onclick, openSignInWindow(url , spotify)); </script> {% endblock %} Aim is to open the {% url 'login' } when the link is clicked but I do not know how to pass the javascript function arguments into the <a> onclick. How do I achieve this? Is there a better way to do this instead of using an <a>? -
docker React, django(gunicorn), nginx reverse proxy with https give Bad request 400 on accessing backend APIs
I have containerized application with following containers working together with docker-compose Nginx - reverse proxy React - frontend Django served using gunicorn - backend When using http all works well with frontend and backend. I used letsencrypt certbot to generate ssl certificates. On switching to https, fronend seems to work fine however none of backend apis are working. Any request to backend such as login generates 'Bad Request 400' response. I have tried following options but none worked. a. Switching Django to production and adding ALLOWED_HOSTS=['*'] or specific domain b. Adding upstream in nginx.conf c. disableHostCheck: true in webpack devServer. Following are my docker-compose and nginx.conf respectively docker-compose.yml services: reverse_proxy: image: nginx:1.17.10 volumes: - ./reverse_proxy/nginx.conf:/etc/nginx/nginx.conf - ./reverse_proxy/certbot-etc:/etc/letsencrypt - ./reverse_proxy/certbot-var:/var/lib/letsencrypt ports: - 80:80 - 443:443 depends_on: - webapp - frontend webapp: build : ./backend/ command: gunicorn --bind 0.0.0.0:8000 ai.wsgi:application expose: - 8000 volumes: - ./backend/:/app ports: - 8000:8000 frontend: build: ./frontend/ai-web/ command: npm run ai ports: - 3000:3000 nginx.conf worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 1024; } http { fastcgi_read_timeout 3000; proxy_read_timeout 3000; client_max_body_size 1000M; upstream django { server webapp:8000; } server { listen 80; server_name localhost 127.0.0.1; location / { proxy_pass http://frontend:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For … -
Replace views functions for view class in Django
I would like to replace my views functions for a class. I'm new in Django and I try to send service object from user function to metrics function but I can´t do that with < a href="{% url 'metrics' %}">Metrics</a> in home.html. I don't know how to call a class instead a function too my code: def user(request): username = request.POST.get('username') password = request.POST.get('password') service = Service() service.start(username=username, password=password) return render( request, 'home.html', { 'service': service, } ) def metrics(request, service): metrics = service.get_metrics() return render(request, 'metrics.html', { 'metrics', metrics } the code I would like or something like it: class User(object): def __init__( self ): super(User, self).__init__() self.usernme = '' self.password = '' self.service = '' def get_service(self, request): self.username = request.POST.get('username') self.password = request.POST.get('password') self.service = Service() self.service.start(username=self.username, password=self.password) return render( request, 'home.html', {} ) def metrics(self, request): metrics = self.service.get_metrics() return render( request, 'metrics.html', { 'metrics': metrics, } ) -
CK - Editor in django is not working in production
I used ckeditor in my django project.It is working fine in local machine.But after deploying to web server it is not working. I can see the textarea without ckeditor tools. -
i got error " tshop.models.Tshirt.DoesNotExist: Tshirt matching query does not exist."
my views.py file cart=request.session.get('cart') if cart is None: cart=[] for c in cart: tshirt_id=c.get('tshirt') tshirt=Tshirt.objects.get(id=tshirt_id) c['size']=Sizevariant.objects.get(tshirt=tshirt_id, size=c['size']) c['tshirt']=tshirt print(cart) return render(request,"cart.html",{"cart":cart}) -
use existing odoo database with django or zend framework
I would like to use an existing odoo database (generated) with a framework in order to retreive and display some data (lms project) my question is which framework can be helpful in my case , django or zend framework -
Django Rest framework as Single Sign On
I have created DRF application with Django OAuth Toolkit (DOT) Rest Application with oAuth2 flow. I was planning to use these api's as Single Sign On (SSO). For javascript client it is working fine with "authorization_code" grant type which is returning me access token and refresh token and with those I can authorize and authenticate my javascript application. But for another Django application I am stuck to do the same. It has its own user database and default authentication backend. I want to authenticate users with SSO user database and create a session on successful login into SSO application (DRF application in my case). I want to achieve following: In Django Application I click on login link. It redirect me to SSO login page and ask me to provide user credentials. On successful login I redirect back to Django application and land on dashboard page after auto login. If anybody can spare some time and let me know if I am getting wrong anywhere it will be helpful. Thank you in advance. -
How can you display only one product in the products page? Django
I'm trying to build a products page, but when I add two products for example, both of the products get displayed instead of just one. How can you fix that? I've been trying some solutions but without much luck and it is driving me crazy already. views.py: def productpage(request, slug): context = {'items': Item.objects.all()} return render(request, 'ecommerceapp/product-single.html', context) HTML code: <section class="ftco-section"> <div class="container"> <div class="row"> {% for item in items %} <div class="col-lg-6 mb-5 ftco-animate"> <a href="images/product-1.png" class="image-popup prod-img-bg"><img src='{% static "images/product-1.png" %}' class="img-fluid" alt="Colorlib Template"></a> </div> <div class="col-lg-6 product-details pl-md-5 ftco-animate"> <h3>{{ item.title }}</h3> <div class="rating d-flex"> <p class="text-left mr-4"> <a href="#" class="mr-2">5.0</a> <a href="#"><span class="ion-ios-star-outline"></span></a> <a href="#"><span class="ion-ios-star-outline"></span></a> <a href="#"><span class="ion-ios-star-outline"></span></a> <a href="#"><span class="ion-ios-star-outline"></span></a> <a href="#"><span class="ion-ios-star-outline"></span></a> </p> <p class="text-left mr-4"> <a href="#" class="mr-2" style="color: #000;">100 <span style="color: #bbb;">Rating</span></a> </p> <p class="text-left"> <a href="#" class="mr-2" style="color: #000;">500 <span style="color: #bbb;">Sold</span></a> </p> </div> {% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} {% if item.discount_price %} <p class="price"><span>${{ item.discount_price }}</span></p> {% else %} <p class="price"><span>${{ item.price }}</span></p> {% endif %} <p>{{ item.description }} </p> <div class="row mt-4"> … -
Reverse for 'UserProfile' with arguments '('',)' not found. 1 pattern(s) tried: ['user/profile/(?P<pk>[0-9]+)/$']
Could someone please help with the template for the particular URL. Thanks in advance. Views.py class UserProfileView(DetailView): model = UserEntry template_name = 'userprofile_app/userprofile.html' def get_context_data(self, *args, **kwargs): users = UserEntry.objects.all() context = super(UserProfileView, self).get_context_data(*args, **kwargs) page_user = get_object_or_404(UserEntry, id=self.kwargs['pk']) context['page_user'] = page_user return context urls.py urlpatterns = [ path('entry/', UserRegistrationView.as_view(), name='UserEntry'), path('profile/<int:pk>/', UserProfileView.as_view(), name='UserProfile'), ] Templates <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <a class="navbar-brand" href="{% url 'UserProfile' UserEntry.id %}">EDIT PROFILE</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> -
Django: create new user with field which has ManyToMany relationship
Hi as I’m quite newby I’m trying to create a new user with ManyToMany relationship on account field: models.py class User(AbstractBaseUser, PermissionMixin): id = models.UUIDField(primary_key=True) name = models.CharField(max_length=250), account = models.ManyToManyField( 'accounts.Account', 'through=’Membership' ) class Account(models.Model): id = models.UUIDField(primary_key=True) name = models.CharField(max_length=250), class Membership(models.Model): id = models.UUIDField(primary_key=True) account = models.ForeignKey(‘accounts.Account’) permissions = models.ManyToManyField(‘accounts.Role’) What I need to achieve is after creating a new user the data from the api, I need to get this JSON: { id: 1, name: 'User 1', accounts: [ { id: 1, name: 'account1', permissions: [ { id: 1, name: 'permission1' } ] }, { id: 2, name: 'account2', permissions: [ { id: 1, name: 'permission' }, { id: 2, name: 'permission2' } ] } ] } So far I have only this and Im wondering how to deal with account with MAnyToMany relationship... user = models.User.objects.create_user( name='user 2', accounts= ???? ) ```’ Do I need to pass an array with accounts ids? but then how I can set the permission ? … Thanks in advanced!! -
How to get Sphinx doctest to reset the Django database after each test?
[TL;DR] When using Sphinx's make doctest, Django models created in tests are committed to the database; how do we prevent them auto-committing or to reset the database between each test (using a similar method to pytest)? Setup I created a basic Django application using the script: python -m pip install django sphinx pytest pytest-django pytest-sphinx django-admin startproject project_name cd project_name mkdir project_name/app python manage.py startapp app project_name/app touch pytest.ini touch conftest.py mkdir docs cd docs ; sphinx-quickstart ; cd .. (Creating separate source and build directories in sphinx-quickstart.) Then: Changed project_name/app/models.py to: """Models for the test application.""" from django.db import models class Animal(models.Model): """A django model for an animal. .. rubric: Example .. testsetup:: animal from project_name.app.models import Animal .. testcode:: animal frog = Animal.objects.create(name="frog") print( frog ) .. testoutput:: animal Animal object (1) """ name = models.CharField(max_length=200) Edited project_name/settings.py to add 'project_name.app' to the INSTALLED_APPS. Edited docs/source/conf.py to add the lines under "Path Setup": import os import sys import django sys.path.insert(0, os.path.abspath('../..')) os.environ['DJANGO_SETTINGS_MODULE'] = 'project_name.settings' django.setup() and, under "General Configuration", to set: extensions = [ "sphinx.ext.autodoc", "sphinx.ext.doctest", ] Replaced docs/source/index.rst with: .. toctree:: :maxdepth: 2 :caption: Contents: Project Name Documentation ========================== .. currentmodule:: project_name.app.models .. autoclass:: Animal Replace pytest.ini … -
Why isn't Admin detecting these models?
I'm making a kanban app to learn Django, and I've run into this problem: Admin doesn't pick up the models I've created. I had an existing Postgresql database with the necessary tables created, and autogenerated the models with python manage.py inspectdb. These are the relevant models: class Boards(models.Model): name = models.CharField(max_length=50) description = models.CharField(max_length=255) class Meta: managed = False db_table = "boards" class Columns(models.Model): name = models.CharField(max_length=25) board = models.ForeignKey(Boards, models.CASCADE, db_column="board") class Meta: managed = False db_table = "columns" class Cards(models.Model): name = models.CharField(max_length=140) description = models.TextField() deadline = models.DateTimeField() column = models.ForeignKey("Columns", models.CASCADE, db_column="column") class Meta: managed = False db_table = "cards" And this is the content of admin.py: from django.contrib import admin from .models import Boards, Columns, Cards admin.site.register(Boards) admin.site.register(Columns) admin.site.register(Cards) Just in case, these are the INSTALLED_APPS in settings.py: INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "rest_framework", ] Thanks in advance for the help! -
Django forms - how to select which model to create in the form
I have some loosely similar models that are separate but share a parent through concrete inheritance. Two of the models have the same form, so I want to be able to select which model to create within the form. To clarify, I want one of the fields to be a select field and the value of that field should tell the form which model class it is going to be creating. I have been trying to research this but I cannot find any related questions and all of my google searches are littered with "model form" and "model choice field" results. -
Deployment of Django project with Apache on windows AWS instance environment
I am trying to deploy a developed django project in AWS ec2 instance ( Windows instance server) with https. I have installed apache and configured the httpd.conf file. After configuration of public ip of ec2 instance in both django settings.py file and httpd.conf file , I tried to run the browser with public IP address of ec2 instance , it shows Internal server error. Kindly find the code of httpd.conf file: LoadFile "c:/users/sanmugapriyab/appdata/local/programs/python/python37/python37.dll" LoadModule wsgi_module "c:/users/sanmugapriyab/appdata/local/programs/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "c:/users/sanmugapriyab/appdata/local/programs/python/python37";" <VirtualHost *:80> ServerName localhost WSGIPassAuthorization On ErrorLog "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/logs/hawkproj.error.log" CustomLog "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/logs/hawkproj.access.log" combined WSGIScriptAlias / "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/wsgi.py" <Directory "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/hawkproj/"> <Files wsgi.py> Require all granted </Files> </Directory> Alias /static "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/static" <Directory "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/static"> Require all granted </Directory> Alias /media "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/media" <Directory "C:/users/sanmugapriyab/Desktop/hawk_web_version1/hawkproj/media"> Require all granted </Directory> </VirtualHost> Kindly do the needful and help me on resolve of this issue. -
which database should i use for large scale web apps?
which database should i use for large scale web apps? i am planning to build a large scale website which include several features q/a , messaging , image posting etc... on fiction if i am predicting almost 5 million users that consistently use all of the features. on large scale which database should i use in django for this application DATA BASE SHOULD HANDLE LARGE NUMBER OF USERS AND REQUEST I KNOW 5 MILLION IS VERY HUGE BUT STILL WHICH DB YOU GUYS PREFER