Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
What should I library should I use for authorize.net in django
there. I've been working on my friend's dad's restaurant website which is using django 3.1. I successfully integrated PayPal to the site, and I plan to add Authorize.net as well. I started researching, but I only found django-authorizenet, which does not support django 3.1. So the question is WHAT LIBRARY SHOULD I USE FOR MY SITE. Thank you in advance. -
How to filter sentences from an list of words in array in Django
I create like books site, I want to show related book by the title of this book, by at least 2 words to be accurate in suggest books, Firstly I split the title of the current book into an array of words like ['good', 'book', 'by', 'mickle'] and filter the books using title__icontains but it shows an empty list My question is how I can filter sentences from a list of words in an array? and if there is a better way to get the related objects by title at least two similar word from the title My Book title class Book(models.Model): author = models.models.ForeignKey(Account, on_delete=models.CASCADE) title = models.CharField(max_length=90, null=True, blank=True) My function to get the related books by title. class BookRelatedObj(ListAPIView): serializer_class = BookRelatedSerializer lookup_field = 'title' def get_queryset(self): book_pk = self.kwargs['pk'] book = Video.objects.get(pk=book_pk) lst = book.title split = lst.split() print(split) return Book.objects.filter(title__icontains=[split]) -
Trying to print out result from query set.. returning a tuple
I am trying to print out the query set just to determine what is being returned from the query but it is returning the error "str returned non-string (type tuple)" File "/Users/richard/Documents/FordHack/backend/fleetCommand/views.py", line 20, in findExistProp print(OrgList) File "/Users/richard/Documents/FordHack/fordHack/lib/python3.9/site-packages/django/db/models/base.py", line 521, in __repr__ return '<%s: %s>' % (self.__class__.__name__, self) TypeError: __str__ returned non-string (type tuple) My model is below: class FleetCommandModel(models.Model): vehicleId = models.CharField(max_length=255, blank=False, editable=False) uuid = models.CharField( max_length=32, default=hex_uuid, editable=False, unique=True, primary_key=True ) req_date = models.DateTimeField(auto_now_add=True, editable=False) ok_bySuper = models.BooleanField(editable=True, default=False) ok_byCustRep = models.BooleanField(editable=True, default=False) initiated_byWho = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.DO_NOTHING, related_name="initiated_byWho") Super_Ok = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, editable=False, on_delete=models.DO_NOTHING, related_name="Super_Ok") CustRep_Ok= models.ForeignKey(settings.AUTH_USER_MODEL, null=True, editable=False, on_delete=models.DO_NOTHING, related_name="CustRep_Ok") active_Req = models.BooleanField(editable=True, default=True) req = models.CharField(max_length=255, blank=False, editable=False) def __str__(self): return (f'vehicleId: {self.vehicleId}.',f'uuid: {self.uuid}.') My function to print out the query is below: def findExistProp(self, vehicleId): Org_obj = FleetCommandModel.objects.filter(active_Req=True).filter(vehicleId=vehicleId) if Org_obj: exist = True OrgList= list(Org_obj) print(OrgList) return {"exist":exist, "Org_obj":OrgList} else: return {"exist":False} -
Running Scrapy from a Django Channels -based script
I wanted to add an async behavior while scraping single items from a URL using a Scrapy spider. Having Django Channels working great for other projects, I thought I might go with it instead of a similar server like scrapyd. Although scrapy does everything expected; -generating a request, -scrape its content, -saving it to the DB, etc., it is generating an error that resulting in the Django channels socket failing before sending anything back to the client. Here is the error message I am receiving inside my terminal: Web_1 | 2021-07-05 22:24:32 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min) web_1 | 2021-07-05 22:24:32 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023 web_1 | 2021-07-05 22:24:32 [aioredis] DEBUG: Cancelling waiter (<Future cancelled>, [None, None]) web_1 | 2021-07-05 22:24:32 [aioredis] DEBUG: Waiter future is already done <Future cancelled> web_1 | 2021-07-05 22:24:33 [daphne.server] ERROR: Exception inside application: Task got bad yield: <Deferred at 0x7fddc8564f10> web_1 | Traceback (most recent call last): web_1 | File "/usr/local/lib/python3.8/site-packages/channels/staticfiles.py", line 44, in __call__ web_1 | return await self.application(scope, receive, send) web_1 | File "/usr/local/lib/python3.8/site-packages/channels/routing.py", line 71, in __call__ web_1 | return await application(scope, receive, send) web_1 | File "/usr/local/lib/python3.8/site-packages/channels/routing.py", line … -
count after difference between two columns with django
I have a table with the following data. table_1 col_a col_b 1 2 0 1 2 0 I want to add a with b. I can do this with annotate: table_1.objects.annotate(diff=F('col_a ')+F('col_b ')) what I can't do is apply a filter. Example. count where col_a + col_b is greater than 2: Desired result: 1 Can you help me? -
Value assigned to the function is not rendered
In class NewEntry, there is a variable called dis has value "d" assigned. In the function create, the value is set as "test". However, string "test" is not rendered. Why? I have tried global dis in the function but still not render "test" I have also tried it in a couple of other ways but I can't get it to change before it is sent to the client side. class NewEntry(forms.Form): dis = "d" title = forms.CharField(label="Title") title.widget = forms.TextInput(attrs={ "value": dis }) contentArea = forms.CharField(label="Content", widget=forms.Textarea()) This function should be able to set the value for the class. def text(self,text): self.dis = text class searchEntry(forms.Form): q = forms.CharField(label="", widget= forms.TextInput(attrs={'placeholder':'Search Encyclopedia'})) def index(request): return render(request, "encyclopedia/index.html", { "entries": util.list_entries() }) def create(request): if request.method == "POST": form = NewEntry(request.POST) form.dis = "test" if form.is_valid(): title = form.cleaned_data["title"] contentArea=form.cleaned_data["contentArea"] if (util.get_entry(title) is None): messages.success(request, f'"{title}" is created!') util.save_entry(title, contentArea) messages.success(request, f'"{title}" is created!') ##return HttpResponseRedirect(reverse('entry',kwargs = {'title':title})) return redirect('entry',args=[title]) else: messages.info(request,'Title exists') return render(request,"encyclopedia/create.html",{ "form":form }) return render(request, "encyclopedia/create.html",{ "form":NewEntry(),NewEntry.text(NewEntry(),"test"):"test" }) -
How to show different messages based on Query strings in Django?
I have a login page. It has a message that I can dynamically generate based on request method by configuring the view. I also have a logout button custom admin panel. That logout button redirects to login page. All I want is to show two different messages in the login page. One will be general message when you go to login page and another one when you come to login page by clicking on logout (redirected to login page) Both are GET method. So how will I make it possible? I got one response asking me to add query string after in the logout redirect url like 'login?logOut=True' and then use it as a parameter in view. But I don't know how to do that. Please help. -
Pass id from button in template to Django View
im on my 2nd week trying to learn Python+Django and wanted to make a litte project. But im getting stuck on some JS-bs. I don't know JS well at all and would need some help. I want to pass the ID ("Value" in the button) of the selected button as data in the Ajax function, but can't really get this to work. How do i pass the value to the Ajax function? I want to use the value in the "id" variable in views. Thank you! HTML - I want to pass an ID of selected pressed button. {% for product in products %} <button type="button" id="submit" class="btn" value="{{product}}">{{product}}</button> {% endfor %} Javascript To the Ajax POST function here. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> var data = new FormData(); $(document).on('click', '#submit', function(e) { data.append('action', 'toggle_button') data.append('csrfmiddlewaretoken', '{{ csrf_token }}') $.ajax({ type: 'POST', url: '{% url "toggle_button" %}', data: data, cache: false, processData: false, contentType: false, enctype: 'multipart/form-data', }) }) </script> Django view file from django.http import HttpResponse, request from django.shortcuts import render from django.http import JsonResponse def home_view(request): context = { "products": ["Button1", "Button2", "Button3", "Button4"], } return render(request, "home.html", context) def toggle_button_view(request): if request.POST.get('action') == 'toggle_button': token = request.POST.get('csrfmiddlewaretoken') id = … -
How can i use Django signals for price calculations for items?
Info: Hello! i am trying to make an monthly installment app using Django my models are fine but i don't understand how can i calculate items price using Django signals i want to save Property calculate price in database. I want to calculate property price with Payment amount and get remaining price and save into database. Models.py class Property(models.Model): area = models.CharField(max_length=255) price = models.IntegerField(default=0) class Customer(models.Model): name = models.CharField(max_length=255) prop_select = models.ForeignKey(Property, on_delete=models.SET_NULL, null=True) class Payment(models.Model): customer = models.ForeignKey(Customer, null=True, on_delete=models.SET_NULL, blank=True, related_name='payment') amount = models.IntegerField(default=0) remaining = models.IntegerField(default=0) -
unable to implement basic login in the django framework
I am trying as hard as I can to learn to concept of authentication within the Django framework. I am reading the documentation and trying to code similar which will help me get the subject. At the moment I am trying to implement a simple login which redirects to a page. If the user is logged in he should see a message other wise he should see a different message. This is my code. I have made a simple login form class LoginForm(forms.Form): username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput()) this is my login view def login_view(request): if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] password = form.cleaned_data['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return redirect('/users/success/') else: return redirect('/users/success/') else: form = LoginForm() return render(request, 'testauth/login.html', {'form': form}) (I know the above code is a little bit redundant ... at the moment this is not so important) and this is the success view def success_view(request): print(request.user) if request.user.is_authenticated: return HttpResponse("logged in") else: return HttpResponse("you are not logged in") The problem is, I always get the "logged in" message even with users which do not exist. I tried restarting the server my … -
What would be a good way to create a model for bunch of check boxes in Django?
I'm trying to create a model for these check boxes below. There is also dosage text input next to each check box. I think there should be a better way to save it to database rather than creating field for each check box and dosage text field in the model. -
Logging/print statements do not work in subprocess in Python Django application
In my Django project I have a file called views.py. There are a couple of logging/print statements there, which work fine. However, views.py calls another python script using subprocess’s run method. Surprisingly, no logging/print statements work in that script. This is how run() is being called: out= run([sys.executable, /path/to/script.py, param1, param2], shell=False, stdout=PIPE) Logging is configured like this in settings.py: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'class': 'logging.StreamHandler', }, }, 'loggers': { 'my_logger': { 'handlers': ['console'], 'level': 'INFO', }, }, } Please advise what is going wrong. Thanks. -
How to use Django-rest-resetpassword to update password in the database
I'm trying to use django-rest-resetpassword to create password reset session in my django app. The programme is returning token already, and when I send post request with the token I get a success message, but the password never enters the django-rest-resetpassword table in the database (Which was created when I migrated). And as such I'm unable to loginh with the new password. Please, is there anything missing from the code? I have the following blocks of code: urls.py path('account/password-reset/', include('django_rest_resetpassword.urls', namespace='password_reset')), views.py @receiver(reset_password_token_created) def password_reset_token_created(sender, instance, reset_password_token, *args, **kwargs): # send an e-mail to the user context = { 'current_user': reset_password_token.user, 'user_name': reset_password_token.user.user_name, 'email': reset_password_token.user.email, 'reset_password_url': "{}?token={}".format( instance.request.build_absolute_uri(reverse('password_reset:reset-password-confirm')), reset_password_token.key), 'site_name': "crispy" } # render email text email_html_message = render_to_string('account/user/reset_password.html', context) msg = EmailMultiAlternatives( # title: "Password Reset for {title}".format(title="Account API"), # message: email_html_message, # from: "noreply@example.com", # to: [reset_password_token.user.email] ) msg.attach_alternative(email_html_message, "text/html") msg.send() Templates User/rest_password.html {% load i18n %}{% autoescape off %}Hello from {{ site_name }}! You're receiving this e-mail because you requested to change your password. It can be safely ignored if you did not request a password reset. Click the link below to reset your password. {{ reset_password_url }} {% if user_name %}{% blocktranslate %}In case you forgot, … -
How to change content if the page is requested from a specific url in django?
Say I have two pages one is example.com/login and another page is example.com/admin And when I put the credentials on the login page I get redirected to the admin page. Admin page has a logout button. If I press that button then it redirects me to the login page again. What I exactly want to do is, I want to display a message "Login again" dynamically (I know how to display a message dynamically) but only when user gets redirected from the login page via admin panel. How can I do that? -
Photo does not display in Django
I spent a few hours trying to display the image in Django, I am trying to display a wordcloud in Django. Here's my views.py: import tweepy from tweepy.auth import OAuthHandler from .models import Tweet from .models import Dates from django.core.paginator import Paginator, EmptyPage, InvalidPage from django.shortcuts import render from django.db import models, transaction from django.db.models import Q import os import tweepy as tw import pandas as pd import nltk from .forms import TweetIDForm from wordcloud import WordCloud, STOPWORDS import matplotlib.pyplot as plt import pandas as pd from io import StringIO from django import template import urllib, base64 import io import requests consumer_key = 'IkzuYMak76UcXdnL9HabgIfAq' consumer_secret = 'Lt8wrtZ72ayMEcgZrItNodSJbHOPOBk5YnSpIjWbhXpB4GtEme' access_token = '1405021249416286208-GdU18LuSmXpbLTz9mBdq2dl3YqKKIR' access_token_secret = 'kOjGBSL2qOeSNtB07RN3oJbLHpgB05iILxT1NV3WyZZBO' def clean_tweet_id(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = TweetIDForm(request.POST) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required tweet_id = form.cleaned_data.get("tweet_id") auth = tw.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tw.API(auth, wait_on_rate_limit=True) twtjson = requests.get('https://publish.twitter.com/oembed?url=' + tweet_id + '&omit_script=true') tweets = twtjson.json() tweet = tweets.get('html') ida = tweet_id.split('/')[-1].split('?')[0] identification = int(ida) status = api.get_status(identification) user_name … -
Import model from one app to another app in Django
I am very new to Python and Django so please excuse this "noob" question! I have the following project structure: rr |-rr |-settings.py |-kg |-models.py |-lp |-lpint.py |-manage.py I have omitted all other files and dirs for brevity. The script I am working on is 'lpint.py' and this is not working out: #lpint.py from kg.models import ModelName I get the error: "ModuleNotFoundError: No module named 'kg'". . I have read a lot of SO answers on this and nothing seems to be working. I tried adding this to my lpint.py file: import os os.environ["DJANGO_SETTINGS_MODULE"] = "rr.settings" import django django.setup() And I get this error message: "ModuleNotFoundError: No module named 'rr'" Any input would be greatly appreciated! -
Django - Not Recognizing Javascript File - Problem with Static?
When I try to go to five_day_forecast.html I'm getting the error: 127.0.0.1/:3 GET http://127.0.0.1:8000/five_day/static/capstone/five_day.js net::ERR_ABORTED 404 (Not Found) It's not recognizing my Javascript file but I don't know why. Here is how my files are setup, I'm using Django: five_day_forecast.html currently is just: HELLO <script src="static/capstone/five_day.js"></script> I've tried having all my code there as well, or just this, and it still doesn't work. I don't understand because when I'm on home.html (which calls temp.js file) it works totally fine. And both js files are under static/capstone. I just don't know why it's not recognizing the js file here. -
trying to instantiate the record in a model for CRUD operations in Django getting error "update_user() missing 1 required positional argument: 'eid'
# models.py.......................................... from django.db import models class angelaFormModel(models.Model): First_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) phone = models.IntegerField() email = models.EmailField(max_length=50) confirm_email=models.EmailField(unique= True) password=models.CharField(max_length=50) confirm_password=models.CharField(max_length=50) def __str__(self): return self.First_name # forms.py.................................................... from django.forms import ModelForm from .models import angelaFormModel from django import forms class angelaFormModel_form(ModelForm): class Meta: model = angelaFormModel widgets = { 'password': forms.PasswordInput(), 'confirm_password': forms.PasswordInput(), } fields = '__all__' class angelaFormModelUpdate_form(ModelForm): class Meta: model = angelaFormModel widgets = { 'password': forms.PasswordInput(), 'confirm_password': forms.PasswordInput(), } fields = ['First_name', 'last_name', 'phone', 'password', 'confirm_password'] # views.py.................................................. from django.shortcuts import render, get_object_or_404, redirect from .forms import angelaFormModel_form, angelaFormModelUpdate_form from .models import angelaFormModel # working def home(request): return render(request, 'home.html') # working def create(request): if request.method == 'GET': return render(request, 'create.html', {'form': angelaFormModel_form, 'message': 'Please, fill the form carefully...'}) else: form = angelaFormModel_form(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') confirm_email = form.cleaned_data.get('confirm_email') password = form.cleaned_data.get('password') confirm_password = form.cleaned_data.get('confirm_password') if email != confirm_email: return render(request, 'create.html', {'form': angelaFormModel_form, 'message': 'Please, fill the form again! Provided email is not matching'}) if password != confirm_password: return render(request, 'create.html', {'form': angelaFormModel_form, 'message': 'Please, fill the form again!, Provided password is not matching'}) form.save() return render(request, 'create.html',{'form': angelaFormModel_form, 'message': 'Bingo! your form hase been submitted.'}) # return render(request, 'create.html') return … -
How to overwrite MinValueValidator error message in Django?
I have a field in the model: my_date = models.DateField('my date', validators=[MinValueValidator(date(2021, 1, 14))], null=True) and when my_date is earlier than 2021-1-14 i get message: Ensure this value is greater than or equal to 2021-01-14 but i want date in format: "%d.%m.%Y" so it should be: Ensure this value is greater than or equal to 01.14.2021 How to change format of date? maybe in forms.py? -
Turn off http buffering between Django and Windows IIS
I've created a web application using Django 3.2.3 and Python 3.6.8. The web app has a long running process so I use the Django yield function to output activity to the browser to keep the user informed. The app worked brilliantly in development until I moved it into production on a Windows server and fronted it with IIS, now the yield function is effectively crippled as IIS buffers the output before returning it to the user. Now they now sit and wait with a blank page for up to a minute and all the output is returned at once. This is a real shame as the app was informative and well presented until this point. Does anyone know of a way that I can disable buffering under IIS when used in conjunction with Python/Django so that the yield function can work again or, a creative way of achieving the same thing without the Django yield function. Thank you. -
Django admin page no reverse match error when adding a model instance
In the admin site, I get a NoreverseMatch error: raise NoReverseMatch(msg) django.urls.exceptions.NoReverseMatch: Reverse for 'Main_client_change' with arguments '('',)' not found. 1 pattern(s) tried: ['admin/Main/client/(?P<object_id>.+)/change/$'] Command Prompt: (virtualEnv) C:\Users\maria\Desktop\siteLast\djangoProject>python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). July 05, 2021 - 14:02:52 Django version 3.2.5, using settings 'djangoProject.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [05/Jul/2021 14:02:54] "GET /admin/Main/client/add/ HTTP/1.1" 200 14835 Internal Server Error: /admin/Main/client/add/ Traceback (most recent call last): File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\contrib\admin\options.py", line 616, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner return view(request, *args, **kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\contrib\admin\options.py", line 1657, in add_view return self.changeform_view(request, None, form_url, extra_context) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\contrib\admin\options.py", line 1540, in changeform_view return self._changeform_view(request, object_id, form_url, extra_context) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\contrib\admin\options.py", line 1591, in _changeform_view return self.response_add(request, new_object) File "C:\Users\maria\Desktop\siteLast\virtualEnv\lib\site-packages\django\contrib\admin\options.py", line 1182, in … -
DRF - Create Serializer: accepting ForeignKey data with Non-Primary Field value
I am totally new to Django/DRF, and trying to work with Create/Read/Update of a Model. Here are the dummy model/serializers: AddressModel and UserModel: class AddressModel(models.Model): name = models.CharField(max_length=255) street = models.CharField(max_length=255) class UserModel(models.Model): email = models.CharField(max_length=255) address = models.ForeignKey(Address, on_delete=models.PROTECT) And I have BaseSerializer and WriteSerializer: class UserBaseSerializer(serializers.ModelSerializer): email = serializers.CharField(required=True) address = AddressSerializer() class Meta: model = User fields = ['email', 'address'] class UserWriteSerializer(UserBaseSerializer): class Meta(UserBaseSerializer.Meta): read_only_fields = ["created_by"] def create(self, validated_data): return super().create(validated_data) Now the problem is, reading data through BaseSerializer, is working fine, I am able to display User and Address on UI correctly. But having issues with Create/Update. For creating new user from UI, I have a select dropdown for Address, which has some constant values, these constant values are on UI side, it's not getting fetched from Backend. But backend will have related row in database. And the issue is, I am not sending primary key of the address, I am sending name field of the address in the post call, so how can I still handle name field on Create serializer to store correct address, and return it in success? validated_data in create method does not contain Address instance. It's omitting that, may be … -
Docker doesn't refresh code inside it when I pull my backend repo
I'm getting this issue when I deploy my code it works fine. But when I pull the main branch again then the code in my repo is the latest but not inside the docker container. I know it's because the volume is already created but I want them to sync whenever I pull new changes. so this is my main docker-compose.prod.yml file: - version: '3' services: django: build: context: ./ dockerfile: docker-compose/django/Dockerfile.prod expose: - 8000 volumes: - static_volume:/app/django/staticfiles environment: CHOKIDAR_USEPOLLING: "true" stdin_open: true tty: true env_file: - ./.env.prod nginx-proxy: container_name: nginx-proxy build: nginx restart: always ports: - 443:443 - 80:80 volumes: - static_volume:/app/django/staticfiles - certs:/etc/nginx/certs - html:/usr/share/nginx/html - vhost:/etc/nginx/vhost.d - /var/run/docker.sock:/tmp/docker.sock:ro depends_on: - django nginx-proxy-letsencrypt: image: jrcs/letsencrypt-nginx-proxy-companion env_file: - .env.staging.proxy-companion volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - certs:/etc/nginx/certs - html:/usr/share/nginx/html - vhost:/etc/nginx/vhost.d depends_on: - nginx-proxy volumes: static_volume: certs: html: vhost: Then I have my Dockerfile.prod: - ########### # BUILDER # ########### # pull official base image FROM python:3.9.1-buster as builder # set work directory WORKDIR /app # set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # install psycopg2 dependencies RUN apt-get update && apt-get -y install libpq-dev gcc && pip install psycopg2 && apt-get -y install nginx # lint RUN pip install … -
If statement in table in django-templates
say we have table in template <table class="table"> <thead> <tr> <th>Status</th> </tr> </thead> <tbody> {% for student in students %} <tr> {% if {{student.academic_status}}=="promoted" %} <td class=text-success>promoted</td> {% endif %} </tr> {% endfor %} </tbody> </table> So is it possible using if statement in table in django-templates -
Question related to MySQL , html,css,js,django
Hi I was making a website but when I decided to use MySQL with django as database I had question from where do you connect your MySQL to your website while hosting your website,is it in the server or you should have a api or what ? Please help if you can