Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django CONN_MAX_AGE with multiple database
It seems to me that CONN_MAX_AGE setting is set globally? If I have multiple databases setup in my project, how do I apply CONN_MAX_AGE only to a specific database such as other_db? DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'other_db': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'other_db.sqlite3'), }, -
In my Django API, I am generating a PDF file. I want to send a request to a PHP file which handles upload to upload that file. Here is what I wrote:
url = 'url.to.the.php.file.which.handles.upload' files = { file: ('file_name', open('file/path', 'rb')) } response = requests.post(url, files=files) I also tried the following url = 'url.to.the.php.file.which.handles.upload' files = { name: 'file_name', file: open('file/path', 'rb') } response = requests.post(url, files=files) And also tried by changing 'files' to 'data' as follows response = requests.post(url, data=data) In the PHP file, I have the following code (if it helps) $filename = $_FILES['file']['name']; $tempPath = $_FILES['file']['tmp_name']; $file_no=substr($filename,0,10); I am either getting an 'Internal server error' or no error - but the file is not being uploaded. -
How the parameters get passed in django
I have a simple question on how the self or the obj is being retrieved in python. I have this function: def amount_invested_formatted(self, obj): value = '$' + intcomma(int(obj.invested)) return value amount_invested_formatted.short_description = "AMOUNT INVESTED" and many others just like it. I call the function on the list_display like so: list_display = ( 'amount_invested_formatted') It works but I don't know where or how self and obj got passed. I know from here that: The list_display attribute of an admin.ModelAdmin object specifies what columns are shown in the change list. This value is a tuple of attributes of the object being modeled. But it's still not clear what self or obj are since from reading this, python functions are straightforward on the parameters but what's above is not. So can anyone show me what's happening here? Appreciate the answers. -
Where to store constant App information in Django?
I'm building a banking app using Django. Where could I store things like my Bank's name, address, phone number, etc... I thought a little hack could be to just add a table called Info with one entry. But it feels Django has a way for everything. -
Passing url parameter on django modelform attributes
I need to create a form with 5 select fields, each one dependent of the previous one (Schools, Disciplines, Macro-Content, Micro-Content, Teacher) I'm able to get only one working, passing an Ajax view to the form div: <form action="" id="orderForm" method="POST" discipline-queries-url="{% url 'ajax-load-discipline' %}> and <script src="//code.jquery.com/jquery-3.6.0.js"></script> <script> $("#institute").change(function () { const url = $("#discipline").attr("discipline-queries-url"); const instituteId = $(this).val(); $.ajax({ url: url, data: { 'institute_id': instituteId }, success: function (data) { $("#discipline").html(data); } }); }); </script> From what I understand I'd need 4 different ajax views, one for each database query, and pass the url attribute through modelform attributes like this: 'discipline': forms.Select(attrs={'id': 'discipline', 'class': 'form-control', 'discipline-queries-url': '{% url "ajax-load-discipline" %}'}), But the special characters are escaping and returning something like this: "GET /order/create/%7B%%20url%20%22ajax-load-discipline%22%20%%7D?institute_id=1 HTTP/1.1" 404 13568 So it is passing {% url "ajax-load-discipline" %} to the url... Any idea of what I can do to pass the correct parameters? -
Only Add Certain Fields in Variable - Python Function - Django - Views
I have Django model with CharFields 'flname1', 'date1', and 'time1'. My goal in my HTML is to have a {{ forloop }} that runs through only the 'date1' and 'time1' fields and displayed all of them. My Problem is that in my views file I can't find a way to create a python variable that only contains two of the three fields from one model. Ie tried a lot but what I'm trying to avoid is... posts = DocPost.objects.all() This puts all three fields into a variable and displays them in my for loop which I don't want. I've also tried a lot of work with filters and go things that other people on the internet had success with that didn't work for me like... posts = DocPost.objects.filter('flname1').only('date1', 'time1') This didn't work and didn't section off date1 and time1 and pack them away in a variable that I could loop through. Ive tried a lot more than this at this point to no prevail. Thank for any help. -
Is there any way to store repeating foreign keys in M2M field in Django?
I've got: class Item(models.Model): item_id = models.IntegerField(default=1, unique=True, primary_key=True) name = models.CharField(default="None", max_length=256) class Backpack(models.Model): items = models.ManyToManyField(Item) The backpack should store 6 or fewer items. But I can't add to it two the same ones. Can I solve it somehow without 6 different foreign keys in my Backpack model? -
How to get working markdown with code blocks included in django
i want to know if there's a package or installation that I can install or get in django that allows me to do markdown. I know there are many posts in Stackoverflow like this, but none of them work or help, and this is separate. The requirements that I need in the installation are: must allow bold text using **text** must allow italics using _text_ must allow comments using > text must allow bullets using - text must allow formatting using `` must allow code blocks like: ```python def function(): return something so for the code blocks, when I put ` and a language following, it must highlight the text inside. more or less the installation should be like StackOverflow markdown. So please let me know if you have a package or installation or something that enables me to get markdown in django. Thanks! -
Django forms with crispy forms not creating new entries
I have the following form to create new clients on a database on Django and rendered using crispyforms. However, even thoug it is rendered correctly, it's not creating new entries. models.py class Client (models.Model): def __str__(self): return self.name + ' '+ self.surname name = models.CharField(max_length=120) surname = models.CharField(max_length=120, null=True) phone = models.PositiveIntegerField(null=True) mail = models.EmailField(null=True) sport = models.TextField(blank=True, null=True) gender_options=( ("F", "femenino"), ("M", "masculino"), ) gender = models.CharField(max_length=120, null=True, choices=gender_options) birth = models.DateField(null=True) def get_absolute_url(self): return reverse("clientes:cliente", kwargs={"client_id": self.id}) pass forms.py from django import forms from .models import Client class NewClientForm(forms.Form): name = forms.CharField(label='Nombres') surname = forms.CharField(label='Apellidos') phone = forms.CharField(label='Teléfono') mail = forms.EmailField(label='Correo electrónico') gender = forms.ChoiceField(label='Género', choices= Client.gender_options) birth = forms.DateField(label='Fecha de nacimiento', widget=forms.TextInput(attrs={ 'id': "datepicker", })) sport = forms.CharField(label='Deportes') html {% extends 'base.html' %} {% load bootstrap4 %} {% load crispy_forms_tags %} {% block content %} <h1>Nuevo cliente</h1> <section class="container"> <form action="." method="POST" class="form-floating mb-3"> {%csrf_token%} <div class="form-row"> <div class="form-group col-md-6 mb-0"> {{ form.name|as_crispy_field }} </div> <div class="form-group col-md-6 mb-0"> {{ form.surname|as_crispy_field }} </div> <div class="form-group col-md-6 mb-0"> {{ form.phone|as_crispy_field }} </div> <div class="form-group col-md-6 mb-0"> {{ form.mail|as_crispy_field }} </div> <div class="form-group col-md-6 mb-0"> {{ form.sport|as_crispy_field }} </div> <div class="form-group col-md-6 mb-0"> {{ form.gender|as_crispy_field }} </div> <div class="form-group … -
Django how to iterate a form and save multiple objects?
I have a modelform (model: Student) with a TextField where the user enters several names at once. My intention is for my view to parse this text input (getting a first name, last name, and then coming up with a nickname) and loop through the lines, saving a new student each time through the loop. However, only the last time through the loop is a student saved. In the past I have solved this problem by using a custom save method in my model but I wanted to try doing it all in the view. I saw some posts in stackoverflow such as this one where it seemed that others were able to iterate through a loop and save objects. models.py class Student(models.Model): classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE) student_first = models.CharField(default='John', max_length=30) student_last = models.CharField(default='Smith', max_length=30) nickname = models.CharField(default='JohnS', max_length=31) attend = models.BooleanField(default=True) do_not_pick = models.BooleanField(default=False) multistudentinput = models.TextField(blank=True, default='') def __str__(self): return self.nickname forms.py class MultiStudentForm(ModelForm): class Meta: model = Student fields = ('multistudentinput',) views.py def addmultistudent(request, classroom_id): classblock = Classroom.objects.get(id=classroom_id) if request.method == 'POST': form = MultiStudentForm(request.POST) if form.is_valid(): student = form.save(commit=False) # save the classroom that the student belongs to student.classroom = classblock student_list = [] student_list = … -
Django migrate from using non-abstract base class for models
I had 3 Django models: Task, SubTask and TaskBase which was a base class for both of them. I am new to Django, so unknowingly I didn't make the TaskBase abstract which resulted in 3rd table creation - taskbase. Task and SubTask contained a taskbase_ptr_id pointing at the row in taskbase table containing almost all the information. I wanted to change this, so I made some changes: I've added the class Meta:\nabstract: True to TaskBase I moved two of the foreign keys that resided in TaskBase - creator and assignee to both Task and SubTask I've added related_names to both of them to not cause a foreign key name clash So my classes now look like this: TaskBase: class TaskBase(models.Model): status = models.CharField("State", max_length=2, default="NW", choices=TASK_STATUSES) title = models.CharField("Title", max_length=100, default="") description = models.CharField("Description", max_length=2000, default="") created_at = models.DateTimeField(default=timezone.now) last_updated = models.DateTimeField(default=timezone.now) class Meta: abstract = True Task: class Task(TaskBase): type = models.CharField("Type", max_length=1, default="T", choices=TASK_TYPES) creator = models.ForeignKey(User, on_delete=models.CASCADE, related_name="task_creator") assignee = models.ForeignKey(User, on_delete=models.CASCADE, related_name="task_assignee") SubTask: class SubTask(TaskBase): type = models.CharField("Type", max_length=1, default="S", choices=SUB_TASK_TYPES) creator = models.ForeignKey(User, on_delete=models.CASCADE, related_name="sub_task_creator") assignee = models.ForeignKey(User, on_delete=models.CASCADE, related_name="sub_task_assignee") parent_task = models.ForeignKey(Task, on_delete=models.CASCADE, related_name="parent_task") When I run python manage.py makemigrations - everything works (I … -
ManyToManyField or ForeignKeys in an intermediary model?
I am doing my Django app, and gone throught a lot of documentation, started coding etc. However I can't understand why should I use ManyToManyField if I will (or might) store extra information along the many-to-many relationships. The doc here shows this example: from django.db import models class Person(models.Model): name = models.CharField(max_length=50) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField( Person, through='Membership', through_fields=('group', 'person'), ) class Membership(models.Model): group = models.ForeignKey(Group, on_delete=models.CASCADE) person = models.ForeignKey(Person, on_delete=models.CASCADE) inviter = models.ForeignKey( Person, on_delete=models.CASCADE, related_name="membership_invites", ) invite_reason = models.CharField(max_length=64) Why even having the members field there, if the developer already defines the relationship model and also defines the ForeignKeys? :D Why not leaving out the members ManyToManyField ?? What is the benefit? Thank you. -
super().save() returns nothing in django
I'm trying to overwrite save() method in my forms.py ,i'm trying to prevent creating duplicated objects , and if the object exists only update some fields of the model this is my models.py class Item(models.Model): item = models.ForeignKey(Product,on_delete=models.CASCADE) quantity = models.IntegerField() my forms.py class ItemForm(forms.ModelForm): class Meta: model = Item fields = ['item','quantity'] def save(self,*args,**kwargs): if self.instance.item: Item.objects.filter(item__name=self.instance.item).update( quantity=F('quantity') + self.instance.quantity) else: super().save(*args,**kwargs) my views.py def addNewItem(request): form = ItemForm() if request.method == 'POST': form = ItemForm(request.POST) if form.is_valid(): form.save() return render(request,'temp/add_item.html',{'form':form}) lets say i have entered this data : item = abc , quantity = 100 for the next time if i entered abc it prevent from creating another object with the same name , but when i try to enter a new object it returns nothing ! does it is a wrong way to call super().save(*args,**kwargs) ! -
post() missing 1 required positional argument: 'request'
I have a problem with the registry. And it is that when I make the request through postman it throws me the error: post () missing 1 required positional argument: 'request' My url: from .views import UserRegistrationView urlpatterns = [ path('register', UserRegistrationView.post), ] Url include: urlpatterns = [ path('admin/', admin.site.urls), path('api/user/', include('user.urls')), ] My View from rest_framework import status from rest_framework.generics import CreateAPIView from rest_framework.response import Response from rest_framework.permissions import AllowAny from .serializers import UserRegistrationSerializer from rest_framework.decorators import api_view class UserRegistrationView(CreateAPIView): permission_classes = (AllowAny,) @api_view(('POST',)) def post(self, request): serializer = UserRegistrationSerializer(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() status_code = status.HTTP_201_CREATED response = { 'success' : 'True', 'status code' : status_code, 'message': 'User registered successfully', } return Response(response, status=status_code) My post by Postman: url: http://127.0.0.1:8000/api/user/register Body (raw): { "email":"asdf@asdf.com", "password":"123456", "profile": { "first_name": "asdf", "last_name": "asdf", "phone_number": "622111444", "age": 38, "gender": "M" } } My Error: TypeError at /api/user/register post() missing 1 required positional argument: 'request' -
Permission error with pymemcached and Django 2.2
I am updating a project to Django 2.2.3 from 2.1 and having issue (permission error) when I change from the python-memcached to the pymemcached binding. I can still use python-memcached which works but is deprecated in 2.2. My Memcached setting are (from Ansible): memcached_socket_perms: 775 memcached_socket_file: /run/memcached/memcached.sock memcached_memory_cap: 128 memcached_dependencies: - memcached memcached_user: memcache The asgi server runs under www-data under Ubuntu 20.04. I am using the Django cache setting from the Django docs (here for pymemcached): CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': 'unix:/run/memcached/memcached.sock', } } -
A sequential scan rather than index scan
I can't figure out why this query is exceptionally slow on my production database. I see two sequential scans - the first is from a filter on the dockets_table.content_type_id = 2 and the second one I can't even figure out what it's related to. This query takes many minutes on production machine and needs to be like a few seconds max. The query: SELECT DISTINCT ON (rank, "dockets_document"."id") "dockets_document"."id", "dockets_document"."title", "dockets_document"."url", "dockets_document"."content", "dockets_document"."num_tables", "dockets_document"."num_pages", "dockets_document"."tables_processed", "dockets_document"."summary", "dockets_document"."importance", "dockets_document"."title_vector", "dockets_document"."search_vector", "dockets_document"."datetime_created", "dockets_document"."datetime_modified", "dockets_document"."docket_id", "dockets_document"."docket_number", "dockets_document"."date_filed", "dockets_document"."pdf", ((1 * ts_rank("dockets_document"."search_vector", plainto_tsquery('public.bb'::regconfig, 'rendering set'))) + (0.8 * ts_rank("dockets_attachment"."search_vector", plainto_tsquery('public.bb'::regconfig, 'rendering set')))) AS "rank", ts_headline("dockets_document"."title", plainto_tsquery('public.bb'::regconfig, 'rendering set'), 'StartSel=''<mark>'', StopSel=''</mark>'', HighlightAll=true') AS "title_snippet", ts_headline(CONCAT(array_to_string("dockets_document"."content", ' ', ''), CONCAT(array_to_string("dockets_attachment"."content", ' ', ''), array_to_string(T4."content", ' ', ''))), plainto_tsquery('public.bb'::regconfig, 'rendering set'), 'StartSel=''<mark>'', StopSel=''</mark>'', MaxFragments=5') AS "content_snippet" FROM "dockets_document" LEFT OUTER JOIN "dockets_attachment" ON ("dockets_document"."id" = "dockets_attachment"."main_document_id") LEFT OUTER JOIN "dockets_table" ON ("dockets_document"."id" = "dockets_table"."object_id" AND ("dockets_table"."content_type_id" = 2)) LEFT OUTER JOIN "dockets_table" T4 ON ("dockets_attachment"."id" = T4."object_id" AND (T4."content_type_id" = 8)) WHERE ("dockets_document"."search_vector" @@ plainto_tsquery('public.bb'::regconfig, 'rendering set') OR "dockets_attachment"."search_vector" @@ plainto_tsquery('public.bb'::regconfig, 'rendering set') OR "dockets_table"."search_vector" @@ plainto_tsquery('public.bb'::regconfig, 'rendering set') OR T4."search_vector" @@ plainto_tsquery('public.bb'::regconfig, 'rendering set')) ORDER BY "rank" DESC, "dockets_document"."id" ASC LIMIT 8 Explain Analyze output: Limit … -
How to style a charfield which has choices in it django or which widget to use?
Okay so what I really want to do is to style a charfield which has choices from my forms.py modelform class. My models.py has this code it it... from django.db import models from django.contrib.auth.models import User # Create your models here. cat_choices = ( ("Stationary","Stationary"), ("Electronics","Electronics"), ("Food","Food"), ) class Product(models.Model): name = models.CharField(max_length=100,null=True) category = models.CharField(max_length=100, choices=cat_choices,null=True) quantity = models.PositiveIntegerField(null=True) class Meta: verbose_name_plural = 'Product' ordering = ['category'] and my forms.py has.... from django import forms from .models import Product class AddProduct(forms.ModelForm): class Meta: model = Product fields = ['name','category','quantity'] def __init__(self, *args, **kwargs): super(AddProduct,self).__init__(*args, **kwargs) self.fields['name'].widget = forms.TextInput(attrs={'type':'text','id':'name','name':'name','class':'form-control','placeholder':'Product Name'}) # self.fields['category'].widget = forms.Select(attrs={'class':'form-select'}) So I need a solution as to how I can style it or more appropriately which widget to use. I have already tried Select and it is not working. -
Keeping a file contents between page loads with Django
I am trying to create a page that reads information from a CSV file and then allows a user to run tests against the information in that CSV file. All of this is done on just a single page. This is my page layout: [Upload Form] [Upload Button] [Test Drop Down Selection Menu] [Data Input Text Area] [Parse Button] [Results] So basically you would upload a file. Then it would reload the page and populate the Test Drop down Selection Menu. Then you would select the test, paste the data in the text area and then click parse. Then it will display results underneath the Parse Button. Then I would like for the drop menu to still remain populated with tests so that the user can continue to just run tests and not have to continue uploaded the CSV file. This is my views.py function for this single page. def parse(request): form = CSVParseForm() if request.method == 'POST': if (request.FILES): csvfile = request.FILES.get('csv_file') reader = csv.reader(codecs.iterdecode(csvfile, 'utf-8')) tests = [] for row in reader: tests.append(row[3]) return render(request, 'cbsa/csvparse.html', {'form':form, 'tests' : tests}) else: # Read info from the session to know what to parse input_data = request.POST.get('cbstextarea') else: pass return … -
How to call View from another view in django?
I am creating a wizard using django-formtools. I have created a view for the wizard : class UserQueryWizard(SessionWizardView): template_name = "wizards/index.html" form_list = [forms.ShippingForm, forms.ExporterdetailsForm, forms.ImporterdetailsForm, ] def done(self, form_list, **kwargs): print([form.cleaned_data for form in form_list]) return render(self.request, 'wizards/index.html', { 'form_data': [form.cleaned_data for form in form_list], }) def get(self, request, *args, **kwargs): try: return self.render(self.get_form()) except KeyError: return super().get(request, *args, **kwargs) I have another view that can be called with the post request path('query/', views.UserQueryView.as_view(), name='user_query'), I Want to call the 'query/' URL with Post request in my done function def done(self, form_list, **kwargs): print([form.cleaned_data for form in form_list]) return <--- here with POST data([form.cleaned_data for form in form_list]) -
form.get_user() returning None in Django
Why does form.get_user() within the if form.is_valid() statement return a value whereas form.get_user() outside of the statement returns None Values passed to form: {username='sheriffcarlos', password='Iamc@tbug'} Example 1: from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth import login import logging def user_login(request): if request.method == 'POST': form = AuthenticationForm(request, request.POST) if form.is_valid(): user = form.get_user() logger.info(user) #Logs Sheriffcarlos else: #Do Something Else #Do Something Example 2: from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth import login import logging def user_login(request): if request.method == 'POST': form = AuthenticationForm(request, request.POST) user = form.get_user() logger.info(user) #Logs None if form.is_valid(): #Do something else: #Do Something Else #Do Something -
TAP payment gateway, trying to tokenize the credit card details
I am trying to integrate the provided UI javascript components, for capturing the credit card details and to tokenize those. But it shows the error like goSell requires server side execution, direct calls without origin not allowed. Here is my code, Moreover, TAP Payment gateway doesn't work in our region, So I have also tried by turning on the VPN, but nothing changes, it shows the same error ** I think, it is being triggered when the page loads, so it shows that not to call directly, please guide me how to trigger it. ** {% load static %} <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="{% static 'style.css' %}"> </head> <body> *IT IS UNABLE TO MOUNT DATA IN THE FOLLOWING FORM* <form id="form-container" method="post" action="/charge"> <!-- Tap element will be here --> <div id="element-container"></div> <div id="error-handler" role="alert"></div> <div id="success" style=" display: none;;position: relative;float: left;"> Success! Your token is <span id="token"></span> </div> <!-- Tap pay button --> <button id="tap-btn">Submit</button> </form> <script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script> <script src="https://secure.gosell.io/js/sdk/tap.min.js"></script> **From a survey I was asked to paste the cdns above like and paste the JS code below the above cdns like this** <script type="text/javascript"> **HERE PROVIDED PUBLIC KEY WILL BE INSERTED** var tap = Tapjsli('HERE_WILL_BE_PUBLIC_KEY'); … -
How to use the href link feature as well as pass a Django url to a view in Django?
If I have an .. Element which has a link it points to , but i also want to call a Django View ,how do i do it? <td ><a href="{{ page.url }}" >Click Here</a> But i also want to call 'updateViews' in /views.py like this <td ><a href="{% url 'updateViews' page.title %}" >Click Here</a> -
Import local settings if a command line argument is defined
I have the following code at the end of my Django settings: if not TESTING: # Don't use local settings for tests, so that tests are always reproducible. try: from .local_settings import * except ImportError: pass local_settings.py contains all the external dependencies URLs used by my Django application, such as database server URL, email server URL and external APIs URLs. Currently the only external dependency my test suite uses is the local database; everything else is mocked. However, now I'd like to add some tests that validate responses from the external APIs I use, so that I can detect quickly when an API change and the API owner does not notify me beforehand. I'd like to add a --external-deps command line argument to "./manage.py test" and only run tests that depend on external APIs if this flag is enabled. I know that I can process arguments passed to that command by overriding the add_arguments() method of the DiscoverRunner class, as described in Django manage.py : Is it possible to pass command line argument (for unit testing) , but my conditional Django settings loading are run before that, so the following won't work: if not TESTING or TEST_EXTERNAL_DEPS: # Don't use … -
Django Admin delete user exception - Django Phone number
I have a django project which was working fine. I got the requirement to include phone verification so i used twilio and used the django [phone number][1]. I did the verification part and everything is working fine until i noticed the following exception when i tried to delete a user from admin panel. I am not 100% sure if it has anything to do with phone number per this is the only new thing added to project. I tried adding and updating new user from admin panel and it worked fine. The issue is in deletion of user. Request URL: http://127.0.0.1:8000/admin/projectapp/customuser/ Django Version: 3.0.8 Python Version: 3.8.4 Installed Applications: ['django.contrib.admin', 'django.contrib.gis', 'projectapp', 'django.contrib.sites', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'phonenumber_field', 'verify_email.apps.VerifyEmailConfig', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "D:\installedSoft\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "D:\installedSoft\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "D:\installedSoft\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "D:\installedSoft\Python\Python38-32\lib\site-packages\django\contrib\admin\options.py", line 607, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "D:\installedSoft\Python\Python38-32\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "D:\installedSoft\Python\Python38-32\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File … -
Django Templates put quotation marks in to <noscript> tag. How to remove quotes?
I have code peace from Search System's Analyst service in my page Template in block: <noscript><div><img src="https://mc.yandex.ru/watch/75335146" style="position:absolute; left:-9999px;" alt="" /></div></noscript> But in browser it has shown like: <noscript> "<div><img src="https://mc.yandex.ru/watch/75335146" style="position:absolute; left:-9999px;" alt="" /></div>" </noscript> I tried to use {% autoescape off %} construction, but it did't helped. https://allgid.ru/al_home.html Code Validation in https://validator.w3.org/unicorn/check?ucn_uri=https%3A%2F%2Fallgid.ru&ucn_lang=ru&ucn_task=conformance# print Error: "Bad start tag in “div” in “noscript” in “head”."