Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Datatables not loading for the table containing child rows
I am trying to apply the jQuery Datatable function in my html table, which contains an another child table in 2nd row of my table. I am getting the following error in my browser's console : Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined When I had empty with no data filled, the datatable was working perfectly, while the datatable didn't work properly when I uploaded the data in it. I am confused what the matter is? {% extends 'base2.html' %} {% load static %} {% load tz humanize %} {% timezone "Asia/Kolkata" %} {% block content %} <h2 class="align-left">Previous Dispatches</h2> {% include 'classroom/teachers/dispatcher_header.html' with active='dispatches' %} <div class="card"> <table class="table table-striped mb-0 dispatches" id="dispatcherhistory"> <thead> <tr> <th>ID</th> <th>Vehicles</th> <th>Gross Weight</th> <th>Route</th> <th>Route Distance</th> <th>Route TAT</th> <th>ETD</th> {# <th></th>#} <th></th> <th></th> <th></th> </tr> </thead> <tbody> <form method="post" novalidate> {% csrf_token %} {% for plan in plan %} <tr> <td class="align-middle">{{ plan.comments }}</td> <td class="align-middle">{{ plan.pk }}</td> <td class="align-middle">{{ plan.truck_type }} {{ plan.truck_name }}</td> <td class="align-middle">{{ plan.weight }}.00 KG</td> <td class="align-middle">{{ plan.origin }}-{{ plan.destination }}</td> <td class="align-middle">{{ plan.route_distance }} KM</td> <td class="align-middle">{{ plan.route_tat }}</td> <td class="align-middle">{{ plan.etd }}</td> {# <td class="align-middle">{{ plan.eta }}</td>#} <td class="align-middle"> <button class="btn" type="button" data-toggle="collapse" data-target="#multiCollapse{{ plan.pk … -
How can I iterate through an SQL database using a function within a Django model?
I need to know how I can create a function within a Django model which iterates through a SQL database, specifically another model. My Django project contains two models, 'Accelerator' and 'Review'. The Accelerator model has a decimal field 'overall_rating', the value of which is to depend on the accumulation of values inputted into one of the Review model fields, 'overall'. To make this work, I have concluded that I need to create a function within the Accelerator model which: Iterates through the Review model database Adds the value of Review.overall to a list where a certain condition is met Calculates the total value of the list and divides it by the list length to determine the value for overall_rating The value of accelerator.overall_rating will be prone to change (i.e. it will need to update whenever a new review of that 'accelerator' has been published and hence a new value for review.overall added). So my questions are: Would inserting a function into my accelerator model ensure that its value changes in accordance with the review model input? If yes, what syntax is required to iterate through the review model contents of my database? (I've only included the relevant model fields … -
Redirect user to previous page after login in django allauth social facebook login
I am using django-allauth for social login. I am using method="js_sdk" . So it gives a popup for login. But its redirecting to profile page or home page if specified in settings. Is there a way to redirect to previous page on which user was originally. for examples if I have a page https://www.example.com/product/t-shirsts-black/ so when user login it should redirect to this page. I have read the docs but it seems they have missed it. -
Context data not being passed if called from different view function
I have this function, def event (request): all_events = Quiz.objects.filter(owner_id=request.user.pk, status="Assigned") get_event_types = Quiz.objects.filter(owner_id=request.user.pk, status="Assigned") context = {"events": all_events, "get_event_types": get_event_types, } print("context is", context) return render(request, 'classroom/teachers/calendar.html', context) and it runs fine if I pass the template as 'calendar.html'. It is supposed to draw a calendar, and also pass the context called events, which is then processed by a JavaScript function to populate the days with some data values. This is my correct working calendar.html: {% extends 'base.html' %} {% load fullcalendar_tags %} {% block content %} {% for i in events %} {{ i }} {% endfor %} {% calendar %} <script> $(document).ready(function () { var currentView = '', d = new Date(), today = d.getDay(), dow = 1; $('#calendar').fullCalendar({ header: { left: 'prev,next', center: 'title', right: 'month,agendaWeek' }, defaultDate: d, events: [ {% for i in events %} { title: "{{ i.weight}} Kg", start: '{{ i.scheduled_date|date:"Y-m-d" }}', end: '{{ i.scheduled_date|date:"Y-m-d" }}', }, {% endfor %}], navLinks: true, firstDay: 1, //Monday viewRender: function (view) { if (view && view.name !== currentView) { if (view.name === 'agendaWeek') { dow = today; } else { dow = 1; } setTimeout(function () { $("#calendar").fullCalendar('option', 'firstDay', dow); }, 10); } if (view) … -
Get queryset by using filter objects on template in django
In models: class Match(models.Model): hot_league = models.ManyToManyField(HotLeague, blank=True) In template: {% for hot_league in match.hot_league.all %} By writing match.hot_league.all in template I can get all queryset of HotLeague class. But I want to use filter here with user. Like in views we can use HotLeague.objects.filter(user=request.user). But {% for hot_league in match.hot_league.filter(user=request.user) %} is not working on template. How can I do that kind of filter in template? -
Lists are not currently supported in HTML input. in django rest API framework
My project is about a university system. 2 Custom Users named Student and Professor are defined which inherits Django User Model. There is a course Model which have ManyToMany relation with Professor model to define courses and define professor for each course. I used CreateMixinModel, UpdateMixinModel, DestroyMixinModel to Update, Create and delete courses. CRUD was applied correctly. But there was a problem in displaying Professor's information and it just return professor id. I use a nested serializer in CourseCreateSErializer to display professor information beside course info. And now I cannot edit Course Object. I want to be able to edit Course Object models.py: class Professor(models.Model): user = models.OneToOneField(CustomUser, on_delete=models.CASCADE) professor_no = models.PositiveIntegerField() def get_full_name(self): return self.user.first_name def __unicode__(self): return self.user.first_name + " " + self.user.last_name def __str__(self): return self.user.first_name + " " + self.user.last_name class Course(models.Model): professor = models.ManyToManyField(Professor) name = models.CharField(max_length=100) unit = models.PositiveIntegerField() serializers.py: class CustomUserSerializer(serializers.ModelSerializer): class Meta: model = CustomUser fields = ('first_name', 'last_name', 'identity_no', 'email') def create(self, validated_data): return CustomUser.objects.create(**validated_data) class ProfessorDetailSerializer(serializers.ModelSerializer): user = CustomUserSerializer() class Meta: model = Professor fields = ( 'user', 'professor_no' ) def create(self, validated_data): return CustomUser.objects.create(**validated_data) class CourseDetailSerializer(serializers.ModelSerializer): professor =ProfessorDetailSerializer(many=True) class Meta: model = Course fields = ( 'professor', 'name', 'unit', … -
How can I throw max_length error in password User form in Django?
I am trying to thrown the max length error in a User form but I didn't get this error. I found this document docs where it is wrotten the following thing: To remedy this (DoS attack), Django's authentication framework will now automatically fail authentication for any password exceeding 4096 bytes. I don't get to launch this error when I exced the 4096 bytes. How can I launch this error? I counted the number bytes in a UTF-8 counter web and I introduced 55.000 bytes but I don't get the error -
Django settings LOGIN_REDIRECT_URL dynamic based on language
Let's say I have LOGIN_REDIRECT_URL='/foo/bar/' and I am on http://127.0.0.1/en/login/ and I login successfully. I will be redirected to http://127.0.0.1/foo/bar/ resulting in losing the language prefix. What should I do in order to maintain the language code in the url? Of course, I want all the other languages codes work and also the default one just like that: http://127.0.0.1/en/login/ -> http://127.0.0.1/en/foo/bar/ http://127.0.0.1/login/ -> http://127.0.0.1/foo/bar/ http://127.0.0.1/ro/login/ -> http://127.0.0.1/ro/foo/bar/ -
How to add custom error message when using createsuperuser command in Django?
I have created a custom user model and I want email and username to be a unique field. And I am using email as my main username field. Both are unique. The issue is that when I create a "createsuperuser" I get an instant error if the email is already taken by someone but in case of username field it checks the unique condition at the end which gives an ugly Postgres unique constraint failed error. I want username field to be instantly checked like the email field. Check the images below. models.py from django.contrib.auth.models import AbstractUser, BaseUserManager from django.db import models from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ class UserManager(BaseUserManager): """Define a model manager for User model with no username field.""" use_in_migrations = True def _create_user(self, email, password, **extra_fields): """Create and save a User with the given email and password.""" if not email: raise ValueError('The given email must be set') email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_user(self, email, password=None, **extra_fields): """Create and save a regular User with the given email and password.""" extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(email, password, **extra_fields) def create_superuser(self, email, password, **extra_fields): """Create and save a SuperUser … -
How can I query data from database in django 2.2
I´m building a app that manage a book library and i need to retrieve data from sqlite3 database I'm using djano 2.2. And i read some books and they some like this class LanguageView(viewsets.ModelViewSet): queryset = Language.objects.get() serializer_class = LanguageSerializer class Language(models.Model): name = models.CharField(max_length=50) paradigm = models.CharField(max_length=50) ```` And my serializer class is class LanguageSerializer(serializers.ModelSerializer): class Meta: model = Language fields = ('id','name','paradigm') And i expect the output of {"id":1,"name":"Learning Python", "paradigm":"object-oriented"} but it raise a error Class 'Language' has no 'objects' member -
Looking for a small dev team [on hold]
I am currently working on a youtube application geared towards helping users gain more viewers. The way it works is by correctly selecting keywords that match well with the user’s channel data such as engagement rate, watched hours and clickrate/ clickthrough. For example, a user with 1000 subs will not benefit from using the keyword fortnite, while a larger channel might. Through the use of AI, I would like to create an app that looks over the user’s channel data and then organize the generated keywords from best to worst. I have the foundations of the project but I have spent 60+ hours on it and I still have lots more to do. If anyone would like more information or would like to join, please message me. (For anyone wondering, this app will have a premium version and people who help out will get a share from the monthly earnings.) -
How to serve a Prophet model for my Django application?
I created a model with Facebook Prophet. I wonder now what is the "best" way to access these predictions from an online web application (Django). Requirements are that I have to train/update my model on a weekly base with data from my Django application (PostgreSQL). The predictions will be saved and I want to be able to call/access this data from my Django application. After I looked into Google Cloud and AWS I couldn't find any solution that hosts my model in a way that I can just access predictions via an API. My best idea/approach to solve that right now: 1) Build a Flask application that trains my models on a weekly base. Predictions are saved in a PostgreSQL. The data will be a weekly CSV export from my Django web application. 2) Create an API in my Flask application, that can access predictions from the database. 3) From my Django application, I can call the API and access the data whenever needed. I am pretty sure my approach sounds bumpy and is probably not the way how it is done. Do you have any feedback or ideas on how to solve it better? In short: 1) Predict data … -
Get reason data on failure transaction
With paypal-ipn, I am using paypal payment integration in my django application. I can track data on successful transaction through POST call but on failure transaction it return request in get method with no data. I need help to get the reason for failing transactions on failure transaction -
Is there any way to login to Django admin interface using username or email?
I want to implement a login system to login to Django admin via email or username. Does anyone know how to implement it. I use custom user model. I know how to allow user to login to website using username or email. But it doesn't work in Django admin interface -
How can I edit the css of an django form error message`?
I have a form on my Django app, which should allow users upload only csv files and whenever a user uplaods a file with a different extension, I want to render an error message. Currently I check the extention of the file which is uploaded and if the extension is not .csv then I add an error in the ValidationErrors The problem is that I can not find a way to edit the css of that error. Right now it is being displayed as an element of a list but I would like to put it in h1 tags. Here is my code: forms.py from django import forms from .models import CSVUpload import time class CsvForm(forms.ModelForm): csv_file = forms.FileField(widget=forms.FileInput( attrs= { 'class': 'form-group', } )) class Meta: model = CSVUpload fields = ('csv_file', ) def save(self): csvfile = super(CsvForm, self).save() return csvfile def clean_csv_file(self): uploaded_csv_file = self.cleaned_data['csv_file'] if uploaded_csv_file: filename = uploaded_csv_file.name if filename.endswith('.csv'): return uploaded_csv_file else: raise forms.ValidationError("File must be csv") else: return uploaded_csv_file template {% extends "fileconverter/base.html" %} {% block content %} <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form.csv_file }} {{ form.csv_file.errors }} <button type="submit" class="uploadbutton">Convert CSV</button> </form> {% endblock %} Could someone help me understand how … -
Django migration error,auth_permission_content_type_id_codename_01ab375a_uniq duplicated key
I am trying to migrate my module to PostgresSQL but when I do I got an error that teling me the key unique "auth_permission_content_type_id_codename_01ab375a_uniq" is duplicated . the key (content_type_id, codename)=(1,view_arrets) are existed . The code somehow create a duplicates views . my modules are : from django.db import models from django.urls import reverse class ProfilsHoraires(models.Model): P_id = models.AutoField(primary_key=True) id_profil = models.CharField(unique=True,max_length=120) d_p_1 = models.TimeField() f_p_1 = models.TimeField() d_p_2 = models.TimeField() f_p_2 = models.TimeField() class Meta: db_table = 'profilsHoraires' ordering = ['P_id'] def get_absolute_url(self): return reverse("profiles-edit", kwargs={"P_id": self.P_id}) class categorie(models.Model): Categorie = models.CharField(primary_key=True,max_length=20, blank=True) class Meta: db_table = 'categorie' ordering = ['Categorie'] def get_absolute_url(self): return reverse("categorie-edit", kwargs={"id": self.Categorie}) class Destination(models.Model): destinationNom=models.CharField(primary_key=True,max_length=90, blank=True) class Meta: db_table = 'disination' ordering = ['destinationNom'] def get_absolute_url(self): return reverse("destination-edit", kwargs={"id": self.destinationNom}) class Collaborateurs(models.Model): mle = models.AutoField(primary_key=True) nom = models.CharField(max_length=90, blank=True, null=True) prenom = models.CharField(max_length=90, blank=True, null=True) address = models.TextField(blank=True, null=True) latitude = models.FloatField(blank=True, null=True) longtitude = models.FloatField(blank=True, null=True) libele_dest = models.ForeignKey(Destination, on_delete=models.SET_NULL, null=True) profil = models.ForeignKey(ProfilsHoraires, on_delete=models.SET_NULL, null=True) class Meta: db_table = 'collaborateurs' ordering = ['mle'] def __unicode__(self): return self.title def get_absolute_url(self): return reverse("collabs-edit", kwargs={"mle": self.mle}) class Vehicules(models.Model): V_id = models.AutoField(primary_key=True) allocation= models.FloatField(null=False) capacite = models.IntegerField(null=False) type = models.CharField(max_length=20, blank=True, null=False) class Meta: db_table = … -
How to set up Django model inheritance with foreign key
I have three models, one superclass and two subclasses. Both subclasses belong to another model (expressed through a foreign key). I am not really sure what the best setup would look like in regards to my FK? Do I put the foreign key in the superclass, in the subclass, or in both? Every building can have many energy objects, which means it can have many Heating and Cooling objects. Every Heating/Cooling/Energy object belongs to one building. So a classic One-to-many relationship expressed with a Foreign Key. Here are my models: Superclass class Energy(models.Model): year : models.BigIntegerField(...) value : models.IntegerField(...) connected_building : ForeignKey ?????? Subclasses class Heating(Energy): connected_building : ForeignKey ????? class Cooling(Energy): connected_building : ForeignKey ????? Related class class Building(models.Model): name = models.Charfield(...) I am kind of scared of messing up my db, so any help is highly appreciated. Thanks in advance! -
'ProjectFormFormSet' object has no attribute 'request'
I want to add to my project one feature that only authenticated users can have access their stuff. But when I write queryset it throws an error like ModelNameFormSet object has no request attribute views.py class BaseAuthorFormSet(BaseModelFormSet): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.queryset= Project.objects.filter(author_id=self.request.user.pk) def add_object(request): ProjectFormSet = modelformset_factory(Project, formset=BaseAuthorFormSet, fields=( 'service_name', 'service_code', 'report_month', 'report_year', 'last_year'), extra=1) if request.method == "POST": form = ProjectFormSet(request.POST) form.author = request.user if form.is_valid(): form.save() form = ProjectFormSet() return render(request, 'app1/home.html',{'form':form}) I have only this code. How can I solve this issue? Thank you beforehand! -
How do i Accept payments in my Django website
I just finished learning, python and django and i am currently doing a small project to get better experience with backend web development. I created a registration portal for a Festival, where users register themself and select events they want to participate. I want to create an online payment option so that users can pay online for the events they want to participate in. I researched on the internet for some online payment gateway that i can implement on my website. I decided to use Razorpay as it was recommended by many people. I want to accept all kind of credit/ debit and UPI payments. The documentation are not begineer friendly. So i need a detail step by step guide on how i can do this. -
image filed returns null
i Have a model like this:i'm trying to create sign up with this fields: username first name and last name and email and address and profile image class User(AbstractUser): username = models.CharField(blank=True, null=True, max_length=50) Email = models.EmailField(_('email address'), unique=True) Address = models.CharField(max_length=100, default="") UserProImage = models.ImageField(upload_to='accounts/',blank=True, null=False) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['Email', 'first_name', 'last_name', 'Address', 'UserProImage'] def __str__(self): return "{}".format(self.username) def get_image(self, obj): try: image = obj.image.url except: image = None return image def perform_create(self, serializer): serializer.save(img=self.request.data.get('UserProImage')) and for this model i wrote a serilaizer with like this: class UserCreateSerializer(ModelSerializer): Email = EmailField(label='Email Address') ConfirmEmail = EmailField(label='Confirm Email') class Meta: model = User fields = [ 'username', 'first_name', 'last_name', 'Address', 'UserProImage', 'Email', 'ConfirmEmail', 'password', ] extra_kwargs = {"password": {"write_only": True} } objects = PostManager() def __unicode__(self): return self.username def __str__(self): return self.username def validate(self, data): return data def perform_create(self, serializer): serializer.save(self.request.data.get('UserProImage')) return self.data.get('UserProImage') def validate_email(self, value): data = self.get_initial() email1 = data.get('ConfirmEmail') username = data.get('username') email2 = value if email1 != email2: raise ValidationError("Emails must match.") user_qs = User.objects.filter(email=email2) username_qs = User.objects.filter(username=username) if user_qs.exists(): raise ValidationError("This user has already registered.") if username_qs.exists(): raise ValidationError("This user has already registered.") return value def validate_email2(self, value): data = self.get_initial() email1 = data.get('Email') … -
NOT NULL constraint failed: loginpage_location.org_id
I am new to django and learning to get a hang of the entire thing. I am not really sure why the problem is existing. I have looked up in a few stackoverflow questions, but me being a novice, i couldn't understand much from the explanation. I would like to know the 'why' alongwith the 'how' if possible. views.py def orgdataentry(request): if request.user.is_authenticated: orgdataform = OrgDataEntryForm(data=request.POST or None) orglocform = OrgLocEntryForm(data=request.POST or None) if orgdataform.is_valid() and orglocform.is_valid(): #fs = orgdataform.save(commit=False) #fs.user = request.user orgdataform.save() orglocform.org = request.POST['org_name'] #fs = orglocform.save(commit=False) #fs.user = request.user orglocform.save() return HttpResponse('Success') else: return render(request, 'org_login/dataentry.html', {'orgdataform': orgdataform, 'orglocform': orglocform}) else: return redirect('login') I have tried running the code with the commented code lines as well but no luck forms.py class OrgDataEntryForm(forms.ModelForm): class Meta: model = Organization db_table = 'Organization Details' fields = 'all' class OrgLocEntryForm(forms.ModelForm): class Meta: model = Location db_table = 'Organization Locations' exclude = ['org'] And models.py class OrgType(models.Model): org_type_id = models.AutoField(primary_key=True) org_external = models.BooleanField(default=True) org_sector = models.CharField(max_length=50, default='', verbose_name='Sector') org_type_des = models.CharField(max_length=50, null=True, verbose_name='Sector Description') def __str__(self): return self.org_sector class Organization(models.Model): org_id = models.AutoField(primary_key=True) org_name = models.CharField(max_length=50, default='', verbose_name='Company Name') org_type = models.ForeignKey(OrgType, on_delete=models.CASCADE, verbose_name='Company Type') org_inc_date = models.DateField(blank=True, null=True, verbose_name='Incorporation Date', … -
First query in Django is always slow
I have a simple Django app, just two models and a view. Whenever I query the db, the first query always takes about a second, and any query after that is almost instantaneous. My view looks like this: def my_view(request): start = time.time() print('0', time.time() - start) a = TestClass.objects.get(name="test") print('1', time.time() - start) b = TestCustomer.objects.get(name="test") print('2', time.time() - start) return render(request, 'test.html', {}) When I run it, I get the following output: 0 0.0 1 1.0049302577972412 2 1.0059285163879395 which means that the first query is much slower than the second one. If I comment out the first query, (the TestClass query), I get the following output: 0 0.0 1 0.0 2 1.0183587074279785 meaning that the TestCustomer query suddenly got a lot slower. Both models have one field only (name, which is a CharField). How come the first query is always so much slower? I have tried disabling Debug but that makes no difference. And if I run the queries directly, bypassing Django, they're instantaneous: SELECT `customers_testcustomer`.`id`, `customers_testcustomer`.`name` FROM `customers_testcustomer` WHERE `customers_testcustomer`.`name` = 'test'; /* Affected rows: 0 Found rows: 1 Warnings: 0 Duration for 1 query: 0,000 sec. */ -
slow django developent server
my django development server has just started running extremely slow (a number of minutes to load a page). Yesterday it was working fine, as it has been for the past 1-2 years. I/m at a loss as to what might to causing this so unsure where to even start looking to troubleshoot. I'm on ubuntu 18.04 and as far as I am aware there have been no software updates overnight. Internet speed is still blistering fast so that doesnt seem to be the issue. I'd appreciate any ideas for things I could start to look into to try and resolve this. -
Troubles with serializer for proxy models DRF/DJANGO
I have a question regarding serializes in DRF: I have a following Models: class Heading(models.Model): name = models.CharField(max_length=20, db_index=True, unique=True, verbose_name='heading ' 'title') order = models.SmallIntegerField(default=0, db_index=True, verbose_name='Order') foreignkey = models.ForeignKey("UpperHeading", on_delete=models.PROTECT, null=True, blank=True, verbose_name="Upper heading", ) one_to_one_to_boat = models.OneToOneField(BoatModel, on_delete=models.SET_NULL, null=True,blank=True, verbose_name="correspondent boat for the category", ) change_date = models.DateTimeField(db_index=True, editable=False, auto_now=True) # primary model class UpperHeadingManager(models.Manager): def get_queryset(self): return models.Manager.get_queryset(self).filter(foreignkey__isnull=True) class UpperHeading(Heading): objects = UpperHeadingManager() def __str__(self): return self.name class Meta: proxy = True ordering = ("order", "name") verbose_name = "Upper heading" verbose_name_plural = "Upper headings" # secondary model class SubHeadingManager(models.Manager): def get_queryset(self): return models.Manager.get_queryset(self).filter(foreignkey__isnull=False) class SubHeading(Heading): objects = SubHeadingManager() def __str__(self): return "%s - %s" % (self.foreignkey.name, self.name) class Meta: proxy = True ordering = ("foreignkey__name", "name") verbose_name = "Sub heading" verbose_name_plural = "Sub headings" I want to make serializer for the model Upperheading in a such way that it would include secondary model’s “SubHeading” related data Here is what I written: class UpperHeadingSerializer(serializers.Serializer): id = serializers.IntegerField(read_only=True) name = serializers.CharField(max_length=20, required=True, allow_blank=False) order = serializers.IntegerField() subheading_set = serializers.PrimaryKeyRelatedField(many=True, read_only=True) def create(self, validated_data): return UpperHeading.objects.create(**validated_data) def update(self, instance, validated_data): instance.name = validated_data.get("name", "instance.name") instance.order = validated_data.get("order", "instance.order") instance.save() return instance class Meta: model = UpperHeading fields = ("id", … -
Unusual behavior of form during the update of the content already published
I'm developing the backend of my personal blog and, using this tutorial for the date and time, I've created a form for the creation of a blog post. I notice two things: If I try to update an existing post the publishing date field is blank into the form but I can see the publication date in the details of the post. If I try to update an existing image or document the upload field is blanck Why happen this? create_post.html <form class="" method="POST" enctype="multipart/form-data" novalidate>{% csrf_token %} <div class="form-group"> <div class="row"> <div class="col-sm-9"> <div class="form-group mb-4"> <div>{{ form.title }}</div> <label for="id_title"> <span class="text-info" data-toggle="tooltip" title="{{ form.title.help_text }}"> <i class="far fa-question-circle"></i> </span> <small class="text-danger">{{ form.title.errors }}</small> </label> </div> <div class="form-group mb-4"> <div>{{ form.description }}</div> <label for="id_description"> <span class="text-info" data-toggle="tooltip" data-placement="bottom" title="{{ form.description.help_text }}"> <i class="far fa-question-circle"></i> </span> <small class="text-danger">{{ form.description.errors }}</small> </label> </div> <div class="form-group mb-4"> <div>{{ form.contents }}</div> <label for="id_contents"> <span class="text-info" data-toggle="tooltip" data-placement="bottom" title="{{ form.contents.help_text }}"> <i class="far fa-question-circle"></i> </span> <small class="text-danger">{{ form.contents.errors }}</small> </label> </div> <div class="form-group mb-4"> <div>{{ form.header_image_link }}</div> <label for="id_header_image"> <span class="text-info" data-toggle="tooltip" title="{{ form.header_image_link.help_text|safe }}"> <i class="far fa-question-circle"></i> </span> <small class="text-danger">{{ form.header_image_link.errors }}</small> </label> </div> </div> <div class="col-sm-3"> <div class="form-group mb-4"> <div class=""><h4>{{ …