Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
In Django, how to create file field database variable in a query?
I know how to create a simple query variable in views.py But I don't know what it represents. As for an instance there is a CharFiled in models.py (model name being Information) named age. And to store a single row's data in a variable one could use either var1 = Information.objects.order_by('-id')[:1] OR var2 = Information.objects.order_by('-id')[:1].get() From this what I'm understanding is that in var1 stores the queryset list and var2 stores the actual object. Please correct me if I'm wrong. Does it mean the var2 has the actual value of the age parameter from the database? If not, then var2 just point to that location? Moreover, let's say there is a FileFiled called userfile in the models.py along with age and that takes in the any file user wants to store on the DB. Let's assume the file is uploaded through the form and the whole uploading function is working just fine. Now I want to reduce the userfile into half, so for that I need to store the file's data in a variable at first. Can I do file_data = var2.userfile or file_data = var1.userfile? Again, what will be in file_data? Path to the file in DB or the … -
Localization_fields: as per Django Documentation & tutorial still gives error
I am practice on Django documentations on ModelForms and copying it as mentioned in docs still getting error Please advise what is wrong here As per Django Docs By default, the fields in a ModelForm will not localize their data. To enable localization for fields, you can use the localized_fields attribute on the Meta class. Code is as follows >>> from django.forms import ModelForm >>> from myapp.models import Author >>> class AuthorForm(ModelForm): ... class Meta: ... model = Author ... localized_fields = '__all__' If localized_fields is set to the special value '__all__', all fields will be localized. Error is as follows ile "/Users/rishipalsingh/Projects/notes/mdndjango/venv/lib/python3.9/site-packages/django/forms/models.py", line 250, in __new__ raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form AuthorForm needs updating. -
What is the proper way to add authentication to my django-react blog app
I have my blog app using Django in the backend and React on the front. I want that only an authenticated user can do some actions such as delete and edit articles on the front end. The front end is communicating with the backend via Restful APIs My project structure at the moment is this base-project backend blog frontend manage.py db.sqlite3 At a later stage, I plan to move the frontend to make it an independent folder. Do I have to create another Django app to deal with users or there is another way. Please share any reading materials on this that you think can help. The tutorials I see online are either building a blog or a users portal but what is the way to combine the two -
Stripe AttributeError: 'str' object has no attribute 'objects' (custom user model)
I'm trying to configure Django Stripe Subscriptions. And now trying to setup webhook to create a new customer data by below code. views.py import stripe from django.conf import settings from django.contrib.auth.models import User from subscriptions.models import StripeCustomer @csrf_exempt def stripe_webhook(request) ... #Get the user and create a new StripeCustomer user = settings.AUTH_USER_MODEL.objects.get(id=client_reference_id) StripeCustomer.objects.create( user=user, stripeCustomerId=stripe_customer_id, stripeSubscriptionId=stripe_subscription_id, ) print(user.username + ' just subscribed.') Traceback and Error message is below. Traceback (most recent call last): File "/home/app_admin/venv_ruling/ruling/subscriptions/views.py", line 125, in stripe_webhook user = settings.AUTH_USER_MODEL.objects.get(id=client_reference_id) AttributeError: 'str' object has no attribute 'objects' I'm following this manual to create this app https://testdriven.io/blog/django-stripe-subscriptions/ The manual specify the code below. user = User.objects.get(id=client_reference_id) but I'm using "custom user model". therefore I changed the above code to below user = settings.AUTH_USER_MODEL.objects.get(id=client_reference_id) Below is other codes. My models.py from django.conf import settings from django.db import models class StripeCustomer(models.Model): user = models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE) stripeCustomerId = models.CharField(max_length=255) stripeSubscriptionId = models.CharField(max_length=255) def __str__(self): return self.user.username accounts/models.py from django.contrib.auth.models import AbstractUser class CustomUser(AbstractUser): class Meta: verbose_name_plural = 'CustomUser' My settings.py #used for django-allauth AUTH_USER_MODEL = 'accounts.CustomUser' I just mentioned the above settings in this question but still if more code is required then tell me I'll update my question with that information. … -
Can Anyone Explain what keys are in dict of jwt when generating key
Can anyone help regarding this?? I generated a key in python using jwt using below command and stored in a variable key key = jwk.JWK.generate(kty='RSA', size=512) and when i used key.export() it returned the below dict {'d': 'Z1apo6KRMoS0xyqqTu7lEwZ7f_AON_tve42nSUkwXypMF1rDNj_xgIn9J5I4TvAisUaRYq82uZfYf76eMgj8uQ', 'dp': '4k-hSfYmT8H2zdHVFVQpBD-_w5G9ASSADgKn3F08AAs', 'dq': 'E4fXlCY6oT3yPTnOb3LvLxMtKDPmwoI-FLYbNP2L0-k', 'e': 'AQAB', 'kty': 'RSA', 'n': 'wuALgiButVPQy8bCnSkvU-QlBqYB5pk6rfwlcTr-csc8DOvPzekHJYWPjbP_ptAxSW3r5Bnpac1MDgMQKFjOtw', 'p': '8ZI61ugJ3WblKvY-JfkyWXUcdoGAWQB8B9VcfWRvLuM', 'q': 'zoPN8ItkA_0rf_XobRkjhYIdtoXyOLXCqYSU0i8etR0', 'qi': 'JhXuF6EDTrrPysGzsVhco4hpVsSHCXgS7UGZUISc2Ug'} can anyone explain what are the keys in this dict like d, dp, dq, e, n, p, q, qi Thank you in advance -
Django channels and websocket not working
I've checked all the related questions none of them helped me. I'm making a simple application where I will get JSON responses on the websocketking.com site. No matter how many times I make changes none of the tries are working. here every detail asgi.py file import os from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter from django.core.asgi import get_asgi_application from django.urls import path from home.consumers import * os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') ws_patterns = [ path('ws/test/', TestConsumer), ] application = ProtocolTypeRouter({ "http": get_asgi_application(), "websocket": AuthMiddlewareStack(URLRouter(ws_patterns)), }) consumers.py file from channels.generic.websocket import WebsocketConsumer from asgiref.sync import async_to_sync import json class TestConsumer(WebsocketConsumer): def connect(self): self.room_name = "test_consumer" self.room_group_name = "test_consumer_group" async_to_sync(self.channel_layer.group_add)(self.room_name, self.room_group_name) self.accept() self.send(text_data=json.dumps({'status' : 'connected'})) def receive(self): pass def disconnect(self): pass These are the things I added in my settings.py file ASGI_APPLICATION = 'core.asgi.application' CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { "hosts": [("localhost", 6379)], }, }, } And here is the error I got in console WebSocket HANDSHAKING /ws/test/ [127.0.0.1:2795] Exception inside application: object.__init__() takes exactly one argument (the instance to initialize) Traceback (most recent call last): File "D:\PythonProjects\channels_project\env\lib\site-packages\channels\staticfiles.py", line 44, in __call__ return await self.application(scope, receive, send) File "D:\PythonProjects\channels_project\env\lib\site-packages\channels\routing.py", line 71, in __call__ return await application(scope, receive, send) File "D:\PythonProjects\channels_project\env\lib\site-packages\channels\sessions.py", … -
How to Assign User Permission using action drop-down in Django Admin
I am trying to assign permission for multiple selected users through Admin Action dropdown. So select the multiple user using check box and click on action dropdown and select assign user permission and click on the go button after that it will go to the next page where I am showing all models permission related to the project. But when I selected multiple or single permission and click on the submit button then nothing is happening. admin.py class AssignUserPermissionForm(forms.ModelForm): permission = forms.ModelMultipleChoiceField(queryset= Permission.objects.all()) class Meta: model = Permission fields = ('permission',) def assign_user_permissions(modeladmin, request, queryset): if request.method == "POST": form = AssignUserPermissionForm(request.POST) if form.is_valid(): print('---form valid---------') multi_val = form.changed_data['Permission'] print(multi_val,'-------') else: form = AssignUserPermissionForm() return render(request, "admin/assign_user_permissions.html", context= {'permission_list': form}) assign_user_permissions.short_description = 'Assign User Permissions' class UserProfileAdmin(SimpleHistoryAdmin, ImportExportActionModelAdmin): # form = AssignUserPermissionForm resource_class = UserProfileExport formats = ( base_formats.CSV, base_formats.XLS, ) filter_horizontal = ('skillset',) inlines = [SampleFileAdmin,] # user_first_name() list_display = ('full_name', 'is_approved', 'is_active', 'is_fixed_pricing_fl', 'created', 'updated') list_filter = (('created', DateRangeFilter), ('updated', DateRangeFilter), ContactLinksFilter, 'is_approved', 'is_active', 'skillset') search_fields = ('user__username', 'user__email', 'user__contact_no',) raw_id_fields = ('user',) history_list_display = ["status"] actions = ['send_mail', 'reset_password', assign_user_permissions, get_user_last_work] -
Cannot resolve NoReverseMatch error in Django
I am new in Django and try to make a quick search engine, but I have this error and cannot fix it after reading Django documentation. Could anyone help me? Thanks. This is the error: Reverse for 'search' with no arguments not found. 1 pattern(s) tried: ['(?P<name>[^/]+)$'] My codes are as below: layout.html <form method="POST" action="{% url 'encyclopedia:search' %}"> {% csrf_token %} <input class="search" type="text" name="q" placeholder="Search Encyclopedia"> <input type="submit" value="Go"> </form> urls.py from django.urls import path from . import views app_name = "encyclopedia" urlpatterns = [ path("", views.index, name="index"), path("<str:name>", views.entry, name="entry"), path("<str:name>", views.search, name="search") ] views.py def search(request, searched_name): """ Deal with search engine on the left widget """ result = util.get_entry(searched_name) if result: return HttpResponseRedirect(reverse('encyclopedia:entry', args=(result))) return render(request, "encyclopedia/error.html", { "error_name": "Requested page not found" }) -
Django DetailView with custom identifier (not pk): Field 'id' expected a number but got 'XQ1wfrpiLVAkjAUL'
I am using Django 3.2 I have a model and GCBV defined as follows: class Foo(models.Model): identifier = models.CharField(max_length=16, db_index=True) # ... class FooDetailView(DetailView): model = Foo template_name = 'foo_detail.html' pk_url_kwarg = 'identifier' # TODO, need to add logic of flagged items etc. to custom Manager and use that instead queryset = Foo.objects.filter(is_public=True) # # FIXME: This is a hack, just to demo # def get_object(self, queryset=None): # objs = Foo.objects.filter(identifier=self.request.GET.get('identifier', 0)) # if objs: # return objs[0] # else: # obj = Foo() # return obj In urls.py, I have the following statement: path('foo/view/<str:identifier>/', FooDetailView.as_view(), name='foo-detail'), Why is Django expecting a number (even though I have explicitly specified a string - AND also provided a pk_url_kwarg parameter)? How do I fix this? -
Cannot send my output from views.py to template in django
what my application does is capture live images and extract some values using google vision ocr. I get data from an external python script and i want to show the output in html text field. here is my views.py template from django.shortcuts import render, render_to_response from django.http import HttpResponse from django.http import JsonResponse from .models import TemperatureRecordsF, TemperatureRecordC , BloodPressureRecord , SPO2Levels import sys import base64 from PIL import Image from subprocess import run, PIPE def button(request, *args, **kwargs): return render(request,'capturr1.html',) def external(request, *args, **kwargs): request_getdata = request.POST.get('img64',None) selected_radio = request.POST.get('radio_seleect',None) print(selected_radio) # print(request_getdata) headed, encoded = request_getdata.split(",",1) data = base64.b64decode(encoded) with open("D:/dev/django/src/OCR/media/image.png", "wb") as f: f.write(data) path = 'D:/dev/django/src/OCR/media/image.png' out = run([sys.executable,'D://dev//django//src//OCR//detect_text.py',path],shell=False,stdout=PIPE) print(out.stdout) context = { 'output' : out.stdout } return render(request,'capturr1.html',context) Here is my template capturr1.html <form class="contentarea" action="/external" method="POST" id="capture" name="capture"> {% csrf_token %} <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> <label class="form-check-label" for="inlineRadio1">Temperature °F</label> <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> <label class="form-check-label" for="inlineRadio2">Temperature °C</label> <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> <label class="form-check-label" for="inlineRadio3">Blood Pressure</label> <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio4" value="option4"> <label class="form-check-label" for="inlineRadio4">Oxygen Saturation Levels</label><br> <video id="video">Video stream not available.</video><br> <button id="startbutton">Take photo</button> <input type="submit" value="Save" class="save" name="savebutton"/> <input type="text" />{{ output }} <canvas id="canvas" style="display: none;"><br> … -
Using tailwind with django ckeditor?
So I have a project with Tailwind and Django 3. I needed a syllabus field for the project and went with Django-ckeditor. The package worked great but after uploading the text on the RichTextField, it's rendered as normal HTML and I want it to work with a tailwind. As tailwind uses classes to convert CSS utilities, is there a way I can use the CKEditor and render the file with applied tailwind classes in the HTML? I could not find much in the docs Thanks -
DjangoModelPermissions is not working for view level permission in my API application
I have created an API and I am trying to provide permissions to the views in my API app. I have assigned users to groups with permissions in my admin portal and then I am using DjangoModelPermissions in my views so that the permissions behave according to the admin portal which is not working. When I use IsAdminUser then its working it is preventing other users to read the view. but for DjangoModelPermissions it is not working. Users and Groups in my admin group One super_user assigned to Developers groups with all permissions. One Testuser assigned to Language groups with only access to language view. The code for Model from django.db import models class Paradigm(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name # Create your models here. class Language(models.Model): name = models.CharField(max_length=50) paradigm = models.ForeignKey(Paradigm,on_delete=models.CASCADE) # this method will help us to get the actual Name insted of object name def __str__(self): return self.name class Programmer(models.Model): name = models.CharField(max_length=50) languages = models.ManyToManyField(Language) def __str__(self): return self.name The Code for view from django.shortcuts import render from rest_framework import viewsets, permissions from .models import Language, Programmer, Paradigm from .serializers import LanguageSerializer, ParadigmSerializer, ProgrammerSerializer from rest_framework.permissions import BasePermission, IsAdminUser, DjangoModelPermissions # Create your … -
Error when using elasticsearch with django
I'm trying to use elasticsearch for my django project and following this tutorial with my own model: https://django-elasticsearch-dsl.readthedocs.io/en/latest/quickstart.html#populate My model: class Product(models.Model): STATUS = ( ('True', 'True'), ('False', 'False'), ) title = models.CharField(max_length=150) keywords = models.CharField(max_length=255) description = models.TextField(max_length=255) price = models.DecimalField(max_digits=12, decimal_places=2,default=0) image=models.ImageField(blank=True) amount=models.IntegerField(default=0) minamount=models.IntegerField(default=3) slug = models.SlugField(null=False, unique=True) status=models.CharField(max_length=10,choices=STATUS) create_at=models.DateTimeField(auto_now_add=True) update_at=models.DateTimeField(auto_now=True) rating = models.IntegerField(default=0) def __str__(self): return self.title my documents.py: # documents.py from django_elasticsearch_dsl import Document from django_elasticsearch_dsl.registries import registry from .models import Product @registry.register_document class CarDocument(Document): class Index: # Name of the Elasticsearch index name = 'products' # See Elasticsearch Indices API reference for available settings settings = {'number_of_shards': 1, 'number_of_replicas': 0} class Django: model = Product # The model associated with this Document # The fields of the model you want to be indexed in Elasticsearch fields = [ 'title', 'keywords', 'status', 'description', ] # Ignore auto updating of Elasticsearch when a model is saved # or deleted: # ignore_signals = True # Don't perform an index refresh after every update (overrides global setting): # auto_refresh = False # Paginate the django queryset used to populate the index with the specified size # (by default it uses the database driver's default setting) # queryset_pagination = 5000 … -
Minor trouble installing mod_wsgi into venv
I thought this question would help me understand my file system and how mod_wsgi installs on my macOS (even though i am also stuck). Simply i am experimenting with django and apache. i have two different django projects (very basic tutorials) with venv's and one basic web app in each. I have pip installed mod_wsgi into one and it has added the package to the venv successfully and runs fine. When i tried the other venv it replied: - Requirement already satisfied: mod_wsgi in /Users/mjwallis/opt/anaconda3/lib/python3.7/site-packages (4.8.0) I must have installed mod_wsgi more globally prior in this case (can't remember what i did). Guess this is v basic of me to ask for help but i have been hitting a wall for some reason! Also this my first StackOverflow question! If anyone has time to reply it would be a relief!! -
How to check if an object has more than constant number of many to many field objects
I have 2 tables say "A" and "B" having ManyToMany relationship with one of the field with table "A", I have created a Model Admin from where I am creating both the tables object. I have a constraint that I have to create constant number of "B" object for each fields (relation) I have written below code but it gives an error: ValueError: “needs to have a value for field ”id“ before this many-to-many relationship can be used count = 10 class A(models.Model): field_a = models.CharField(max_length=100) class B(models.Model): field_b = models.CharField(max_length=100) fields = models.ManyToManyField(A, related_name="bs") def save(*args, **kwargs): for item in self.fields.all(): if item.bs.count() > count: raise ValidationError( "item count is exeeded" ) return super(B, self).save(*args, **kwargs) Please suggest how to handle this case. -
How can I make a separate database in django and not use the default database?
Okay, so I am a complete newbie and this might be a silly question but I couldn't find any answer related to this. I have created a login page using google authentication and it works perfectly but the problem it saves the user data directly into default database but I want it to be stored in my own mysql database. I want it to store the information that google authentication gave and store it in mysql database i.e email,name,etc . -
How to use cryptography to get private key of x509 certificate
As title, I have google many different way to get the private key from X509 certificate but unfortunately none of the solutions work for me. I have try solution from https://pyjwt.readthedocs.io/en/latest/faq.html but when I try to retrieve the private key, it give me the error message of '_Certificate' object has no attribute 'private_key' -
Django: Override SimpleListFilter get_queryset method (super(type, obj): obj must be an instance or subtype of type)
I'm trying to make a filter for users to filter them by created drafts. I'm stuck inside overriding the get_queryset. This is the error I get: super(type, obj): obj must be an instance or subtype of type What am I missing? class DraftFilter(SimpleListFilter): title = _('created drafts') parameter_name = 'user_drafts' def lookups(self, request, model_admin): return( ('has_drafts', 'Yes'), ('no_drafts', 'No'), ) def queryset(self, request, queryset): def get_drafts(status): return super().get_queryset(request).annonate( is_draft=Exists(Operation.objects.all().filter( company_id=OuterRef('active_company_id'), is_draft=status)) ) if not self.value(): return queryset if self.value().lower() == 'has_drafts': return get_drafts(True) if self.value().lower() == 'no_drafts': return get_drafts(False) -
Is there a way to call a django model function from a template inside an javascript function?
I am trying to trigger my note.send function (from a method) whenever I call a javascript function. Here is my Javascript code. function send_mail(){ {{ note.send }} } I then call the function send_mail() whenever an specific action happens on the website, however the django template function is called each time I reload the website even if I don't call the javascript function at all. Please help -
Here, i want to achieve that I want to take my current site's URL (not using forms) and convert those into short urls and display it here
in this picture I have written what i wanted to achieve. I am trying to use hashlib, but i am not able to do the following. This is my views. def SaveURL(request): full_url = request.META['HTTP_HOST'] obj = create_short_url('full_url') url = full_url=full_url, obj=obj url.save() return render(request, 'link.html', {"full_url": obj.full_url, "short_url": request.get_host()+'/'+obj.short_url}) #generating short link def create_short_url(self, request, full_url): temp_url = md5(full_url.encode()).hexdigest()[:8] try: obj = self.objects.create(full_url=full_url, short_url=temp_url) except: obj = self.objects.create(full_url=full_url) return render(request, 'link.html', {"obj": obj}) This is my html template, its just not so clean , plz help. #this is my original url {{ request.scheme }}://{{ request.META.HTTP_HOST }}{{ request.path }} #IT DISPLAYS - http://127.0.0.1:8000/product/product_view/10001 But i have not achieved the soln. -
Error 400 when adding Google Analytics Script
I put a Google Analytics tag in the header of my website: <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-V51YR2QF7N"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-V51YR2QF7N'); </script> But even after reloading the website in my pythonanywhere integrated development environment, still no statistics appear. I ran this code locally and here are the errors: (dja_env) C:\Users\antoi\Documents\Programming\Projects\django3-personal-portfolio>python manage.py runserver Looks like no local file. You must be on production Looks like no local file. You must be on production Performing system checks... System check identified some issues: WARNINGS: blog.Blog: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the BlogConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. portfolio.Project: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the PortfolioConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. System check identified 2 issues (0 silenced). May 30, 2021 - 21:20:44 Django version 3.2.3, using settings 'personal_portfolio.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [30/May/2021 21:22:47] "GET / HTTP/1.1" 400 143 … -
Set different logout time for different users in django?
Can anyone know how to set session timeout per user in Django? I'm building a system where I need to set a user timeout session, if a user is failed to perform any action till a timeout setting then he will be logout of the system. Is this possible in Django? -
Django Rest Framework Create New Data If Not Exist
I have been created a new user to user messaging app on Django. I want to if there is no User1i and User2ii created ever create new one and if it exist return the ID of this conversation. views.py class ConversatViewSet(viewsets.ModelViewSet): serializer_class = ConversatSerializer authentication_classes = (JSONWebTokenAuthentication,) permission_classes = (IsAuthenticated,) def get_queryset(self): queryset = Conversation.objects.all() return queryset models.py class Conversation(models.Model): User1i = models.ForeignKey(User, related_name='u1', on_delete=models.CASCADE) User2ii = models.ForeignKey(User, related_name='u2', on_delete=models.CASCADE) class Meta: unique_together = ('User1i', 'User2ii') JSON output [ { "id": 1, "User1i": 1, "User2ii": 2 }, { "id": 2, "User1i": 3, "User2ii": 1 }, { "id": 3, "User1i": 3, "User2ii": 2 } ] For example if "POST" to '1' as "User1i" and '2' as "User2ii" return the ID of conversation ("id": 1,) and if "POST" TO '4' as "User2i" and '2' as "User2ii" create a new conversation and return it's ID. -
supervisord/celery/python - "dynamic" environment variables - "global" versus "local" - DRY
Let's imagine I have the following /etc/supervisord.conf main file: [unix_http_server] file = /tmp/supervisor.sock [supervisord] <snip> environment = STATIC_VAR="foo", DYNAMIC_VAR="bar_%%s" [include] files = /etc/supervisord.d/worker1.conf /etc/supervisord.d/worker2.conf The worker1 and 2 files: [program:worker1] environment = WORKER_1_VAR_1"toto", WORKER_1_VAR_2="toto_too" [program:worker2] environment = WORKER_2_VAR_1"toto", WORKER_2_VAR_2="toto_too" (skipping the other file contents as they are not relevant) My supervisor version is 3.4.0 on Centos 7.9. This runs within a virtualenv on the back on Python 3.9.0 MAIN GOAL: Somewhere in the code run by one of the workers, something like this will occur (the "%%s" turned into "%s" will be replaced by a dynamic value): from django.conf import settings final_value = settings.DYNAMIC_VAR % ('replacement_string_of_some_kind') What happens is the above always results in an error upon supervisor startup: Error: Format string <snip> for 'supervisord.environment' is badly formatted: not enough arguments for format string HOWEVER, if I remove the supervisord.environment section from the main configuration file, and copy its contents to the individual worker files, startup occurs normally. For example: [program:worker1] environment = STATIC_VAR="foo", DYNAMIC_VAR="bar_%%s", WORKER_1_VAR_1"toto", WORKER_1_VAR_2="toto_too" Am I doing something wrong? Is there some kind of "double parsing" happening upon startup? Can this even be made to work. Asking because my list of "global env variables" is quite long, … -
Render dynamic value inside content django template
Please, I would like to render a varible in django template, kind of {{ user.name }} inside of a textfield from database, that I filled up on the django admin. like this how can I manage to achieve it please, thank you all, have a good day.