Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to get the browser to render links in streamed content
I am using EventSource to get streamed text content in the browser. The problem is that when I want a link to appear even though I have the correct text, the link doesn't render. This is the text that is outputted (correctly) Here are a few options for single burner camping stoves that you might find suitable:1. The <a href='https://www.bcf.com.au/p/companion-lpg-portable-single-burner-gas-stove/292578.html?cgid=BCF08188'>Companion LPG Portable Single Burner Gas Stove</a> is a great option. It's portable and uses LPG, which is a common fuel type for camping stoves. This makes it a practical choice for camping trips.2. Another good choice is the <a href='https://www.tentworld.com.au/buy-sale/companion-1-burner-wok-cooker-stove'>Companion 1 Burner Wok Cooker Stove</a>. This stove is also portable and has a wok cooker, which adds versatility to your cooking options.For more options, you can check out the range of <a href='https://www.anacondastores.com/camping-hiking/camp-cooking/camping-stoves?q=:relevance:brand:coleman:dealType:OnSale:dealType:CLUB%20PRICE'>Camping Stoves</a> at Anaconda stores. They offer a variety of brands and styles, so you might find other single burner stoves that suit your needs. And here is the html/js: <div id="response-display"></div> <script> const responseDisplay = document.getElementById('response-display'); const eventSource = new EventSource('http://127.0.0.1:8000/do-chat'); eventSource.onmessage = function(event) { console.log('We have a message'); console.log(event.data); // Append received data to the div // responseDisplay.textContent += event.data + "\n"; responseDisplay.innerHTML += event.data; }; … -
Issues with django-channels deployment on elastic-beanstalk
I am working on deploying my django app on Elastic Beanstalk using gunicorn for my wsgi and daphne to handle asgi. I managed to get my app deployed but the websockets are not functioning properly. I was able to test that the EC2 instance connects to the redis cache by running the code below on my elastic beanstalk environment : eb ssh source /var/app/venv/*/bin/activate cd /var/app/current/ python manage.py shell >>> import channels.layers >>> from asgiref.sync import async_to_sync >>> channel_layer = channels.layers.get_channel_layer() >>> async_to_sync(channel_layer.send)('test_channel', {'foo': 'bar'}) >>> async_to_sync(channel_layer.receive)('test_channel') >>> {'foo': 'bar'} # <---------- I was able to receive a response However, I was not able to run the initiate the daphne server on my EC2 instance manually : daphne -b 0.0.0.0 -p 5000 tattoovalley.asgi:application The code above generated the following error : ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. However I have configured the DJANGO_SETTINGS_MODULE environment module in my .ebextensions config file : .ebextensions/01_env.config option_settings: aws:elasticbeanstalk:environment:proxy:staticfiles: /static: static value: static/ aws:elasticbeanstalk:container:python: WSGIPath: tattoovalley/wsgi.py aws:elasticbeanstalk:application:environment: DJANGO_SETTINGS_MODULE: tattoovalley.settings PYTHONPATH: /opt/python/current/app/tattoovalley:$PYTHONPATH aws:elbv2:listener:80: DefaultProcess: http ListenerEnabled: 'true' Protocol: HTTP Rules: ws aws:elbv2:listenerrule:ws: PathPatterns: /ws/* Process: websocket Priority: 1 … -
React make messages of other user appear different color
I am making a chat app with django channels and react and I want messages from a different user to appear at a different color. To create the messages I save them in state const [messages,setMessages] = useState([]) chatSocket.onmessage = function(e) { if (ran == true) { const data = JSON.parse(e.data); setMessages(old => [...old, <p ref={oneRef} className={currentUser[0]?.username}>{data.message}</p>]) } } For every message's className it is the current user's username. I want to basically do something like this. {currentUser.username} { background:'red' } And if not then appear a different color. How can I make it work. -
Cal-heatmap, date not converted with good timezone
I have a problem with the cal-heatmap library and the timezone. I use Django, and I have a date in UTC like this: 2023-10-04T14:03:31.040000+00:00 I want to use the timezone Europe/Paris so if I convert the date with timezone, I have this: 2023-10-04T16:03:31.040000+02:00. I don't arrive to display the good date in cal-heatmap, I have always the date with hour 14... I only get it if I use the date 2023-10-04T16:03:31.040000+00:00 (So the good hour with UTC timezone) So I tried with the UTC timestamp (1696428211040), but I have always the same hour even if I change the timezone in the date key options in cal-heatmap... Do you have a solution? -
how should i add the tradingview chart to my website usding python/django. i am using louisnw01/ lightweight-charts-python from github
i am using the following code : import pandas as pd from lightweight_charts import Chart def get_bar_data(symbol, timeframe): if symbol not in ('AAPL', 'GOOGL', 'TSLA'): print(f'No data for "{symbol}"') return pd.DataFrame() return pd.read_csv(f'bar_data/{symbol}_{timeframe}.csv') def on_search(chart, searched_string): # Called when the user searches. new_data = get_bar_data(searched_string, chart.topbar['timeframe'].value) if new_data.empty: return chart.topbar['symbol'].set(searched_string) chart.set(new_data) def on_timeframe_selection(chart): # Called when the user changes the timeframe. new_data = get_bar_data(chart.topbar['symbol'].value, chart.topbar['timeframe'].value) if new_data.empty: return chart.set(new_data, True) def on_horizontal_line_move(chart, line): print(f'Horizontal line moved to: {line.price}') if __name__ == '__main__': chart = Chart(toolbox=True) chart.legend(True) chart.events.search += on_search chart.topbar.textbox('symbol', 'TSLA') chart.topbar.switcher('timeframe', ('1min', '5min', '30min'), default='5min', func=on_timeframe_selection) df = get_bar_data('TSLA', '5min') chart.set(df) chart.horizontal_line(200, func=on_horizontal_line_move) chart.show(block=True) here chart.show() gives the Python webview app but I want to integrate this chart into my own website. I tried searching the web a lot but every time I get the Tradingview lightweight chart widget or its javascript library that the trading view provides by itself but not using the above python library. -
Github Action exits with code 1 even if command returns 0
I have a Django application and a step in the workflow that should check if any migrations need to be done: - name: Check outstanding migrations run: | python manage.py makemigrations --check The makemigrations --check command exits with 0 when I run it locally in Powershell but the Github Action workflow fails with Error: Process completed with exit code 1.. The only output of the command is a log warning message that I set. -
Is there a good way to access the "model" attribute for a ListView in Django so that it can be used in a template?
thanks in advance for the help. Long story short, I'm attempting to build a CRM-type application in Django (think of it as a Salesforce clone, if you're familiar). I want to be able to access the model attribute that I'm providing to my ExampleListView class. I'm reading through the docs on the ListView class but either can't find how to do it, or I'm just missing the connection. For context here's some example code (what I've got so far isn't far off of the boilerplate from the docs): views.py: class ExampleListView(ListView): model = Example app/templates/app/example_list.html: {% block content %} <h2>Examples</h2> <!-- Ideally, I'd love to be able to create this dynamically --> <table> <thead> <tr> {% for header in ???? %} <!-- Here's what I can't figure out --> <th>{{header}}</th> {% endfor %} </tr> </thead> <tbody> <tr> {% for example in object_list %} --- Display record data here --- {% endfor %} </tr> </tbody> </table> {% endblock %} I've thought about the idea of trying to add the model attribute to the context dictionary, but I'm unsure how to go about it. Am I on the right track? -
Some Models permission are missing from the permission list in django admin
Account models has lot of the models but only the user models permission are visible -
Django-table wrong output
I have django model: class Sessions(models.Model): id = models.AutoField(primary_key=True) user = models.ForeignKey('Users', on_delete=models.CASCADE, related_name='user') session_start = models.DateTimeField() last_confirmation = models.DateTimeField(null=True) error_status = models.CharField(max_length=50, default="Lost connection.", null=True) session_end = models.DateTimeField(null=True) status = models.CharField(null=True, max_length=1) And I have a view function which must return QuerySet with three columns ( 'session_start','last_confirmation',differenc_time ('last_confirmation' - 'session_start'): def user_home(request): info = Sessions.objects.filter(user=request.user.id).annotate( time_difference=ExpressionWrapper( F('last_confirmation') - F('session_start'), output_field=fields.DurationField() ) ).values('last_confirmation', 'session_start', 'time_difference') return render(request, 'home_user.html', context={'data': info}) But in browser i get all columns: -
Aspose.slides python error convert a pdf to PowerPoint ( ppt )
I want to convert a pdf to PowerPoint ( ppt ) using the Aspose library with python and I got this error below: pres.slides.add_from_pdf(pdfPath) RuntimeError: Proxy error╗): Bad state (unknown compression method (0x47)) the code I wrote to convert pdf to ppt is the following : def pdf2ppt(pdfPath, pptPath): with slides.Presentation() as pres: pres.slides.remove_at(0) pres.slides.add_from_pdf(pdfPath) pres.save(pptPath, slides.export.SaveFormat.PPTX) I would really appreciate the help. -
a function for print S3 data to html by usiong django
I had a correct connection to S3, because i am able to upload pdf file to Amazon S3, but i can't display the S3 data into django template my expecting result is when i open the page to view pdf that upload to Amazon S3 it should show all the pdf that had upload. But right now nothing had show in django template Following is my code models.py class PDFDocument(models.Model): title = models.CharField(max_length=100) pdf_file = models.FileField(upload_to='pdfs/') urls.py path('display-pdf/<str:file_key>/', views.DisplayPDFView, name='display_pdf'), view.py class DisplayPDFView(View): def get(self, request, file_key, *args, **kwargs): print(s3) s3 = boto3.client('s3') bucket_name = settings.AWS_STORAGE_BUCKET_NAME try: print('ds') response = s3.get_object(Bucket=bucket_name, Key=file_key) pdf_content = response['Body'].read() print(response) # Set the appropriate content type for PDF response = HttpResponse(pdf_content, content_type='application/pdf') response['Content-Disposition'] = f'inline; filename="{file_key}"' return response except s3.exceptions.NoSuchKey: return HttpResponse('PDF not found.', status=404) except: print("fucking error") viewCVpage.html {% for pdf_document in pdf_documents %} <div class="col-md-4 col-sm-12"> <div class="card" style="width: 100%; float: left; margin-bottom: 10px;"> <!-- Display the PDF using an object tag --> <object data="{{ pdf_document.pdf_file.url }}" type="application/pdf" style="width: 100%; height: 400px;"> <p>Unable to display PDF. Please <a href="{{ pdf_document.pdf_file.url }}">download the PDF</a> instead.</p> </object> </div> </div> {% endfor %} -
Django Cors Headers stopped working all of a sudden
I have set up my back-end with Django over 10 months ago and it's been working perfectly fine... However, after changing virtual environment recently and re-downloading the required packages, I am receiving cors errors. Below is my code for the cors issue I'm facing. ALLOWED_HOSTS = ['*'] INSTALLED_APPS = [ 'django_filters', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'playgroundapp', 'budgetapp', 'rest_framework', 'rest_framework.authtoken', 'djoser', "corsheaders" ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', "corsheaders.middleware.CorsMiddleware", 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] CORS_ALLOWED_ORIGINS = [ "http://localhost:4200", "https://mywebsite.com" ] Django version: 4.2.6 This is the order on my settings.py Error I'm currently getting is: Access to fetch at 'https://myexamplebackend.com' from origin 'https://myexamplewebsite.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. Not sure if it's related but after changing virtual environments I am getting the error: "WARNING:root:No DATABASE_URL environment variable set, and so no databases setup" on VS Code... I've tried "heroku config" to fix the problem but it didn't solve the issue. What did I try? I have read a lot … -
How can I solve this error? : 'WSGIRequest' object has no attribute 'objects'
I am trying to create a web app for managing expenses for a company but I ran into a problem that I quite don't know how to work around it. The error message is 'WGSIRequest' object has no attribute 'objects'. I am new in python that's why it is stressing me out. I have linked the line that spawns the error as well as my views.py file as well as my urls.py. The error: 'WGSIRequest' object has no attribute 'objects' Line associated with error: user = request.objects.filter(email=email) My view.py file: from django.shortcuts import render, redirect from django.views import View import json from django.http import JsonResponse from django.contrib.auth.models import User from validate_email import validate_email from django.contrib import messages from django.core.mail import EmailMessage from django.contrib import auth from django.utils.encoding import force_bytes, force_str, DjangoUnicodeDecodeError from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.contrib.sites.shortcuts import get_current_site from django.urls import reverse from .utils import token_generator from django.contrib.auth.tokens import PasswordResetTokenGenerator # Create your views here. class EmailValidationView(View): def post(self, request): data=json.loads(request.body) email=data['email'] if not validate_email(email): return JsonResponse({'email_error': 'Email is invalid'}, status=400) if User.objects.filter(email=email).exists(): return JsonResponse({'email_error': 'Sorry email in use, choose another one'}, status=409) return JsonResponse({'email_valid': True}) class UsernameValidationView(View): def post(self, request): data=json.loads(request.body) username=data['username'] if not str(username).isalnum(): return JsonResponse({'username_error': … -
OperationalError at at /users/login/ no such table: auth_user when trying to login on my website
I've deployed my website using Railway. I'm pretty sure the error is because I'm switching from sqllite to postgres. settings.py import dj_database_url DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, } if 'DATABASE_URL' in os.environ: DATABASES['default'] = dj_database_url.config( conn_max_age=500, conn_health_checks=True, ) I've run makemigrations and migrate, but it doesn't fix the error. -
django foreignkey sort per user
Help me implement it. Let's say I have 3 models one user another branches and depart of branches. I need everyone to see only the depart of their branches - Create a record @login_required(login_url='my-login') def create_record(request): form = CreateRecordForm() if request.method == "POST": form = CreateRecordForm(request.POST) if form.is_valid(): form.instance.cr_user = request.user form.save() messages.success(request, "Запись созданно успешно") return redirect("dashboard") context = {'form': form} return render(request, 'tik/create-record.html', context=context) -
Django apps.get_models(): how to load models from other folders
I have the following folder structure: All models from apps/<some_app_name>/models.py are loaded OK when using apps.get_models(), but unfortunately the folders client/brand/reseller/company on the image also have a models.py file on each of them, which are not being loaded on apps.get_models() (code below): import pytest from django.apps import apps # Set managed=True for unmanaged models. !! Without this, tests will fail because tables won't be created in test db !! @pytest.fixture(autouse=True, scope="session") def __django_test_environment(django_test_environment): unmanaged_models = [m for m in apps.get_models() if not m._meta.managed] for m in unmanaged_models: m._meta.managed = True Can someone explain me how/where should I set pytest/Django to lookup for models? Using Python 3.9.18, and Django 3.2.21 Not sure if it helps on something: these 4 models inherit from Account, and that model inherit from PolymorphicMPTTModel (which allows for some pretty crazy/confusing parent-child relations). -
onnect() failed (111: Connection refused while connecting to upstream, client: 172.31.45.233, upstream: "http://127.0.0.1:8000/", host: "172.31.45.81" [closed]
My error: 2023/10/04 17:17:19 [error] 39625#39625: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.45.233, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.45.81" 2023/10/04 17:17:30 [error] 39625#39625: *21 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.10.148, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.45.81" I am running a Django Project through AWS EB using websockets and am encountering this error. Please help! I've tried adding environment variables setting PORT and SERVER_PORT both to 8000. -
My script works properly on Chrome, but not on Safari
The following script is the code for a dark mode toggle on my website. I don't really know Javascript (I only know Python), so writing this code was a challenge and it might be poorly written. But what it does is it checks for a session variable "is_dark_mode" using Django Templating Language, to check if the current user has previously set his view to light or dark mode, and then it proceeds to switch the Boolean for that variable and adds or removes a "dark-mode" class to the body of my HTML (which is how I'm switching styles when in dark mode). It works fine in Chrome, but it doesn't work at all in Safari, and I don't know why. When using the JavaScript console, it throws an error: SyntaxError: Unexpected token ';' This SyntaxError is pointing to this line of code: var darkMode = ; Could someone give me a hand in figuring this out? I'm learning backend only, so I got no idea of how to solve this, and I've already tried googling it, with no success. <script> document.addEventListener("DOMContentLoaded", function () { var modeToggle = document.getElementById("modeToggle"); function setInitialDarkMode() { var darkMode = {{ request.session.is_dark_mode|default_if_none:"false"|lower }}; modeToggle.checked = darkMode; … -
Django- change password failed for a tester user. I cannot find the error
Hello user Tester cannot change the password. I used chat gpt for help, but it fails What ought I to change/correct? User logs into the My_account website and tries to change the password, but nothing happens. "With this change, the user is always returned to the "my_account" page after saving the password, regardless of whether the password was changed or not. If the password has been changed, the success message is displayed, otherwise the error message. The new password is only saved if it has been successfully changed"- this doesn't happen views.py from django.contrib import messages from django.http import HttpResponseRedirect from django.urls import reverse from django.shortcuts import render, redirect from django.views import View from django.contrib.auth.forms import PasswordChangeForm from .models import Note class MyAccountView(View): template_name = "my_account.html" def get(self, request): password_form = PasswordChangeForm(request.user) notes = Note.objects.filter(user=request.user) context = {"password_form": password_form, "notes": notes} return render(request, self.template_name, context) def post(self, request): password_form = PasswordChangeForm(request.user, request.POST) if 'change_password' in request.POST: if password_form.is_valid(): user = password_form.save() update_session_auth_hash(request, user) messages.success(request, "Successfully changed.") return redirect("my_account") else: messages.error(request, "Error changing the password. Please check your entries.") return HttpResponseRedirect(reverse("my_account")) # If the password has not been changed or the password form is invalid, # redirect the user back to … -
Setting {{ user.email }} as input value does not save Django form?
I am trying to set the default value of an input as {{ user.email }} so that the user does not have to type their email again when they are submitting a POST request. When a user signs up for an account, they use their email and I store it in a model. However, when I was testing this, I get a field error saying that the email field is required. I am printing the error in my views.py file like this: form = UserDataForm(request.POST) for field in form: print("field_error: ", field.name, field.errors) field_error: email <ul class="errorlist"><li>This field is required.</li></ul> I am setting the input value through JavaScript like so, and I am also hiding the input by setting the display to none: document.querySelector("#id_email").setAttribute("value", "{{user.email}}") document.querySelector("#id_email").value = "{{user.email}}" document.querySelector("#id_email").style.display = "none" I used inspect element and i see that the input tag shows the email in the value attribute: <input type="email" name="email" maxlength="320" required id="id_email" value="test@gmail.com" style="display: none;"> forms.py: class UserDataForm(forms.Form): email = forms.EmailField(required=True, label="Email address") # other fields models.py: class UserDataModel(models.Model): email = models.EmailField(default="", max_length=100) # other fields views.py: from .models import UserDataModel from .forms import UserDataForm def profile(request): if request.method == "POST": form = UserDataForm(request.POST) if form.is_valid(): cd … -
How to solve the Runtime.ImportModuleError: Unable to import module 'vc__handler__python': No module named 'django' error on Vercel?
I'm trying to deploy a Django Project on Vercel but I'm facing this error bellow: Runtime.ImportModuleError: Unable to import module 'vc__handler__python': No module named 'django' I've preapered my settings.py allowing vercel deployment as bellow: ALLOWED_HOSTS = ['127.0.0.1', '.vercel.app', '.now.sh'] And edit my JSON file too as bellow: { "builds": [{ "src": "ang/wsgi.py", "use": "@vercel/python", "config": { "maxLambdaSize": "15mb", "runtime": "python3.9" } }, { "src": "build.sh", "use": "@vercel/static-build", "config": { "distDir": "staticfiles" } } ], "routes": [ { "src": "/static/(.*)", "dest": "/static/$1" }, { "src": "/(.*)", "dest": "ang/wsgi.py" } ], "outputDirectory": "staticfiles" } My requirments also shows that I've Django installed asgiref==3.7.2 dj-static==0.0.6 Django==4.2.6 django-stdimage==6.0.1 Pillow==10.0.1 sqlparse==0.4.4 static3==0.7.0 typing_extensions==4.8.0 tzdata==2023.3 whitenoise==6.5.0 So does anyone knows what is causing the problem?? I've try to install whitenoise already, change folder roots and install different django modules I was expecting to fix this Runtime.ImportModuleErro -
How to retrieve all customers bookings by either their username or id. Django
I am trying to retrive all bookings made by the logged in user. I am getting the following error: Cannot assign "'leonie'": "Customer.user" must be a "User" instance. What i don't understand is how this is not an instance of the user model. Views.py from django.shortcuts import render, get_object_or_404 from .forms import CustomerForm, BookingForm from django.contrib.auth.models import User from .models import Booking, Customer # Create your views here. # https://stackoverflow.com/questions/77218397/how-to-access-instances-of-models-in-view-in-order-to-save-both-forms-at-once?noredirect=1&lq=1 def customer_booking(request): if request.method == 'POST': customer_form = CustomerForm(request.POST, prefix='customer') booking_form = BookingForm(request.POST, prefix='booking') if customer_form.is_valid() and booking_form.is_valid(): customer = customer_form.save(commit=False) customer.user = request.user.username customer.save() booking = booking_form.save(commit=False) booking.customer = customer booking.save() customer_form = CustomerForm() booking_form = BookingForm() else: customer_form = CustomerForm(prefix='customer') booking_form = BookingForm(prefix='booking') context = { 'customer_form': customer_form, 'booking_form': booking_form, } return render(request, 'booking.html', context) def display_booking(request): bookings = Booking.objects.filter(customer=request.user) context = { 'bookings': bookings, } return render(request, 'booking.html', context) models.py from django.db import models from django.contrib.auth.models import User # Create your models here. BOOKING_STATUS = ((0, 'To be confirmed'), (1, 'Confirmed'), (2, 'Declined')) class Customer(models.Model): first_name = models.CharField(max_length=80) last_name = models.CharField(max_length=80) email = models.EmailField() phone_number = models.CharField(max_length=20) user = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return f"{self.user}" class Booking(models.Model): booking_date = models.DateField() booking_time = models.TimeField() number_attending = models.IntegerField(default=2) booking_status … -
Cookies between nginx and gunicorn with ssl and without it
Now in my django project everything is configured without Nginx. I've never used it before and I want to use it now. My cookies (sessionid) are protected and httponly. I have one self-written SSL certificate for 127.0.0.1:8000. I'm interested in how cookies will be transmitted if the connection between Nginx and the frontend is HTTPS, and between Nginx and Gunicorn is HTTP. Will Nginx decrypt them and pass them on to Django, who in turn will receive them? Is it possible to somehow use the same SSL certificate for Nginx and Gunicorn? -
Group Symbols Together during order_by
When using order_by in the Django ORM it seems that it is ignoring symbol characters in the text when sorting. For example with the folowing query set. +--------+ | name | +--------+ | 'A' | | '@B' | | 'C' | | 'D' | | '@E' | | 'F' | | '$G' | | '$H' | +--------+ When using Item.objects.all().order_by("name"), the list is returned exactly as you see above. How do i order that list where the symbols are sorted together like so: A,C,D,F,@B,@E,$G,$H -
How to add google analytics 4
I am trying to add Google Tag code in head block of Django-CMS but it ruins the django-cms admin css and tag does not work. {% load cms_tags menu_tags sekizai_tags %} {% load static %} <!DOCTYPE html> <html dir="ltr" lang="{{ LANGUAGE_CODE }}"> <head> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-P1JCM2KX92"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-P1JCM2KX92'); </script> .... How can we add Google Tag to Django-CMS? Thanks