Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Force browser to render with en locale
I am dealing with a browser rendering problem that renders decimal points using a comma, instead of a dot, in some languages. This breaks some javascript code. I tried setting lang attribute to en on the script/HTML tags and it appears not to work, and the browser still renders decimal points using a comma. My question is there a way to override the Accept-Language header, and set it to only use en? I am using Django. Otherwise dealing with this case directly in the code seems the only way. -
Execute delete() within save() in Django
I'm working on a Django/Wagtail project. I'm trying to build a very customized feature that requires an object to be deleted when hitting the Save button when certain conditions are met. I override the Save method: def save(self, *args, **kwargs): if condition: return super(ArticleTag, self).delete() else: return super(ArticleTag, self).save(*args, **kwargs) I know this looks very odd and completely anti-adviseable, but it is exactly the behavior I'm trying to achieve. Is there a better or "correct" way to do this? Are there other steps to exactly reproduce the behavior as if the user had hit Delete directly? -
ajax 500 error on adding a new field in django forms
I added a new file field in forms.py, no change in ajax- which is using form.serialize(),views- having no request.FILES attribute or any other change anywhere right now. models.py- class B(models.Model): filename = models.FileField(upload_to='files/') user = models.ForeignKey(User) class A(models.Model): ref = models.CharField(max_length=64, unique=True, blank=True) file = models.ManyToManyField(B, blank=True) forms.py class AForm(forms.ModelForm): file = forms.FileField(label='Select a file to upload', widget=forms.ClearableFileInput(attrs={'multiple': True}), required=False) class Meta: model = A fields = '__all__' and it is now giving a 500 (Internal Server Error) AJAX error, I am really not sure what the issue is since I have not done any changes. Please suggest- stuck on this for a long time now. -
Permission Denied - Django Deployment on Ubuntu 16.04 with web server Nginx
I am trying to deploy a django website on a Ubuntu 16.04 system using Nginx webserver but I am having issues. I am pretty new to system administration. ERRORS Error I get from my nginx error.log file: connect() to unix:/home/teddycrepineau/contoursandcolors/contoursandcolors.sock failed (13: Permission denied) while connecting to upstream, client: 64.125.191.37, server: 173.255.210.63, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/teddycrepineau/contoursandcolors/contoursandcolors.sock:", host: "173.255.210.63", referrer: "http://173.255.210.63/" uwsgi status uwsgi[25361]: thunder lock: disabled (you can enable it with --thunder-lock) uwsgi[25361]: uwsgi socket 0 bound to UNIX address /home/teddycrepineau/contoursandcolors/contoursandcolors.sock fd 3 uwsgi[25361]: Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] uwsgi[25361]: !!! Python Home is not a directory: /home/teddycrepineau/Env/contoursandcolors !!! uwsgi[25361]: Set PythonHome to /home/teddycrepineau/Env/contoursandcolors uwsgi[25361]: Fatal Python error: Py_Initialize: Unable to get the locale encoding uwsgi[25361]: ImportError: No module named 'encodings' uwsgi[25361]: Current thread 0x00007f0ec8429700 (most recent call first): uwsgi[25361]: Thu Apr 12 13:31:57 2018 - [emperor] curse the uwsgi instance contoursandcolors.ini (pid: 4955) uwsgi[25361]: Thu Apr 12 13:32:00 2018 - [emperor] removed uwsgi instance contoursandcolors.ini SET UP Using Python 3 Ubuntu 16.04 Using Virtualenvwrapper and virtualenv Virtualenvwrapper set up echo "export WORKON_HOME=~/Env" >> ~/.bashrc echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc /etc/uwsgi/sites/contoursandcolors.ini [uwsgi] project = contoursandcolors uid = teddycrepineau base = /home/%(uid) chdir … -
Simple todolist Bradtraversy lower limit error
I am trying to run the bradtraversy simple todo list django code on my raspberry pi and have run into the following error. I have run into the following traceback: Environment: Request Method: GET Request URL: HIDDEN Django Version: 1.11.11 Python Version: 2.7.13 Installed Applications: ['todos.apps.TodosConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/usr/local/lib/python2.7/dist-packages/django/utils/deprecation.py" in __call__ 138. response = self.process_request(request) File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in process_request 57. host = request.get_host() File "/usr/local/lib/python2.7/dist-packages/django/http/request.py" in get_host 105. if domain and validate_host(domain, allowed_hosts): File "/usr/local/lib/python2.7/dist-packages/django/http/request.py" in validate_host 579. if pattern == '*' or is_same_domain(host, pattern): File "/usr/local/lib/python2.7/dist-packages/django/utils/http.py" in is_same_domain 291. pattern = pattern.lower() Exception Type: AttributeError at / Exception Value: 'list' object has no attribute 'lower' I am fairly new to Django but thought I made all the correct adjustments to match my system specifics. I updated the settings file to match my allowed hosts and database setting and used the "python manage.py migrate" command to bring over migrations. Any thoughts or help would be greatly appreciated. Thank you -
django-admin startproject makes installer makes wrong django admin version django1 instead of 2
with commanf $ pip3 install Django==2.0.2 inside of virtualenv and command $django-admin startproject new_project Django installeer djando-admin 1.1.1. instead of django 2. Andy tips? -
Prevent form resubmission after post without redirect
Preface: I'm answering my own question, which i was stuck on for a while, but answered on another question thread. I have to start a new thread instead of commenting or voting on the answer that helped me, becasue I am not reputable (not enough StackOverflowreputation points). I guess I need to use StackOverflow more and suffer the catch 22 in the meantime. So I'd like to thank 'Eugen Konkov' for his solution here: https://stackoverflow.com/a/47247434/3588977 Sometimes Post/Redirect/Get is not possible. In my case the form is just a password used to decrypt content stored in database with a symettric AES cipher. The password is not to be stored anywhere and thrown away after decryption and render without any caching. It's simply not possible with Post/Redirect/Get. Even Django sessions are ot safe enough for my password/key or the decrypted content. With a simple javascript function to clear the history when the resultant render page is loaded, the user cannnot re-submit the form with back button and resubmit the previous post. -
Having two fields mandatory in a serializer togeather
I have a serializer which looks like this : > class MySerializer(serializers.Serializer): > lat = serializers.FloatField(required=False) > lng = serializers.FloatField(required=False) I want to make sure that if a request came with the 'lat' field, the 'lng' field will be mandatory and vice versa. I can do it with validate function but beleive there is a better way of doing that. -
django rest use relation model field in objects filter
product, category, and categoryassin i want get 10 row from product object where category title is develop . i did like this but it not work and i get error Related Field got invalid lookup: title how can in fix it? this is my models class Product(models.Model): product_id = models.AutoField(primary_key=True) author = models.ForeignKey(User, on_delete=models.CASCADE, db_index=True) title = models.CharField(max_length=200) video_length = models.CharField(max_length=20, null=True, blank=True) mini_description = models.CharField(max_length=1000, null=True, blank=True) full_description = models.TextField(null=True, blank=True) you_need = models.CharField(max_length=1000, null=True) you_learn = models.CharField(max_length=2000, null=True) price = models.CharField(max_length=50, null=True, blank=True) free = models.BooleanField(default=False) video_level = models.CharField(max_length=100, null=True, blank=True) created_date = models.DateTimeField(auto_now_add=True) updated_date = models.DateTimeField(auto_now=True) publish = models.BooleanField(default=False) draft = models.BooleanField(default=False) slug = models.SlugField(allow_unicode=True, null=True, blank=True) image = models.FileField(upload_to=upload_to_custom_p, null=True, blank=True) class Category(models.Model): parent_id = models.IntegerField(null=True, blank=True) title = models.CharField(max_length=200) class CategoryAssin(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE, to_field='product_id', related_name='category') cat_id = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='categoryid') and this is related serilizers class CategorySerializer(ModelSerializer): class Meta: model = Category fields = [ 'id', 'parent_id', 'title', ] read_only_fields = ['id'] class CategoryAssinSeralizer(ModelSerializer): product = serializers.SerializerMethodField() def get_product(self, obj): return obj.product.title cat_name = serializers.SerializerMethodField() def get_cat_name(self, obj): return obj.cat_id.title class Meta: model = CategoryAssin fields = [ 'cat_id', 'cat_name', 'product', ] read_only_fields = ['id'] # product class ProductSerializer(ModelSerializer): product_ratings = ProductRatingsSerializer(many=True, read_only=True) … -
Passing django url with tag to d3 js
I am trying to pass a url to d3.json and the url contains a variable. The url looks like this: url(r'my/url/(?P<tag>[0-9]{2})', some_view, name='my_url'). The url is to a view, which returns a json file. The html template containing the piece of code looks like this: d3.json("{% url 'my_url' tag %}", function(d){ //do some stuff }); Sadly, I am getting a NoReverseMatch error. How should I pass the tag to d3.json? -
Incrementing a database counter concurrently
From what I read in the PostgreSQL documentation, it seems that queries like UPDATE accounts SET balance = balance + 100 WHERE account_id = 12345 are atomic and can be safely executed concurrently. Is this only the case when a single integer column is updated? In my Django app I have a query like this (generated by the ORM): UPDATE "mytable" SET "counter" = ("mytable"."counter" + 1), "owner" = NULL, "updated" = '2018-04-12T12:53:17.826257+00:00'::timestamptz WHERE "mytable"."id" = 27; args=(1, datetime.datetime(2018, 4, 12, 12, 53, 17, 826257, tzinfo=<UTC>), 27) which is executed concurrently by multiple background jobs. Will the counter be updated atomically in this case? I'm using the autocommit mode (Django default). -
Heroku Memory quota vastly exceeded in Django Project using SKLearn
I have deployed a Django application on Heroku with the goal of allowing trusted, known, internal users to upload a CSV file, click "Run", and behind the scenes, the Django app: loads a saved sklearn pipeline .pkl model (120 MB size, let's say) reads the user's CSV data using Pandas calls predict on the model using CSV data as input outputs file to S3 using Django Storages This works for small CSV files, but causes Memory quota vastly exceeded if user uploads a large CSV file... and it makes sense that larger CSV files are going to increase memory consumption. I'm not sure where to adjust. I'm wondering if someone out has experienced a similar scenario when deploying sklearn models and how they "solved" it? Ideas I have are: Identify memory leaks? No idea really even where to start on this one. Django DEBUG is set to False. Change my celery task to process the inputted file in chunks instead? Make a smaller SKLearn pipeline file somehow with joblib (I use compress=1 already)? My celery task looks like this: @shared_task def piparoo(id): instance = Upload.objects.get(id=id) model = joblib.load(instance.mlmodel.file.storage.open(instance.mlmodel.file.name)) data = pd.read_csv(instance.file) data['Predicted'] = model.predict(data) buffer = StringIO() data.to_csv(buffer, index=False) content … -
Django: Allowing a User to vote only once
I want a user to be able to vote only once. I know to create another Model called "Vote" to have a productID and userID and check to see if the User had a vote casted for the productID already then it should not be able to upvote. But I do not know how to implement it. Below is part of the models.py class Product(models.Model): title = models.CharField(max_length=255) url = models.TextField() pub_date = models.DateTimeField() votes_total = models.IntegerField(default=1) image = models.ImageField(upload_to='image/') icon = models.ImageField(upload_to='image/') body = models.TextField(max_length=500) hunter = models.ForeignKey(User,on_delete=models.CASCADE) def __str__(self): return self.title def pub_date_pretty(self): return self.pub_date.strftime('%b %e %Y') def summary(self): return self.body[:100] class Vote(models.Model): productID = models.ForeignKey(Product,on_delete=models.CASCADE) userID = models.ForeignKey(User,on_delete=models.CASCADE) And below is part of the views.py @login_required def upvote(request,product_id): if request.method == 'POST': product = get_object_or_404(Product,pk=product_id) product.votes_total += 1 product.save() return redirect('/products/' + str(product.id)) -
Set form values on page load
How to populate a form from DB based on the pk? So if the url is http://demo.com/edit-voucher/123456, how do I get the values of voucher entry 123456 into the form? The form displays, but don't know how to populate it... urls.py: url(r'^edit-voucher/(?P<pk>[\d]+)', reports.EditVoucherView.as_view()), forms.py: class EditVoucherForm(forms.ModelForm): class Meta: model = Vouchers fields = ['event_name', 'valid_start', 'valid_end', 'duration'] views.py: class EditVoucherView(LoginRequiredMixin, GroupRequiredMixin, FormView): template_name = 'edit_voucher.html' group_required = u'voucherEdit' form_class = EditVoucherForm -
How to write a Django test that checks whether an error occurs on a page?
I'm currently debugging a pull request that has made a certain page error out: The view is subclassed from Django's generic UpdateView, and corresponds to the check-ins tab of a URL named 'family' in the dashboard app: url( r'^families/(?P<pk>[0-9]+)/' r'(?P<tab>case-management|scheduling|family-demographics|activation-payment|check-ins)$', views.FamilyUpdate.as_view(), name='family'), As a first step, I'd like to write a test which captures what I see, namely, an error occurring, so that after I fix it I can be sure it never happens again. How can achieve this? I've tried the following test case, from django.test import TestCase from django.urls import reverse from lucy_web.test_factories import FamilyFactory, UserFactory class TestDashboardNavigation(TestCase): '''Test class to simply navigate to pages and click the links, making sure no errors occur''' def setUp(self): self.client.force_login(UserFactory(is_superuser=True)) def test_family_navigation(self): family = FamilyFactory() for tab in ["case-management", "scheduling", "family-demographics", "activation-payment", "check-ins"]: url = reverse('dashboard:family', kwargs={'pk': family.id, 'tab': tab}) response = self.client.get(url) print(response.status_code) where FamilyFactory is a factory_boy test fixture which creates a Family object (the underlying model of the UpdateView), but this test simply passes: (venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py test dashboard.tests.test_navigation Creating test database for alias 'default'... System check identified no issues (0 silenced). 302 302 302 302 302 . ---------------------------------------------------------------------- Ran 1 test in 1.294s OK How … -
what does "=" mean in a django queryset filter on a ManyToManyField?
I'm not clear from the docs what an "=" filter condition means when used directly on a ManyToManyField. For example, if I have: class Publication(models.Model): title = models.CharField(max_length=30) class Article(models.Model): headline = models.CharField(max_length=100) publications = models.ManyToManyField(Publication) What does the .filter(publications=pub) do here: pub = Publication.objects.get(id=1) # or any other Publication Article.objects.filter(publications=pub) Will it select articles that have exactly/only this publication? Will it select articles that have at least this publication, among others? And what does the .filter(publications=pubs) mean here: pubs = Publication.objects.filter(id__in=[1,2]) # or any other subset query of Publication Article.objects.filter(publications=pubs) Will it select articles that have exactly/only this subset of publications? Will it select articles that have at least all of the publications, among others? Will it select articles that have at least one of these publications? -
Error in "Add Comment" functionality django framework"
Whenever I try to hit the ADD COMMENT button, it takes me to post list instead of comment form. It is weird that it takes me to post list but in my browsers url path, I do see the comment extension. Not sure why is that happening. Can anyone please help me out. Views.py @login_required def add_comments_to_post(request, pk): post = get_object_or_404(Post, pk=pk) if request.method == 'POST': form = CommentForm(request.POST) if forms.is_valid(): comment = form.save(commit=False) comment.post = post comment.save() return redirect('post_detail', pk=post.pk) else: form = CommentForm() return render(request, 'comment_form.html', {'form': form}) URLS.PY url(r'^post/(?P<pk>\d+)/comment/$',views.add_comments_to_post, name='add_commentss_to_post'), HTML FILE Where I am calling the "Add Comment" view using urls <hr> <a class="btn btn-primary btn-comment" href="{% url 'add_commentss_to_post' pk=post.pk %}">Add Commment</a> -
Printing csv files from same model in Django
I have the following model : class EntryExitGate(models.Model): ''' Model to Maintain Entry and Exit Through Gate ''' name_of_the_person = models.CharField(max_length=255, blank=True) entry = models.BooleanField(default=False) exit = models.BooleanField(default=False) timestamp = models.DateTimeField(auto_now=True) def __str__(self): return "{} -> {}".format(self.name_of_the_person, self.timestamp) class Meta: verbose_name = 'Entry Exit' verbose_name_plural = 'Entries and Exits' I want to print csv file in the following format. name_of_the_person, entry (T/F), timestamp || name_of_the_person, exit(T/F), timestamp [i.e with couple of blank rows in between] I have tried django standard example of printing csv from the model. Which is like this : def report_generation(request): response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="report.csv"' writer = csv.writer(response) writer.writerow(['Name Of The Person', 'Entry', 'Exit', 'Timestamp']) entry_exit_qs = EntryExitGate.objects.filter(timestamp__lte=datetime.now(), exit=True).values_list( 'name_of_the_person', 'entry', 'exit', 'timestamp') for entry in entry_exit_qs: writer.writerow(entry) return response How can I acheieve the above mentioned task? -
Store data from API-url in a SQLite database with requests-library
Is it possible to fetch data from a API-url by using the python library "requests", and then store the data in SQLite database? The goal is to fetch dynamic data (not static data) with the API-url. Because I have fetched API-url just to use the data without storing the data in a database in other applications. If you could give me a quick example or any resources to how I should do it that would be really helpful. Have been searching several days for other solutions but none of them suits what I am trying to do. -
Django in docker: ajax POST is failing csrf
I'm attempting to set up my Django 1.11 application in Docker containers. Here's a summary of what I've done so far: Set up docker-compose.yml with an image for redis, django/uwsgi, and jwilder/nginx-proxy:alpine. docker-compose build runs with no issues. Set up my Django code so the client sends an X-CSRFToken custom header with each ajax POST request. This works fine when running Django with runserver. Set up my Django code to use redis as the session cache. Added the virtual hosts defined in docker-compose.yml to my /etc/hosts. Set up the virtual host name (dev.mysite.com) in Django's ALLOWED_HOSTS setting. At this point, I run my Docker setup using docker-compose up and I access my site in my browser using the virtual host (dev.mysite.com). It works for normal GET requests, but a subsequent ajax POST request fails on CSRF verification with the following CSRF failure reason: CSRF token missing or incorrect. The original response has a SET-COOKIE header with a csrf token that matches the X-CSRFToken header that the later ajax request contains. The ajax POST request also has the csrf cookie set, and that cookie also matches the SET-COOKIE header from the first request. At this point, I have no idea why … -
how to display the names of all books by a particular author in django
The following code gives the number of books by a particular publisher with help of .count() present at the end. So my query is what should I replace .count() in the following code with,,to get the names/titles of all the books published by a particular publisher models.py:: class publisher(models.Model): def get_books_count(self): return book.objects.filter(publisher=self).count() -
python IDLE Screen stuck with a recurring error
=============================== RESTART: Shell =============================== Unhandled server exception! Thread: SockThread Client Address: ('127.0.0.1', 51603) Request: Traceback (most recent call last): File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 317, in _handle_request_noblock self.process_request(request, client_address) File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 348, in process_request self.finish_request(request, client_address) File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\idlelib\rpc.py", line 511, in init socketserver.BaseRequestHandler.init(self, sock, addr, svr) File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 696, in init self.handle() File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\idlelib\run.py", line 433, in handle import pydoc # import must be done here to capture i/o binding File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\lib\pydoc.py", line 68, in import urllib.parse File "C:\Users\Ayush Ghai\AppData\Local\Programs\Python\Python36\urllib.py", line 7, in import urllib.parse ModuleNotFoundError: No module named 'urllib.parse'; 'urllib' is not a package *** Unrecoverable, server exiting! this error keeps on coming on my IDLE screen trying interrupting executio but not worked Please Help -
How to connect existing Django app with existing react app using webpack
So I have a Django project that acts as a backend REST server, and I would like to integrate that with an existing React project that makes AJAX calls to this REST server. Again, both of these projects already exist, I just want to connect them. Let's say the root of my Django project is DJANGOROOT and that is where manage.py is located. My Django project has a couple of Django apps that are part of the project. Let's say my Django project is called "mydjangoproj", the two Django apps are called "myapp1" and "myapp2" and the React project is called "myreactproj". Each of these two projects (the Django project with the two apps, and the React project) is stored in a separate GIT repo and to connect them on my server I have the following directory structure: DJANGOROOT/ DJANGOROOT/mydjangoproj DJANGOROOT/mydjangoproj/settings.py DJANGOROOT/mydjangoproj/urls.py DJANGOROOT/mydjangoproj/static/ DJANGOROOT/mydjangoproj/templates/ DJANGOROOT/myapp1 DJANGOROOT/myapp2 DJANGOROOT/myreactproj DJANGOROOT/myreactproj/package.json DJANGOROOT/myreactproj/src DJANGOROOT/myreactproj/src/index.js etc Note that the React app root folder is inside DJANGOROOT and is parallel to my django project and app folders. The React app uses an npm module called react-scripts (see https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build) that has a build script that will build all the stuff in DJANGOROOT/myreactproj/src (staring with index.js) and will … -
How to change the css of template in django?
I import a bootstrap template in django, the index.html is: {% load staticfiles %} <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Business Casual - Start Bootstrap Theme</title> <!-- Bootstrap Core CSS --> <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"> <!-- Custom CSS --> <link href="{% static 'css/business-casual.css' %}" rel="stylesheet"> <!-- Fonts --> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <div class="brand">university search</div> <div class="address-bar">3481 Melrose Place | Beverly Hills, CA 90210 | 123.456.7890</div> ... All my staticfiles in the folder static , the setting.py file is: STATIC_URL = '/static/' I want to modifie the image of bacground of template but doesn't work , the css file is : body { font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif; background: url('/home/hadoop/PROJET/static/img/theboatthatrocked.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; background-size: cover; -o-background-size: cov but it does not change anything, you can help me -
How to use {{ variable }} in {% if is_exist %} in Django template?
Like I asked in the title, I wanna do something like the below in Django. {% for i in "xxxxx" %} {% if store{{ forloop.counter }} %} ... {% endif %} {% endfor %} I pass variables named 'store1', 'store2', and 'store3' from views.py However, an error happens saying "Could not parse the remainder: '{{' from 'store{{'" , which seems like {{ }} can't be used inside {% %} Does anyone know how to do this?