Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
add more model info to the JWT token
i'm creating a messaging app. i have 3 models in my backend djago. i have a profile model that stores user & which room they are connected with(so that everytime they log in, their rooms will pop up in side bar like whatsapp). in profile model i have a many to many relationship with Room model that stores rooms list. as i'm using JWT web token for authentication, i want users profile model/rooms like of that user to be added in the token. so that i can fetch the info from token directly but i don't know how to add that fields info into the token views. i've already customised my token obtain view where i added users name as extra but i need to add the list of rooms too. thanks in advance for helping... #model.py from django.db import models from django.contrib.auth.models import User from django.dispatch import receiver from django.contrib.auth.models import User # Create your models here. class Room(models.Model): name = models.CharField(max_length=100,blank=True,null=True) class Profile(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE) rooms = models.ManyToManyField(Room) class Message(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE,blank=False,null=True) message = models.TextField(max_length=500,blank=False,null=True) name = models.CharField(max_length=100,blank=True,null=True) room = models.ForeignKey(Room,on_delete=models.CASCADE,null=True) time = models.DateTimeField(auto_now_add=True) received = models.BooleanField(default=False,null=True) #views.py from rest_framework_simplejwt.serializers import TokenObtainPairSerializer from rest_framework_simplejwt.views import TokenObtainPairView … -
Django - How to Manually update/set/Reset password
I tried to reset password manually by passing key But it always says AttributeError : 'str' object has no attribute 'get' I googled many times even if i saw Manual Password with hiding password field Django but no luck favor me. // In my form #forms.py class UserResetPasswordForm(forms.Form): new_password1 = forms.CharField( label=_("New Password"), widget=forms.PasswordInput(attrs={"autocomplete":"off"}), strip=False, help_text=password_validation.password_validators_help_text_html(), ) new_password2 = forms.CharField( label=_("New Password Confirmation"), strip=False, widget=forms.PasswordInput(attrs={"autocomplete":"off"}), ) In Url path('password-reset/confirm/<str:reg_key>/', accounts_view.myreset_password_confirm, name='myreset_password_confirm'), In View #views.py def myreset_password_confirm(request, reg_key): user = User.objects.filter(activate_key=reg_key).first() if user is not None: if request.method == 'POST': form = UserResetPasswordForm(request.POST) if form.is_valid(): #password1 = form.cleaned_data.get('new_password1') #password2 = form.cleaned_data.get('new_password2') password1 = request.POST['new_password1'] password2 = request.POST['new_password2'] if password1 and password2: if password1 != password2: raise ValidationError("Your password didn't match.") password_validation.password_validators_help_text_html() return password2 print(password2) user.activate_key = '' user.set_password(password2) user.save() print("Print User") print(type(user)) messages.success(request, f"Your password for {user.email} has been reset successfully!") return HttpResponseRedirect('/') else: form = UserResetPasswordForm() return render(request, 'reset_password_confirm.html', {'form':form}) else: print("U R Boomed") messages.error(request, "Your requested URL is not Valid, Please try with valid URL.") return HttpResponseRedirect('/') Please help, how to solve it? -
How to prevent Modal from hiding when submitting if there is an error in the form?
when I click the Add User button the modal is hiding even if the form has errors. If I reopen the modal the error messaged are there, I need to show the error messaged and not close the modal if the there is an error message. I think I can use the {{form.errors}} to verify if there is an error message. But I don’t know how? <div class="card-body d-flex justify-content-between"> <h4 class="box-title">Users</h4> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#add_user" data-whatever="" >Add a user</button> <div class="modal fade" id="add_user" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h1 class="h3 mb-3 fw-normal text-center" id="exampleModalLabel">Create Account</h1> </div> <div class="modal-body"> <form action="" method="POST"> {% csrf_token %} <div class="form-floating"> {{ form.username }} <span class="text-danger">{{ form.errors.username }}</span> </div> <div class="form-floating"> {{ form.email }} <span class="text-danger">{{ form.errors.email }}</span> </div> <div class="form-floating"> {{ form.password1 }} <span class="text-danger">{{ form.errors.password1 }}</span> </div> <div class="form-floating"> {{ form.password2 }} <span class="text-danger ">{{ form.errors.password2 }}</span> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button class=" btn btn-primary" type="submit" >Add User</button> </div> </div> </form> </div> </div> </div> I used to the Django form for validation and error messages. from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class CustomUserCreationForm(UserCreationForm): … -
How display html content into div element by clicking on a href="" link, in django and django-messages?
I am trying to display HTML file into div element. I tried a few examples from js to jquery, but nothing seems to work. I am also using django-message. In inbox.html I am trying to display message content into a div element after clicking on a link. Message contact needs to change after clicking on another link. This needs to be displayed on the same page. inbox.html: {% extends "user_dashboard_page.html" %} {% load static %} {% block content %} {% if user.is_authenticated %} <link rel="stylesheet" type="text/css" href="{% static 'css/inbox.css' %}"> <script src="{% static 'js/inbox.js' %}"></script> {% load i18n %} {% if message_list %} <section class="sidebar"> <div class="sidebar--inner"> <div class="is-settings--parent"> <div class="sidebar-menu"> <ul> <li class="inboxItem isActive"><a href="#0">Inbox (<span class="numCount"></span>) </a></li> <li class="sentItem"><a href="{% url 'messages_outbox' %}">Sent</a></li> <li class="spamItem"><a href="#0">Spam</a></li> <li class="trashItem"><a href="{% url 'messages_trash' %}">Trash</a></li> </ul> </div> </div> </div> </section> <section class="view"> <section class="emails is-component"> <div class="emails--inner"> <div> <h1 class="email-type">Inbox</h1> <!-- inbox email cards --> {% for message in message_list %} <div class="inbox"> <div class="email-card"> <div class="is-email--section has-img"> <div class="sender-img" style=""> </div> </div> <div class="is-email--section has-content"> <div class="sender-inner--content"> <p class="sender-name">From: {{ message.sender.username }}</p> **a link elements!!!** <p class="email-sum">Subject: <a href="{{ message.get_absolute_url }}">{{ message.subject }}</a></p> <p class="email-sum">Time: {{ message.sent_at|date:_("DATETIME_FORMAT") }}</p> </div> </div> … -
Django rest framework get data from foreign key relation?
I have a models like this: class Author(models.Model): name = models.CharField(max_length=150, blank=False, null=False) dob = models.DateField(null=True, blank=True) description = models.TextField(max_length=2000, blank=False, default="This author doesn't have any description yet!") image = models.ImageField() created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) class Meta: ordering = ['created'] def __str__(self): return self.name class Book(models.Model): title = models.CharField(max_length=200, blank=False, null=False) author = models.CharField(max_length=200) genres = models.ManyToManyField(Genre, related_name='genre', blank=True) author = models.ForeignKey(Author, related_name='author', blank=True, on_delete=models.CASCADE) description = models.TextField(max_length=1200, blank=False, default="This book doesn't have description yet!") image = models.ImageField(default="") created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) class Meta: ordering = ['created'] def __str__(self): return self.title class Review(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, null=True) book = models.ForeignKey(Book, on_delete=models.CASCADE) title = models.CharField(max_length=100, null=False, blank=False, help_text="Title overall of your review") rating = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(5)], help_text='Rating in range 0-5') description = models.TextField(max_length=1000, null=False, blank=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) I want to get Book data response in json with my reviews of the book from my Review table but don't know how. I am not getting any useful solution from documentation and Google, please help. -
How do I update my list data when data is already sent in the backend? (VUE/DJANGO)
I'm new to vue and trying to work it with django. I have a field called status that uses boolean field and set the default=False. I'm trying to update the data in the backend by onclick. When i click the div, data will emit to parent and update the status to !status. Child: <div @click="$emit('update-status', this.task)">{{ task.status}} </div> Parent: <Task v-for="task in tasks" :key="task.slug" :task="task" :slug="task.slug" @update-status="updateStatus"/> async updateStatus(task) { let endpoint = `/api/v1/tasks/${task.slug}/`; const response = await axios.put(endpoint, { status: !task.status, }); } It updates once and it keeps returning the same value True when I keep on clicking (it should always return opposite of status). I have to manually refresh my browser, so when I click it again it will return False. -
Display sum value of nested object in serializer
I have an app where users enters their daily expenses and incomes. The API data looks like this [{ "id": "07cf140c-0d4d-41d7-9a31-ac0f5f456840", "owner": 2, "entry": [ { "id": 1, "owner": 1, "title": "aa", "amount": 22, "description": "za pizze", "entry_type": "income", "date_added": "2022-08-13", "entry_category": 1 } ], "viewable": [ 1, 2 ], "name": "as", "date_added": "2022-08-13" }, { "id": "d458196e-49f1-42db-8bc2-ee1dba438953", "owner": 1, "entry": [ { "id": 1, "owner": 1, "title": "aa", "amount": 22, "description": "za pizze", "entry_type": "income", "date_added": "2022-08-13", "entry_category": 1 }, { "id": 2, "owner": 1, "title": "sas", "amount": 323, "description": "stacja", "entry_type": "expenses", "date_added": "2022-08-13", "entry_category": 5 } ], "viewable": [], "name": "dsdsds", "date_added": "2022-08-13" }] And I know how to sum the amount field to get sum of income/expenses def get_queryset(self): user_id = self.request.user.id available = BudgetEntry.objects.filter( Q(owner=user_id) ) a = available.filter(entry_type='income').aggregate(Sum('amount'))['amount__sum'] print(a) return available but how can I get this data to be display directly in the JSON? In a way that is reusable because I want also to get top categories where user spends or saves the most Serializers.py class CategorySerializer(serializers.ModelSerializer): class Meta: model = Category fields = ('name',) class BudgetEntrySerializer(serializers.ModelSerializer): owner = serializers.ReadOnlyField(source='owner.id') class Meta: model = BudgetEntry fields = '__all__' class WalletInstanceSerializer(serializers.ModelSerializer): owner = … -
I am getting an unexpected keyword argument error in a function I didn't call
I am building a online exam system where in exam cohorts there will be exams. I have created Models for cohort and exams and questions. Now I am trying to put a foreign key exams in questions model where there is a cohort in exams models as foreign key. Here is the code views.py def addCohort(request): if request.method == 'POST': form = createCohortForm(request.POST) if form.is_valid(): u = request.user name = form.cleaned_data['name'] chrt = cohort(CohortName = name , Admin = u.email) chrt.save() chrtInfo = cohortInfos(cohort = chrt, Member = u, MemberStatus = 'admin') chrtInfo.save() return HttpResponseRedirect('/dashboard') else: form = createCohortForm() return render(request, 'cohort/createcohort.html', {'f': form}) def cohortIndex(request,cID): chrt = cohort.objects.get(CohortID = cID) cohortInformation = cohortInfos.objects.get(cohort = chrt , Member = request.user) exams = ExamInfo.objects.filter(cohort = chrt) if request.user.email == cohortInformation.cohort.Admin: return render(request, 'cohort/cohortIndexAdmin.html',{'Info':cohortInformation, 'exams': exams}) else: return render(request, 'cohort/cohortIndexExaminee.html',{'Info':cohortInformation, 'exams': exams}) def addMember(request,cID): chrt = cohort.objects.get(CohortID = cID) cohortInformation = cohortInfos.objects.get(cohort = chrt, Member = request.user) if request.method == 'POST': form = addMemberForm(request.POST) messages.success(request, 'Examinee added successfully') if form.is_valid(): email = form.cleaned_data['memberEmail'] member = User.objects.get(email__exact = email) cohortadd = cohortInfos(cohort = chrt, Member = member, MemberStatus = "examinee") cohortadd.save() form = addMemberForm() else: form = addMemberForm() memberlist = cohortInfos.objects.filter(cohort = chrt) … -
How to save audio file recored via Javascript/ajax into django media
I am recording voice via mic from front end using javascript and sending it back using ajax. <center> <p> {% csrf_token %} <button class="btn btn-primary py-3 px-5" id=record>Record</button> <button class="btn btn-primary py-3 px-5" id=stopRecord disabled>Stop</button> </p> <p> <audio id=recordedAudio></audio> </p> <h4 id="result" > Result</h4> </center> This is my html template Ajax file $.ajax({ type: 'POST', url: '/demo/audio/', data: fd, dataType: 'text' }) I have not created any model for this. Here is views.py function def audio_demo(request): if request.method=='POST': req=request.POST.get('data') d=req.split(",")[1] file_name='sub_app/media/file_{}.oga'.format(random.randint(0,99)) with open(file_name, 'wb') as f: f.write(base64.b64decode(d)) Though this is saving in media folder, but this is not the right way. I think the right way is to create a model object like we do for file field or image field. But i dont want to upload file like in file field. Instead i want to record it. My ultimate gaol is to store the audio file in media folder which is actually an S3 bucket and then get the file path. The above code snippet is storing file, but in local media folder, not on S3. Just for clarification, my media folder is configured for S3. My images are being uploaded there. -
Python Django - Prevent a booking record form being updated 24 hours before the booking starts
I've not started writing the code as I'm in planning stages for my assignment. I'm creating a booking app where the user selects a date and time. I want to restrict the user from updating their booking 24 hours (1 day) before the booking date. The user will be presented with a pop-up modal instead. Any ideas on how to achieve this please let me know. I'll be using Django, bootstrap for this. Thank you in advance. -
Why does CSS in the same Django project work correctly in Pycharm but does not work in Visual Studio?
I tried to open my django project written in pycharm in visual studio code and got a problem with CSS. In pycharm it works as it should, when I code in .css files it's displaying correctly on the website, but in VS, for example, if I open a project in VS with CSS code already written in in Paycharm, it works, but when I add something to the .css file in VS, nothing happens. Just no changes. The website displays css previously written in Pycharm. What could be the problem? -
how do we send file from django to reactjs where i dont need RESTFRame work?
I am new to ReactJS,I am using a django as backend, React as frontend i need to send a dict/json to reactjs which is locally created by choices not from data base. is there a way to send Data from django to reactjs without restframe work? -
How to use django tags in External js file.?
I want to append the chat popup in the html body from Jquery when the element gets clicked and then I want to show the messages from the database. Following is my code in an external js File, chatPopup = '<div class="message_box" style="right:290px" rel="'+ userID+'"><div class="message_header" rel="'+ userID+'">'+ '<img src="http://127.0.0.1:8000'+pro+'" class="user_icon"><h3 class="username">'+username+'</h3>'+ '<i class="fa fa-times close" rel="'+ userID+'"></i></div><hr><div class="message_content"><div class="messages" rel="'+ userID+'">'+ '{% for chat in thread.chatmessage_thread.all %}'+ '<div class="chat">'+ '{% if chat.user == user %}'+ '<div class="new_messages p2">{{ chat.message }}</div>'+ '{% else %}'+ '<div class="new_messages p1">{{ chat.message }}</div>'+ '{% endif %}</div>{% endfor %}</div><div class="input_box">'+ '<textarea type="text" class="message_input" rel="'+ userID+'" placeholder="Type Message..."></textarea>'+ '<i class="fa fa-arrow-circle-right enter" rel="'+ userID+'"></i></div></div></div>'; if ( $('[rel="'+userID+'"]').length == 0) { $("body").append( chatPopup ); What I know that we can't use the Django tags other than .html files, But is there any way how to send Django variable thread.chatmessage_thread.all (<model_name><related_name>all) look like variable in external file using the trick used in the following answer in link? https://stackoverflow.com/a/7318511/14715170 -
Django don't runserver in docker
I have django project and I want to dockerize it. when I use python manage.py runserver 0.0.0.0:8000 on my system its work: view result picture, but when I try use this command on docker, django server is not running view result picture This is my Dockerfile that used for build docker image: FROM python:3.9 ENV PYTHONUNBUFFERED=1 RUN mkdir /app WORKDIR /app COPY requirements.txt /app/ RUN pip install -r requirements.txt COPY . /app/ -
Serving resized images from backend to frontend
We're making varied size of image when uploading images so that the frontend could use proper size of image depending on their situation(mobile vs desktop, network speed and etc). To do so, I can think of two ways and wonder which one is better than the other and what's the reason for that. option1) the backend just reply back "base_url"(http://sample_image_path.jpg) of image so that the frontend can pick image by appending image size(http://sample_image_path.jpg.small) according to their circumstance. option2) the backend pick and send the image size according to user agent in http request header and the frontend just render whichever returned from the backend. Because there's no way to know the network status in backend side, I thought 1st option is better but wonder if there's any other opinions. Thanks in advance -
Django Formset Form Delete Doesn't Work with Formset Management Form
I am using a formset to dynamically add fields and update the existing data. If I use {{formset}}, form delete buttons work properly, but if I use the formset managementform they don't work. {{formset.management_form}} {% for form in formset %} {% for hidden in form.hidden_fields %} {{ hidden }} {% endfor %} <div id="social-form-list"> <div class="social-form flex"> {{form.social}} {{form.link}} {% if formset.can_delete %} <div class="flex items-center ml-8"><h2>Delete: </h2>{{form.DELETE}}</div> {% endif %} {% endfor %} {% endif %} When I post this form, it sets form-index-DELETE': ['on'] but it doesn't delete the existing data from the database. What can I change to make this work? THis is the post request it sends: <QueryDict: {'csrfmiddlewaretoken': ['token'], 'form-TOTAL_FORMS': ['5'], 'form-INITIAL_FORMS': ['5'], 'form-MIN_NUM_FORMS': ['0'], 'form-MAX_NUM_FORMS': ['1000'], 'form-0-id': ['24'], 'form-0-social': ['1'], 'form-0-link': ['link1'], 'form-1-id': ['25'], 'form-1-social': ['2'], 'form-1-link': ['link2'], 'form-2-id': ['33'], 'form-2-social': ['7'], 'form-2-link': ['link3'], 'form-3-id': ['51'], 'form-3-social': ['15'], 'form-3-link': ['link4'], 'form-4-id': ['67'], 'form-4-social': ['10'], 'form-4-link': ['link5'], 'form-4-DELETE': ['on']}> Thanks in Advance!! Any help is appreciated -
By default, is "transaction.atomic" already applied to the data which is added and changed in Django Admin?
I checked Django repository on GitHub. Then, transaction.atomic(using=using, savepoint=False) and transaction.mark_for_rollback_on_error(using=using) are called in save_base() which is called in save() in class Model(metaclass=ModelBase): as shown below: # "django/django/db/models/base.py" class Model(metaclass=ModelBase): # ... def save( self, force_insert=False, force_update=False, using=None, update_fields=None ): # ... self.save_base( using=using, force_insert=force_insert, force_update=force_update, update_fields=update_fields, ) # ... def save_base( self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None, ): # ... # A transaction isn't needed if one query is issued. if meta.parents: context_manager = transaction.atomic(using=using, savepoint=False) # Here else: context_manager = transaction.mark_for_rollback_on_error(using=using) # Here with context_manager: # ... So, by default, "transaction.atomic" is already applied to the data which is added and changed in Django Admin, right? In other words, when adding and changing data in Django Admin, the data is atomic by default, right? So, in "class Person(models.Model):", if we override "save()" which calls "super().save(*args, **kwargs)" in it as shown below: # "models.py" from django.db import models class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) def save(self, *args, **kwargs): super().save(*args, **kwargs) # Here We don't need to put "@transaction.atomic" on "save()" as shown below, right?: # "models.py" from django.db import models from django.db import transaction class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @transaction.atomic # Don't need def … -
Is there a way filter only selected tags in Django-bleach?
Im trying to use Django-ckeditor with Django-bleach, but Im running into problems where Django-bleach would filter all the tags that Django-ckeditor uses. Is there a way around this? -
No module named django-redis
No module named 'django.core.cache.backends.redis' django-redis installed enter image description here -
How to add HarperDB to a django project?
I have created a django project and I want to use harperDb with it. How can I connect Harper db with my django project? In setting.py the database code looks like this: -
NOT NULL constraint failed: DJANGO Rest Framework
I'm following an udemy tutorial, and all it's going nice until I try to do a POST to create an article on the database. When I send a POST to /api/posts with Multipart form: title: What is Java? description: Java order: 1 I receive the error: NOT NULL constraint failed: posts_post.order I can't find the solution to this specific situation. So I let you the code of my: models.py: from django.db import models class Post(models.Model): title = models.CharField(max_length=255) description = models.TextField() order = models.IntegerField() created_at = models.DateTimeField(auto_now_add=True) serializers.py: from rest_framework.serializers import ModelSerializer from posts.models import Post class PostSerializer(ModelSerializer): class Meta: model = Post fields = ['title', 'description', 'created_at'] views.py from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status from posts.models import Post from posts.api.serializers import PostSerializer class PostApiView(APIView): def get(self, request): serializer = PostSerializer(Post.objects.all(), many=True) return Response(status=status.HTTP_200_OK, data=serializer.data) def post(self, request): print(request.POST) serializer = PostSerializer(data=request.POST) serializer.is_valid(raise_exception=True) serializer.save() return Response(status=status.HTTP_200_OK, data=serializer.data) I can do a GET request to my api/posts properly. The real problem is the POST request where I should create a new article/post -
Celery "No Nodes Replied within Time Constraint"
I am building a django web application for day-trading and I need to manage many celery workers that'll execute trades for users. Each botting strategy is ran as a task which is then consumed on a celery worker on an external shell window. Celery worker processes are created as a detached shell process using the python subprocess module. In the django app directory I am creating a dummy .sh bash files as targets that will initialize celery workers directly after launching the terminal window. f"celery -A MyDjangoServer4_0_4 worker --pool solo -Q bot{id}_queue -n bot{id} -l INFO -E" begins the celery worker on the terminal and cmd /k at the end prevents the terminal window from immediately closing afterwards for debugging. Each celery worker is getting it's own unique name and unique queue so they should be independently and concurrently operational from one another. I can spawn and create celery workers with new names and even signal tasks to them successfully. But I cannot recreate or reinitialize them using the same target name even after closing the sub process window. I believe I need to shutdown/terminate the node somehow so I can restart/reinitialize the subprocess worker, but I get an error … -
HTTP 400 BAD_REQUEST between dockerised Django and Spring boot service
I am running Django and a Spring boot application as Dockerised services with the same Docker volume and network. For one of the requirement, I am making a request from my Django service to the Spring boot service using Python's request module, as shown below, res = requests.post( f'http://{spring_host}:8080/getTranslatedAsFile/', data={ 'document-json-dump': json.dumps(data), "doc_req_res_params": json.dumps(res_paths), "doc_req_params": json.dumps(params_data), }) Here data, res_paths and params_data are python dicts. data contains keys and values depending on the content of the document. More the content (e.g. more words, sentences) more will be keys & values of data. The request is received by the Spring boot service at the controller as shown below, @PostMapping(value = "/getTranslatedAsFile/") public String getTranslatedAsFile(@RequestParam("doc_req_params") String docReqParams, @RequestParam("doc_req_res_params") String docReqResParams, @RequestParam("document-json-dump") String documentJsonDump) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); Document document = objectMapper.readValue(documentJsonDump, Document.class); ObjectMapper objectMapper1 = new ObjectMapper(); DocumentReqParameters documentReqParameters = objectMapper1 .readValue(docReqParams, DocumentReqParameters.class); ObjectMapper objectMapper2 = new ObjectMapper(); DocumentReqResourceParameters documentReqResourceParameters = objectMapper2 .readValue(docReqResParams, DocumentReqResourceParameters.class); return documentProcessService.translate(documentReqParameters, documentReqResourceParameters, document); } When I make a request for document with less content (< 50000 words), i.e data with less keys and values, I am receiving a HTTP 200 response from Spring boot service and able to process the response data. But … -
Django form not showing
Hi I'm trying to create a form in Django but it is not showing in the browser view.py from django.shortcuts import render, HttpResponse from .forms import FormularioRegistro def registro(request): form= FormularioRegistro() return render(request,'Proyecto_RapiExpress_App/registro.html', {'form': form}) forms.py from django.shortcuts import render, HttpResponse from .forms import FormularioRegistro def registro(request): form= FormularioRegistro() return render(request,'Proyecto_RapiExpress_App/registro.html', {'form': form}) registro.html {% extends "base.html" %} {% block title %} Registro {% endblock %} {% block content %} {{form}} {% endblock %} -
Login django only recognizes the superuser first created in the project
I am doing a web project for a barbershop in which there will be several users, the problem is that the login only enters with the super user created for the first time in the project, if I enter the admin and create more users as estaff or as super users either They enter neither the page login nor the admin login, they only enter with the initial super user. I have already reviewed the models and settings but I have not been able to know what the problem is, as extra information I have the project running in Docker, I do not know if it is a problem with the docker or with the django project. I need urgent help, thank you very much in advance.