Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django File Upload ,can't add file field using form from instance object
I need to save a file upload object, but in two views... First views can save without problem, but the second i get nothing change in my object I have a models.py class file_upload(models.Model): x= models.FileField() y = models.FileField() I have forms.py class form_upload(ModelForm): class Meta: model = file_upload widgets={ 'x': FileInput(attrs={'class': 'form-control'}), class form_upload_2(ModelForm): class Meta: model = file_upload widgets={ 'y': FileInput(attrs={'class': 'form-control'}), I have created an objects, also have uploaded a file on "x", i need to add file on "y" using form_upload_2 this is my views.py data_upl_instance = file_upload.objects.get(id=1) form = form_upload2(request.FILES,request.POST,instance=data_upl_instance) if request.method == "POST": if form.is_valid(): print(form.cleaned_data['y']) form.save() mydata['form'] = form return render(request, "status.html", mydata) this is my status.html <form action="" method="post" enctype="multipart/form-data" class="form-horizontal">{% csrf_token %} <div class="alert alert-danger"> {{ form }} </div> <button type="submit" class="btn red">Upload</button> </div> </form> After i clicked submit, the result is Printed "None" on terminal Form is valid but nothing change, file cant be uploaded -
django 1.11 html "href" doesn't work with template url
My urls.py urlpatterns = [ url(r'^index', views.index, name='index'), my views.py def index(request): return render(request, 'index.html', {}) index.html <ul> <li><a href="{% url 'all_contacts' %}"></a>All Contacts</li> </ul> My page with the href hyperlink not working The source: So I had a look at https://www.w3schools.com/tags/att_a_href.asp and it indicates that relative paths only work if it's pointing to a file. Not sure what I'm missing here? -
Django: How to use audit-log as decorator using cassandra
**models.py** class Mydata(DjangoCassandraModel): name = columns.Text(primary_key=True) email = columns.Text() password = columns.Text() creation_date = columns.DateTime(default=datetime.datetime.today()) modified_on = columns.DateTime(default=datetime.datetime.now) **views.py** class UsersViewSet(viewsets.ViewSet): def list(self, request): queryset = Mydata.objects.all() if request.GET.get('name'): queryset = queryset.filter(name=request.GET.get('name')) serializer = CheckSerializer(queryset, many=True) return Response(serializer.data) def create(self, request): serializer = CheckSerializer(data= request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.data, status=status.HTTP_400_BAD_REQUEST) I am new to django and I want to know how could I make a function of auditing in views.py to use that function as decorator on list and create function. Please help. -
python django: views, models and forms in directories
django 1.11 python 3.x I have been trying to breakout models, views and forms into folders. I started out with models and it seemed to work. Changing views.py to views/index.py is stumping me. I have seen posts on this and I think that I am setting the __init__.py files correctly but makemigrations still yells at me about views/Profile.py. File "/home/me/AppBase/MyApp/Members/urls.py", line 3, in <module> from . import views File "/home/me/AppBase/MyApp/Members/views/__init__.py", line 1, in <module> from .Profile import * File "/home/me/AppBase/MyApp/Members/views/Profile.py", line 7, in <module> from MyApp.Members.models.Profile import * ImportError: No module named 'MyApp.Members' the file structure MyApp |-- Members | |-- __init__.py | |-- account_adapter.py | |-- admin.py | |-- apps.py | |-- forms | | |-- ProfileForm.py | | |-- __init__.py | |-- models | | |-- Profile.py | | |-- __init__.py | |-- tests.py | |-- urls.py | `-- views | |-- Profile.py | |-- __init__.py views/__init__.py is: from .Profile import * views/Profile.py is: from django.contrib import messages from django.core.exceptions import * from django.shortcuts import redirect from django.shortcuts import render from MyApp.Members.models.Profile import * def create_profile(user): pass def profile(request): if not request.user.is_authenticated: return redirect('/account/login') try: profile = Profile.objects.get(user=request.user) messages.add_message(request, 1, "have profile") except ObjectDoesNotExist: messages.add_message(request, 1, "create profile") … -
404 error when filtering URL for key arguments with django rest framework generic views
Basically I'm following a tutorial on how to filter for results through url regular expressions for my rest api. I'm looking to go to /api/v1/users/1/goals to get a list of the goals associated with a user. I've scoured the django rest framework docs and numerous tutorials and can't get this to work. I'm getting a 404 error that the url I'm requesting does not exist. myapp.views.py class ListCreateUser(generics.ListCreateAPIView): queryset = User.objects.all() serializer_class = serializers.UserSerializer class RetrieveUpdateDestroyUser(generics.RetrieveUpdateDestroyAPIView): queryset = User.objects.all() serializer_class = serializers.UserSerializer class ListCreateGoal(generics.ListCreateAPIView): queryset = Goal.objects.all() serializer_class = serializers.GoalSerializer def get_queryset(self): return self.queryset.filter(user_id=self.kwargs.get('user_pk')) class RetrieveUpdateDestroyGoal(generics.RetrieveUpdateDestroyAPIView): queryset = Goal.objects.all() serializer_class = serializers.GoalSerializer urls.py urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api/v1/users', include('dataStoreApp.urls', namespace='users')), ] myapp.urls.py urlpatterns = [ url(r'^$', views.ListCreateUser.as_view(), name='user_list'), url(r'(?P<pk>\d+)/$', views.RetrieveUpdateDestroyUser.as_view(), name='user_detail'), url('r^(?P<user_pk>\d+)/goals/$', views.ListCreateGoal.as_view(), name='goals_list'), url('r^(?P<user_pk>\d+)/goal/(?P<pk>\d+)/$', views.RetrieveUpdateDestroyGoal.as_view(), name='user_goal_detail'), ] myapp.serializers.py class GoalSerializer(serializers.ModelSerializer): class Meta: model = Goal fields = ('id', 'user_id', 'name', 'amount', 'start_date', 'end_date', ) class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('username', 'email', 'id', 'password') read_only_fields = ('id', ) extra_kwargs = {'password': {'write_only': True}} myapp.models.py class Goal(models.Model): class Meta: verbose_name_plural = 'Goals' user_id = models.ForeignKey(settings.AUTH_USER_MODEL, default=1, on_delete=models.CASCADE) NAME_CHOICES = ( ("Goal 1", "Goal 1"), ("Goal 2", "Goal 2"), ("Goal 3", "Goal 3"), ) name = models.CharField(max_length=100) … -
Django Dyanmic form: presentation and information collections
I have a complex form: <<forms.py>> class AttributeOptionForm(forms.Form): option_name = forms.CharField(label="Attribute Option") class AttributeForm(forms.Form): attr_name = forms.CharField(max_length=100, label="Attribute Name") attr_options_list = [AttributeOptionForm(), AttributeOptionForm()] class ProjectForm(forms.Form): name = forms.CharField(max_length=250, label="Name") attr_form_list = [AttributeForm()] ProjectFrom holds at least one AttributeForm (which may grow on runtime) and each AttributeForm holds at least two AttributeOptionForm (which may also grow on runtime). You may think of any AttributeForm as a question with multiple answers (AttributeOptionForm), which I want the user to fill in. This is how I present the ProjectForm. <<project_form.html>> <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> {% csrf_token %} <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <span class="text-danger small">{{ form.name.errors }}</span> </div> <label class="control-label col-sm-2">{{ form.name.label_tag }}</label> <div class="col-sm-9">{{ form.name }}</div> </div> {% for attr_form in form.attr_form_list %} <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <span class="text-danger small">{{ attr_form.att_name.errors }}</span> </div> <label class="control-label col-sm-2">{{ attr_form.attr_name.label_tag }}</label> <div class="col-sm-9">{{ attr_form.attr_name }}</div> {% for option in attr_form.attr_options_list %} <div class="col-sm-offset-2 col-sm-10"> <span class="text-danger small">{{ option.option_name.errors }}</span> </div> <label class="control-label col-sm-2">{{ option.option_name.label_tag }}</label> <div class="col-sm-9">{{ option.option_name }}</div> {% endfor %} </div> {% endfor %} </form> In the form, in addition, there are an 'add_attribute_option' buttons (per attribute), 'add_attribute' button, and 'submit' button. How do I collect the data in my views.py file? … -
I am not able to initialize selectpicker in my vue js?
$('.selectpicker').selectpicker('refresh') This is done to initialize the selectpicker. When I run this is in console of chrome.. the dropdown list appears. So, in vuejs I added this code in mount(). But nothing is happening.. I have asked another question regarding the same and did not got an answer. Is there any way to initialize the same. My front end is html and vuejs and backend in python Django.. I am stuck or last two days and did not get anything new. Is there any way to initialize the same? -
Django-Leaflet Map not appearing in detailview
I am trying to use leaflet to display a map on one of my detail view pages on my django website. I am not receiving any errors when loading the page but the map does not appear. Settings: """ Django settings for crowdfunding project. Generated by 'django-admin startproject' using Django 1.11.6. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '_=@ti6j%*!5fcg-c#=f29yy7-unusuk*)oi7neew#k8==8rgz8' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'application.apps.ApplicationConfig', 'leaflet' ] 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', ] ROOT_URLCONF = 'crowdfunding.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['./templates',], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'crowdfunding.wsgi.application' LEAFLET_CONFIG = { 'DEFAULT_CENTER': (0, 0), 'DEFAULT_ZOOM': 16, 'MIN_ZOOM': 3, 'MAX_ZOOM': 18, } # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases DATABASES … -
Auto populate custom user model if field exists in another table/model
As a newbie if my logic or thought process is incorrect please help direct me. I'm attempting to auto populate a field in my custom user model with a 1 or a 0 if the formattedusername exists in another model/pre-existing database table with the following signal, but i can't seem to get it to work correctly: @isthisflag def is_this(self, is_this): if cfo.ntname is user.formattedusername: return 1 else: return 0 I have a custom User model like the following: class User(AbstractBaseUser, PermissionsMixin): username = models.CharField(max_length=7, unique=True) formattedusername = models.CharField(max_length=11, unique=True, primary_key = True) is_this = models.BooleanField(default=False) USERNAME_FIELD = 'username' I then have another model we'll call cfo that has a list of formattedusernames with the ntname field as a FK to formattedusernames. class cfo(models.Model): ntname = models.OneToOneField(settings.AUTH_USER_MODEL,db_column='CFO_NTName',primary_key=True, serialize=False, max_length=11) class Meta: managed = False db_table = 'cfo' If ntname exists as the User who logs with their LDAP authentication I want to place a 1 in the User.is_this field. -
How can I know where the request.user from?
How can I know where the request.user from ? I have a TestRequestUserAPIView: class TestRequestUserAPIView(View): def dispatch(self, request, *args, **kwargs): result = super(TestRequestUserAPIView, self).dispatch(request, *args, **kwargs) return result def get(self, request): user = request.user # this line I get the user (who access the API) return HttpResponse("ok") When it execute this line user = request.user. I can get the request user(who request this API). I want to know how the user generate in request, why I request this API in browser like Chrome, I the request will have the user property? Does it through the cookie ? or some token (In my test project, I logined. But I did not put the token to the request when access the API, still get the user in backend reqest.user)? -
'NoneType' object has no attribute 'rsplit'
I'm not sure how to track down this error: I'm running a django app on Python 3.4 in AWS. I re-deployed a couple of hours ago and discoverd this error while trying to fix an error with environmental variables. I'm not sure where to start, or where I could have gone wrong. It seems to have something to do with mail, and while I did recently mess around with some mail code, commenting out such code did nothing to resolve the problem or change the error. [Wed Nov 29 01:34:08.382512 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] Traceback (most recent call last): [Wed Nov 29 01:34:08.382537 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/handlers/exception.py", line 42, in inner [Wed Nov 29 01:34:08.382541 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] response = get_response(request) [Wed Nov 29 01:34:08.382559 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/utils/deprecation.py", line 136, in __call__ [Wed Nov 29 01:34:08.382562 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] response = self.get_response(request) [Wed Nov 29 01:34:08.382579 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/handlers/exception.py", line 44, in inner [Wed Nov 29 01:34:08.382582 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] response = response_for_exception(request, exc) [Wed Nov 29 01:34:08.382599 2017] [:error] [pid 8768] [remote 172.31.5.39:46384] File … -
Django Queryset : Remove 'u'
how to remove 'u' from Django Queryset. Let say i have result from my QuerySet <QuerySet [u'MANAGER']> Hot to remove the <QuerySet [u' ']> so that i got the result as MANAGER only. -
custom authenticate function does not accept third argument
trying to write my own custom authentication backend using the following as a guideline: https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#writing-an-authentication-backend I want to implement the authenticate function with the following elements: username password verification_code I define the function as follows: def authenticate(self, username=None, password = None, verification_code = None): ... I however only get a value for username and password not however for verification_code. The login form looks as follows: <form id="login-form" method="POST"> {% csrf_token %} ... <input id="user_name" type="text" class="form-control" name="username" placeholder="Email Address" required="" autofocus="" /> <input id="password" type="password" class="form-control" name="password" placeholder="Password" required=""/> <input id="verification_code" type="text" class="form-control" name="verification_code" placeholder="Verification Code" required=""/> <button class="btn btn-lg btn-primary btn-block" type="submit">Login</button> </form> Any help would be much appreciated :) -
Digitalocean django one-click second site
I am a noobie when it comes to deploying django on a webserver. I always used digitalocean one-click instalation. Now I wanted to add a second website on the server but it is more difficult than I thought.Since you have generate a new gunicorn.socket?? I searched duckduckgo and google to find the awnser. So before I start reading in on how to use gunicorn and wsgi to create a gunicorn.socket file. Or maybe some other ways to do it with gunicorn without the socket file. My question is: How can I add a second website to the digitalocean one-click server? -
django formset unique_together integrity error
I am using Django and jquery.formset.js. I am trying to update multiple objects with a formset. My model looks like this: class Item(models.Model): class Meta: unique_together = ('index', 'parent') ordering = ['index'] index = models.PositiveIntegerField() parent = models.ForeignKey('playlist', related_name='items', on_delete=models.CASCADE) Every time the order gets changed on update it creates IntegrityError on unique_together. How do I update multiple objects with unique_together on required fields? Any help would be much appreciated. -
Declaring objects for globals() using a nested for loop
Firstly, I know I shouldn't be using globals(). I know I shouldn't. But I'm using a custom Django API which doesn't allow me to use collections (as far as I can tell), so I'm pretty much stuck with using globals(). I'm trying to design a game where a player will have 1 choice in the first round, 2 choices in the second round, 4 choices in the third round (so the formula for calculating choices per round is num_choices = 2^num_rounds). Of course, the first round has only 1 choice, so I am declaring that statically. However, for subsequent rounds I am trying to use the following code: for i in range(2, NUM_ROUNDS): dec_num = math.pow(2, i) for j in range(1, int(dec_num)): globals()['dec_r{}_{}'.format(i).format(j)] = models.CharField( choices=list_of_choices, widget=widgets.RadioSelect(), blank=False, initial='blank' ) However, when I attempt to run my Django app, I receive the following error: IndexError: tuple index out of range I figure it has something to do with the way that I am declaring the variable name. Is there an alternative I can use? Thanks! -
Django/Python and Raw SQL Querying with PostgreSQL
I'm practicing my raw SQL querying in a Django project using cursor.execute. Here's my Django models.py database schema: class Client(models.Model): date_incorporated = models.DateTimeField(default=timezone.now) And here's the psql description of the table: # \d+ client Column | Type | Modifiers | Storage | -------------------+--------------------------+--------------------+----------+ date_incorporated | timestamp with time zone | not null | plain | Here's where I get confused: If I use psql to query the data from the table, I get: # SELECT date_incorporated FROM client; date_incorporated ------------------------ 2017-06-14 19:42:15-04 2017-11-02 19:42:33-04 (2 rows) This makes sense to me. In the PostgreSQL docs, it shows that this is (I believe) just a string that is correctly formatted and stored as a UTC timestamp. When I go through Django using this query: cursor.execute('SELECT date_incorporated FROM client;') data = [dict(zip(columns,row)) for row in cursor.fetchall()] (using the dictfetchall method from the Django docs) ...my date_incorporated field gets turned into a python datetime object. {'date_incorporated': datetime.datetime(2017, 11, 2, 23, 42, 33, tzinfo=<UTC>)} In this app I'm building, I wanted a user to be able to input raw SQL, and put that inputted string into the cursor.execute(rawSQL) function to be executed. I expected the output to be the same as the psql version. … -
Is django's EmailMessage filtering out certain HTML attributes and properties?
I'm having an issue... I'm trying to properly setup Google's schema for event reservations I'm printing out the rendered template before the email is sent and it outputs properly, however after sending the email and opening it up,the HTML attributes and properties I set are not there. The only tag that is shown properly is the one. Shown below is the case for when I'm using HTML. I tried the same thing using the script version shown in the linked URL and I'm having an issue where it just disappears... anyone know what's going on? Template code: ... <body style="margin:0; padding:0; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;" bgcolor="#f3f3f3"> <div itemscope itemtype="http://schema.org/EventReservation"> <meta itemprop="reservationNumber" content="{{rsvp.id}}"/> <div itemprop="underName" itemscope itemtype="http://schema.org/Person"> <meta itemprop="name" content="{{rsvp.candidate.first_name}} {{rsvp.candidate.last_name}}"/> </div> <div itemprop="reservationFor" itemscope itemtype="http://schema.org/Event"> <meta itemprop="name" content="{{rsvp.event.title}}"/> <time itemprop="startDate" datetime="{{rsvp.event.start_date_iso}}"/> <div itemprop="location" itemscope itemtype="http://schema.org/Place"> <meta itemprop="name" content="{{rsvp.event.event_location.name}}"/> <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> <meta itemprop="streetAddress" content="{{rsvp.event.event_location.address1}}"/> <meta itemprop="addressLocality" content="{{rsvp.event.event_location.city}}"/> <meta itemprop="addressRegion" content="{{rsvp.event.event_location.state}}"/> <meta itemprop="postalCode" content="{{rsvp.event.event_location.zipcode}}"/> <meta itemprop="addressCountry" content="US"/> </div> </div> </div> </div> ... </body> This is what's in the email when I inspect it... -
Method in Django to give privileges to users based on the Group?
Is there a way in Django 1.11 to give privileges to users based on the Group they belong to? Please can someone direct me to a good resource to look into. -
Strange publish date in django
I have a publish date for blog posts in my model like this: published=models.DateTimeField(verbose_name="date published") Then somewhere in my templates, I have this: {{ post.published }} {{ post.published.day }} And the output becomes this: November 29, 2017 28 So why the second line shows one day earlier??? PS: It wasn't like this last week, but I don't know what I have changed since then. I don't use version control! -
How to turn off rounding numbers in FloatField model
Hello I have got problem I am saving latitude and longitude data from google maps to my database in FloatField model and when there are numbers which have a lot of integers after comma the FloatField form django is automatically rounding them. For example from google maps I get coordinates: latitude': 49.82895324990301, 'longitude': 21.160517976135225 And in my database the saved values are: latitude': 49.828953249903, 'longitude': 21.1605179761352 So the saved numbers are rounded and I dont know how to disable it. I will be very thankful for every help. Field in my models.py looks like: class MuseumLocation(models.Model): owner = models.ForeignKey(User) name = models.CharField(max_length=150) location = models.CharField(max_length=150, null=True, blank=True) latitude = models.FloatField(null=True, blank=True) longitude = models.FloatField(null=True, blank=True) -
Django how to add a pk to a request object?
I am struggling in my TDD to add a pk inside a request object in Django. Here is my trial : request = HttpRequest() request.method = "GET" request.GET = request.GET.copy() request.GET["pk"] = 1 response = info_station(request) knowing that the info_Station take a pk as parameter : def info_station(request, pk): And my url file : url(r'^info_station/(?P<pk>[0-9]+)$', views.info_station) The error is : info_station() missing 1 required positional argument: 'pk' How can I add this 'pk' parameter into my request ? -
Django: Wrong permissions for created SOCK file using mod_wsgi
I have a Django app running on my server using Apache2 and mod_wsgi. I also having WSGI running in daemon mode. Due to this, I have a small issue that occurs every time I restart my apache2 service. A new sock file is created in /var/run/ which isn't the issue itself, but due to this, the new file is being created by root and therefore, my user who is serving the files is not the owner. My Question: How do I make it so that the new sock file being created is created with user as the owner and www-data as the group? -
Can't add new rows to Postgres database at Heroku via Django admin
After provisioning my Postgres database on Heroku, I restored the structure and data from a local backup created using pg_dump. I am unable to add new data to any table via Django admin. I get: null value in column "id" violates not-null constraint when adding data for any model. What's going on with this database? -
Display dynamic data from database in Django
I am using Django and Postgresql as database. I have a HTML page with two fields name and item. I can save the data in the database by clicking on submit. But, I want to show the saved data from database in the HTML page. It means, whenever we load the page, it should show the existing saved data and after submitting new data, the list should be updated. Below is my python code. models.py from django.contrib.auth.models import User from django.db import models class AllocationPlan(models.Model): name = models.CharField(max_length=50) item = models.CharField(max_length=4096) views.py class HomePageView(TemplateView): template_name = "index.html" def post(self, request, **kwargs): if request.method == 'POST': form = AllocationPlanForm(request.POST) if form.is_valid(): form.save() return render(request, 'index.html', { 'form': AllocationPlanForm() }) forms.py from django import forms from django.forms import ModelForm from homeapp.models import AllocationPlan class AllocationPlanForm(ModelForm): class Meta: model = AllocationPlan fields = "__all__" index.html <html> <form method="post">{% csrf_token %} Name:<br> <input type="text" name="name" > <br> Item:<br> <input type="text" name="item" > <br><br> <input type="submit" value="Submit"/> </form> {% for i in form %} {{ i.name }} {{ i.item }} {% endfor %} </html> It is returning NONE