Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django create s3 bucket with button
I'm trying to create a button which will create an S3 bucket in AWS once clicked. I am still a bit green when it comes to Django so I'm not sure how to get this to run. I read a few tutorials but all of them show how to add something to a database when clicking a button. Here's what I have done so far: views.py class createS3(TemplateView): template_name = 'project/create_s3.html' def get(self, request): form = S3Form() return render(request, self.template_name, {'form': form}) def createBucket(self, bucketName): form = S3Form(request.POST) s3 = boto3.resource('s3') if form.is_valid(): name = form.cleaned_data['name'] s3.create_bucket(Bucket=name) def post(self, request): form = S3Form(request.POST) if form.is_valid(): name = form.cleaned_data['name'] args = {'form':form, 'name':name} return render(request, self.template_name, args) Here's the template: {% include "home/_header.html" %} {% block content %} {% load staticfiles %} <div class="mainPage"> <div class="s3Wrapper"> <form method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit" name="create" class="button create">Create</button> </form> </div> </div> {% endblock content %} Now my problem is, how do I call the createBucket function by clicking the button? Or do I need to create a new url and pass the 'name' variable there to create a new bucket? Thanks! -
Django TabularInline fields giving error on updating inline fields
I have a models like class Section(models.Model): section_title = models.CharField(max_length=200) section_tiles = models.ManyToManyField(Tile, blank=True) on_menu = models.BooleanField(default=False) section_is_active = models.BooleanField(default=True) class Meta: verbose_name = "Section" verbose_name_plural = "Sections" def __unicode__(self): return self.section_title class Page(models.Model): page_title = models.CharField(max_length=200) page_sections = models.ManyToManyField(Section, blank=True) on_menu = models.BooleanField(default=False) page_is_active = models.BooleanField(default=True) class Meta: verbose_name = "Page" verbose_name_plural = "Pages" def __unicode__(self): return self.page_title And at the admin part I have code such as: class SectionTabularInline(admin.TabularInline): model = Page.page_sections.through class PageAdmin(admin.ModelAdmin): inlines = [SectionTabularInline,] list_display =[ 'page_title', 'on_menu', ] list_filter =[ 'on_menu', ] search_fields = [ 'page_title', ] ordering = ['page_title'] admin.site.register(Page, PageAdmin) When I make changes in inline section of the page, Its giving an error "Please correct the errors below." without any additional information. If I remove sections from page and save it, then I can reassign them from scratch. Is there any way to change them without removing them first? -
Custom ForeignKey migration error: "ValueError: Related model 'external.Currency' cannot be resolved"
I'm trying to develop a Django (1.11) app in the lines of django-money (a composite MoneyField that handles amount AND currency seamlessly) but replacing the dynamically created CurrencyField (a custom CharField) with a custom ForeignKey (which points to a Currency model). However, though makemigrations works fine and produces the expected migrations, the migrate command returns an error: ValueError: Related model 'external.Currency' cannot be resolved Note: the overall solution works fine if I perform a two-step migration, without and then with the CurrencyField. However, I am trying to make migrations work automatically in one go. Can anyone shed some light if there is a way to make this work? No discussion I've read regarding custom ForeignKeys helped so far. The Currency Model class Currency(TenantMixin): code = models.CharField(_('code'), max_length=3, unique=True) name = models.CharField(_('name'), max_length=64) The BankAccount Model (where the MoneyField is declared) class BankAccount(TenantMixin): balance = MoneyField(max_digits=19, decimal_places=4, blank=True, null=True) ... The MoneyField (within which the CurrencyField is dynamically created) This creates a custom field that inherits from DecimalField and automatically generates a second field, a custom CurrencyField that inherits from ForeignKey. class MoneyField(models.DecimalField): """ A field that stores both currency and amount. """ ... def contribute_to_class(self, cls, name, **kwargs): cls._meta.has_money_field = … -
Django manytomany with value
Source example: class Amenities(models.Model): title = models.CharField("Title", max_length=300) value = models.BooleanField("Bool",default=False) class Meta: db_table = "amenities" def __str__(self): return self.title class Property(models.Model): title = models.CharField("Name category", max_length=300) amenities = models.ManyToManyField(Amenities) I wanna to create a list Aminities. Merge Amenities table with the Rent table and for each row add a value. Like in picture -
How to decode nested JSON data from JQuery Ajax GET call in Django view?
How do I send nested data in JSON format using JQuery's Ajax method, and then decode the data into a Python dictionary in a Django view? JQuery seems to be flattening the nested data into a string, which is expected... but once I receive the string in my Django view there seems to be no way to efficiently decode it back into the nested format that I want. JQuery Ajax call: $.ajax({ url: 'save/quest', data: JSON.stringify({ quest: { "id": 4, "requirements": ['metalworking'] } }), dataType: "json", contentType: "application/json" }); Django view: import json def save_quest(request): # does not work, apparently the string is not well-formatted JSON data = json.loads(str(request.GET.dict())) return JsonResponse({}) Django version: 1.11.7, Python version: 3.4.3, JQuery version: 3.2.1 -
Django reset password link is wrong using docker and nginx
I'm serving my django app with nginx using docker-compose. Here's my docker-compose.yml: version: '3' services: nginx: image: nginx:latest container_name: ng01 ports: - "80:80" volumes: - .:/code - ./config/nginx-dev:/etc/nginx/conf.d depends_on: - "web" db: image: postgres container_name: ps01 web: build: . command: bash -c "python manage.py migrate && gunicorn cyberchallenge.wsgi -b 0.0.0.0:8000" volumes: - .:/code expose: - "8000" depends_on: - "db" And here's my nginx configuration file: upstream web { ip_hash; server web:8000; } server { location / { proxy_pass http://web/; } listen 80; server_name localhost; } So, the problem is in the proxy_pass. When I try to reset my password with the django app, the reset link I receive starts with http://web/. How can I make it so that is uses the url of the app? -
Unable to save forms to the database for inline formsets using form wizard in Django
enter image description hereI am currently working on building a survey. The parent model 'Person' is linked to a 'Question' model via ManytoMany relationship. Both Question and Person model are linked to an 'Answer' model via foreign key. Currently, I am having issues using the Form Wizard which consists of two steps: First step is the Person form and the second step is the form consisting of an inline formset linking the Person and Answer model. On saving the forms to the database in the 'done' function of the wizard, only the first form seems to be saved to the database while the other one fails to even print on the terminal.views.py -
im trying to use django on kali. but everytime i use the django-admin startproject mysite command it fails
im trying to use django on kali. but everytime i use the django-admin startproject mysite command it fails. root@kali~#:django-admin startproject mysite Traceback (most recent call last): File "/usr/local/bin/django-admin", line 11, in <module> sys.exit(execute_from_command_line()) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/startproject.py", line 34, in handle super(Command, self).handle('project', project_name, target, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/templates.py", line 162, in handle if new_path.endswith(extensions) or filename in extra_files: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128) -
django too many values to unpack error
i have stored a list in django and now i want to convert that list to query set . ques=list(sorted(Upload.objects.filter(unique_id=tdetail), key=lambda x: random.random())) platform=Platform() platform.user=request.user platform.test_key=article platform.list=ques platform.save() ques is the list which i have stored in database.. it is the list of questions in random pattern . not to access the same questions in that pattern i am using this. now when i am using it to convert it into a query set platform=get_object_or_404(Platform,user=request.user,test_key=article) ques=Upload.objects.get(platform.list) it gives the error as... arg, value = filter_expr ValueError: too many values to unpack I want to access it in template..as {{ques.0.field}} -
Django - Serialize response from another server
I'm using DRF to make a GET request to another server and return this reponse to the client. What I want to know is how do I get only selected fields from that other server's response to return to my client. What I have is a response like this: { "plans": [ { "setup_fee": 500, "amount": 990, "code": "plano01", } { "setup_fee:... "code": "plano02", }... An array with many objects. And I want to give to the client something like this: { "plans": [ { "code": "plano01", } {"code": "plano02"... Only the code field. Whats the best way to do this with Django/DRF? -
nested serializer validation error
I'm trying to integrate a foreign key Currency inside my Invoice however whenever i execute i get below error. I guess this is because the object already exists, how do i tell the serializer to not trying to create if exists or ignore the validators? error response { "currency": { "name": ["currency with this name already exists."], "symbol": ["currency with this symbol already exists."], "img": ["The submitted data was not a file. Check the encoding type on the form."] } } post json { "currency": { "exchangePctFee": "0.50" "id": 3 "img": "static/img/currencies/krone.png" "maximum": 40 "minimum": 0.1 "name": "Krone" "precision": 2 "symbol": "DKK" }, "deposit_amount": 2.01 "receive_amount": 1267.28 "task": 1 } Serializers class CurrencySerializer(serializers.ModelSerializer): img = serializers.ImageField(required=False) class Meta: """Meta class to map serializer's fields with the model fields.""" model = Currency fields = ('id', 'name', 'symbol', 'img', 'precision', 'exchangePctFee', 'minimum', 'maximum') read_only_fields = ('created_at', 'updated_at') def create(self, validated_data): return Currency.objects.update_or_create(**validated_data) def update(self, instance, validated_data): instance.name = validated_data.get('name', instance.name) instance.symbol = validated_data.get('symbol', instance.name) instance.save() return instance class InvoiceSerializer(serializers.Serializer): currency = CurrencySerializer() user = AccountSerializer(read_only=True, required=False) deposit_amount = serializers.FloatField() receive_amount = serializers.FloatField() task = serializers.IntegerField() created_at = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False) class Meta: """Meta class to map serializer's fields with the model fields.""" … -
I am trying to make a reverse URL call but getting NOreverse match found
I am trying to use reverse URL to call a URL in an app(music) in django, but not able to. Below is my code My main_web_app URL file from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^login$/', include('login.urls')), url(r'^admin/', admin.site.urls), url(r'^music/', include('Music.urls'), name='indexView') ] My music/URL file from django.conf.urls import url from . import views app_name = 'music' urlpatterns = [ # /music/ url(r'^$', views.IndexView.as_view(), name='indexView'), # /music/852 url(r'^(?P<album_id>[0-9]+)/$', views.DetailView.as_view(), name='detailsView'), # /music/add url(r'^add/$', views.AddAlbum.as_view(), name='addView') ] My View file from django.shortcuts import render from django.views import generic from django.views.generic.edit import CreateView, UpdateView, DeleteView from .models import Album class IndexView(generic.ListView): template_name = 'Music/index.html' context_object_name = 'Album_List' def get_queryset(self): return Album.objects.all() class DetailView(generic.DetailView): template_name = 'Music/details.html' model = Album class AddAlbum(CreateView): model = Album fields = ['Album_name', 'Artist', 'Genere', 'Album_logo'] My Template file <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <ul> {% for album in Album_List %} <li><a href="{% url 'music:detialView' %}">{{ album.Album_name }} </a></li> {% endfor %} </ul> <a href="{% url 'music:addView' %}" > Add Album</a> </body> </html> The error coming up is Error during template rendering In template C:\Users\Varun\Desktop\newsite\Music\templates\Music\index.html, error at line 10 Reverse for 'detailView' not found. 'detailView' is not a … -
Where should the authentication functionality for my website reside?
I'm making a workout calendar app where a person can register a user and start logging his workouts in a calendar. This is how the project is structured right now. Inside of workoutcal/urls.py, I've defined, among others, the following urls: url(r'^login/$', views.login, name='login'), url(r'^register/$', views.UserFormView.as_view(), name='register') The views that handle the requests reside in workoutcal/views.py. My question is if this is the right way to do it. I'm a little bit confused about what an "app" in django (such as the workoutcal app) encapsulates. I think I want user to log in to the whole functionality of my website, and if that is the case, shouldn't the login urls reside in workout/urls.py? -
How to parse a javascript list containing dictionary in python django
I have a webhook. data0=[{"senderId":"smsdia","requestId":"******383233353233","report":[{"date":"2017-12-02 17:00:41","number":"12345","status":"1","desc":"DELIVERED"}],"userId":"119385","campaignName":"viaSOCKET"}] I receive the above data in a POST request to my server. Content-Type: application/x-www-form-urlencoded How do I parse it? I know that if it is a list: data1=['sree','kanth'] I can parse it with request.POST.getlist('data1[]') But I don't know how to parse when it is a list containing dict. edit1 Moreover, I get len(data1) is 2. But len(data0) is 0. -
How To Deploy Django1.11 In AWS with RDS?
I am new Django and python. now I want to deploy Django to aws EC2. and I also want to use RDS for DB. please suggest some best practices and deployment checklist. -
webpack server on nginx refused to connect
I'm trying to run my django app with a Vue.js frontend to docker. I want to have a django image, a nginx image for the server and a postfgresql image for the database. I also need an app for webpack to run it's hot-reload server while in development, when in production this is not really needed as django/nginx will just read the build.js file directly and no extra server is needed. My configuration looks like this: 1 - My main dockerfile # Set the base image FROM python:latest ENV PYTHONUNBUFFERED 1 # File Author / Maintainer MAINTAINER Maintaner @cosbgn # Set variables for project name, and where to place files in container. # overwrite -e SETTINGS=LOCAL when runnign local dev. ENV PROJECT=analyticme ENV SETTINGS=PROD ENV CONTAINER_HOME=/opt ENV CONTAINER_PROJECT=$CONTAINER_HOME/$PROJECT RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ 2 - My Node Dockerfile FROM node:latest WORKDIR ./client # Install Node COPY /client/package.json ./ RUN npm install #COPY . /client COPY . . EXPOSE 8080 CMD [ "npm", "start" ] alternatively I've also tried with: FROM node:latest WORKDIR ./client # Install Node ADD ./client/package.json /client RUN npm install COPY . /client My Docker compose file: … -
How to use pre-designed form in django
I have a designed form in my template and i want to use it instead of Django Forms. I created my model and view class and urls.but i don't know how to recive and use form's data. I've already studied Rendering fields manually but i want to use my form inputs and labels and only need the data. Plz be aware that class and models work perfect and i can use data if i use {{ form }} in my template instead of html code below Here's my class in my forms.py: class Reserve(forms.Form): name = forms.CharField(label='نام و نام خانوادگی', max_length=100) phone = forms.CharField(label='شماره تماس', max_length=11) email = forms.EmailField(label='ایمیل', max_length=100) occasion = forms.CharField(label='مناسبت', max_length=100) month = forms.CharField(label='ماه', max_length=100) day = forms.CharField(label='روز', max_length=100) week = forms.CharField(label='روز هفته') time = forms.CharField(label='ساعت', max_length=100) message = forms.CharField(label='توضیحات') Here's my function in views.py: def add_reserve(request): if request.method == 'POST': form = Reserve(request.POST) if form.is_valid(): name = form.cleaned_data['name'] phone = form.cleaned_data['phone'] email = form.cleaned_data['email'] occasion = form.cleaned_data['occasion'] month = form.cleaned_data['month'] day = form.cleaned_data['day'] week = form.cleaned_data['week'] time = form.cleaned_data['time'] message = form.cleaned_data['message'] reserve = MangReserve(name=name, phone=phone, email=email, occasion=occasion, month=month, day=day, week=week, time=time, message=message) reserve.save() return HttpResponseRedirect('/') else: form = Reserve() return render(request, 'mang/temp.html', {'form': form}) And … -
¿How to use FilteredSelectMultiple widget for a single select object?
Maybe it would be really simple to do, but I searched for two hours and nothing... When I have a ManyToMany field in Django, I can use the FilteredSelectMultiple widget in a form: class Promocion(forms.ModelForm): class Meta: model = Promocion fields = "__all__" widgets = { 'restaurante': admin.widgets.FilteredSelectMultiple("Somethings", is_stacked=True), } My question is, I need to use some similar for a ForeignKey field that has a search box and allow me select a single object, because actually I only can select from a list (something tedious): See image -
Using Django admin as a base for backend
First sorry for my poor English. I came from asp.net mvc. Now I use django with nanoboxio In asp, I can create sections like below. Create model and add it to dbcontext Right click controller folder and create new controller with views. Modify as you wish For now, I know Django can create admin interface for your model. I try and happy with it. but i want to develop it. I want to for example; Create a post model. Create a admin interface for it. Copy generated admin interface controller and views to another app Modify it How can I do that? -
Why the webpage is not scrolling down even if the content is present in django?
I have some code which connects the base.html to index.html using django. The problem is the page is not scrolling down even though extra content is present below. I have added overflow css attribute also. But still,it is not working. The base.html is: <!DOCTYPE html> {% load staticfiles %} <html> <head> <meta charset="utf-8"> <title>Star Social</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> <link rel="stylesheet" href="{% static 'simplesocial/css/master.css'%}"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <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> <body> <nav class="navbar mynav" role="navigation" id="navbar"> <div class="container"> <a class="navbar-brand mynav" href="{% url 'home' %}">Star Social</a> <ul class="nav navbar-nav navbar-right"> {% if user.is_authenticated %} <li><a href="{% url 'posts:create' %}" class="btn btn-simple">Post</a></li> <li><a href="{% url 'groups:all' %}" class="btn btn-simple">Groups</a></li> <li><a href="{% url 'groups:create' %}" class="btn btn-simple">Create Group</a></li> <li><a href="{% url 'accounts:logout' %}" class="btn btn-simple">Log out</a></li> {% else %} <li><a href="{% url 'groups:all' %}"class="btn btn-simple">Groups</a></li> <li><a href="{% url 'accounts:login' %}" class="btn btn-simple">Log in</a></li> <li><a href="{% url 'accounts:signup' %}" class="btn btn-simple">Sign up</a></li> {% endif %} </ul> </div> </nav> {% block content %} {% endblock %} <canvas id="canvas"></canvas> </body> <script src="{% … -
loaddata through yaml shows DeserializationError
I want provide intial data in django i have model name like AbcD My yaml is like this: - model: app.abcd pk: 1 fields: number: 1 when i run python manage.py loaddata test.yaml it shows this: django.core.serializers.base.DeserializationError: Problem installing fixture '/home/mike/fixtures/test.yaml': while parsing a block collection in "/home/mike/fixtures/test.yaml", line 1, column 1 expected , but found '?' -
React form submittal and Django POST request
I need help identifying the bug in my current code. Few things to note: Admin server validates model exist however the admin dashboard displays empty fields. Client side: form submits successfully and captures data in state My issue is being able to collect the data from the client and send it to the api. My request.POST object returns empty even though the rest of the app seems to be working. I want the data from the React form to POST to the Django server. Things I have tried: changing django.views.generic from TemplateView to FormView to View change path to template ./djangorest/template/index.html views.py from __future__ import unicode_literals from django.shortcuts import render, redirect from django.http import HttpResponse from django.views.generic import TemplateView from api.models import Risk class create_user(TemplateView): def index(self, request): template = 'index.html' return render(request, self.template) def post(self, request): if request.method == 'POST': risk_type = request.POST.get('risk_type') first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') age = request.POST.get('age') zipCode = request.POST.get('zipCode') prize_amount = request.POST.get('prize_amount') currency = request.POST.get('currency') Risk.objects.create( risk_type = risk_type, first_name = first_name, last_name = last_name, age = age, zipCode = zipCode, prize_amount = prize_amount, currency = currency ) return redirect('/') print('*'*50) print(request.POST) print('*'*50) return HttpResponse("<h1>Submitted</h1>") models.py from __future__ import unicode_literals import datetime from … -
How to prefetch SocialAccount with django-allauth?
Django-allauth package creates a model SocialAccount, with a ForeignKey to User. I can't manage to prefetch this information in my queryset. My model: class Placerating(models.Model): author = models.ForeignKey('auth.User', null=True, on_delete=models.SET_NULL) Django-allauth model: class SocialAccount(models.Model): user = models.ForeignKey(allauth.app_settings.USER_MODEL, on_delete=models.CASCADE) When I try to prefetch this data: rating = Placerating.objects.all().prefetch_related('author__socialaccount') I get the following error message: AttributeError: Cannot find 'socialaccount' on User object, 'author__socialaccount' is an invalid parameter to prefetch_related() Any clue ? Thanks! -
Django image form isn't saving the image
I have a form that involves uploading a profile picture. I have it working so that I can upload images in the /admin/ interface and display them correctly, but I cannot get my Modelform to save the image. Here is what I have: models.py class Candidate(models.Model): UserID = models.ForeignKey(User, on_delete=models.CASCADE) ElectionID = models.ForeignKey(Election, on_delete=models.CASCADE) Bio = models.CharField(max_length=500, blank=True) ProfilePicture = models.ImageField(upload_to="profilepics/", null=True, blank=True) forms.py class AddCandidateForm(forms.ModelForm): class Meta: model = Candidate fields = ['ElectionID', 'Bio', 'ProfilePicture'] cand_reg.html (Template) {% block content %} <h1>Register as a candidate</h1> <form method="POST" class="post-form"> {% csrf_token %} <h2>Select an election:</h2><br> {{form.ElectionID}}<br> <h2>Enter your bio:</h2><br> {{form.Bio}}<br> <h2>Upload a profile picture:</h2><br> {{form.ProfilePicture}}<br> <button type="submit">Register</button> </form> {% endblock %} When I try the view function like so I get the error: MultiValueDictKeyError at /register/ "'ProfilePicture'" views.py def add_candidate(request): if request.method == 'POST': form = AddCandidateForm(request.POST, request.FILES) if form.is_valid(): candidate = form.save(commit=False) candidate = request.FILES['ProfilePicture'] candidate.UserID = request.user candidate.save() return redirect('/home/') else: form = AddCandidateForm() return render(request, 'cand_reg.html', { "form": form }) views.py When I remove the offending line, the error goes away. def add_candidate(request): if request.method == 'POST': form = AddCandidateForm(request.POST, request.FILES) if form.is_valid(): candidate = form.save(commit=False) # candidate = request.FILES['ProfilePicture'] candidate.UserID = request.user candidate.save() return redirect('/home/') else: … -
The page is not scrolling down in django
I have written code for developing social media site using django. I am facing a problem that, the pages are not scrolling down even a lot of content present below. How to rectify this? Normally, in html pages when extra data is added, the will be modified to be able to scroll down. But this is not working in my page. {% extends "posts/post_base.html" %} {% block prepost %} <body> <div class="col-md-4"> <h1>@{{ post_user.username }}</h1> <p>Post History</p> </div> </body> {% endblock %} {% block post_content %} <div class="col-md-8"> {% for post in post_list %} {% include "posts/_post.html" %} {% endfor %} </div> {% endblock %} Please help me with this. How to make the page to scroll down when extra content is added.