Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django-import-export package get Foreignkey value while Export to XL file
First pardon me for my bad english. I am very new in Django Framework. I want to Export a foreignkey value called title which is in 'Product' model. There is multiple Foreignkey Relations between different django app models. Please take a look below all of this models: products/models.py class Product(models.Model): title = models.CharField(max_length=500) brand = models.ForeignKey( Brand, on_delete=models.CASCADE, null=True, blank=True) image = models.ImageField(upload_to='products/', null=True, blank=True) price = models.DecimalField(decimal_places=2, max_digits=20, default=450) old_price = models.DecimalField( default=1000, max_digits=20, decimal_places=2) weight = models.CharField( max_length=20, help_text='20ml/20gm', null=True, blank=True) size = models.CharField( max_length=10, help_text='S/M/L/XL/32/34/36', null=True, blank=True) active = models.BooleanField(default=True) timestamp = models.DateTimeField(auto_now_add=True) update = models.DateTimeField(auto_now=True) carts/models.py class Entry(models.Model): product = models.ForeignKey(Product, null=True, on_delete=models.CASCADE) cart = models.ForeignKey(Cart, null=True, on_delete=models.CASCADE) quantity = models.PositiveIntegerField(default=1) price = models.DecimalField(default=0.00, max_digits=100, decimal_places=2) last_purchase_price = models.DecimalField( default=0.0, max_digits=20, decimal_places=15) weight_avg_cost = models.DecimalField( default=0.0, max_digits=20, decimal_places=15) updated = models.DateTimeField(auto_now=True) timestamp = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['-timestamp'] And my working models is analytics/models.py, from where I want to export the product title in XL sheet. class AllReportModel(models.Model): # All report model invoice = models.ForeignKey(Invoice, on_delete=models.CASCADE, null=True, blank=True) ws_invoice = models.ForeignKey(WholesaleInvoice, on_delete=models.CASCADE, null=True, blank=True) entry = models.ForeignKey(Entry, on_delete=models.CASCADE, null=True, blank=True) stock_quantity = models.IntegerField() timestamp = models.DateTimeField(auto_now_add=True) update = models.DateTimeField(auto_now=True) and Finally analytics/admin.py is : class … -
unknown directive "mywebsite.co.uk" in /etc/nginx/conf.d/flaskapp.conf:3
Running nginx -t in terminal results in nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2020/10/19 08:43:08 [warn] 127100#127100: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1 2020/10/19 08:43:08 [emerg] 127100#127100: unknown directive "mywebsite.co.uk" in /etc/nginx/conf.d/flaskapp.conf:3 nginx: configuration file /etc/nginx/nginx.conf test failed Is this an error to do w my domain "mywebsite.co.uk" or is something not configured right? I'm new to this so would appreciate any help and lmk if you need any further files. -
EmbeddedDocument ChoiceField
I have a model, lets call it A, with field: downloadable_material = fields.ListField(fields.EmbeddedDocumentField('Downloadable'), verbose_name='') Those documents are being created in 'A' Form. I want my 'A' Form to also have a MultipleChoiceField which lets you choose from already added 'downloadable_material'. Of course I want my choices to be saved in model 'A'. Here's a use-case scenario, just to be more clear: I open my 'A' Form in browser I create a couple 'downloadable_material' documents inside my 'A' Form, for example I've created DM1 and DM2. I click on my multiplechoicefield, which in this case lets me choose from DM1 and DM2. Let's pretend I've chosen only DM1, now I click save object As a result I would like to have an object, which has DM1 and DM2 in downloadable_material and DM1 in, for example, additional_material. Sure this sound complicated, you can ask me any question to make sure you have got the idea of my problem. -
Django project using scrapy on windows
I want to develop a Django project that uses scrapy. I am working on Windows and know that scrapy should be installed on Windows using Anaconda/conda. However, I don't know how to use scrapy installed by conda in my Django project. In Python shell import scrapy raises an error message. Is it possible to use Django+scrapy on Windows or I have to switch to Linux? -
Django - Reverse a queryset
I have very basic view with queryset, but for some reason I cannot reverse it. def home(request): posts = Post.objects.all().reverse() return render(request, "home.html", {'posts': posts}) For some reason no matter how I change code - instanses from queryset always rendering in same order. Below there are lines of code that I already tried and which didn't worked for some reason: Post.objects.all().reverse() Post.objects.order_by('-date') Post.objects.order_by('date').reverse() home.html: {% for post in posts %} {{ post.title }} {{ post.content }} {% endfor %} models.py: class Post(models.Model): title = models.CharField(max_length=100, unique=True, blank=True, null=True) image = models.URLField(blank=True, null=True, unique=True) content = models.TextField(blank=True, null=True) date = models.DateField(auto_now=False, auto_now_add=True) #To make in name, not objXXX def __str__(self): return self.title -
Build tools for using Github Actions for CI Pipeline for Python Django Project
Do you need a build tool like PyBuilder/Setuptools/etc. to have a CI Pipeline with Github actions for a Python Django app, or is a virtual environment and pip enough? -
How to properly configure certbot in docker?
Please help me with this problem, i have been trying to solve it for 2 days! Please, just tell me what i am doing wrong. And what i should to change to make it work! And what i should to do to take it work. ERROR: for certbot Cannot start service certbot: network 4d3b22b1f02355c68a900a7dfd80b8c5bb64508e7e12d11dadae11be11ed83dd not found My docker-compose file version: '3' services: nginx: restart: always build: context: ./ dockerfile: ./nginx/Dockerfile depends_on: - server ports: - 80:80 volumes: - ./server/media:/nginx/media - ./conf.d:/nginx/conf.d - ./dhparam:/nginx/dhparam - ./certbot/conf:/nginx/ssl - ./certbot/data:/usr/share/nginx/html/letsencrypt server: build: context: ./ dockerfile: ./server/Dockerfile command: gunicorn config.wsgi -c ./config/gunicorn.py volumes: - ./server/media:/server/media ports: - "8000:8000" depends_on: - db environment: DEBUG: 'False' DATABASE_URL: 'postgres://postgres:@db:5432/postgres' BROKER_URL: 'amqp://user:password@rabbitmq:5672/my_vhost' db: image: postgres:11.2 environment: POSTGRES_DB: postgres POSTGRES_USER: postgres certbot: image: certbot/certbot:latest command: certonly --webroot --webroot-path=/usr/share/nginx/html/letsencrypt --email artasdeco.ru@gmail.com --agree-tos --no-eff-email -d englishgame.ru volumes: - ./certbot/conf:/etc/letsencrypt - ./certbot/logs:/var/log/letsencrypt - ./certbot/data:/usr/share/nginx/html/letsencrypt My Dockerfile FROM python:3.7-slim AS server RUN mkdir /server WORKDIR /server COPY ./server/requirements.txt /server/ RUN pip install -r requirements.txt COPY ./server /server RUN python ./manage.py collectstatic --noinput ######################################### FROM nginx:1.13 RUN rm -v /etc/nginx/nginx.conf COPY ./nginx/nginx.conf /etc/nginx/ RUN mkdir /nginx COPY --from=server /server/staticfiles /nginx/static nginx.conf file user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; events { worker_connections 1024; } … -
VSCode debugging error AttributeError: type object 'winpty.cywinpty.Agent' has no attribute '__reduce_cython__'
I'm on windows and building an app with django=3.0.3 and python 3.7.9. I'm on Windows 10. While I debug the app in VSCode I get this error: AttributeError: type object 'winpty.cywinpty.Agent' has no attribute '__reduce_cython__' on an import: from notebook import notebookapp The app works perfectly fine when run on windows commandline. There is a discussion in another page for a similar error but mine is specific to the VSCode debugging. This is driving me mad. -
What are the possibilities to integrate phaser with react
I have the question about the Phaser (JS Game library) integration with React. I know that I can use the ion-phaser lib to add this lib to work in react, but lets assume I don't want to write the code from scratch again. Brief info: I have a full working set of games working in django. Each game has 2 scenes, starting with intro and playable with game itself. I have to move the logic etc to the another app that is react based on the frontend. Due the lack of time is it possible to somehow copy the code (all .js files) put them into public dir of react app and put them into iframe, or div. Maybe someone has similar situation. Rewriting the code base to fit ion-phaser lib frames could take a while. There are like 20 games with different logic and specific to django references. -
Why is jwt issued by another server also authenticated by my server in django rest framework?
I used the djangoreostframework-simplejwt module to implement jwt authentication in django rest framework. Using this, login class was created and user authentication was carried out normally when the user sent the request after putting the access to the header issued when accessing the views that require authentication among other views. The problem is that it also worked normally when I tried to authenticate with the access token issued by another server that applied the djangoreostframework-simplejwt. Could you check if there is any problem with my authentication method? Here's my code. views.py class customLoginView (GenericAPIView) : serializer_class = customLoginSerializer def post (self, request) : serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) try : user = User.objects.get(email=serializer.data['email']) except User.DoesNotExist : return Response({'message': ['이메일 또는 비밀번호를 확인해주세요.']}, status=401) if user.check_password(raw_password=serializer.data['password']) == False : up = serializer.data['password'].upper() if user.check_password(raw_password=up) == False : down=serializer.data['password'].lower() if user.check_password(raw_password=down) == False : return Response({'message': ['이메일 또는 비밀번호를 확인해주세요.']}, status=401) if not user.is_verified : return Response({'message': ['이메일 인증을 먼저 해주세요.']}, status=401) if not user.is_active : return Response({'message': ['계정이 비활성화 되었습니다. 관리자에게 문의하세요.']}, status=401) token = RefreshToken.for_user(user) data = { 'token_type': 'Bearer', 'access_token': str(token.access_token), 'expires_at': str((datetime.now() + timedelta(minutes=30)).astimezone().replace(microsecond=0).isoformat()), 'refresh_token': str(token), 'refresh_token_expires_at': str((datetime.now() + timedelta(hours=8)).astimezone().replace(microsecond=0).isoformat()) } return Response(data, status=200) serializers.py class customLoginSerializer (serializers.ModelSerializer) : … -
TemplateSyntaxError at /music/ Invalid block tag on line 6: 'path', expected 'empty' or 'endfor'. Did you forget to register or load this tag?
I wanted to remove a hardcoded urls and used a dynamic coded urls and load it over the server but I am receiving an error as: TemplateSyntaxError at /music/ Invalid block tag on line 6: 'path', expected 'empty' or 'endfor'. Did you forget to register or load this tag? Here are my code: index.html: {% if all_albums %} <h3>here are all my albums:</h3> <ul> {% for album in all_albums %} <li><a href = "{% path 'music:detail' album.id %}"> {{ album.album_title }}</a></li> {% endfor %} </ul> {% else %} <h3>You don't have any Albums</h3> {% endif %} music.urls.py: from django.urls import path from . import views app_name = 'music' urlpatterns = [ # /music/ path('', views.index, name='index'), # /music/712/ path('<int:album_id>/', views.detail, name='detail'), ] music.views.py: from django.shortcuts import render, get_object_or_404 from .models import Album # noinspection PyUnusedLocal def index(request): all_albums = Album.objects.all() return render(request, 'music/index.html', {'all_albums': all_albums}) # noinspection PyUnusedLocal def detail(request, album_id): album = get_object_or_404(Album, pk=album_id) return render(request, 'music/detail.html', {'album': album}) Analytic_practice.urls: from django.contrib import admin from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), path('music/', include('music.urls')), ] -
How to add an attribute to a Django model from a view?
I have a Django application and I'm trying to add attributes to my Django model according to user datas. I have added some new attributes such as below; def add_new_columns(column_dict): conn = mysql.connector.connect( user=username, password=password, host=host, database=dbname ) cursor = conn.cursor() for key, value in column_dict.items(): sql_data = "ALTER TABLE data_data ADD %s varchar(50);" % (key) cursor.execute(sql_data) sql_cost = "ALTER TABLE cost_cost ADD %s varchar(50);" % (key) cursor.execute(sql_cost) sql_optimize_cost = "ALTER TABLE optimize_cost_optimizecost ADD %s varchar(50);" % (key) cursor.execute(sql_optimize_cost) conn.close() However when I try to create a ModelForm with the attributes that defaults and the new added attributes, I'm getting the error below even if the database contains the new added attributes; Unknown field(s) (color) specified for Data How can I create the ModelForm and add object to that model with new added columns? -
Django Admin Page is looking very Ugly(without CSS I think)
Recently I hosted my django website on EC2 ubuntu Instance with nginx server on AWS. When I open my admin page of this website IT is looking very ugly and there is not css but on local server 127.0.0.0:8000 it works fine. I also inspect on browser console, It is giving this error: GEThttp://jassem.in/static/admin/css/dashboard.css [HTTP/1.1 404 Not Found 51ms] The resource from “http://jassem.in/static/admin/css/nav_sidebar.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). admin The resource from “http://jassem.in/static/admin/css/base.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). admin The resource from “http://jassem.in/static/admin/js/nav_sidebar.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). admin The resource from “http://jassem.in/static/admin/css/responsive.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). admin The resource from “http://jassem.in/static/admin/css/dashboard.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). admin How can I get back my previous django admin page. FYI I am a newbie on web technology and Django -
Skipping a send email function and celery task during the unit testing
I have a Django view that I want to unit test it but the problem is in some line of the function it calls another function which has a send email function and this send email function has a celery task inside it. I don't know what to do to surpass this function call because when the debugger hits this line it stops and does nothing which I think is because of the celery task. Due to this problem, my unit test can't run completely. So I would be happy if someone could tell me what to do then. My own solution was to mock the sending email function but it doesn't work. I don't know what to do now. here is the code example of what happens during the view function. view_funtion(): ... function_a is called here function_a(): ... send_email_function is called here send_email_function(): some code here and initialization of the email template celery_task.delay() please let me know if I should add more detail. Thanks. -
In Django any user can block any user if user follow another user who blocked that user can't see his post
enter code here class post(models.Model): title = models.CharField(max_length=100) image = models.ImageField(upload_to='post_pics', null=True, blank=True) video = models.FileField(upload_to='post_videos', null=True, blank=True) content = models.TextField() likes = models.ManyToManyField(User, related_name='likes', blank=True) date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) objects = postManager() class UserProfile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='owner', on_delete=models.CASCADE) following = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True, related_name='followed_by') class Blocked(models.Model): user = foreign_key_field(User, related_name="blocked_users", ....) usres = many_to_many_field(User, related_name="blocked_by" ) i am developing small blog system where user can login follow and unfollow each other also block and unblock system if user block he another user that user which is blocked cant see his posts. i try many ways but can't get result like instagram and twitter system -
C:\Anaconda3\envs\MyDjangoEnv\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
I am trying to install channels but it is giving me following errors: 1.Building wheel for twisted (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'C:\Anaconda3\envs\MyDjangoEnv\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-install-twx22bnj\twisted\setup.py'"'"'; file='"'"'C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-install-twx22bnj\twisted\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-wheel-54761_h4' cwd: C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-install-twx22bnj\twisted\ 2.C:\Anaconda3\envs\MyDjangoEnv\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory 3.C:\Anaconda3\envs\MyDjangoEnv\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe' failed with exit status 2 ERROR: Failed building wheel for twisted Running setup.py clean for twisted 4.C:\Anaconda3\envs\MyDjangoEnv\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe' failed with exit status 2 5.ERROR: Command errored out with exit status 1: 'C:\Anaconda3\envs\MyDjangoEnv\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-install-twx22bnj\twisted\setup.py'"'"'; file='"'"'C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-install-twx22bnj\twisted\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\NextGen DigiTech\AppData\Local\Temp\pip-record-atgh_ht3\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Anaconda3\envs\MyDjangoEnv\Include\twisted' Check the logs for full command output. My installed environment are: 1.Windows 10 pro 2.Virtual environment 3.Django 3.8 4.Microsoft Visual Studio Community 2019 So, what will be the solution here? Any help will be highly … -
Django Docker: custom static/media roots outside of app folder: collectstatic and upload failing silently - why?
I used django-cookiecutter to dockerize my Django project. All works in development but in production, my custom locations /var/www/... are seemingly ignored. When powering up the production.yml, it says: django_1 | 2718 static files copied to '/var/www/static', 4936 post-processed. But no files to be found in /var/www/static. Similarly, django-filer uploads seem to disappear quietly for no apparent reason. Django DOCKERFILE: RUN mkdir -p /var/www/static RUN chown django:django /var/www/static RUN mkdir -p /var/www/media RUN chown django:django /var/www/media In Django production.py settings, I overwrite the static_root and media_root locations: # STATIC STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" STATIC_ROOT = "/var/www/static/" # MEDIA MEDIA_ROOT = "/var/www/media/" -
Django - migrating only new migrations after loading dump
The migration process of my test suite got very long in my project, so I created a pg_dump which I load to my DB each time I run my unit tests. Now the pg_dump was created manually, (which later I tend to integrate into a CI system) However now, I have some other migrations I created after the dump (and I don't want to create a new dump) and I need to run migrations. My question: How do I make django migrate only the new migrations? I searched for this topic online but found addressing this specifc problem. The closest thing I found was this post which wasn't very helpful for me Django backup strategy with dumpdata and migrations -
Error WORKER TIMEOUT on Docker Django AWS S3 and Heroku
I need to upload various and heavy files to my app, In development works fine but in production environment crash with this the traceback: 2020-10-19T06:51:02.387330+00:00 app[web.1]: [2020-10-19 06:51:02 +0000] [3] [CRITICAL] WORKER TIMEOUT (pid:87) 2020-10-19T06:51:02.403179+00:00 app[web.1]: [2020-10-19 08:51:02 +0200] [87] [INFO] Worker exiting (pid: 87) 2020-10-19T06:51:02.601253+00:00 app[web.1]: [2020-10-19 06:51:02 +0000] [112] [INFO] Booting worker with pid: 112 2020-10-19T06:51:02.405325+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/app/tratamiento/crear_media/197/" host=softwaredilains.herokuapp.com request_id=6dfc67b9-eb21-4ba2-b44b-4b9c23a5c350 fwd="95.19.228.74" dyno=web.1 connect=1ms service=30806ms status=503 bytes=0 protocol=http I have read something about Heroku workers and request timeout. Anybody know how to set config on Django, Heroku or Docker to fix it ? Thanks in advanced. -
How to display "for loop" data for another "for loop" in djnago render template?
views.py def index(request): data = posts.objects.all().order_by("post_date").reverse() p = Paginator(data, 3) page_num =request.GET.get('page',1) try: page = p.page(page_num) except EmptyPage: page=p.page(1) context = { "data" : page, "one":[likes.objects.filter(post_id=dat.id).count() for dat in data], } if request.method == 'POST' and "post" in request.POST: post = request.POST['post'] user_id = request.user data = posts(post = post, user_id = user_id).save() return render(request, "network/index.html", context) @csrf_exempt def like_post(request): if request.method == 'POST': data = json.loads(request.body) user_id = data.get("user_id","") user = User.objects.get(username=user_id) post_id = data.get("post_id","") post = posts.objects.get(pk=post_id) lik = likes(user_id = user, post_id = post) lik.save() liked = likes.objects.filter(post_id = post_id).count() print(liked) return JsonResponse({"liked":liked}) index.html {% for datas in data %} <div class="row"> <div class="col-md-12"> <div class="card shadow-lg"> <div class="card-body" id="div1"> <div class="row"> <div class="col-md-6"> <h5 class="card-title"><i class="fa fa-user-circle" aria-hidden="true"></i> <a href="{% url 'profile' datas.id %}">{{datas.user_id|capfirst}}</a></h5> </div> <div class=" col-md-6 text-right" > {% if request.user.id == datas.user_id_id %} <button class="btn btn-sm btn-outline-primary" onclick="load_post(this, '{{datas.id}}')" id="edit"> Edit</button> {% endif %} </div> </div> <div id="msg"> <hr> {{datas.post}} <hr> </div> <div id="one"> </div> <div class="row"> <div class="col-md-4"> <i class="fa fa-thumbs-up" ></i> <span id="add"> {% for gg in one %} {{gg}} {% endfor %} </span> </div> <div class="col-md-4"></div> <div class="col-md-4 text-right">{{datas.post_date}}</div> </div> </div> </div> </div> </div> <br> {% endfor %} I need … -
Unable to symbolicate stack trace: Network request failed - React Native
I can't communicate with my server. I just getting an error like this on android Unable to symbolicate stack trace: Network request failed -
GET a parameter with & included
I am receiving a URL such as the following: /return-graph/?rc=Mahindra%20&%20Mahindra_Nasik HTTP/1.1" 200 0 But when I try to get the URL it only shows the following q = request.GET['rc'] print(q) output: Mahindra whereas I need the fullname to make the query Desired Output: Mahindra & Mahindra_Nasik -
Django Error reporting with Custom send_email
I kindly need your help to make django error reports by email. I use service account with Gmail API to authorize and send emails. How can this work with default django error reporting send_email. I know I have to add the below to the settings and debug must be false: ADMINS, MANAGERS, SERVER_EMAIL -
How to pass value entered in textbox to flask in text format from django?
I am a beginner in django and flask. I want to pass the value entered in textbox from django to flask. views.py from django.shortcuts import render import requests # Create your views here. def form(request): return render(request,'hello/index.html') html file <!DOCTYPE html> <html> <body> <form action="output"> Enter name: <br/> <input type="text" name="name"> <br/> <input type="submit" ><br/> </form> </body> </html> flask app = Flask(__name__) @app.route('/') def index(): return "hello" if __name__ == '__main__': app.run(debug=True) In the flask i should get the values entered in django textbox.... -
Passing model field to html source/path in django templates
so im trying to pass an image to my html here is my code {% if q.number > 105 and q.number < 116 %} <p>{{ q.number }} </p> <img src="{% static 'images/{{ q.number }}.png' %}" alt={{ q.number }} /> {% endif %} the paragraph work fine, but i cant get to my image, its work fine if i replace the source with 106 - 115 (all is well) "{% static 'images/106.png' %}" both of them use the same if else, only the source changed i have tried to search the documentation but im having a difficult time understanding a lot of them