Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django return render or HttpResponse to an Ajax using the same template
I want to render a Django template that extends the base.html. an Ajax call is made from the template when it is already rendered, using a form. Now I need to return the ajax response to the same template but show data conditionally if the view function had successfully created/passed a context object to the template. I tried below with render(request, template, context). It did not work. Shall I be using HttpResponse? What is the right way to do this? #empty dictionary a_source_dict ={ 'key':'', 'value1':'', ... } views def createObject(request): if request.method == "POST": ... ... person = copy.deepcopy(a_source_dict) ... #add data to the new intance of the dict else: pass return render(request, 'body-object.html', context={'person': person}) #person is a dictionary, sending to the template to render the data in it conditionally body-object.html {% extends "base.html" %} {% block content %} <form method="POST" ="{% url 'createObject' %}"> {% csrf_token %} ... </form> #form used to make the ajax call that responce is being sent for {% if person %} #show below div only if an object person, a context is present; else hide div <div class="box" id="objectbox"> <div> {{ person['key'] }} </div> #tryin to print the value in the dict … -
Reques.post.get() returns the value and none
I have a form that submits the absentee's name to the database. I tried to pass the name via request.POST.get to the views.py. However, it passed the name and none together and it does not save to database. Below is my code: views.py def AbsentStudent(request, id=None): wk = LabDuration.objects.get(sDate=today) wk1 = MarkAtt.objects.filter(currentDate=today) if wk.sDate == today.date() and wk1 == today.date(): wk2 = wk1.week if wk2 == wk1.week: q1 = Namelist.objects.filter(classGrp=id).values('name') q2 = MarkAtt.objects.all().values('studName__name') q3 = q1.difference(q2) else: q1 = Namelist.objects.filter(classGrp=id).values('name') q2 = MarkAtt.objects.all().values('studName__name') q3 = q1.difference(q2) form_class = studStatus form = form_class(request.POST) if request.method == 'POST': if form.is_valid(): a = form.save(commit=False) a.studName__name = request.POST.get("sname") //does not submit into database form.save() return redirect('editStudStatus',id) else: form = form = studStatus(request.POST ) context = { 'form' : form, 'q3':q3 } return render(request,'studDetails.html',context, {'form':form}) template: <tbody> {% for q in q3 %} <tr> <form method="post" enctype="multipart/form-data"> {% csrf_token %} <td><input type="text" name="sname" values="{{q.name}}">{{q.name}} <td>{{form.status }}</td> <td>{{form.remarks}}</td> <td><button type ="submit" class="btn btn-outline-success" >Submit</button> </form></td> </tr> {% endfor %} </tbody> -
Why am i getting error when i am deploying this code on a production server while it's perfectly working in local server?
I want to take voice input from an user in a vernacular language. This code has been implemented on a Django web app, when the Django server is working in locally it is perfectly working but when i am deploying it on cloud it is showing the error: not allowed. When it is working on a local machine then why is it not working when it is being deployed on a cloud? Error: var message = document.querySelector('#message'); var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition; var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList; var grammar = '#JSGF V1.0;' var recognition = new SpeechRecognition(); var speechRecognitionList = new SpeechGrammarList(); speechRecognitionList.addFromString(grammar, 1); recognition.grammars = speechRecognitionList; recognition.lang = 'bn'; recognition.interimResults = false; recognition.onspeechend = function() { recognition.stop(); }; recognition.onerror = function(event) { message.textContent = 'Error : ' + event.error; } document.querySelector('#btnGiveCommand').addEventListener('click', function() { recognition.start(); }); recognition.onresult = function(event) { var last = event.results.length - 1; var command = event.results[last][0].transcript; // Pass this variable's value at the backend if (command != null) { document.getElementById('user_text').value = command; //user_text.style.display = "block"; //submit.style.display = "block"; document.getElementById("userText").submit(); } }; <form action="./user_input" ,method="get" id="userText"> <input type="text" id='user_text' name="user_data"> </form> <button id='btnGiveCommand'>Press here to speak</button> <br><br> <span id='message'></span> <br><br> -
Confusion in Foreign key concepts
I am new to working on database schema. I have a schema mentioned in the following image. Database Schema Here, let's consider Table 1 and Table 2 . Which of the following statements are true? 1) field1 in the Table1 is a foreign key to field5 in Table2 (or) 2) field5 in the Table2 is a foreign key to field1 in Table1 because only one of the both the statement can be true. Note :- The relations between two tables are linked with a line segment as shown in the image which is why I got confused. If there would have been an arrow, it would have been very clear to understand. -
How to query in django datetimefield with default timezone.now for a specific day?
I have a model Game with datetimefield set to default timezone.now(). I want to query how many games were played on a specific day. I have tried following command and that works fine. games = Game.objects.filter(time=timezone.now().strftime("%Y-%m-%d")) But now I want to query Games with filter set to a specific day, let say timezone.now - 1 day. I have tried different variations of timezone.localtime and timezone.localdate and they yield a TypeError. >>> timezone.localtime(datetime.datetime, timezone.get_default_timezone()) Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/savi/python-environments/comments/lib/python3.6/site-packages/django/utils/timezone.py", line 206, in localtime if is_naive(value): File "/home/savi/python-environments/comments/lib/python3.6/site-packages/django/utils/timezone.py", line 261, in is_naive return value.utcoffset() is None TypeError: descriptor 'utcoffset' of 'datetime.datetime' object needs an argument I have looked at different questions and other sites and none have suggested any approach for what I am trying to do. Maybe I am not looking at the right places. If someone can guide me through this, I will really appreciate that, Thanks in advance and a very happy new Year. my settings.py file # TIME_ZONE = 'UTC' TIME_ZONE = 'Asia/Kolkata' USE_I18N = True USE_L10N = True USE_TZ = True -
Deploy Python apps to Azure App Service on Windows Server
I can't find any proper guideline how to deploy a Django web application on Windows Server, almost all tutorials talk about Linux. Can someone explain or give a link? I now we need an IIS. What about DNS and AD, or any other services? I would like to know the relationship among IIS, DNS and AD, or any other services. -
referencing users by primary key in class based view django
So I am building a blog website and I want to reference a detailed profile view after the user who is interacting with the website clicks the link to the detail profile view of an author Now, class ProfileDetailView(DetailView): model = User context_object_name = 'user' So in urls.py, I add primary key path('profile/<int:pk>', ProfileDetailView.as_view(), name='profile-detail') Now in html, I say like: {{ user.username }} <img src="{{ user.profile.image.url }}" > {{ user.email }} Now, what happens is, in my homepage where I have created like 30 blogs and each of them have a link to view the profile of author. Now I have just created 2 authors and those two posted those 30 blogs. Now If I like go to the author's page of 30th blog, it takes me to the route http://localhost:8000/profile/30 So it is creating urls with primary key 1 to 30 but I have primary keys for my authors' just 1 and 2. So, it is giving error that page not found. So I want the link to take me to the url that refers to the profile of an author. Like even if I click on the 30th post, it should take me to author id 2 … -
Issues loading css on specific page in django
I don't seem to be getting the css for a specific page to load on django. This is the code for the page in question #home2.html {% load static %} <!DOCTYPE html> <html class="st-layout ls-top-navbar-large ls-bottom-footer show-sidebar sidebar-l3" lang="en"> <head> <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>Learning</title> <link href="{% static 'second/css/vendor/all.css' %}" rel="stylesheet"> <link href="{% static 'second/css/app/app.css' %}" rel="stylesheet"> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"> </script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> ... This is the structure of the files: django-project -->project static css img vendor second css images js app templates classroom school templates mentor home2.html registration login signup Not sure what I am doing wrong since I am loading the static folder with the css files -
Viewing django from local network
I have just successfully installed and run django http://127.0.0.1:8000/. I was wondering if it is possible for me me to log into from a local network with a 192.168.x.x instead of local host? I can remotely edit files just wanted to know if i can remotely view the page also? -
Is it possible to customize the default django admin page?
I'm new to web development. I started Django a couple of days ago. I want the css style to apply to the admin page. Is it possible and how should i do it? -
How to print new text in same page using Django?
I am new to Django and I am stuck with this issue. I am trying to create a login page where the user enters his/her username and password and Submit to go to the next page. For now just to test, I want to print a text saying " successfully logged in" when the user enters id and password in my login page itself. This is my urls.py from django.urls import path from . import views urlpatterns = [ path('login',views.log, name = 'login'), ] This is my Views.py from django.shortcuts import render def log(request): return render(request, 'login_page.html') def verify_num(request): username = request.GET['uname'] password = request.GET['pass'] grant = 'successfully logged in' if username == 'harish' and password == 'harish': return render(request, 'login_page.html',{'access':grant}) And this is my html page. {% extends 'base.html' %} {% block content %} <h1 align = 'center'><b>LOGIN</b></h1> <form action = '' align ='center'> Enter Username: <input type = 'text' name = 'uname' text-align :'center'><br><br> Enter Password: <input type = 'password' , name = 'pass' align = 'center'><br><br> <input type= 'submit'><br> <h3 >{{access}} </h3> </form> {% endblock %} How do I call my funtion verify_num in views.py so that the text saying "Successfully logged in" prits -
Django Admin Change password link broken
Example for user "Bob" Django Admin: Home › Authentication and Authorization › Users › Bob When modifying a user in Django Admin interface, under the password it says: Raw passwords are not stored, so there is no way to see this user's password, but you can change the password using this form. However, the this form link fails with a Page not found 404, and the address is: http://127.0.0.1:8000/password/ Whereas the correct URL (which works) should be: http://127.0.0.1:8000/admin/auth/user/40/password/ After some searching I found: Lib/site-packages/django/contrib/auth/forms.py:129 : class UserChangeForm(forms.ModelForm): password = ReadOnlyPasswordHashField( label=_("Password"), help_text=_( "Raw passwords are not stored, so there is no way to see this " "user's password, but you can change the password using " "<a href=\"{}\">this form</a>." ), ) But I dont see how the change password link is set in the href, it looks blank to me. I also dont want to change the Django sourcecode because then the same bug will manifest when there are updates. How to I get the link to point to the change password page which works? -
Can I specify or change fields to use in a ModelFrom from within my Views.py?
Let's say I have the following ModelForm: forms.py class JournalEntryForm(ModelForm): def clean_date(self): data = self.cleaned_data['date'] # Some validation... return data class Meta: model = JournalEntry fields = ['user','date','description'] widgets = {'date': DateTypeInput()} I want to reuse the above modelform in several views. But the different views require different fields to be used from the model form. Is there a way I can "over ride" the fields in the ModelForm meta? I tried this: @login_required def entries_update(request, pk): journal_entry = get_object_or_404(JournalEntry, pk=pk) if request.method == 'POST': journal_entry_form = JournalEntryForm(request.POST, instance=journal_entry) journal_entry_form.fields = ['date','description'] # Just testing ! if journal_entry_form.is_valid(): journal_entry_form.save() messages.success(request, "Journal entry successfully updated.") return HttpResponseRedirect(reverse('journal:entries_show_detail', kwargs={'pk': journal_entry.id}) ) return render(request, 'journal/entries_update.html',{'journal_entry': journal_entry, 'journal_entry_form': journal_entry_form, }) I get an error: Exception Value: 'list' object has no attribute 'items' The end of the traceback: C:\Users\Philip\CodeRepos\Acacia2\venv\lib\site-packages\django\forms\forms.py in _clean_fields for name, field in self.fields.items(): … ▼ Local vars Variable Value self <JournalEntryForm bound=True, valid=True, fields=(date;description)> -
DjangoCMS TemplateSyntaxError when create first new page
I'm trying to make a site with DjangoCMS on IIS. I'm using Windows Server 2019 on Azure VM. When I tried to make first page, I got an error message below. TemplateSyntaxError at /ko/cms_wizard/create/ 'menu_tags' is not a registered tag library. Must be one of: (tag list...skip) Request Method: POST Request URL: https://pdmnu.com/ko/cms_wizard/create/ Django Version: 2.2.9 Exception Type: TemplateSyntaxError Exception Value: 'menu_tags' is not a registered tag library. Must be one of: admin_list admin_modify admin_static admin_style_tags admin_tree admin_tree_list admin_urls cache cms_admin cms_alias_tags cms_js_tags cms_static cms_tags djangocms_text_ckeditor_tags easy_thumbnails_tags filer_admin_tags filer_image_tags filer_tags i18n l10n log sekizai_tags snippet_tags static staticfiles thumbnail tz Exception Location: C:\inetpub\python\lib\site-packages\django\template\defaulttags.py in find_library, line 1023 Python Executable: C:\inetpub\python\Scripts\python.exe Python Version: 3.8.1 Python Path: ['.', 'C:\\inetpub\\wwwroot', 'C:\\Program Files\\Python38\\python38.zip', 'C:\\Program Files\\Python38\\DLLs', 'C:\\Program Files\\Python38\\lib', 'C:\\Program Files\\Python38', 'C:\\inetpub\\python', 'C:\\inetpub\\python\\lib\\site-packages'] Server time: 수요일, 1 1월 2020 18:46:53 +0900 I didn't edit any of DjangoCMS' original source and I'm just using Python 3.8.1 venv and wfastcgi. What should I do? -
Difference between using CreateView and forms.Modelform in creating a form for a django model?
i have a Django model to store information of a Article , i saw to methods to create a form through which users can create a article and save it in the data base but i am not able to find what is the difference between two please help me with this? 1.This is the first method using ModelForm from django forms ... from django.forms import ModelForm from myapp.models import Article class ArticleForm(ModelForm): class Meta: model = Article fields = ['pub_date', 'headline', 'content', 'reporter'] ... 2.This is the second method using createview from django.views.generic.edit import CreateView from myapp.models import Article class ArticleForm(CreateView): model = Article ... fields = ['pub_date', 'headline', 'content', 'reporter'] what is the difference between using these two methods? -
django in production enviorment, urls.py only matching empty path i.e " " and nothing else?
Everything works fine on development server but in production server I can only access views.home at https://www.host.com/ I'm using django 2.1 in python 3.7. Cheers! Here's the project level urls.py from django.contrib import admin from django.urls import path, include from django.contrib.auth import views as auth_views from ext.forms import CustomAuthForm from mysite import settings from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns = [ path('admin/', admin.site.urls), path('login/', auth_views.LoginView.as_view(authentication_form = CustomAuthForm), name='login'), path('logout/', auth_views.LogoutView.as_view(next_page= settings.LOGOUT_REDIRECT_URL), name='logout'), path('', include('ext.urls')), ] urlpatterns += staticfiles_urlpatterns() And app level urls.py looks like this from django.urls import path, re_path from django.conf.urls import url from ext import views from django.contrib import admin from django.conf import settings from django.conf.urls.static import static app_name = 'ext' urlpatterns = [ path('', views.home, name='home'), path('int/', views.get_int_status, name='home-load-int'), path('ext/', views.get_ext_status, name='home-load-ext'), path('tab/', views.get_tab_status, name='home-load-tab'), path('b/', views.uzair, name='home-uzair'), ] -
Error opening photos stored in zip file in Django
I'm going to create a zip file from some of the image files stored on my server. I've used the following function to do this: def create_zip_file(user, examination): from lms.models import StudentAnswer f = BytesIO() zip = zipfile.ZipFile(f, 'w') this_student_answer = StudentAnswer.objects.filter(student_id=user.id, exam=examination) for answer in this_student_answer: if answer.answer_file: answer_file_full_path = answer.answer_file.path fdir, fname = os.path.split(answer_file_full_path) zip.writestr(fname, answer_file_full_path) zip.close() # Close zip_file_name = "student-answers_"+ str(examination.id)+"_" + str(user.id) + "_" + date=datetime.datetime.now().strftime("%Y-%m-%d-%H-%M") + '.zip' response = HttpResponse(f.getvalue(), content_type="application/x-zip-compressed") response['Content-Disposition'] = 'attachment; filename=%s' % zip_file_name return response Everything is fine and all photos are made in zip file but there is only one problem. The problem is that the photos won't open and this error will appear in Windows: Its look like we don't support this file format. What is wrong with my codes? -
i got error, when i try to save object in django
'''help me to solve below issue (i am just beggener,(even i may not ask question in right way)). what else i need to provide you. students() got an unexpected keyword argument 'stu_name' Request Method: POST Request URL: http://127.0.0.1:8000/studentsenter code here Django Version: 2.2.5 Exception Type: TypeError Exception Value: students() got an unexpected keyword argument 'stu_name' Exception Location: C:\Users\GAGAN\Desktop\tarkProject\myapp\views.py in students, line 18 Python Executable: C:\Users\GAGAN\Anaconda3\envs\djangoenv\python.exe Python Version: 3.7.5 Python Path: ['C:\Users\GAGAN\Desktop\tarkProject', 'C:\Users\GAGAN\Anaconda3\envs\djangoenv\python37.zip', 'C:\Users\GAGAN\Anaconda3\envs\djangoenv\DLLs', 'C:\Users\GAGAN\Anaconda3\envs\djangoenv\lib', 'C:\Users\GAGAN\Anaconda3\envs\djangoenv', 'C:\Users\GAGAN\Anaconda3\envs\djangoenv\lib\site-packages'] Server time: Wed, 1 Jan 2020 06:23:38 +0000''' views.py from django.shortcuts import render from .models import students # Create your views here. def home(request): return render (request, 'myapp/home.html') def contact(request): return render (request, 'myapp/contact.html') def students(request): if request.method == 'POST': name = request.POST.get('stu_name') father = request.POST.get('stu_father') mother = request.POST.get('stu_mother') cl = request.POST.get('stu_class') s = students(stu_name=name, stu_father=father, stu_mother=mother, stu_class=cl) s.save() return render (request, 'myapp/students.html') else: return render (request, 'myapp/students.html') models.py from django.db import models # Create your models here. class contact(models.Model): stu_name = models.CharField(max_length=30) stu_father = models.CharField(max_length=30) stu_mother = models.CharField(max_length=30) # stuClass = models.CharField(max_length=30) def __str__(self): return self.stu_name class students(models.Model): stu_name = models.CharField(max_length=30) stu_father = models.CharField(max_length=30) stu_mother = models.CharField(max_length=30) stu_class = models.CharField(max_length=10) def __str__(self): return self.stu_name -
How to define a relationship in Django model?
I am writing a Django app where a user can create a post about available rooms for rent with descriptions and pictures. I am having a hard time figuring out how to define the relations in the model. I think the relation between the user class and landlord class will be many-to-one relationship. My question is, how do I define the relation between the user, landlord and the other classes like rentalProperty, contract and media. Thanks. from django.db import models from django.contrib.auth.models import User # Create your models here. class Landlord(models.Model): user = models.ForeignKey("User", on_delete=models.PROTECT) address = models.CharField(max_length=255) social_security_number = models.CharField(max_length=255) email_address = models.CharField(max_length=255) class rentalProperty(models.Model): landlord = models.ForeignKey("Landlord", on_delete=models.PROTECT) PROPERTY_LISTING_CHOICES = [ (APARTMENT, 'Apartment'), (HOLIDAY_HOME, 'Holiday home'), (SINGLE_FAMILY_HOME, 'Single family home'), (COMMERCIAL, 'Commercial'), ] type_of_property_listing = models.CharField( max_length = 50, choices = PROPERTY_LISTING_CHOICES, default = APARTMENT ) BUILDING_LISTING_CHOICES = [ (CONDOMINIUM, 'Condominium'), (ROW_HOUSE, 'Row house'), (SINGLE_FAMILY_HOUSE, 'Single family house'), (HOLIDAY_HOME, 'Holiday_home'), (DUPLEX, 'Duplex'), (SINGLE_FAMILY_HOME_COOP, 'Single family home(CO-OP)'), (CONDOMINIUM_EXTERNAL_ENTRANCE, 'Condominium external entrance'), (WOODEN_COMDOMINIUM_HOUSE, 'Wooden condominium house') ] type_of_building_choices = models.CharField( max_length = 50, choices = BUILDING_LISTING_CHOICES, default = CONDOMINIUM ) created_by = models.ForeignKey(User, related_name='rentalProperties') class Location(models.Model): rental_property = models.ForeignKey("rentalProperty", on_delete=models.PROTECT) street = models.CharField(max_length=255) borough = models.CharField(max_length=255) postal_code = models.CharField(max_length=20) city … -
Correct library to place my BaseFormSets and BaseInlineFormSets?
At the moment I have these located in forms.py, but the documentation doesn't make it clear which file / library I should have these located in. I think on one project I saw them located in a file called formsets.py. Thank you -
No such table: solutions_account when I create another superuser
Long story short, I messed up my migrations and ended up deleting them, but now when I create a superuser the compiler gives me an error saying that I have no table. What can I do to start from a completely clean slate? -
best way to design scheme in django when we have diff categories and products
I am designing django models for a E-commerce market place site where user can buy 4 type of products . Like I have 4 type of diff models for them . For clothes class Merchandise(models.Model): adOwner = models.ForeignKey(VendorProfile, on_delete=models.CASCADE) imagesMerchandise = models.ManyToManyField(merchandiseImages) productName = models.CharField(max_length=50, null=False, blank=False) price = models.IntegerField() availableQuality=models.IntegerField() color=models.CharField(max_length=20, null=False, blank=False) size = models.CharField(max_length=50 , null=False , blank=False) description=models.CharField(max_length=250 , null=False , blank=False) is_approved = models.BooleanField(default=False) def __str__(self): return str(self.productName) for Rent a Car class Vehicle(models.Model): adOwner=models.ForeignKey(VendorProfile, on_delete=models.CASCADE) carImages=models.ManyToManyField(Image) make=models.CharField(max_length=50, null=False, blank=False) modelName=models.CharField(max_length=50, null=False, blank=False) registrationNumber=models.CharField(max_length=50, null=False, blank=False) modelYear=models.CharField(max_length=50, null=False, blank=False) modelColor=models.CharField(max_length=50, null=False, blank=False) carType=models.CharField(max_length=50, null=False, blank=False) fuelMileage=models.CharField(max_length=50, null=False, blank=False) SeatingCapacity=models.CharField(max_length=50, null=False, blank=False) vehicleCondition=models.CharField(max_length=50, null=False, blank=False) fuelType=models.CharField(max_length=50, null=False, blank=False) price=models.CharField(max_length=50, null=False, blank=False) description=models.CharField(max_length=500, null=True, blank=True) registerIn=models.CharField(max_length=500, null=True, blank=True) is_approved = models.BooleanField(default=False) def __str__(self): return str(self.modelName) book a hotel class Accommodation(models.Model): adOwner = models.ForeignKey(VendorProfile, on_delete=models.CASCADE) hotleImages = models.ManyToManyField(HotleImages) accommodationTitle=models.CharField(max_length=150) location = models.CharField(max_length=150) accommodationName = models.CharField(max_length=150) checkIn = models.TimeField() checkOut = models.TimeField() # accessibility = models.CharField(max_length=20, null=False, blank=False) address = models.CharField(max_length=150) pets = models.CharField(max_length=150) child = models.CharField(max_length=150) is_approved = models.BooleanField(default=False) Create a Activity class ActivityOrganizer(models.Model): adOwner = models.ForeignKey(VendorProfile, on_delete=models.CASCADE) activityImage = models.ManyToManyField(ActivityImage) activityName = models.CharField(max_length=50 , null=False, blank=False) activityId = models.CharField(max_length=20, null=False, blank=False) ageSuggestion = models.CharField(max_length=20, null=True, blank=True) duration … -
when i run the python django services in local machine by ip address,it is not working
When i run the python django services in local machine by ip address,it is not working .It is not working can you solve this issue. python manage.py runserver 192.168.1.48:8000 -
Operational error/no_such_table error with herokuapp database - Django
I get an operational error, no_such_table when I need the database. I'm not sure what happened but it was working fine. When I run heroku run python3 manage.py migrate after migrations, the migrate part works fine. But if re run migrate, the same migrations happen and no matter how many times I run it, it never says No migrations to apply. Ive tried a lot of things including deleting postgres, the heroku app as well and making a new one with the same name but still no use. What could be the problem? -
Getting the content from the database in the template without loops?
I am having model called furniture and I am having template and also wrote my views and I want to the single phrase from the database My views.py def project3(request): furn=furniture.objects.all() return render(request, 'project3.html',{'furniture':furn}); My template is: <div class="col-4"> <h6 class="display-6 mt-3"><b><center>{{furniture.phrase}}</center></b></h6> <p class="demo"><center>I'm designing the room </p> </div> <div class="col-4"> <h6 class="display-6 mt-3">{{furniture.phrase}}</b></h6> <p class="demo">I'm designing around a few pieces I already own</p> </div> <div class="col-4"> <h6 class="display-6 mt-3"><b>{{furniture.phrase}}</b></h6> <p class="demo">I want to put the finishing touches on my room</p> </div> </div> </p> My models.py: class furniture(models.Model): id=models.IntegerField(primary_key=True) phrase=models.CharField(max_length=60,default='111111') def __str__(self): return self.phrase There are three phrases in the database but i am rendering them and I am not getting them in the webpage please help me out from this?