Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Iterate over a list in a template from a dictionary generated in View file
I am creating a table in Django with columns of static and dynamic data. The dynamic data is easy to call from the database and loop through. The static data has been stored in the View as a dictionary. The problem I'm facing is when I need to iterate over a list in the template that comes via the dictionary. Here is the template code: <thead> <tr> <th>Amino acid</th> <th>Common</th> <th>Example species</th> <th>All consumers</th> <th>Text</th> <th>Image</th> </tr> </thead> <tbody> {% for amino_acid, use, text, image in amino_acids %} <tr> <td>{{ amino_acid }}</td> <td>{{ amino_acid_counts|dict_lookup:amino_acid|default_if_none:''|dict_lookup:'count' }}</td> <td> {{ amino_acid_counts|dict_lookup:amino_acid|default_if_none:''|dict_lookup:'example_list' }} </td> <td> {{ amino_acid_counts|dict_lookup:amino_acid|default_if_none:''|dict_lookup:'total_count' }} </td> <td> {{ text }} </td> <td><img src="{{ image }}" style="width: 200px; height: 150px;"> </td> </tr> {% endfor %} </tbody> This works fine, except for {{ amino_acid_counts|dict_lookup:amino_acid|default_if_none:''|dict_lookup:'example_list' }} which just displays the list like this: ['bacteria1', 'bacteria2' etc.]. Ideally, I'd like to iterate over this list and link urls to each list item, e.g.: {% for bug in example_list.items %} <i><a href="/bacteria/{{ bug.slug }}" target="_blank">{{bug}};</a></i> {% endfor %} Is there a way to do this either in the template or in the view? -
'QuerySet' object has no attribute 'book_set'
I have these models: from django.db import models # Create your models here. class Author(models.Model): full_name = models.CharField(max_length=255, null=False, blank=False,verbose_name="Full Name") def __str__(self): #template = '{0.name}' return self.full_name class Meta: verbose_name_plural='01-Author' class Book(models.Model): author = models.ForeignKey(Author, on_delete=models.CASCADE, null=True,blank=True) title = models.CharField(max_length=255, null=False, blank=False, verbose_name="Book Titles") production = models.DateField(max_length=255, null=False, blank=False, verbose_name="Productions Date") def __str__(self): return self.ttile class Meta: verbose_name_plural='02-Book' When I try to call method book = author.book_set.all() in views: def detail_book(request, id): author = Author.objects.all() book = author.book_set.all() context = { "title": f"Detail Book", "author": author, "book": book, } return render(request, 'detail_book.html', context) And it cause error 'QuerySet' object has no attribute 'viajems' -
django to vercel deployment error "serverless function has crashed"
I created a django application with a postgres database, im trying to deploy to vercel, by all indication on the browser the server is working correctly , vercel is also working correctly however I'm receiving the message "serverless function has crashed". help ive checked the logs, crosschecked the details and database values and ensured it runs locally. -
How to decide the resolution of image extracted from pdf by pymupdf
I am using pymupdf and django, I extract images from pdf. my source code is like this. doc = fitz.open(file_path) for page in doc: pix = page.get_pixmap() # render page to an image pix.save(media_root+ "/parsed/" + str(page.number) + '.png') It makes 1192 x 842 size,96 resolution png. I wonder what makes this size and resolution? The picture in the pdf is more clear, but extracted image is blurred How can I set the final png resolution? I can do this with this perameters? -
Why does database receive no data on a successful Django POST?
I am getting a successful 302 redirect POST when submitting my form, but data is not populating in the database. I am trying to create a simple comments post. Take the comment, submit it, redirect to the one page back ('lists'), display new comments - fairly straightforward - but I cannot figure out why I am not getting any data in the database I am using a postgres backend models.py class TicketComment(models.Model): ticket = models.ForeignKey(TicketList, on_delete=models.CASCADE) technician = models.ForeignKey(TechnicianUser, on_delete=models.CASCADE) body = models.TextField() date_added = models.DateTimeField(auto_now_add=True) def __str__(self): return '%s -%s' % (self.ticket.name, self.ticket) forms.py class TicketCommentAddForm(forms.ModelForm): class Meta: model = TicketComment fields = '__all__' views.py def apps_tickets_comments_view(request,pk): tickets = TicketList.objects.get(pk=pk) comments = TicketComment.objects.all() context = {"tickets":tickets,"comments":comments} if request.method == "POST": form = TicketCommentAddForm(request.POST or None,request.FILES or None,instance=tickets) if form.is_valid(): form.save() print(form.cleaned_data['technician']) messages.success(request,"Comment inserted Successfully!") return redirect("apps:tickets.list") else: print(form.errors) messages.error(request,"Something went wrong!") return redirect("apps:tickets.list") return render(request,'apps/support-tickets/apps-tickets-details.html',context) ticket-details.html <form action="{% url 'apps:tickets.comments' tickets.identifier %}" method="POST" enctype="multipart/form-data" class="mt-3"> {% csrf_token %} {{ form.as_p }} <div class="row g-3"> <div class="col-lg-12"> <label for="bodyTextarea1" class="form-label">Leave a Comment</label> <textarea class="form-control bg-light border-light" id="bodyTextarea1" rows="3" placeholder="Enter comment" name="body"></textarea> <input name="technician" type="hidden" name="technician" value="{{user.pk}}"> <input name="ticket" type="hidden" value="{{tickets.pk}}"> </div> <div class="col-lg-12 text-end"> <button type="submit" class="btn btn-success" id="add-btn">Post Comment</button> … -
django-axes doesn't lock users after multiple failed login attempts
I'm using django axes and I'm running my tests, for now, in the admin login area, but for some reason, it's not blocking the user after consecutive failures. When I test it on my localhost, it works normally, but when I deploy it and do the tests with the site on the server, it doesn't block users. django is logging everything to the database as normal. I'll show my settings.py code below: INSTALLED_APPS = [ ... 'axes', ] MIDDLEWARE = [ ... 'axes.middleware.AxesMiddleware', ] AUTHENTICATION_BACKENDS = [ # AxesStandaloneBackend should be the first backend in the AUTHENTICATION_BACKENDS list. 'axes.backends.AxesStandaloneBackend', # Django ModelBackend is the default authentication backend. 'django.contrib.auth.backends.ModelBackend', ] AXES_FAILURE_LIMIT = 3 import datetime as dt delta = dt.timedelta(minutes=5) AXES_COOLOFF_TIME = delta AXES_RESET_ON_SUCCESS = True AXES_ENABLE_ACCESS_FAILURE_LOG = True AXES_LOCK_OUT_AT_FAILURE = True USE_TZ = False I ran the commands python manage.py check and python manage.py migrate OBS: I put the command USE_TZ = False, because I'm using mysql and from what I've read, it needs to be like this -
fullstackcapapi.models.version.Version.DoesNotExist: Version matching query does not exist
I'm making a public prayer journal full stack(for context, the version in the error is closer to Bible translation). Whenever I edit a verse and submit it, I get "fullstackcapapi.models.version.Version.DoesNotExist: Version matching query does not exist." on the backend and this on the frontend: "PUT http://localhost:8000/verses/2 500 (Internal Server Error)". The lines these errors point to: fetch(${dbUrl}/verses/${verseId}, verse.version_id = Version.objects.get(id=request.data["version_id"]) Backend: def update(self, request, pk): "Handle PUT requests for a single post""" verse = Verse.objects.get(pk=pk) verse.uid = User.objects.get(id=request.data["uid"]) verse.verse = request.data["verse"] verse.version_id = Version.objects.get(id=request.data["version_id"]) verse.content = request.data["content"] verse.save() serializer = VerseSerializer(verse) return Response(serializer.data) Frontend: const updateVerse = (user, verse, verseId) => new Promise((resolve, reject) => { const verseObj = { version_id: Number(verse.version_id.id), verse: verse.verse, content: verse.content, uid: user.id, }; fetch(`${dbUrl}/verses/${verseId}`, { method: 'PUT', body: JSON.stringify(verseObj), headers: { 'Content-Type': 'application/json' }, }) .then((response) => resolve(response)) .catch((error) => reject(error)); }); And also this in case it's needed: const handleSubmit = (e) => { e.preventDefault(); if (verseObj.id) { updateVerse(user, currentVerse, verseObj.id) .then(() => router.push('/')); } else { const payload = { ...currentVerse }; createVerse(payload, user).then(setCurrentVerse(initialState)); } }; I don't really know what to do here, any help is appreciated. -
listen for django signals in JS
Is there any way to implement a JS addEventListener that receives a signal from Django? I have to upload multiple files, each one is processed individually sequentially, the idea is to notify as a list each time a document is finished processing. My idea: document.addEventListener('documento_extraido', function(event) { const nombreDocumento = event.detail.nombre_documento; console.log(`El documento ${nombreDocumento} ha sido procesado.`); // Aquí puedes agregar el código para mostrar la notificación de finalización de un documento en el frontend. }); -
Django & React - Session Authentication
I am using session authentication in my Django - React application. But no session cookie is stored in the cookie storage. (A csrf token cookie is stored!) On the frontend Part, I make a post request for the login: axios.defaults.xsrfCookieName = "csrftoken"; axios.defaults.xsrfHeaderName = "X-CSRFToken"; axios.defaults.withCredentials = true; const client = axios.create({ baseURL: "http://127.0.0.1:8000", }); function submitLogin(e) { e.preventDefault(); setIsLoading(true); client .post("/login", { email: email, password: password, }) .then(function (res) { setCurrentUser(true); window.location.reload(); // Refresh the page after login }) .catch(function (error) { setIsLoading(false); }); } I get a status code 200, user is logged in everything seems to work fine. but no session Cookie is stored and I get a SameSite attribute error in dev tools: Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute even though I set everything in settings.py: SESSION_ENGINE = 'django.contrib.sessions.backends.db' SESSION_COOKIE_SECURE = False # Set it to False during development with HTTP SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SAMESITE = 'None' # If using cross-site requests SESSION_COOKIE_SECURE = True # If using HTTPS note that when setting SESSION_COOKIE_SAMESITE = 'lax' or 'strict' and removing SESSION_COOKIE_SECURE = True # If using HTTPS the log in no longer works I also tried without … -
Django CookieCutter fails on setup with DistutilsFileError
I'm trying to use a Material Design theme for the CookieCutter library. Here's the git to the theme. However after providing all the setup details I get a crash Here's the cookiecutter command I ran cookiecutter https://github.com/app-generator/cookiecutter-django.git Here are the settings I provided during setup Traceback (most recent call last): File "C:\Users\Praneeth\AppData\Local\Temp\tmp6gmwl1xi.py", line 48, in <module> post_hook() File "C:\Users\Praneeth\AppData\Local\Temp\tmp6gmwl1xi.py", line 22, in post_hook copy_tree(fromDirectory, toDirectory) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\distutils\dir_util.py", line 123, in copy_tree raise DistutilsFileError( distutils.errors.DistutilsFileError: cannot copy tree './tmp/apps/static': not a directory ERROR: Stopping generation because post_gen_project hook script didn't exit successfully Hook script failed (exit status: 1) What's going on here? I'm not even sure where this /tmp/apps/static path is on my system. Any recommendations? I'm very lost as I'm new to Django and this CookieCutter library -
Adding custom header to DRF test APIClient
I need to add a custom header to the APIClient for a test. I have tried to follow this section of the official docs from rest_framework.test import APIClient client = APIClient() client.credentials(HTTP_AUTHORIZATION='Token ' + token.key) Following the official docs results in an error because the name has hyphens This raises a syntax error because the name is not valid. from rest_framework.test import APIClient client = APIClient() client.credentials(HEADER-WITH-HYPHEN='Token ' + token.key) I also tried using from rest_framework.test import RequestsClient but this needs the url to include http which isn't possible because the server doesn't run while testing. It also isn't possible to change the header name to something more pythonic :| -
django-phone-field and rest framework: not a valid number
I'd like to use django-phone-field together with rest-framework. I've configured a simple model: from phonenumber_field.modelfields import PhoneNumberField class UserProfile(models.Model): user = models.OneToOneField(CustomUser, on_delete=models.CASCADE) phone = PhoneNumberField(null=True, blank=True) As well es as a modelSerializer: from phonenumber_field.serializerfields import PhoneNumberField class UserProfileSerializer(CountryFieldMixin, serializers.ModelSerializer): phone = PhoneNumberField(required=False) user = serializers.StringRelatedField(read_only=True) class Meta: model = UserProfile fields ="__all__" I'd like to be able to use international numbers. The problem is, that depending on the country-prefix used, I'm getting a repsonse to enter a valid number. The examples from the django-phone-field documentation work, using a prefix +1 . The prefix for France and Germany work as well. However, other countries I've tried don't work, e.g. CZ: +420 . But maybe I'm using the module wrong altogether. Does someone know, how to use django-phone-field + rest-framework with international numbers? Thanks a lot. -) -
problem to deploy in vps ( Ubuntu 22.04 64-bit with Django/OpenLiteSpeed)
I bought a vps on hostinger to deploy a django project that I already have, but I'm a beginner and I didn't find anything that would help me, can anyone help me? I use this vps option: Ubuntu 22.04 64-bit with Django/OpenLiteSpeed I already tried to clone my git repository with git clone (my repository) but I couldn't put it as the main repository in the vps -
What is the difference between python script run in shell and python script run in djanho web server?
I am beginner in django and I would like to understand what is the difference between a python script run in shell and Python script run in django web server? I created a python script which is in charge to scrape data from a website. For that, I use a rotating proxy and a very similar website header. It works very well. However, when I set this script in a Django app, it does not work and the website detects a bot and my direct IP. Everything is enacted but I don’t understand why is it difficult to scrap from a django webserver. Do you have an idea of my problem? -
Vue files not deploying properly with django backend
Vue/Django app deployed to Heroku. Everything works great on local machine in development. On Heroku domain the app and all django templates load fine, only issue is that no vue components render. See here: [https://brainteasers.herokuapp.com/anagram-game/] In chrome dev tools I see "(failed)net::ERR_CONNECTION_REFUSED", or simply "(failed)" for the vue specific files. The Request URL: http://localhost:8080/js/chunk-vendors.58fb68d0.js My directory structure: static (backend) ├── css ├── dist (vue build files output here) │ ├── css │ └── js └── img vue-games ├── node_modules ├── public ├── src │ ├── components │ ├── app.vue │ ├── main.js │ └── router.js ├── package.json └── vue.config.js My vue.js.config: module.exports = { publicPath: 'http://localhost:8080', // The base URL where your app will be deployed outputDir: '../static/dist', // The path for where files will be output when the app is built indexPath: '../../templates/_base_vue.html', // The path for the generated index file configureWebpack: { devServer: { devMiddleware: { writeToDisk: true } } } }; The request for the vue files appear to go through my publicPath at 'http://localhost:8080' , and my best guess is this is my issue. I tried changing publicPath to the name of my domain, no luck. As a beginner I'm still struggling with fully understanding the … -
Python tox in Django
I'm using Visual Studio Code. I downloaded a GitLab project to run it and I cloned it from GitLab to Visual Studio Code. The main issue is running the proyect in localhost:8000, it is a Django proyect but there isn't any manage.py file. It has this tox.ini file: [tox] envlist = py3 [testenv:run] usedevelop = true deps = commands = 12apps runserver [testenv] usedevelop = true deps = pytest pytest-cov flake8 mypy django-stubs pytest-django commands = pytest --cov=src/twelveapps --cov-report=term --cov-report={env:COV_REPORT_TYPE:html} {posargs} flake8 src/twelveapps tests mypy src/twelveapps [coverage:run] branch = True [coverage:report] exclude_lines = pragma: no cover raise NotImplementedError [flake8] per-file-ignores = src/twelveapps/**/migrations/*.py:E501 [pytest] norecursedirs = tests/helpers DJANGO_SETTINGS_MODULE = test_settings I talked to the GitLab proyect admin and he told me to follow this steps in the terminal: tox -e run --notest mkdir .tox/run/var .tox/run/bin/12apps migrate .tox/run/bin/12apps loaddata tmp/fixtures.json tox -e run Please, give me the steps I have to follow to run this proyect in localhost (8000). Thanks. Obviously I installed tox and I have a python version which the proyect supports (3.10). The first step doesn't work (it gives me the following error: tox run: error: argument -e: expected one argument) -
Is it possible to force users to go through OTP before accessing the password reset form in Django?
path('PassChangeForm/',views.PassChangeForm, name="PassChangeForm" ), i don't want user type PassChangeForm in the URL bar of the browser, and they got PassChangeForm page, They must attempt previous page before accessing this page Suppose I have 2 Functions in my views.py the first function is to enter OTP and the second function is to get the password reset form I just want, User doesn't access that password reset form directly (like type url name or url in the URL bar of the browser). They must attempt the previous page which is Entering OTP and then they got a form of password reset. -
Unable to Login Django Admin
I'm unable to access the admin panel after deploying my Django project on an Ubuntu server using nginx and gunicorn, but wrong password is authenticated on admin panel still on entering correct details it reloads and shows admin panel login page again HTTPS SETTINGS SESSION_COOKIE_SECURE = False CSRF_COOKIE_SECURE = True SECURE_SSL_REDIRECT = True HSTS SETTINGS SECURE_HSTS_SECONDS = 3153600 SECURE_HSTS_PRELOAD = True SECURE_HSTS_INCLUDE_SUBDOMAINS = True SESSION_ENGINE = 'django.contrib.sessions.backends.db' -
django project error ValueError: source code string cannot contain null bytes
django i have django project when i run python manage.py runserver in my client, project runs good. but when i push project into my vps when i run python manage.py runserver this error is showing up why!? and how can i solve it Traceback (most recent call last): File "/home/roubinaa/public_html/env/roubinaa/manage.py", line 22, in <module> main() File "/home/roubinaa/public_html/env/roubinaa/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 416, in execute django.setup() File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/apps/registry.py", line 124, in populate app_config.ready() File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/contrib/admin/apps.py", line 27, in ready self.module.autodiscover() File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/contrib/admin/__init__.py", line 50, in autodiscover autodiscover_modules("admin", register_to=site) File "/home/roubinaa/public_html/env/lib/python3.9/site-packages/django/utils/module_loading.py", line 58, in autodiscover_modules import_module("%s.%s" % (app_config.name, module_to_search)) File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 786, in exec_module File "<frozen importlib._bootstrap_external>", line 923, in get_code File "<frozen importlib._bootstrap_external>", line 853, in source_to_code File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed ValueError: source code string cannot contain null bytes i try to install full package of my project on the … -
How to resolve CORS error when accessing 'localhost:8000/auth/jwt/create' with Django, Djoser, and Simple JWT?
me estoy trabajando con django djoser y my autenticacion esta basada en simplejwt. my error se trata de cuando accedo a "localhost:8000/auth/jwt/create" me da un error de cors no mermitido, tengo todo bien configurado, cors middleware y todo en la configuracion de rest framework, solo es en esta ruta q me da error y cuando accedo con post, sy accedo con option methods no me da ningun error. erfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -
Django HTML: Background Image only shows on one templates html file and not on other templates
I'm making a portfolio website using django. My templates are master.html, home.html, about.html, all_categories.html, app_projects.html, and project.html. Every html files extends to the master.html and the master.html loads static. I don't know why but every possible solution that I can think of only resulted in the background-image only appearing on the home.html. home.html with background image all_categories.html with no background image First thing I tried is to have the master.html show the background image so all html files extended to it will also have background image as well. Same outcome, it only shows on the home.html {% load static %} <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css"> <link rel="stylesheet" href="{% static 'myglobal.css' %}"> <title>{% block title %}{% endblock %}</title> </head> {% for y in H_Info %} <body style="background-image: url({{y.bg_photo}});background-repeat: no-repeat; background-attachment: fixed; background-size: cover;"> <header> <nav class="navibar" style="background-color:#e3c378"> <div class="navbar-logo"> {% for x in H_Info %} <a href="/" style="text-decoration:none;color:#000000;margin-left: 100px;">{{ x.lastname }} Portfolio</a> {% endfor %} </div> <ul class="navbar-menu" style="margin-right: 100px;;"> <li class="navbar-menu-item"><a href="/categories/">Portfolio</a></li> <li class="navbar-menu-item"><a href="/about/">About</a></li> </ul> </nav> </header> <main class="main-content"> {% block content %} {% endblock %} </main> </body> {% endfor %} </html> But then I think maybe I should have put it on the overall css … -
How to store text mixed with HTML tags and properly display the tags in a Django and jinja2 project?
I take text of an article from PostgreSQL database where it is stored in TEXT type and then insert into html template using jinja as in the expample below: <p>{{article.text}}</p> The problem is that atricle should be divided into paragrafs, which means html tags need to be put inside text. I have tried writing html tags inside the text, like is example below: ...development. Simplicity... However, tags is displayed as a part of an ordinary text. Are there any options to store text mixed with HTML tags? Or, perhaps, there is an alternitive solution? -
Separate form fields to "parts"; render part with loop, render part with specific design, render part with loop again
I want to render part of the form via a loop in template and a part with specific "design". # forms.py class HappyIndexForm(forms.Form): pizza_eaten = forms.IntegerField(label="Pizzas eaten") # 5 more fields minutes_outside = forms.IntegerField(label="Minutes outside") class TherapyNeededForm(HappyIndexForm): had_therapy_before = forms.BooleanField() # about 20 more fields class CanMotivateOthers(HappyIndexForm): has_hobbies = forms.BooleanField() # about 20 more fields The only purpose of HappyIndexForm is to pass the 7 fields to other forms that need work with the "HappyIndex" (it is a made up example). I have designed a very nice and complex template for the HappyIndexForm. The fields of TherapyNeededForm exclusive of the HappyIndexFormfields I want to simply loop over. <!-- template.html --> {% for field in first_ten_fields_therapy_needed %} {{ field }} {% endfor %} {% include happyindexform.html %} {% for field in second_ten_fields_therapy_needed %} {{ field }} {% endfor %} Task: Loop over first ten fields of TherapyNeededForm, then display the specific template I wrote for the fields coming from HappyIndexForm called 'happyindexform.html', then loop over second ten fields of TherapyNeededForm. My problem: If I loop over the fields and include my 'happyindexform.html' the fields coming from inheritance get displayed twice. I for sure can also write the specific template for all … -
Escaping % in django sql query gives list out of range
I tried running following SQL query in pgadmin and it worked: SELECT <columns> FROM <tables> WHERE date_visited >= '2023-05-26 07:05:00'::timestamp AND date_visited <= '2023-05-26 07:07:00'::timestamp AND url LIKE '%/mymodule/api/myurl/%'; I wanted to call the same url in django rest endpoint. So, I wrote code as follows: with connection.cursor() as cursor: cursor.execute(''' SELECT <columns> FROM <tables> WHERE date_visited >= '%s'::timestamp AND date_visited <= '%s'::timestamp AND url LIKE '%%%s%%'; ''', [from_date, to_date, url]) But it is giving me list index out of range error. I guess I have made mistake with '%%%s%%'. I tried to escale % in original query with %%. But it does not seem to work. Whats going wrong here? -
Django quill editor affecting html video tag
So i have a model that collects the description for a course. It is a quill field as shown below: class Course(models.Model): description = QuillField(null=True, blank=True) and i have a model form: class SubTopicForm(ModelForm): class Meta: model = CourseContentSubTopic fields = ['description'] Anytime i try to render this form in the frontend by doing this: {{form.media}} {{form.description}} My html video tag stops working. I noticed the problem comes when i add {{form.media}} to the html file. i have tried looking thorough the docs but i have not seen anything that has proven helpful.