Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django ORM And Multiple Dynamic Databases
Disclaimer: I am still pretty new to Django and am no veteran. I am in the midst of building the "next generation" of a software package I built 10 years ago. The original software was built using CodeIgniter and the LAMP stack. The current software still works great, but it's just time to move on. The tech is now old. I have been looking at Django to write the new software in, but I have concerns using the ORM and the models file getting out of control. So here's my situation, each client must have their own database. No exceptions due to data confidentiality and contracts. Each database mainly stores weather forecast data. There is a skeleton database that is currently used to setup a client. This skeleton does have tables that are common across all clients. What I am concerned about are the forecast data tables I have to dynamically create. Each forecast table is unique and different with the exception of the first four columns in the table being used for referencing/indexing and letting you know when the data was added. The rest of the columns are forecast values in a real/float datatype. There could be anything from … -
Django/Heroku deployment problems: Won't work on Debug = False
I got my app to deploy, but pages that require an id in session are not rendering. When I set debug = true, everything works fine. Otherwise, I get error 500 message. I've tried many different solutions to no avail. I imagine the problem is somewhere in my settings.py so I have included that below. I was also able to log the startup so that is included as well. The main page and pages that don't get a request.session passed into them work fine, as well as functions that update the database. Only pages that require an id passed into the path are not working. import dj_database_url import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com'] # Application definition INSTALLED_APPS = [ 'whitenoise.runserver_nostatic', 'wiki_app', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.postgres', ] MIDDLEWARE = [ 'whitenoise.middleware.WhiteNoiseMiddleware', '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', ] ROOT_URLCONF = 'coding_dojo_final_project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'coding_dojo_final_project.wsgi.application' ... DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': '***', 'HOST': 'localhost', 'PORT': '****', } } WHITENOISE_USE_FINDERS = True ... LOGGING … -
There is a problem that several products are floating in Django. I think it's an if and for tag problem
I am a student who is learning Django. I want to show the purchase history of the product in the html file, but if I use the for statement to load the join_detail and element, the same syntax keeps repeating. I really don't know what's wrong. How can I modify it so that I can express it's? Please help me. I'm really desperate. I can only move forward if I solve this problem. html <div class="container"> <h4 style="margin-top:20px; margin-bottom: 30px;"><b>구매</b></h4> <div class="table-wrap"> <table class="board all-open"> <caption></caption> <colgroup> <col> <col style="width:15%;"> <col span="3"> </colgroup> <thead> <tr> <th scope="col">상품번호</th> <th scope="col">상품정보</th> <th scope="col">상품명</th> <th scope="col">수량</th> <th scope="col">가격</th> <th scope="col">옵션</th> <th scope="col">구매일자</th> <th scope="col">링크</th> </tr> </thead> <tbody> <tr> {% for product in products %} {% for join in join_objects %} {% if join.product_code.product_code == product.product_code %} {% for designated in designated_object %} {% if designated.product_code.product_code == product.product_code %} {% for join_detail in join_detail_objects %} {% if join.join_code == join_detail.join_code.join_code %} {% for element in element_object %} {% if element.designated_code == join_detail.designated_code %} <td class="num">{{join.join_code}}</td> <td class="name"><a href="{{product.get_absolute_url}}"><img style="width: 90px" height= 90px" src="{{product.image.url}}" alt="상품 이미지"></a></a></td> <td class="subject">{{join.product_code}}<a href="#" class="ellipsis"> </a><a href="#" title="{{product.name}}"></a> </td> <td class="hit">{{join_detail.quantity}}</td> <td class="date">{{join_detail.price}}</td> <td class="date">{{element.value_code}}</td> <td class="name">{{join.part_date|date:"Y-m-d"}}</td> <td class="name"><a href="{{ … -
Change django array field size depending on another field?
I am building an app that displays different courses. For each course there is a list of the different classes it has. Some courses have two classes, somo have eight, some have just one or in the future some courses may have 10 classes. It's up to the app's administrator when they register a new course class Curso(models.Model): clases = models.IntegerField(default=1) content = ArrayField(models.CharField(max_length=30),blank=False) This model will only be for the administrator. I want to store the different classes (just their names) in an array. But theres no need to show 8+ fields if the admin is just going to fill one in... Or is that the correct approach? I want the admin to have an integer field where she types in how many classes the course has and depending on that the array fields will be displayed. I understand ArrayField has a size attribute where I can say how long the array is. Right? So my question is: Is there a way to dinamically change the array size depending on what the admin types in in the "clases" field? I need this to work in the admin app. I am new to django and I'm finding the admin app … -
New fields are not saving in django admin
I’m making a register form for my app and also it work pretty well.But the bug is whenever user log into application it will not save data of new fields and also in register page full register form can be seen.First_name and Last_name other data like username and email are save without any problem.And I migrate database as well.Here is picture of admin of app. here is my code forms.py from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from django.contrib.auth import login, authenticate, logout from django import forms class RegisterForm(UserCreationForm): email = forms.EmailField() First_name = forms.CharField() Last_name = forms.CharField() class Meta: model = User fields = ["First_name", "Last_name","username", "email", "password1", "password2"] def __init__(self, *args, **kwargs): super(RegisterForm, self).__init__(*args, **kwargs) def clean_email(self): email = self.cleaned_data.get('email') if User.objects.filter(email__iexact=email).exists(): raise forms.ValidationError('A user has already registered using this email') return email def clean_username(self): username = self.cleaned_data.get('username') if User.objects.filter(username__iexact=username).exists(): raise forms.ValidationError('A user has already registered using this username') return username views.py from django.shortcuts import render, redirect from django.contrib import messages from .forms import RegisterForm from django.contrib.auth import login, authenticate, logout def register(request): if request.method == 'POST': #if the form has been submitted form = RegisterForm(request.POST) #form bound with post data if form.is_valid(): … -
I can't connect static files to my django project on hosting (directAdmin)
I have an error when I try to load static files on my django project. My site is working, all pages are loading but images, JavaScript and CSS files don't connect. I'm using directAdmin on hosting. This error show me in Chrome console. Refused to apply style from 'https://cvvaiu.ru/static/home/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. My code in settings.py: STATIC_ROOT = os.path.join(BASE_DIR, 'static/') STATIC_URL = '/static/' My code in index.html: <link rel="stylesheet" type="text/css" href="{% static 'home/css/style.css' %}"> ... <script src="{% static 'home/js/script.js' %}"></script> Static files and templates are located in the same folder where located manage.py What can I do? Help me please P.S This is my first experience with DirectAdmin. Please correct my mistakes. -
How to pass list containing dictionary in html template and access its values
In django i have this list my_list=[{'id':1,'username':'sometext'},{'id':2,'username':'someothertext'}] now i am passing this list into the template return render(request,'template.html',{'mylist':my_list}) This is my template.html {% for i in mylist.items %} <tr> <td>{{ mylist.id }}</td> <td>{{ mylist.username }}</td> </tr> {% endfor %} But by doing this i didn't get the value of id and and username. Please suggest if someone have solution. -
Django ignore/ disable Invalid HTTP_HOST header
Using sentry for tracking issues with my Django app, I get a lot of reports of the following style: Invalid HTTP_HOST header: 'example.com'. You may need to add 'example.com' to ALLOWED_HOSTS.. As this seems pretty suspicious (if I understand correctly this would mean that somebody poses as my site) I would like Django to disable this entirely. I have a fixed set of ALLOWED_HOSTS and wouldn't want to use up my sentry capacities with this error message. Using nginx on the server I already added the following to my config: if ($host !~* ^(mysite1.com|mysite2.com)$) { return 444; } The error still persists. I also added in Sentry settings "allowed domains" but this only affects the origin and referrer headers not the host header. -
Different Timezones in Django Model
Is there a way to store dates with different timezones in DateTimeField In settings.py, i currently have timezone turned on and set to: TIME_ZONE = 'US/Pacific' When i save date in the model: class DateStore(models.Model): date = models.DateTimeField() the date is automatically converted to US/Pacific zone which is fine, but when i try to save date with timezone set to UTC, those dates are also converted to US/Pacific. I need the timezone info saved and not be replaced with the set timezone in settings.py Note: I already know we can have a text field that stores zone information and then we can localize accordingly, but my question is that can we preserve timezone info from datetime when saving instead of replacing it with saved TIME_ZONE. -
An issue making addition through models.py making a simple calculation
Hello guys im practicing on django by now developping a simple expense tracker for a main project expample: Buying a flippable car for X amount and adding all the other expenses to get a single total. my operation is mainly done in my model.py models.py from django.db import models # Create your models here. class Project(models.Model): title = models.CharField(max_length=100) amount = models.FloatField() description = models.TextField(blank=True, null=True) def __str__(self): return self.title class Expenses(models.Model): project = models.ForeignKey(Project, related_name='expenses', on_delete=models.CASCADE) title = models.CharField(max_length=100) amount = models.FloatField() def __str__(self): return self.title def get_total_project_amount(self): return self.amount + self.project.amount What i wanna do is adding the main project and all the expenses togheter, but im not using the proper way, when i render the resuld it renders like this: main project: 50$ expenses added from a model form : 2(new) expense: 13(new) expense: 25(new) the total is: 52 total: 63 total: 75 when i wanna di is render the main project and all the expenses to get a single result, something like 50+2+13+25 total : 90$ total amount soent to fix the car. Anyone that understand addition lojic help please and thank you . -
How to serialize DateTimeField in Django
How can I serialize dob field to achieve dob to be in the format; 03/Jan/2020 or 05-Feb-2021 class PersonSerializer(): .... ........ dob = serializers.DateTimeField(format="%d/%m/%Y") class Meta: model = Person fields = "__all__" -
python - Trailer slashes at the end of a Django URL
I was making an application that has parts to update and delete objects (cats) from my database. Before, the URL for Updating a cat data was written in urls.py in urlpatterns as : # in cats/urls.py path('updatecat/<int:cat_id>',views.Cat_Update.as_view(),name="update_cat"), and the view was similar to this : # in cats/views.py class Cat_Update(LoginRequiredMixin, UpdateView): model = Cat fields = "__all__" success_url = reverse_lazy("cats:main") template_name = 'cats/updatecat.html' def get_query_set(self, request): return Cat.objects.filter(id=escape(request.GET['cat_id'])) #I was editing the get_query_set because I wasn't sure what the name of the argument #needed to be written in the URL to be passed to the UpdateView is, and I want to finish as soon #as possible. But I think now that the name may not be too important, right? If it is not #allowed to answer more than one question, it's okay. the template was like: <!--in cats/templates/cats/updatecat.html--> <html> <body> <h1>Edit Cat</h1> <form action = "{% url 'cats:update_cat' object.id %}" method="post"> {% csrf_token %} {{ form.as_p }} <input class="cats_sbmt" type="submit" value="Submit"/> </form> </body> </html> and when I go to this url, it gives me the error as Generic detail view Cat_Update must be called with either an object pk or a slug in the URLconf. And when I added a … -
Loading multiple keras models in django
I have 5 trained keras models with their weights saved. To get predictions, I first create the model with same architecture and then load the saved weights. Now, I wanna get predictions from all these models in django and return them as json response. Where should I load the models so that they are loaded only when the server starts? -
OSError: Unable to load weights from pytorch checkpoint file while configuring AWS EC2
I'm working on a chatbot project that uses DialoGPT, and Django back-end. I've saved the model through save_pretrained method in my colab environment and decided to load them through the following codes in my settings.py tokenizer = AutoTokenizer.from_pretrained('microsoft/DialoGPT-medium') model = AutoModelForCausalLM.from_pretrained("bot/static/friends_model") The friends_model folder contains config.json and pytorch_model.bin. The point I am stuck is that when I run the server locally in django, the chatting works perfectly fine without any errors, but when I try to runserver in a linux ec2 environment, I bump into an OSError mentioned in the title. I git cloned a git repository, and used scp to transfer my model in the local environment to the server(EC2). My wildest guess is something went wrong during the transfer. I'm using a Windows OS, Python 3.9 and Pytorch 1.9.0 for all the environments I am programming (including virtual ones). Can anyone help me out? Many thanks in advance! -
Django queryset more simpel
is there a way to combine those 2 lines of code? a = terminal.provisioning_set.first() b = a.usergroup.id the result is coming from: terminal = Terminal.get_object(terminal_id, request.user) I like to see something like this: result = terminal.provisioning_set.first(usergroup.id) -
ModuleNotFoundError: No module named 'None'
I tried pip install none and the installation was successful, After trying to do python manage.py runserver the same error still occurs. -
Mongodb aggregation in Python : cannot pickle 'SSLContext' object
I need to find count of same groups (like count of same colour products or same price products) and I try to do aggreagtion using '$group'. result = collection.aggregate( [ { "$group" : {"_id":group_aggregation_format, "count": {"$sum":1}} } ]) print(result) group_aggreagtion_format is a data like {'title': '$title', 'colour': '$colour'} Then I get this error | INFO:dill:# T4 web_1 | D2: <dict object at 0x7efec3bfbe40> web_1 | INFO:dill:D2: <dict object at 0x7efec3bfbe40> web_1 | T4: <class 'pymongo.client_options.ClientOptions'> web_1 | INFO:dill:T4: <class 'pymongo.client_options.ClientOptions'> web_1 | # T4 web_1 | INFO:dill:# T4 web_1 | D2: <dict object at 0x7efec3c13dc0> web_1 | INFO:dill:D2: <dict object at 0x7efec3c13dc0> web_1 | T4: <class 'pymongo.common._CaseInsensitiveDictionary'> web_1 | INFO:dill:T4: <class 'pymongo.common._CaseInsensitiveDictionary'> web_1 | # T4 web_1 | INFO:dill:# T4 web_1 | D2: <dict object at 0x7efec3b84f00> web_1 | INFO:dill:D2: <dict object at 0x7efec3b84f00> web_1 | D2: <dict object at 0x7efec3a79240> web_1 | INFO:dill:D2: <dict object at 0x7efec3a79240> web_1 | # D2 web_1 | INFO:dill:# D2 web_1 | D2: <dict object at 0x7efec3bbfc40> web_1 | INFO:dill:D2: <dict object at 0x7efec3bbfc40> web_1 | # D2 web_1 | INFO:dill:# D2 web_1 | # D2 web_1 | INFO:dill:# D2 web_1 | T6: <class 'pymongo.auth.MongoCredential'> web_1 | INFO:dill:T6: <class 'pymongo.auth.MongoCredential'> web_1 | # T6 … -
How to change the default empty-field error message of Django Form fields
I want to change the default error message of empty fields. i mean this message: and i want to have a text below the "phone number" field that appears if user doesn't type exactly 11 numbers (text will show by typing a character and will disappear by 11 numbers) and is there a way to disable the button if the above conditions are not met? this is forms.py: class LoginForm(forms.Form): phone_number = forms.CharField( label='Phone number', label_suffix=':*', widget=forms.TextInput( attrs={ 'class':'form-control', 'id':'user_phone_number', } )) password = forms.CharField( label='Password', widget=forms.PasswordInput( attrs={ 'class':'form-control', 'id':'user_password', } ) ) def clean_phone_number(self): phone_number = self.cleaned_data.get('phone_number') qs = User.objects.filter(phone_number=phone_number) if not qs.exists: raise forms.ValidationError('This is an invalid phone number') return phone_number this is views.py: def login_view(request): form = LoginForm(request.POST or None) if form.is_valid(): phone_number = form.cleaned_data.get('phone_number') password = form.cleaned_data.get('password') customer = authenticate(request, phone_number=phone_number,password=password) if customer != None: # request.customer == customer login(request, customer) return redirect("/") else: # attempt = request.session.get('attempt') or 0 # request.session['attempt'] = attempt + 1 request.session['invalid_user'] = 1 return render(request, 'authentication/login.html',{'form':form}) this is the template: {%extends '_base.html'%} {%block title%}Login{%endblock title%} {% block content%} <form action="" method="post"> {%csrf_token%} {{form.as_p}} <button type="submit" class="btn btn-success">Login</button> </form> {% endblock content%} Thanks in advance -
How to fix RecursionError for Django Storages SFTPStorage?
I am trying to move my Django file storage to an external server, connected via ethernet to a small local network. This local network is not connected to the internet. I am using django-storages SFTPStorage for my file fields now. The server runs fine, but upon a file upload attempt, I get the following error: Performing system checks... System check identified no issues (0 silenced). August 20, 2021 - 13:23:22 Django version 3.2.4, using settings 'smartlab.settings' Starting ASGI/Channels version 3.0.3 development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Traceback (most recent call last): File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 115, in _mkdir self._mkdir(parent) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 115, in _mkdir self._mkdir(parent) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 115, in _mkdir self._mkdir(parent) [Previous line repeated 2 more times] File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 114, in _mkdir if not self.exists(parent): File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 151, in exists self.sftp.stat(self._remote_path(name)) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 87, in sftp self._connect() File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 61, in _connect self._ssh.load_host_keys(known_host_file) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/client.py", line 127, in load_host_keys self._host_keys.load(filename) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/hostkeys.py", line 101, in load e = HostKeyEntry.from_line(line, lineno) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/hostkeys.py", line 364, in from_line key = ECDSAKey(data=decodebytes(key), validate_point=False) File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/ecdsakey.py", line 163, in __init__ key = ec.EllipticCurvePublicKey.from_encoded_point( File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py", line 191, in from_encoded_point if not isinstance(curve, EllipticCurve): File "/usr/lib/python3.9/abc.py", line … -
JSON parse error in ajax script using Django Rest framework
I am using django rest framework.My views response is ok but when i submit my view using ajax it gives me an error json parse error. Here is my views.py file: @api_view(['GET', 'POST']) @parser_classes([JSONParser]) def signup(request, format=None): if request.method == 'POST': data = JSONParser().parse(request) username = data.get('username') first_name = data.get('first_name') last_name = data.get('last_name') email = data.get('email') password = data.get('password') gender = data.get('gender') birth_date = data.get('birth_date') serializer = UserSerializer(data=data) if serializer.is_valid(): user = User.objects.create_user(username=username,first_name=first_name,last_name=last_name,email=email,gender=gender,birth_date=birth_date) user.set_password(password) user.save() data = {'result': 'success', 'message':'You have registered successfully now you can login'} return Response(data=data, status=201) elif not serializer.is_valid(): data = { 'result': 'error', 'message':serializer.errors} return Response(data=data) if not request.user.id and request.method == 'GET': return render(request, 'sessionauthapp/signup.html') My ajax js script: var frm = $('#signupform'); var token = '{{csrf_token}}'; $('#signupform').on('submit', function(e) { e.preventDefault(); $.ajax({ headers: { "X-CSRFToken": token }, url: '/signup/', type: 'post', data: $(this).serialize(), dataType: "json", contentType: "application/json", success: function(data) { console.log(data); }, error: function(data) { } }); return false; }); My ajax script gives me an error like json parse error but my views response is ok. My ajax script gives me an error like json parse error but my views response is ok. Hi, I am using django rest framework.My views response is … -
django forloop.counter not working as list index
I have a for loop that renders some include blocks in a template. {% for terminal in terminals %} {% if terminal.category %} {{forloop.counter0}} {% include 'app/terminal&location/modals/confirm_delete_modal.html' with obj=terminal url='tb-terminal-delete'%} {% include 'app/terminal&location/modals/update_terminal_modal.html' with obj=terminal form=tb_terminal_update_forms.{forloop.counter0} %} <tr class="text-center"> <td class="txt-oflo">{{ terminal.terminal_name }}</td> <td class="txt-oflo">{{ terminal.terminal_id }}</td> <td class="txt-oflo">{{ terminal.room.room_name }}</td> <td class="txt-oflo">{{ terminal.create_time }}</td> <td class="txt-oflo">{{ terminal.create_user }}</td> <td> <button class="btn btn-lg" data-toggle="modal" data-target="#{{ terminal.id }}"> <span> Remove </span> </button> <button class="btn btn-lg ml-4" data-toggle="modal" data-target="#update_{{terminal.id}}"> <span> Update </span> </button> </td> </tr> {% endif %} {% endfor %} Am I passing the forloop.counter0 correctly? If I do form=tb_terminal_update_forms.1 or form=tb_terminal_update_forms.2 it works, how do I pass the counter? -
Django DeleteView derived CBV is deleting my object without showing confirm delete page
I am using Django 3.2 I have a model Foo, and I have written a CBV to allow for deletion. This is what my CBV looks like: /path/to/foo/view.py class FooDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView): model = Foo slug_url_kwarg = 'identifier' slug_field = 'identifier' success_url = reverse_lazy('homepage') def get_object(self, queryset=None): identifier = self.kwargs[self.slug_field] return self.model.objects.get(identifier=identifier) def test_func(self): photo = self.get_object() return self.request.user == foo.owner def post(self, request, *args, **kwargs) -> HttpResponse: foo = self.get_object() foo.delete() return super().post(request, *args, **kwargs) /path/to/foo/templates/foo/templates/foo_confirm_delete {% extends 'base.html' %} {% load static %} {% block page_title %}Foo deletion Confirmation {% endblock %} {% block content %} <form action="{% url 'myapp:foo-delete' %}" method="post">{% csrf_token %} <div class="form-group"> Are you sure you want to delete this item?<br> <br> <strong>{{ object }}</strong> {{ form.errors }} <br> <br> <input type="hidden" name="confirm_delete" value="confirm_delete"> <p> <input type="submit" class="btn btn-primary">Delete</input> <a href="../">Cancel</a> </p> </div> </form> {% endblock content %} Why is my foo_confirm_delete.html form not being displayed to give me a chance to cancel - before the object is deleted? How do I fix this? -
data-traget attribute undefined in django templates and Jquery
Am trying to access the data-target value , it was working but then it stopped unexpectedly, below is my html " <div class="loan-pending" id='loan-pending-{{loan.loan_id}}' data-target="loan-pending-data-{{loan.id}}" data-query-loan-id="loan={{loan.id}}"> {% trans 'Loan Applications' %}: {{loan.loan_id}} </div> Then, this is the jquery : const loanPendingData = $(`#loan-pending-data-${loanID}`); I also tried , the following : const loanPendingData = $(this).data('target'); but no luck , what causes this in django and jquery ? -
How to receive data who was sent by me - websocket | django
I work on a chat in django with django-channels I would like to receive the data who was sent by me -
Angular + Django Backend. How to Log in base on user types in Django
Im facing a problem on how to integrate user permission like if the is_superuser is False, then log in to Author component and if Superuser is True, log in to Admin Component in Angular. I hope someone can help What I want, 1) If the is_superuser is True in django, then log in to a Admin component / admin dashboard 2) If the is_superuser is False in django, then log in to a Author component / Author dashboard