Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django 2.0 | include multiple urls conf namespace
This "problem" is quite related to : django 2.0 url.py include namespace="xyz" The previous dev used Django 1.9 (or maybe even before) but we are now migrating to Django 2.0. We got 3 sites on the same project, all with only 1 specific URLS Conf ### MAIN PROJECT REFERENCING ALL SITES ### ### Nothing changed here ### from django.conf import settings from django.conf.urls import url, include from django.contrib import admin from django.conf.urls.static import static from django.urls import path from frontend import urls as frontend_urls from search import urls as search_urls from international import urls as international_urls # Customisation admin admin.site.site_header = 'INT - ADMIN' temppatterns = [ # Admin Sites url(r'^admin/', admin.site.urls), # Organisation Sites url(r'^frontend/', include(frontend_urls)), # 1st Platform url(r'^search/', include(search_urls)), # 2nd Platform url(r'^international/', include(international_urls)), ] urlpatterns = temppatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Here is the previous frontend URLs CONF FRONTEND_PATTERNS = [ url(r'^conseiller$', views.GuidanceView.as_view(), name='guidance'), ....... url(r'^contact$', views.ContactView.as_view(), name='contact'), url(r'^$', views.HomeView.as_view(), name='home'), ] COMPANY_PATTERNS = [ url(r'^companydetail/(?P<slug>[-\w]+)/$', views.MemberLgView.as_view(), name='lg-detail'), url(r'^asso/orga/(?P<slug>[-\w]+)/$', views.MemberOrgView.as_view(), name='org-detail'), ] CONTENT_PATTERNS = [ ....... ] EVENT_PATTERNS = [ ....... ] REDIRECT_PATTERNS = [ url(r'^actualite/(?P<pk>\d+)/(?P<slug>[-\w]+)/$', views.OldBlogRedirectView.as_view(), name='blog-redirect'), ....... url(r'^ressources$', RedirectView.as_view( url=reverse_lazy('frontend:doc'), permanent=True)), ] urlpatterns = [ url(r'^', include(FRONTEND_PATTERNS, namespace='frontend')), url(r'^', include(COMPANY_PATTERNS, namespace='companies')), url(r'^', include(CONTENT_PATTERNS, namespace='contents')), url(r'^', … -
jQuery adding extra variables to url
I think this is problem on frontend, and I am not familiar with frontend. So, this might not be the best method, suggestions are most welcome. I need to get some data from a rest api developed via django-rest-framework and put it into the input field on a form. So, this is the code, function getcharmids(){ var get_url = "http://localhost:8000/get_charm_ids/" + name; # name I am declaring in the django template console.log('clicked'); $.ajax({ type: 'GET', dataType: "json", url: get_url, contentType: "application/x-www-form-urlencoded;charset=UTF-8", accept: "application/json", success: function(data){ var charm_input = document.getElementById('id_charm_ids'); console.log(charm_input.value); charm_input.value = data.charm_ids; }, }); }; So, it does call the URL, but with extra parameters. It should call http://localhost:8000/get_charm_ids/Kasam09 But it calls with /get_charm_ids/Shakti_02?callback=jQuery111009547658997639622_1518179689207&_=1518179689208 So, due to extra parameters, my backend cannot process this request. What is the workaround to this problem? What is the correct way to call apis via jquery? Or is there any another good method? -
Concatenate Django urls with parameters as href
I got a template where i send a queryset of this model: Id Item Url 1 Sales "{% shop:sales product.id %}" 2 Payroll "{% shop:payroll area.id type.id %}" . . . And so on... In that template i need to iterate this model items setting each item url as a href, as you can see each url it's different and receive a diferent ammount of parameters, so, i defined the url field in the model as a string and try it: <table class="table table-condensed"> {% for item in items %} <tr> <td>{{ item.name }}</td> <td><a href="{{ item.url }}">Go</a></td> </tr> {% endfor %} </table> Of course, i send product, area and type via context from the view too. But it doesn't work, already tried also: href={{ item.url }} -- with no "" And concatenating the url removing the parameters from the string in the model field to use it like this then: href= "{{ item.url }} + product.id" Any idea ?, thanks in advance. -
Write test for a Django model with many-to-many relation
I want to write a test for Django model with many-to-many relation but I got this error: ValueError: "" needs to have a value for field "id" before this many-to-many relationship can be used. My test: class ModelTestCase(TestCase): def setUp(self): self.mock_file = mock.MagicMock(File) self.mock_file.name = 'MockFile' self.before_count = Tour.objects.count() self.tour_agency = TourAgency.objects.create( name='agency', username='agency') self.tour_category = TourCategory.objects.create(name='category') self.tour_equipment = TourEquipment.objects.create(name='equipment') self.tour_leader = TourLeader.objects.create( name='leader', email='leader@sample.com', username='leader', bio='sample text',) self.tour_tag = TourTag.objects.create(name='tag') def test_model_can_create_tour(self): self.tour = Tour.objects.create( name='tour', description='description', summary='summary', agency=self.tour_agency, equipment=self.tour_equipment, category=self.tour_category, tags=self.tour_tag, activity_type='activity type', date=datetime.now, photo=self.mock_file) self.tour.save() self.tour.save_m2m() count = Tour.objects.count() self.assertNotEqual(self.before_count, count) I'll try to save objects with .save() but it doesn't work. -
Django bower - use was s3 as storage?
im using Django bower (http://django-bower.readthedocs.io/en/latest/installation.html) to manage my jquery plugins. my settings is currently as such, whereby all media and static go to S3, currently bower goes to root/compomnents. Im not sure on how I could send bower to go to functions.py class StaticStorage(S3BotoStorage): location = settings.STATICFILES_LOCATION class MediaStorage(S3BotoStorage): location = settings.MEDIAFILES_LOCATION settings.py AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME STATICFILES_LOCATION = 'static' STATICFILES_STORAGE = 'itapp.functions.StaticStorage' STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION) MEDIAFILES_LOCATION = 'media' MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION) DEFAULT_FILE_STORAGE = 'itapp.functions.MediaStorage' DOCUMENT_ROOT = '/documents/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'djangobower.finders.BowerFinder', ) BOWER_COMPONENTS_ROOT = os.path.join(BASE_DIR, 'components') BOWER_INSTALLED_APPS = ( 'jquery', 'jquery-ui', 'chosen', ) -
Django Multiple File Upload uploads last file twice
I want to use the multiple file upload via one FileField. If the files are being uploaded the last file of the list is uploaded twice. Same if I only upload one file. My model: class UltrasoundImages(models.Model): Ultrasound = models.ForeignKey(Ultrasound, on_delete=models.CASCADE) image = models.FileField(upload_to='UltrasoundImages/%Y/%m/%d/') My view (something wrong in here!): class UltrasoundImagesCreate(LoginRequiredMixin, generic.CreateView): model = UltrasoundImages form_class = UploadForm login_url = 'member:login' def get_initial(self): ultrasound = get_object_or_404(Ultrasound, pk=self.kwargs.get('ves')) return { 'Ultrasound': ultrasound, } def get_context_data(self, **kwargs): context = super(UltrasoundImagesCreate, self).get_context_data(**kwargs) context['patientID'] = self.kwargs.get('id') return context def post(self, request, *args, **kwargs): form_class = self.get_form_class() form = self.get_form(form_class) files = request.FILES.getlist('image') if form.is_valid(): for f in files: if not UltrasoundImages.objects.filter(Ultrasound=get_object_or_404(Ultrasound, pk=self.kwargs.get('ves')), image=f): UltrasoundImages.objects.create(Ultrasound=get_object_or_404(Ultrasound, pk=self.kwargs.get('ves')), image=f) return self.form_valid(form) else: return self.form_invalid(form) I appreciate every help. -
Django count do not show zeros
I write a complex query which count fields in one day. Unfortunately if the conditions are not met the Django do not show zero. My QuerySet: query=Table.objects.all() .filter(time_stamp__range=(before_now_week, now)). .filter(field__gt=0.02) .filter(field__lte=0.03) .annotate(day=TruncDay('time_stamp')) .values('day') .annotate(time=Count('time_stamp')) .annotate(field_count=Count('ipi')) .values('day','field_count') .order_by('-day') My result: 2018-01-17 00:00:00+01:00 2 2018-01-16 00:00:00+01:00 6 2018-01-14 00:00:00+01:00 2 2018-01-13 00:00:00+01:00 4 There is a gap (2018-01-15) where the result do not show 0. Is there any way to show 0 as well despite the conditions are not met? -
Django: make comma separated list based on day name from querySet
How can I make a dictionary efficiently from a queryset. I have days and each day has times associated with it like Day1 - Time1 Day1 - Time2 Day1 - Time3 Day2 - Time1 I would like to make a list of dictionary like [{"day":'Day1', "time":'Time1, Time2, Time3'}, ...] This join listof = ",".join(str([ab.day.day, str(ab.time)]) for ab in vqs.clinicDoctor_dayShift.all().order_by('day__id')) gives me string like ['Sunday', '15:01:00'],['Sunday', '16:02:00'],['Monday', '09:01:00'],['Monday', '15:01:00'],['Monday', '16:02:00'],['Tuesday', '09:01:00'],['Tuesday', '16:02:00'] I would like to have a list like this [{'day':'Sunday', 'time':'15:01:00, 16:02:00, 09:01:00'},{'day':'Monday', 'time':'15:01:00, 16:02:00'},{'day':'Tuesday', 'time':'09:01:00, 16:02:00'}] Can anyone please help me with this. Thank you. -
How to send argument to error function of ajax?
I have one question. How to send argument to error function of ajax? Is it possible? Right now I tried yo use next code: $.ajax({ url: btn.attr("data-url"), type: 'get', dataType: 'json', error: function (xhr, ajaxOptions, thrownError, data) { if(xhr.status==403) { location.href = '/documents/'+data.current_category+'/'; } }, }); In browser console I see next error: TypeError: data is undefined That data attribute I create in views.py file of my Django project: class DocumentCreate(PermissionRequiredMixin, CreateView): permission_required = ('documents.add_document',) raise_exception = True def get(self, request, *args, **kwargs): data = dict() # Some other code data['current_category'] = self.kwargs.get('category') return JsonResponse(data) -
Initiate scrapy spider from different django project using Django API
I have a scrappy and Django project in the same directory. I want to write an API from Django that calls the scrappy spider and returns the output to Django side. Can anyone provide me an idea for implementing this? -
Dynamic colors are not showing in print preview
I am beginner in python and doing my first django project (student score calculation), based on the score i need to set the bgcolor in html page. The problem is unable to print the html page with dynamic bgcolors views.py context = { 'scores' : scores, 'scoreColors' : scoreColors, } return render(request, 'assessment/studentAssessmentReport.html', context) HTML template <div id="printable" class="section"> {% if context %} <table class="table"> <tbody> {% for title in context %} <tr> <td>{{ title.name }}</td> {% for score in title.scores %} <td style="text-align:center;" bgColor="{{score.color}}">{{score.score}}</td> {% endfor %} </tr> {% endfor %} </tbody> </table> {% else %}{{title.midColor}}, <p>No tests taken.</p> {% endif %} </div> I am trying the print the div printable with dynamic bgcolor based on the score with css properties. But unable to print and tried with changing stylesheet with media="print, all". Also googled lot. Sorry for poor english Any help would be praised. -
How to display categories seperated from subcategories Django
I've create a model.py from django.db import models from django.contrib.auth.models import User class Kategoria(models.Model): name = models.CharField(max_length=250, verbose_name='Kategoria') slug = models.SlugField(unique=True,verbose_name='Adres SEO') parent = models.ForeignKey('self', blank=True, null=True, related_name='children', on_delete=models.CASCADE) class Meta: unique_together = ('slug', 'parent',) verbose_name = 'Kategoria' verbose_name_plural = 'Kategorie' def __str__(self): full_path = [self.name] k = self.parent while k is not None: full_path.append(k.name) k = k.parent return ' / '.join(full_path[::-1]) class Firma(models.Model): user = models.ForeignKey(User, default=1, verbose_name='Użytkownik', on_delete=models.CASCADE) title = models.CharField(max_length=250, verbose_name='Nazwa firmy') slug = models.SlugField(unique=True, verbose_name='Adres SEO') category = models.ForeignKey('Kategoria', null=True, blank=True, verbose_name='Kategoria', on_delete=models.CASCADE) content = models.TextField(verbose_name='Opis') draft = models.BooleanField(default=False, verbose_name='Szablon') publish = models.DateField(auto_now=False, auto_now_add=False) class Meta: verbose_name='Firma' verbose_name_plural='Firmy' def __str__(self): return self.title This model create a categories as parent and subcategories as children. After that I can create a post in Firma class and connect with subcategory or category. In my view.py I have: from django.shortcuts import render, get_object_or_404 from .models import Kategoria, Firma def widok_kategorii(request): kategorie = Kategoria.objects.all() context = {'kategorie': kategorie} return render(request, 'ogloszenia/index.html', context=context) and on the end in html file: {% for kategoria in kategorie %} {{kategoria.name}}<br> {% endfor %} In this case I have in browser all records belongs to Kategoria class(category and subcategory are together). How to write a def … -
Docker migrations errors with Django but works locally?
I'm trying to "Dockerize" my Django application to enable continous deployment but I keep having errors regarding the migration process that I've implemented with a Docker entrypoint file. This is my docker-compose.yml file: version: '2' services: db: image: postgres container_name: postgres_1 env_file: - ./env/database.env ports: - "5432:5432" volumes: - postgres-db-volume:/var/lib/postgresql/data api: build: ./buzzbomb.io container_name: buzzbomb_api depends_on: - db env_file: - ./env/buzzbomb.env volumes: - .:/buzzbomb ports: - "8000:8000" front-end: build: ./buzzbomb.io/vue.js-buzzbomb container_name: buzzbomb_front_end ports: - "8080:8080" elasticsearch: build: ./elasticsearch container_name: elasticsearch_1 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - xpack.security.enabled=false - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata1:/usr/share/elasticsearch/data ports: - 9200:9200 volumes: postgres-db-volume: esdata1: Here is my Dockerfile for API: ############################################################ # Dockerfile to run a Django-based web application # Based on an Alpine Image ############################################################ # Set the base image to use to Alpine FROM alpine:3.6 ENV BUILD_DEPS="postgresql-dev gcc python3-dev musl-dev jpeg-dev zlib-dev py-pyldap libffi-dev make" ENV RUNTIME_DEPS="python3 bash" RUN apk add --no-cache $RUNTIME_DEPS $BUILD_DEPS && \ python3 -m ensurepip && \ rm -r /usr/lib/python*/ensurepip && \ pip3 install --upgrade pip setuptools && \ if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \ rm -r /root/.cache # Local directory with … -
Django ORM: Joining a table to itself
I have a table with cryptocurrency prices: id | price | pair_id | exchange_id | date ---+--------+---------+-------------+--------------------------- 1 | 8232.7 | 1 | 1 | 2018-02-09 09:31:00.160837 2 | 8523.8 | 1 | 2 | 2018-02-09 09:31:01.353998 3 | 240.45 | 2 | 1 | 2018-02-09 09:31:02.524333 I want to get the latest prices of a single pair from different exchanges. In raw SQL, I do it like this: SELECT b.price, b.date, k.price, k.date FROM converter_price b JOIN converter_price k WHERE b.exchange_id=1 AND k.exchange_id=2 AND b.pair_id=1 AND k.pair_id=1 ORDER BY b.date DESC, k.date DESC LIMIT 1; 8302.8|2018-02-09 10:05:01.815139|8300.1|2018-02-09 10:05:07.990858 How to do such query in the Django ORM? -
Django calculate 2 values from model
Im fairly new to Django. Im using Django 2. My model: # Create your models here. class Trade(models.Model): quantity = models.IntegerField() open_price = models.FloatField() commision = models.FloatField() exchange_rate_usdsek = models.FloatField() stock = models.ForeignKey(Stock, on_delete=models.CASCADE) user = models.ForeignKey(User, related_name='trades', on_delete=models.PROTECT) open_date = models.DateTimeField(auto_now_add=True, null=True) def get_absolute_url(self): return reverse('trade:detail',kwargs={'pk': self.pk}) def __str__(self): return self.stock.name My view class IndexView(generic.ListView): template_name = 'trade/index.html' context_object_name = 'all_trades' # def get_queryset(self): return Trade.objects.all() #return Order.objects.all().prefetch_related('items') def get_context_data(self, **kwargs): context = super(IndexView, self).get_context_data(**kwargs) return context index.html <h3>All stocks</h3> <table class="table"> <thead> <tr> <th>Stock</th> <th>Amount</th> <th>Open Price</th> <th>Commision</th> <th>USD/SEK</th> <th>Total sek</th> </tr> </thead> {% for trade in all_trades %} <tr> <td>{{trade.stock.name}}</td> <td>{{trade.quantity}}</td> <td>{{trade.open_price}} USD</td> <td>{{trade.commision}} SEK</td> <td>{{trade.exchange_rate_usdsek}}</td> <td>{{open_price * quantity * exchange_rate_usdsek}}</td> </tr> {% endfor %} </table> Now on my index.html I want to calculate and display a value. I make a calculation like this: total_sek = open_price * quantity * exchange_rate_usdsek Do I have to calculate this in the views.py or in the index.html? Also how would I do this? I searched around and found something about filters but im not sure if that is the right way to do it -
Error in set ForeignKey in django models
i want to make a three table and connect them to reach other like : from __future__ import unicode_literals from django.db import models class Author(models.Model): name = models.CharField(max_length=50) class BlogPost(models.Model): title=models.CharField(max_length=250) body=models.TextField() author=models.ForeignKey(Author, on_delete=models.CASCADE) date_create = models.DateTimeField() class Comment(models.Model): blog_post=models.ForeignKey(BlogPost, on_delete=models.CASCADE) text=models.CharField(max_length=500) But when i delete a author in database(sqlite) there is an error!! Is there any way to solve that ??? -
How to overwrite route function of wagtail Page model
I am using Wagtail CMS for managing content in some of the tables in my database. Wagtail's Page model reference is done by linking one to one relation to the table in the database which is not managed by Django migration. The model structure is as follow: class MyDocument(Page): wagtail_page = models.OneToOneField('wagtailcore.Page', models.DO_NOTHING, parent_link=True, primary_key=True) route_field = models.TextField(db_column='route', verbose_name='URL Route (non-editable value)') slug_field = models.TextField(db_column='slug', verbose_name='URL Slug') language_field = models.ForeignKey('Languages', models.DO_NOTHING, db_column='language', to_field='language', verbose_name='Language') label_field = models.TextField(db_column='label', blank=True, null=True, verbose_name='Label') title_field = models.TextField(db_column='title', verbose_name='Title') content_field = RichTextField(db_column='content', verbose_name='Page Contents') def route(self, request, path_components): print("Route is called") return super(MyDocument, self).route(request, path_components) class Meta: db_table = 'document_translations' unique_together = (('route_field', 'slug_field', 'language_field'),) When the request is made from the browser, MyDocument's route method is only called after the parent Page's route method. My first question is 'Why is parent's route method called before child's method?' The second question is 'How to override the Page model's route method completely?' -
How to connect MongoDB with Django?
I am using Python 3.6.3,Django 1.11.10,MongoDb 3.6.2. I already installed Django-nonrel,djangotoolbox,Django MongoDB Engine. What I need to change in django settings. -
Unable connect oracle 10g XE to django
I am trying to connect to oracle 10g XE database from windows but getting following error Here is my settings for database DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', 'NAME': 'xe', 'USER': 'xxx', 'PASSWORD': 'xxx', 'HOST': '127.0.0.1', 'PORT': '1527', } } installed libraries cx-Oracle==6.1 Django==1.11.10 pytz==2018.3 Tried to identify solutions but found nothing related -
django update data that already saved
I have a variable, j= sheet[col10].value and try to pass it as address1 = ADDRESS.objects.get(Store_Nbr = j) But this is showing an error "ADDRESS matching query does not exist". How can i achieve this? -
How RelatedFieldWidgetWrapper (django admin) loads the created content
I'm building a webpage that use ModelForm with ManyToMany relations. The Admin of django has the useful RelatedFieldWidgetWrapper. It creates a + next to relationfields that, when pressed, opens a popup to create a related-object. Once the creation is made the main webpage (the one where we press the +) has the new item loaded. Now, in my website I would like to have something similar, my questions are: is it correct to use the RelatedFieldWidgetWrapper in a webpage outside admin? how does the page autoloads the new content (this is mainly my curiosity) any other applicable solution to have a handy form without requiring complex JS or several pages? thanks -
Angular + Django: Sending POST request with cookies (CORS)
I'm developing an app using Angular for client side and Django for server side. During development I'm running Django in port 8000 for managing all API requests, and serving my client app using Angular CLI running at port 4200. Sending GET requests to Django work w/o problems but when I try to send a POST request that includes some cookies with session information, it fails as the cookies are not included in the header. I know that the source of this "problem" is the CORS issue [read more here] and that it won't be a problem in production as both client and server apps will be running in the same server and port, however I wonder how can I fix this situation at least for development. I've tried using the django-cors-headers module with the options CORS_ALLOW_CREDENTIALSand CORS_ORIGIN_ALLOW_ALL set to True but it didn't work. Any ideas? -
Format timestamp in Django query in values
I am trying to use a Dajngo QuerySet where I have to format time_stamp field in .values ('time_stamp'). In PostgreSql I can dot like this: GROUP BY time_stamp::date I have to do this because in the date column the format (2018-01-22 00:00:28+01) show time as well and I want know the average of the filed only in ONE day. So my main question how can I create a query in Django which equal with this PostgreSQL query. SELECT avg(field) FROM table GROUP BY time_stamp:date -
NoReverseMatch Error- Django
I am trying to build a Django project with multiple applications, hence using urls.py for each application. I encounter a NoReverseMatch Error when Django tries to access the view. Main urls.py: urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^intface/', intface), url(r'^',include("userapp.urls",namespace="userapp")),] userapp urls.py: urlpatterns=[ url(r'^user/',TemplateView.as_view(template_name="user.html")) ] user.html: <form method="POST" action="{% url "userapp:user" %}" > Error: NoReverseMatch at /user/ Reverse for 'user' not found. 'user' is not a valid view function or pattern name. Please help! -
Django including header.html dealigns
I am trying to create web app using django , i have the header html with a search module ,when i search for a particular result the header html included in the result page dealings.Below i have attacked the code for header.html and the based page html where i have extended the header.html. <!DOCTYPE html> <html lang="en"> <head> <title>Signals</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> {% load staticfiles %} <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}" type="text/css"/> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico'%}"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <style> body { padding: 15px 15px 15px 15px; } html, body { height: 100%; width: 100%; margin: 0; } </style> <body class="body" style="background-color:#f6f6f6"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header navbar-center"> <a class="navbar-brand navbar-center" href="#">Signals</a> </div> <!--<div id="menu-outer"> <div class="table"> <ul id="horizontal-list"> <li><a href="#"><img src="images/list-item-1.gif" alt="list item 1" /></a></li> <li><a href="#"><img src="images/list-item-2.gif" alt="list item 2" /></a></li> <li><a href="#"><img src="images/list-item-3.gif" alt="list item 3" /></a></li> <li><a href="#"><img src="images/list-item-4.gif" alt="list item 4" /></a></li> </ul> </div> </div>--> <form class="navbar-form navbar-right-side" method="POST" action="search/">{% csrf_token %} <div class="input-group"> <input type="text" class="form-control" placeholder="Search" name="search" id="search"><br> <br><ul class="list-group" id="result"></ul> <div class="input-group-btn"> <button class="btn btn-default" type="submit" id="click"> <i class="glyphicon glyphicon-search"></i> </button> </div> </div> </form> </div> </nav> <div …