Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to format negative numbers in django-tables2?
I am looking for nice solution to make a simple subclassed NumericColumn for my tables, based on django-tables2. I started with that: class NumericColumn(Column): def render(self, value): return '{:0,.2f}'.format(value) It works great until I decided to make negative values red: class NumericColumn(Column): attrs = { 'td': { 'class': lambda value: 'text-danger' if value < 0 else '' } } def render(self, value): return '{:0,.2f}'.format(value) Code periodically fails with TypeError: '<' not supported between instances of 'str' and 'int', and it seems that lambda function receives already formatted value. I don't see a way to get an original value in record via accessor, and I don't think that it is nice to make a reverse conversion to Decimal for such comparison. Ok, I can test first character for '-', but it is too ugly. Please help. -
TwiML response body too large error - python django
I am getting error "TwiML response body too large". I am trying to create own opt-out list. When user press 0 to opt out via outbound call, I want to store his phone number to the database. How do I create my own opt-out list? Is there any other way to create own opt-out list. I am new to Twilio. Please help. Thanks. def handle_user_response(request): digits = request.data.get('Digits', '') phone=request.data.get('To','') resp = VoiceResponse() if digits == '0': resp.say("Your phone number is opted out.") OptOutList.objects.create(phoneNumber=phone) else: resp.say("Sorry, I don't understand that choice.") return HttpResponse(str(resp)) Here is my model in django. class OptOutList(models.Model): phoneNumber=models.CharField(max_length=20) def __str__(self): return self.phoneNumber -
How to get all fields of related object Django
I have two models: class Checklist(models.Model): author = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) client_name = models.ForeignKey(Client, on_delete=models.CASCADE, related_name='details') filedA = models.CharField(max_length=25, blank=True, null=True) filedA_Check= models.BooleanField(default=False) filedB = models.CharField(max_length=25, blank=True, null=True) filedB_Check= models.BooleanField(default=False) class Client(models.Model): client_filedA = models.CharField(max_length=25) client_filedB = models.CharField(max_length=25) client_filedC = models.CharField(max_length=25) Now I trying to change Client instance fields values via Checklist using following code: @login_required def create_order(request, pk): instance = get_object_or_404(CheckList, id=pk) form = myForm(request.POST or None, instance=instance) if form.is_valid(): form.save() messages.success(request, 'Test message') return get_PDF_order(request, pk) return render(request, 'templates/create_order.html', {'form': form}) And it's works but only once. Data saved and I get a pdf file with this data, but subsequent attempts do not change anything. The field value still the same. I'm guessing that it is because I working with the Checklist instance but not Client. So, my questions are: 1) How I can get an access to all Client fields (a queryset of all fileds) via Checklist? 2) Although my code is incorrect - why does it work (once)? I mean why does it save first time? Thank you all in advance! -
Django forms validating but not showing errors added on clean
I want to get my validation errors printed right after my form. When it comes to validate, it does the work right so if i put a date before today it just doesn´t save the form. Inside this validation I have an error adding line if it doesn´t pass validation like this: class PostVacation(forms.ModelForm): class Meta: model = Vacation fields = ( 'fecha_inicio', 'fecha_fin', ) fecha_inicio = forms.DateField(widget = forms.DateInput(format='%d/%m/%Y',attrs={'type':'date','class': 'form-control'})) fecha_fin = forms.DateField(widget = forms.DateInput(format='%d/%m/%Y',attrs={'type':'date','class': 'form-control'})) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def clean_fecha_inicio(self): data = self.cleaned_data['fecha_inicio'] if data < timezone.now().date(): print(type(data)) self.add_error(None,"La fecha de inicio no puede ser anterior a hoy") return data Inside my template I try this: <div class="col-md-4 listados"> <form method="POST">{% csrf_token %} <div class="form-group"> {{ form.as_p }} {{ form.non_field_errors }} <p>Los campos marcados con * son obligatorios</p> <button type="submit" class="btn boton_generico">Guardar</button> </div> </form> </div> But it just returns empty Any help welcome -
ModuleNotFoundError: No module named 'django.contrib.staticfilesbase'
every time I try to run my program using python manage.py runserver the same error comes up. "ModuleNotFoundError: No module named 'django.contrib.staticfilesbase'" -
Deploy Django Telegram bot on digital ocean
I am a beginner python programmer. I made a Telegram bot in Django framework. The bot's files are located in myapp/management/commands/bot.py. I am using 2 terminals on my computer to use both the bot and the Django administration on the local network. 1-terminal python manage.py bot. 2-terminal python manage.py runserver. I want to deploy this project in the digital ocean. What should I do for the Django administration and bot to work. -
context data wont display anything in detailview
I'm trying to display this models' object where the user is as same as the detail view user. here is my views: class ScientificInfoView(FormMixin, DetailView): model = ScientificInfo template_name = 'reg/scientific-info.html' form_class = ScientificInfoForm def get_success_url(self): messages.success(self.request, 'Profile details updated.') return reverse('scientific-info', kwargs={'pk': self.object.pk}) def get_context_date(self, **kwargs): context = super(ScientificInfoView, self).get_context_data(**kwargs) #THIS IS THE LINE THAT WONT WORK# context['result'] = Results.objects.filter(user=self.object.user) context['sample'] = 'sample text sample text' ################################# context['form'] = ScientificInfoForm() return context def post(self, request, pk): self.object = self.get_object() form = ScientificInfoForm(request.POST, instance=get_object_or_404(ScientificInfo, id=pk)) if form.is_valid(): return self.form_valid(form) else: return self.form_invalid(form) def form_valid(self, form): f = form.save(commit=False) f.user = self.object.user f.save() return super(ScientificInfoView, self).form_valid(form) everything works fine except the result and sample data. it shows nothing in the template. It cant even render a simple text! this is the templates: {% for r in result %} {{r}} {% endfor %} {{ sample }} -
getting error ..................The QuerySet value for an exact lookup must be limited to one result using slicing
I'm building a socialmedia website in django.While I tried to list all the comments in the index page, i am getting this error, The QuerySet value for an exact lookup must be limited to one result using slicing and when i am using.... comments = PostComment.objects.filter(post__in=allPost)... instead of ....comments = PostComment.objects.filter(post=allPost)....the queryset is not getting filtered and i am getting the same comments in all the post, basically i want to show comments under all the post and that comment should be refferd to as that post things i have tried instead of .......... comments = PostComment.objects.filter(post=allPost) 1.....comments = PostComment.objects.filter(post__in=allPost) 2.....comments = PostComment.objects.get(post__in=allPost) 3.....comments = PostComment.objects.get(post=allPost) 4.....comments = PostComment.objects.filter(post_id__in=allPost) 5.....comments = PostComment.objects.filter(post__id__in=allPost) 6.....comments = PostComment.objects.filter(post_id=allPost) but none of them are working............................................please help me what should i do in this case views.py.... def index(request): if request.user.is_authenticated: allPost = Post.objects.all().order_by('-created_on').filter(creater = request.user) allBlog = Blogpost.objects.all() comments = PostComment.objects.filter(post=allPost) context = {'allPost' : allPost, 'allBlog' : allBlog, 'comments' : comments} return render(request, 'index.html', context) else: return render(request, "signoption.html") models.py.... class Post(models.Model): sno = models.AutoField(primary_key=True) caption = models.CharField(max_length=500) hashtag = models.CharField(max_length=500) image = models.ImageField(upload_to='socialmedia/images', default="") created_on = models.DateTimeField(default=timezone.now) creater = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return str(self.sno) + '.....Post By.....' + str(self.creater) class PostComment(models.Model): sno … -
How to filter objects with the pk of another model as filter
I have two models: Project Expense Each Expense object has a column called project_id, in other words, each Expense is associated to a Project. I want to list all the Projects for a specific user (working) and all the Expenses for the projects of the specific user. What I've tried: projects = Project.objects.filter(project_manager = request.user.first_name +" "+request.user.last_name) #working ok expenses = Expense.objects.filter(??????) #stucked here -
Display only certain events in iframe
I am currently using a Service account that displays all the events for all days using the Google api calendar. I would like to display only events for a user within the embed iframe or create an own table. Now I have been looking into OAuth 2.0 Client IDs and tokens as well. Is there a way to create different calendars based of each user and then get their iframe as well(similar idea different execution though as iframe locations would be problematic). The calendars should be permanent unless the user is deleted. Would a generic table creation be more useful here? and how would I go about creating one. iframe: {% block content %} <h1>Calendar</h1> <button> + </button> <iframe src="https://calendar.google.com/calendar/embed?src=------" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"> </iframe> <ul> {% for result in results %} <li>{{result.start.date}}{% if result.end.date %}-{% endif%}{{result.end.date}}: {{result.summary}}</li> {% endfor %} </ul> {% endblock %} for service from decouple import config from google.oauth2 import service_account import googleapiclient.discovery import datetime CAL_ID = config('CAL_ID') SCOPES = ['https://www.googleapis.com/auth/calendar'] SERVICE_ACCOUNT_FILE = './google-credentials.json' def test_calendar(): print("RUNNING TEST_CALENDAR()") credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES) service = googleapiclient.discovery.build('calendar', 'v3', credentials=credentials) """ new_event = { 'summary': "Ben Hammond Tech's Super Awesome Event", 'location': 'Denver, CO USA', 'description': 'https://benhammond.tech', … -
django doesnt run a specific migration (it skipped) in production
when I ran the makemigrations it returns users/migrations/0002_remove_profile_image.py - Remove field image from profile But when i ran migrate users 0002.. it said CommandError: Cannot find a migration matching '0002_remove_profile_image.py' from app 'users' when i ran migrate it said No migrations to apply. Your models in app(s): 'users' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. what can i do? i am deploying on heroku -
django date field with year and month inputs
I have a django form that takes the year and month as integers, and uses these inputs to add the concatenated value (year-month) to a charfield called date: 'date': str(form.cleaned_data['year']) + '-' + str(form.cleaned_data['month']) django model: year = models.IntegerField() month = models.IntegerField() date = models.CharField(max_length=30) the issue, as shown in the chart below, 2021-12 is being treated as smaller than 2021-4. How can I create a django date field that only takes month and year as inputs and can have the result being showed in the right ascending order, 2021-4 then 2021-12 OR in the form of 2021, April then 2021, December. -
How to filter in django using adding days to existing dates
class Payment(models.Model): name = models.CharField() payment_date = models.DateField() Example Table Payment id name payment_date 1 A 2022-01-01 2 B 2022-01-02 3 C 2022-01-02 4 D 2022-01-06 Suppose the due date for each payment is payment_date+10 days. Suppose iam checking on the date '2022-01-12' the records which are due is 2022-01-01 + 10 days = 2022-01-11 Due 2022-01-02 + 10 days = 2022-01-12 Due 2022-01-06 + 10 days = 2022-01-16 Not Due So my sample output should be Sample: <QuerySet [<Payment: A>, <Payment: B>, <Payment: C>]> -
Ajax request in django
I trying use ajax requests and reload only the tbody after the user add or delete a line. In html template I have table and inside the script tag I have a function to load the table, to delete a line, and to add a line. I need to link forms.py with an html template, what am I doing wrong? It is also not possible to delete a row from the table, possibly an error due to a mismatch of the value in urls.py: 'url_to_django/delete-person/int:Id_Group', the value of person.Id_Group, but I don't know how to link them. Also the information in the html template is displayed implicitly. I am trying to use the solution presented on the following page https://stackoverflow.com/a/70352509/17641696 , but I have not been able to understand why the author uses template2. HTML <!--В цикле перечисленные все скрытые поля--> {% for hidden in form.hidden_fields %} {{ hidden }} {% endfor %} <!--В цикле перечисленные все видимые поля указанные в AkpGroupForm в forms.py--> <table class="table align-middle"> <thead> <tr> <th scope="col"></th> <th scope="col">#</th> <th scope="col">Id_Group</th> <th scope="col">Type_Participation</th> <th scope="col">Id_People</th> <th scope="col">Competencies</th> <th>Действие</th> </tr> </thead> <tbody id="table_person_id"> {% if persons %} {% for person in persons %} <tr> <th scope="row"><div><input class="form-check-input" … -
Django Static_Root CDN setup for production
I am using Cropperjs and Opencv for users to crop an image, this requires the temporary upload of a file to the static_root or media_root folder that is deleted after cropping. I am using Amazon S3 for production static files but I am unsure how to setup the static_root to use Amazon S3 in production? I am using Heroku for production if that matters? STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) DEFAULT_FILE_STORAGE = "src.cdn.backends.MediaRootS3Boto3Storage" #backends.py STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / "static", # os.path.join(BASE_DIR, 'static') ] STATIC_ROOT = BASE_DIR / "staticfiles-cdn" # CDN for production? MEDIA_ROOT = BASE_DIR / "staticfiles-cdn" / "uploads" TEMP = MEDIA_ROOT / "temp" -
Create schema while running testcase in django using postgresql
I want to create the schema and set it as the default schema while running the testcase. -
Update is not saving in django rest framework
views.py def productslist(request): products = Products.objects.all() context = {'products':products} return render(request,'productslist.html',context) def productsform(request): return render(request,'productscreate.html') def productsupdate(request): return render(request,'productsupdate.html') def productsAdd(request): if request.method == "POST": data = request.data product = Products() product.title = request.POST["title"] product.description = request.POST["description"] product.image = request.FILES.get("image") product = Products(title=data['title'], description=data['description'], image=data['image']) product.save() serializer = Productserialize(product) return Response(serializer.data) def products_list(request): if (request.method == 'GET'): product = Products.objects.all() serializer = Productserialize(product,many=True) return Response(serializer.data) class ProductsDetailView(DetailView): template_name = "productsdetail.html" queryset = Products.objects.all() context_object_name = 'products' model = Products serializer_class = Productserialize @api_view(['PUT']) def productupdate(request,pk): data = request.data prod = Products.objects.get(id=pk) serializer = Productserialize(prod,data=data, many=True) if serializer.is_valid(): serializer.save() return Response(serializer.data) detail.html <form> Title:- {{products.title }} <br><br> Description:- {{ products.description}}<br><br> {% if products.image %} Image :- <img src="{{products.image.url}}" alt="image"><br><br> {% endif %} <button><a href="/update/{{ products.id}}">Edit</a></button> </form> serializer.py class Productserialize(serializers.Serializer): id = serializers.IntegerField(read_only=True) title = serializers.CharField(required=False, allow_blank=True, max_length=100) description = serializers.CharField(required=False, allow_blank=True, max_length=100) image = serializers.FileField() def create(self, validated_data): """ Create and return a new `Snippet` instance, given the validated data. """ return Products.objects.create(**validated_data) def update(self, instance, validated_data): """ Update and return an existing `Snippet` instance, given the validated data. """ instance.id = validated_data.get('id', instance.id) instance.title = validated_data.get('title', instance.title) instance.description = validated_data.get('description', instance.description) instance.image = validated_data.get('image', instance.image) instance.save() return instance update.html <form … -
DRF Authtoken issues after user model changes
After updating the user model to allow for a user profile I have not been able to log in users from the front end. I can create users with profiles and auth tokens in admin. Please help. REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ) } # AUTH_USER_MODEL = 'profiles.Profile' DJOSER = { # 'LOGIN_FIELD': 'username', 'SERIALIZERS': { 'user_create': 'profiles.serializers.UserSerializer', 'user': 'profiles.serializers.UserSerializer' } } class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) name = models.CharField(max_length=100, null=True) occupation = models.CharField(max_length=100, blank=True, null=True) residence = models.CharField(max_length=100, blank=True, null=True) email = models.CharField(max_length=100, blank=True, null=True) avatar = models.ImageField(null=True, blank=True, upload_to ='uploads/profile_pics',default='uploads/default.jpg') def __str__(self): return self.user.username def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs) img = Image.open(self.avatar.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.avatar.path) class ProfileSerializer(serializers.ModelSerializer): user = serializers.StringRelatedField(read_only=True) avatar = serializers.ImageField(read_only=True) class Meta: model = Profile fields = "__all__" class ProfileAvatarSerializer(serializers.ModelSerializer): class Meta: model = Profile fields = ("avatar", ) class ProfileStatusSerializer(serializers.ModelSerializer): user_profile = serializers.StringRelatedField(read_only=True) class Meta: model = ProfileStatus fields = "__all__" class UserSerializer(serializers.ModelSerializer): profile = ProfileSerializer(read_only=True) class Meta: model = User fields = ('profile', 'username', 'password', 'id') def update(self, instance, validated_data): if 'profile' in validated_data: nested_serializer = self.fields['profile'] nested_instance = instance.profile nested_data = … -
Get data from dropdown list and display it in the form of table
I'm new in Django. Here, I want to get data from drop down list, when click on save button, the data should display in the form of table. Please help me out to solve this. Please. urls.py: urlpatterns = [ path('',views.upload,name='upload'), ] views.py: def upload(request): machines = Machine.objects.all() return render(request,'usermaster/upload.html',{'machines':machines}) models.py: class Machine(models.Model): machine_name = models.CharField(max_length=200) operation_no = models.IntegerField() def __str__(self): return self.machine_name upload.html: <form action="" method="post"> {% csrf_token %} <select> <option>Select Machine Name</option> {% for machine in machines %} <option>{{ machine.machine_name }}</option> {% endfor %} </select> <br> <br> <select> <option>Select Operation Number</option> {% for machine in machines %} <option>{{ machine.operation_no }}</option> {% endfor %} </select> <br> <br> <br> <input type="submit" value="Save"> </form> <tr> <td>{{machine.machine_name}}</td> <td>{{machine.operation_no}}</td> </tr> -
Auto creating profile for two types of users in django
I have a user model and two models Employee and Manager which inherits from the user model. I want to create an employee and manager whenever i register a new user. Should i use a boolean field to ask if it is a employee or a manager when creating a user? or is there another way? btw i am using django signals models.py class User(AbstractUser): email = models.EmailField(_('email address'), blank=True, unique=True) USERNAME_FIELD = "email" REQUIRED_FIELDS = ["username", ] class Employee(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) year_joined = models.DateField(auto_now=False, auto_now_add=False, null=True, blank=True) department = models.IntegerField(null=True, blank=True) def __str__(self): return f'{self.user.username}' def enrolledYear(self): return self.year_joined.strftime("%Y") class Manager(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) designation = models.CharField(null=True, blank=True, max_length=100) departments = models.IntegerField(null=True, blank=True) def __str__(self): return f'{self.user.username}' -
How to install Google Recaptcha v3 with Django CMS and Aldrym Forms
I am trying to get ReCaptcha v3 working for an aldryn form in django / djangocms. Instead of the ReCaptcha riddle all I get is a "Recaptchafieldplugin 1*" on the site: What am I missing? Am I misunderstanding how this "invisible ReCAPTCHA" should work? Should there not be a captcha riddle to solve? There is a working sample project running. To get recaptcha up and runnning here is what I did so far. I followed the readme. pip install aldryn-forms-recaptcha-plugin adjusted settings.py accordingly set RECAPTCHA_SCORE_THRESHOLD = 1 for testing (1 = always activate recaptcha) set the recaptcha keys in the .env file python manage.py migrate added to the bottom of the base.html template Here is the settings.py: import os # isort:skip import environ env = environ.Env() env.read_env(env.str('ENV_PATH', 'recaptchatest/.env')) gettext = lambda s: s DATA_DIR = os.path.dirname(os.path.dirname(__file__)) """ Django settings for recaptchatest project. Generated by 'django-admin startproject' using Django 3.1.14. For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY … -
Update function data is not saving in django
views.py class ProductsDetailView(DetailView): template_name = "productsdetail.html" queryset = Products.objects.all() context_object_name = 'products' model = Products serializer_class = Productserialize def productupdate(request,id): prod = Products.objects.get(id=id) if request.method == "POST": if len(request.FILES) != 0: if len(prod.image) > 0: os.remove(prod.image.path) prod.image = request.FILES['image'] prod.title = request.POST.get('title') prod.description = request.POST.get('description') prod.save() return redirect('productsdetail') return render(request,'productsupdate.html',{'prod':prod}) detail.html <form> Title:- {{products.title }} <br><br> Description:- {{ products.description}}<br><br> {% if products.image %} Image :- <img src="{{products.image.url}}" alt="image"><br><br> {% endif %} <button><a href="/update/{{ products.id}}">Edit</a></button> </form> update.html <form method="post" action="/update/{{prod.id}}" enctype="multipart/form-data"> {% csrf_token %} <table> <tr> <td>Title:<br> <input type="text" name="title" id="title" value="{{ prod.title }}"></td> <br> </tr> <tr> <td>Description:<br> <textarea name="description" id="description" value="{{ prod.description }}">Description</textarea></td> <br> </tr> <tr> {% if prod.image %} <td>Image:<br> <input type="file" name="image" id="image" value="{{prod.image.url}}"></td> {% endif %} <br> </tr> <tr> <td><button type="submit" id="update">Update</button></td> </tr> </table> </form> When i click edit button in detail page it shows update form but when Iam trying to update data is not saving I don't know what is the issue I have given views,detail html and update html code Please help me to solve this Thanks in advance -
Serve Django static files in kubernetes
I am trying to host a Django project inside Kubernetes. But now am facing an issue to serve static files of Django. So I researched about it. In my researches found that storage objects are a better option like S3. Can I serve static files without using S3? I trying to serve using the Nginx server. I tried in different ways but I didn't get a solution. Here is my deployment YAML. And I attached a volume for static files and media files. Can I possible serve static files and media files from that volume using Nginx deployment.yml apiVersion: apps/v1 kind: Deployment metadata: name: m3-mobiles-deployment labels: app: m3-mobiles spec: replicas: 1 selector: matchLabels: app: m3-mobiles template: metadata: labels: app: m3-mobiles spec: volumes: - name: m3-mobiles-assets-vol hostPath: path: /home/docker/m3mobiles/assets - name: m3-mobiles-media-vol hostPath: path: /home/docker/m3mobiles/media containers: - name: m3-mobiles image: amjedsaleel/m3mobiles volumeMounts: - name: m3-mobiles-assets-vol mountPath: /app/assets - name: m3-mobiles-media-vol mountPath: /app/media ports: - containerPort: 8000 env: - name: SECRET_KEY valueFrom: secretKeyRef: name: m3-mobiles-secret key: secret-key - name: DEBUG valueFrom: secretKeyRef: name: m3-mobiles-secret key: debug - name: DB_NAME valueFrom: secretKeyRef: name: m3-mobiles-secret key: db-name - name: DB_USER valueFrom: secretKeyRef: name: m3-mobiles-secret key: db-user - name: DB_PASSWORD valueFrom: secretKeyRef: name: m3-mobiles-secret key: … -
How to solve [Deprecation] Synchronous XMLHttpRequest error in django console
I am currently using Django, but I don't think this is a django-specific error. By the way, I looked at JavaScript console.log causes error: "Synchronous XMLHttpRequest on the main thread is deprecated...", but I don't think it solves my issue. As you can see below, I got the error in the chrome console: Here is the code from my templates that I think is causing the problem: {% block script %} <script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script> ... <script src="{% static 'js/checkout.js' %}" type="text/javascript"></script> {% endblock %} The interesting thing is that the website worked fine in development mode on my desktop, but I had this issue once I depolyed it online. Thank you, and please leave any comments or questions you have. -
Space Between Nav Bar & Body
I have a random gap between the body of my base.html and the navbar above it. When I add a random div after the include navbar line, it fills that space with the new information.. But when removed, it's just blank and nothing shifts up. Additionally, when I remove the class='row' for the div tags in the body, nothing happens. What would be causing this space? base.html: {% load static %} <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous"> {% comment %} <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" /> {% endcomment %} <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" integrity="sha512-vKMx8UnXk60zUwyUnUPM3HbQo8QfmNx7+ltw8Pm5zLusl1XIfwcxo8DbWCqMGKaWeNxWA8yrx5v3SaVpMvR3CA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link href="{% static 'css/base.css' %}" rel="stylesheet"> {% block extracss %}{% endblock %} <title>{% block title %}title{% endblock title %}</title> </head> <body style='background-color:#e7e7e7;'> {% include 'include/navbar.html' %} <div class='row' style='background-color: orange;'> <div class='column' style='padding-left:35px ;float: left; width:17%;background-color: #f1f1f1;'> test </div> <div class='column' style='float: right; width:83%;background-color: #e7e7e7; padding:25px'> {% block content %}{% endblock content %} </div> </div> {% include 'cms/modal/modal.html' %} <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js" integrity="sha384-+YQ4JLhjyBLPDQt//I+STsc9iw4uQqACwlvpslubQzn4u2UU2UFM80nGisd026JF" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="{% static 'cms/js/ajax.js' %}"></script> {% block extrajs %}{% endblock extrajs …