Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can I know everything about python?
I've recently started learning Django. I am picking up the syntax and everything seems to be going on well. I have taken full python courses (including college) before diving into Django. However, every day I see something new in python that I don't know. I do get overwhelmed that my knowledge in Python is not just yet good enough and have to read a lot. Can I know everything about python?? -
How to query self referencing queries in Django for multiple objects
Sorry for the bad title. I hope I can elaborate it better here. I have a model class as below class Employee(models.Model): name = models.CharField(max_length=10) manager = models.ForeignKey('Employee', null=True, on_delete=models.DO_NOTHING) I want to make a query to find all the employees managed by a list of managers. Something like this SELECT r.name FROM employee l JOIN employee r ON l.id = r.manager_id WHERE l.name in ('manger_1', 'manager_2'); How can I achieve this with Django ORM? -
How to insert excel table in django app and create relationships between it's variables?
first time posting here so excuse any mistakes in formating and phrasing. I am making a django-rest app with react frontend into which I have to import excel tables of this type. The purpose of the app will be to accept variable1 (height) and variable2 (width) from the user. Look at the table and return to the user the variable3 (price) that corresponds to their choice. My questions are: What would be a good way to insert the excel tables into django instead of manually typing them Would it be possible to avoid hardcoding every possible combination of the 3 variables and instead create a relationship between them that works thusly: Receive variable1 from user > Return a list of possible variable2 > Receive variable2 from user > Return appropriate variable3 (My question regards the backend, a way for django to process the excel table and how the views and models could be structured. Frontend isn't an issue) I know the question is pretty broad and I hope it is within the scope of stackoverflow. Any and all answers will be greatly appreciated, thanks for your time! -
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17)
I'm trying to run python manage.py runserver on my linux CLI. In my virtual environment, when I run sqlite3 --version I get 3.28.0 but when I run "python", then "import sqlite3", then "sqlite3.sqlite_version", I get 3.7.17. I understand that there is a path file issue but I can't seem to force it to use the newer version of sqlite3. I've tried: django can't find new sqlite version? (SQLite 3.8.3 or later is required (found 3.7.17)) How to use the latest sqlite3 version in python -
ValueError: Field 'id' expected a number but got 'john.smith@gmail.com'
I am trying to create custom user model for authentication. I did everything as in Django documentation but when I am trying to create super user with command line, I get the error. I tried to delete database and migrations and run them again, did not help. Here is my model.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.db.models.deletion import CASCADE from django.utils import timezone from django.utils.translation import gettext_lazy # Create your models here. class UserAccountManager(BaseUserManager): def create_user(self, Email, Name, Surname, Password = None, **other_fields): if not Email: raise ValueError(gettext_lazy('You must provide email address')) email = self.normalize_email(Email) user = self.model(email, Name, Surname, **other_fields) user.set_password(Password) user.save(using=self._db) return user def create_superuser(self, Email, Name, Surname, Password = None, **other_fields): other_fields.setdefault('is_staff', True) other_fields.setdefault('is_superuser', True) other_fields.setdefault('is_active', True) return self.create_user(Email=Email, Name = Name, Surname = Surname, Password = Password, **other_fields) class Customer(AbstractBaseUser, PermissionsMixin): Email = models.EmailField(gettext_lazy('email address'), max_length=256, unique=True) Name = models.CharField(max_length=64) Surname = models.CharField(max_length=64, null=True) Birthday = models.DateField(auto_now=False, null=False,blank=True) PhoneNumber = models.CharField(max_length=16, unique=True, blank=True) Address = models.CharField(max_length=128, blank=True) RegistrationDate = models.DateTimeField(default=timezone.now, editable=False) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_superuser = models.BooleanField(default=False) objects = UserAccountManager() USERNAME_FIELD = 'Email' REQUIRED_FIELDS = ['Name', 'Surname'] def __str__(self): return self.Name + " " + self.Surname def … -
Django channels- Websocket error on heroku
On a local server when i try to connect to make a websocket connection, it successfully runs, But, when i try to connect to websocket on heroku after deploying, i face the following issue 2021-03-26T16:44:22.786720+00:00 app[web.1]: 10.102.191.252:18515 - - [26/Mar/2021:16:44:22] "WSCONNECT /ws/webhooks/586310f018131c1214ff9ece33669e0ebfef2a47/" - - 2021-03-26T16:44:24.018995+00:00 app[web.1]: 2021-03-26 16:44:24,018 ERROR Exception inside application: Expecting value: line 1 column 1 (char 0) 2021-03-26T16:44:24.019005+00:00 app[web.1]: Traceback (most recent call last): 2021-03-26T16:44:24.019006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/sessions.py", line 183, in __call__ 2021-03-26T16:44:24.019006+00:00 app[web.1]: return await self.inner(receive, self.send) 2021-03-26T16:44:24.019007+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/middleware.py", line 41, in coroutine_call 2021-03-26T16:44:24.019007+00:00 app[web.1]: await inner_instance(receive, send) 2021-03-26T16:44:24.019007+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/consumer.py", line 59, in __call__ 2021-03-26T16:44:24.019008+00:00 app[web.1]: [receive, self.channel_receive], self.dispatch 2021-03-26T16:44:24.019008+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/utils.py", line 51, in await_many_dispatch 2021-03-26T16:44:24.019009+00:00 app[web.1]: await dispatch(result) 2021-03-26T16:44:24.019010+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/consumer.py", line 73, in dispatch 2021-03-26T16:44:24.019010+00:00 app[web.1]: await handler(message) 2021-03-26T16:44:24.019028+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/generic/websocket.py", line 196, in websocket_receive 2021-03-26T16:44:24.019029+00:00 app[web.1]: await self.receive(text_data=message["text"]) 2021-03-26T16:44:24.019029+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/generic/websocket.py", line 259, in receive 2021-03-26T16:44:24.019030+00:00 app[web.1]: await self.receive_json(await self.decode_json(text_data), **kwargs) 2021-03-26T16:44:24.019031+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/channels/generic/websocket.py", line 277, in decode_json 2021-03-26T16:44:24.019031+00:00 app[web.1]: return json.loads(text_data) 2021-03-26T16:44:24.019031+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/json/__init__.py", line 348, in loads 2021-03-26T16:44:24.019032+00:00 app[web.1]: return _default_decoder.decode(s) 2021-03-26T16:44:24.019032+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/json/decoder.py", line 337, in decode 2021-03-26T16:44:24.019033+00:00 app[web.1]: obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 2021-03-26T16:44:24.019033+00:00 app[web.1]: File … -
icon badges showed if other users logged in in django
how to show green dot badge if others users are logged in from their ph or computer. similar like facebook, If users are active in my friends list we see a green dot badge in their profile. how to do it. -
how to build a full stack app with load balancer react native react and django (system design)
I am building an app that has django (DRF) as backend framework, React for the front end and React Native for mobile. I am using Docker and Nginx as Load balancer. Now my issue, I read about API gateway, since I intend to deploy my app on AWS, is the system design below the best approach for a small app then could potentially scale without slowing down the app from the start if i ever have a lot of users? Mobile (maybe port 3000) ----> NGINX (Load balancer) * API Gateway -----> backend (Django) Desktop (maybe port 9000) Do I really need the API Gateway, if YES should this be from NGINX or AWS I am looking forward to your advises to make an educated decision. Thank you -
Django create Postgres Enumerated Types fields from models
Does django support postgres enumerated types? I'm creating a model as follows, which generates the following migration. When I run the migration I would expect these types would be enforced at the db level, but it appears they are not. At a high level I'm trying to do run CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy') using the django modeling. Model class Person(models.Model): class Mood(models.TextChoices): Sad = 'sad' Ok = 'ok' Happy = 'happy' name = models.CharField() mood = models.CharField(choices=Mood.choices) Generated Migration class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Person', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100)), ('mood', models.CharField(choices=[('sad', 'Sad'), ('ok', 'Ok'), ('happy', 'Happy')], max_length=10)), ], ), ] -
Page not found (404) : When try to view a page in django
am new to django , so i wrote a simple program to go to Page2 from Page1 using a link in Page 1 and from Page2 to Page 1 using another link in Page 2, but it is showing Page Not Found . urls.py from django.contrib import admin from django.urls import path from website import views urlpatterns = [ path('admin/', admin.site.urls), path('', views.Index,name='IndexPage'), path('darkmode', views.darkmode,name='darkmode'), ] views.py def Index(request): return render(request,'Page1.html') def darkmode(request): return render(request,'Page2.html') Page1.html <div data-url="{% url 'darkmode' %}" class="dark-mode-switcher cursor-pointer shadow-md fixed bottom-0 right-0 box dark:bg-dark-2 border rounded-full w-40 h-12 flex items-center justify-center z-50 mb-10 mr-10"> <div class="mr-4 text-gray-700 dark:text-gray-300">Dark Mode</div> <div class="dark-mode-switcher__toggle border"></div> </div> Page2.html <div data-url="{% url 'Index' %}" class="dark-mode-switcher cursor-pointer shadow-md fixed bottom-0 right-0 box dark:bg-dark-2 border rounded-full w-40 h-12 flex items-center justify-center z-50 mb-10 mr-10"> <div class="mr-4 text-gray-700 dark:text-gray-300">Dark Mode</div> <div class="dark-mode-switcher__toggle dark-mode-switcher__toggle--active border"></div> </div> and am not able to figure put why this happened , Can anyone help me to figure this out -
CommandError: Unable to serialize database
I've checked every solution but can't get it. Actually, I'm new to Django. python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 4 > project_dump.json this is suggested by the instructor so I use it but whenever I enter this code I got this error you can see the error in this image Can anyone know what to do? -
Why is my form text input value POSTing as list?
My form field value is being received as a list and I can't figure out why. I need it to just be a string. form <form id="design-brief-3" name="design-brief-3" data-name="Design Brief 3" class="contact-form" method="POST" action="{% url 'project-design' %}" enctype="multipart/form-data"> {% csrf_token %} <div class="form-field-container"> <label for="business_slogan" class="form-field-label">Business Slogan/Tagline/Mission Statement</label> <input type="text" class="form-field w-input" maxlength="256" name="business_slogan" data-name="business_slogan" placeholder="If we say 'Just Do It' you know what we mean." id="business_slogan" required=""/> </div> <div class="form-field-container"> <label for="essential_content" class="form-field-label">Essential Content</label> <textarea required="" maxlength="5000" id="essential_content" name="essential_content" data-name="essential_content" placeholder="Please include any content you have, it can be as long as you want." class="form-field message w-input"></textarea> </div> <div class="form-field-container"> <label for="logo" class="form-field-label">If you have a logo, upload it here.</label> <input type="file" class="form-field w-input" name="logo" data-name="logo" placeholder="Who is your ideal client?" id="Logo"/> </div> <div class="form-field-container"> <label for="#id_file" class="form-field-label">Additional files, such as page copies & additional images, you can upload multiple.</label> <input type="file" class="form-field w-input" name="#id_file" data-name="#id_file" id="#id_file" multiple="multiple"/> View: def projectdesign(request): if request.POST: print(request.POST) return render(request, 'users/projectdesign.html', context) Output: <QueryDict: {'csrfmiddlewaretoken': ['9p3NTDraxyssQZNdavUSrUaJaT1rQTIImn5rMnjm1F'], 'business_slogan': ['Just do it'], 'essential_content': ['sdsdsad'], 'logo': [''], '#id_file': ['']}> -
Django Customize read-only view in ModelAdmin
I have an ModelAdmin that, with a certain condition, makes has_change_permission equal to false. This makes all fields read-only when attempting to edit a model instance. But how am I able to customize these read-only fields? In particular, in this read-only view, I want: To be able to see a field that is excluded from the creation form (with exclude=[field]). To be able to make certain character fields hyperlinks. -
I want to preserve line breaks in CharField in Django REST framework
I'm using a CharField in the Django REST framework to store text, but how can I preserve line breaks in the API? In the case of Django templates, I think line breaks are possible with {{ value|linebreaksbr }}, but what about the Django REST framework? I would appreciate it if you could tell me how to do this. -
Django Rest-Framework-Simplejwt not working with modheader
I am working on some projects and trying to the list view of the book. I used Django Rest-Framework-Simplejwt to generate tokens and mod header for authentication. When I tried to request a token for a user such as the admin user, and enter it into the mod header, the request is still unauthorized. I tried to do it a couple of times, but still not working. Views.py from rest_framework import generics, permissions from rest_framework.permissions import IsAuthenticated from rest_framework.exceptions import ValidationError from django.contrib.auth.models import User from .models import Book from .serializers import ( BookSerializer, RegistrationSerializer ) class BookCreateView(generics.CreateAPIView): """Create a Book""" queryset = Book.objects.all() serializer_class = BookSerializer permission_classes = (IsAuthenticated,) def perform_create(self, serializer): serializer.save(user=self.request.user) class BookListView(generics.ListAPIView): """Show all books""" serializer_class = BookSerializer permission_classes = (IsAuthenticated,) def get_queryset(self): user = self.request.user return Book.objects.filter(user=user) class BookDetailView(generics.RetrieveAPIView): """Show detail of the book""" serializer_class = BookSerializer permission_classes = (IsAuthenticated,) def get_queryset(self): user = self.request.user return Book.objects.filter(user=user) class BookUpdateView(generics.RetrieveUpdateDestroyAPIView): """update detail of the book""" queryset = Book.objects.all() serializer_class = BookSerializer permission_classes = (IsAuthenticated,) def delete(self, request, *args, **kwargs): book = Book.objects.filter(user=self.request.user, pk=kwargs['pk']) if book.exists(): return self.destroy(request, *args, **kwargs) else: raise ValidationError('Book is not yours!') def perform_update(self, serializer, **kwargs): book = Book.objects.get(pk=self.kwargs['pk']) if self.request.user != book.user: … -
Django Heroku - ModuleNotFoundError: No module named 'django_social_share'
My django site works fine locally but on Heroku has "Application Error" Page . but it exists in settings.py file Thanks in advance so i typed heroku logs --tail My heroku log : -
Deploy Django with VueJS on DigitalOcean Apps
I have a project that consists of Django (DRF) backend and VueJS app frontend. During development, I have two servers - Django deployment server on port 8000 and VueJS on port 8080. I would like to make this work also on DigitalOcean Apps platform so the only thing I need to deploy it is to git push project to master. Structure: django_project/django_project/settings.py ... django_project/django_app1 django_project/django_app2 django_project/vue_app If I deploy this, only Django project is being server. I need to bound VueJS project to / URL and Django to /api url. I have some ideas but I'm not sure how to make them work. For example, I'll setup outputDir to /var/www but I can't access the nginx configuration so I don't know how to do that. Do you have any ideas? -
django-admin to open a new project
I am using this command: django-admin stratproject Hello to initiate a new project, but I am getting the following error django-admin : The term 'django-admin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + django-admin stratproject Hello + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (django-admin:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException just started with django and this is so frustrating -
Update CSS on Django production Server (Nginx, Gunicorn, Whitenoise)
I have a Django production setup on an VPS with Nginx and Gunicorn and I serve static files through whitenoise. I have updated the CSS and pulled the changes on the server but they don't show up. After I pulled the changes, I ran the following commands: python3 manage.py collectstatic <- to collect the new files sudo systemctl reload nginx <- restart nginx kill -HUP /Gunicorn master PID/ <- restart gunicorn I read in the Whitenoise documentation that it should serve new files immediately without restarting. So I think everything should be reset and the new files should be served but it doesn't work. Am I missing a step? For completeness sake here is the nginx config: server { listen 80; server_name XXX.XXX.XXX.XXX; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/ubuntu/project_path/project_name; } location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/project_path/project.sock; } } Thanks in advance -
Django: NoReverseMatch at /home/blog/ Reverse for 'post-detail' not found. 'post-detail' is not a valid view function or pattern name
I have been getting this error, and I didn't know what I did wrong in the code, I checked everything and I still cant figure it out. I also try getting the specific post object in the database by id, i mean doing something like "post = Post.objects.get(id=id)" in post function in my views.py, but i got the same error. Any help will be appreciated. this is my models.py from django.db import models from django.contrib.auth import get_user_model from django.urls import reverse User = get_user_model() class Author(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) profile_pic = models.ImageField() def __str__(self): return self.user.username class Category(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name class Post(models.Model): title = models.CharField(max_length=200) overview = models.CharField(max_length=200) categories = models.ManyToManyField(Category) author = models.ForeignKey(Author, on_delete=models.CASCADE) comment_count = models.IntegerField(default=0) views_count = models.IntegerField(default=0) timestamp = models.DateTimeField(auto_now_add=True) thumbnail = models.ImageField() featured = models.BooleanField(default=False) def __str__(self): return self.title def get_absolute_url(self): return reverse('post-detail', kwargs={'id': self.id}) my urls from django.urls import path from blog.views import home, blog, post app_name = 'blog' urlpatterns = [ path('', home, name='home-page'), path('blog/', blog, name='blogs'), path('post/<id>/', post, name='post-detail'), ] my blog.html template <div class="container"> <div class="row"> {% for post in queryset %} <div class="post col-xl-6"> <div class="post-thumbnail"> <a href="post.html"><img src="{{post.thumbnail.url}}" alt="..." class="img-fluid"></a> </div> <div class="post-details"> … -
How to add a second annotation to an already annotated queryset with django models
I want to create a queryset with following columns movie.id | movie.title | movie.description | movie.maximum_rating | movie.maximum_rating_user Below is are my models and the code I have tried. models.py from django.contrib.auth.models import AbstractUser from django.db import models class User(AbstractUser): pass class Rating(models.Model): movie = models.ForeignKey(Movie, on_delete=models.CASCADE, related_name="ratings") user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="ratings") score = models.DecimalField(decimal_places=2, max_digits=9) class Movie(models.Model): title = models.CharField(max_length=64) description = models.TextField(max_length=4096) When i run below code the following is printed in console: (basically this shows all data in the experimental database) views.py def index(request, movie_id): movies = Movie.objects.all().annotate( maximum_rating=Max('ratings__score'), maximum_rating_user=F('ratings__user') ) for movie in movies: print(movie.id, movie.title, movie.description, movie.maximum_rating, movie.maximum_rating_user) return HttpResponse("") id title description rating user 1 Jumping Cats Running wild 2 1 1 Jumping Cats Running wild 1 2 1 Jumping Cats Running wild 5 3 1 Jumping Cats Running wild 4 4 2 Terminator I'll be back! 8 1 2 Terminator I'll be back! 6 2 2 Terminator I'll be back! 4 3 2 Terminator I'll be back! 10 4 3 Dumbo Walt Disney 6 1 3 Dumbo Walt Disney 8 2 3 Dumbo Walt Disney 9 3 3 Dumbo Walt Disney 2 4 4 Thin Red Line Wartimes 9 1 4 Thin … -
Django SerializerMethodField vs Complex SQL
I'm wondering about what people think about the tradeoffs of efficiency and readability between using Django's SerializerMethodField and writing potentially convoluted SQL. I'm think SQL would generally be quicker, but the complexity of code may not be worth it. I lean towards using the SerializerMethodField for better readability/maintainability, but am curious what others think. This isn't a great example and just serves as an introduction to what I am talking about. These SQL queries could get much more convoluted. I know this code probably isn't actually written perfectly. # Comment # is_admin: Boolean # public_email: String # email: Optional String default_email = 'foo@bar.com' queryset = Comment.objects class CommentSerializer(serializers.Serializer): is_admin = serializers.BooleanField() email = serializers.SerializerMethodField() @staticmethod def get_email(comment): if comment.is_admin: return comment.public_email return comment.email or default_email queryset = Comment.objects.annotate( email=Case( When(is_admin=True, then='public_email'), default=Coalesce('email', Value(default_email)), output_field=CharField(), ) ) class CommentSerializer(serializers.Serializer): is_admin = serializers.BooleanField() email = serializers.CharField() -
How to change admin color in Django based on whether person is an Superuser or not?
I would like to implement a function in Django admin, that if a person logged is superuser then the color in admin is different. How can I approach it? I don't want 'normal' users to have access to admin, but I want to have 2 levels of access - superuser that can change everything (and add more personnel etc) and normal staff level, who can't add other employees and is limited in what he can do. How can I approach the issue? Can I simply add flag somewhere which states that if logged user is superuser then use different/additional css or something? -
How can I get reposted post info? Django
I'm making a small social network on Django. I want to make repost feature. I have Post model in models.py: class Post(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) text = models.TextField('Post text') image = models.ImageField('Image', upload_to='post_pics', blank=True) date = models.DateTimeField('Date') liked = models.ManyToManyField(User, default=None, blank=True, related_name='liked_by_user') def __str__(self): return self.text Then I created the Repost model, that takes Post model: class Repost(Post): post = models.ForeignKey(Post, related_name='reposted_post', on_delete=models.CASCADE) Then I tried to create a repost with admin panel. New was post created, but how can I get info (user, text, image, date and likes) of post that I reposted and paste it in my repost? Part of my html: {% for p in post %} <p>{{ p.user.username }}</p> <p>{{ p.text }}</p> <p>{{ p.date }}</p> {% endfor %} -
What are possible security flaws on using user login with email indirectly in Django using default user model?
I wanted to implement login in Django (version 3.1.7) using email instead of username. So I checked for solutions and stumbled upon this question But as a beginner, I don't want play around default user model class by defining custom user model. So a quick fix was to fetch username from user email and then authenticate. My implementation: from django.shortcuts import render,redirect from django.contrib.auth.models import User,auth from django.contrib import messages def login(request): if request.method == 'POST': email=request.POST['email'] userinfo= User.objects.filter(email=email)[:1] if userinfo.exists(): username=userinfo.first() else: messages.info(request,'Email doesn\'t exist..') return redirect('login') password=request.POST['password'] user= auth.authenticate(username=username,password=password) if user is not None: auth.login(request,user) return redirect('/') else: messages.info(request,'Invalid credentials') return redirect('login') else: return render(request,'login.html') I made sure that email is unique while registration: def register(request): if request.method == 'POST': username=request.POST['username'] email=request.POST['email'] password=request.POST['password'] password1=request.POST['password1'] if password1 == password: if User.objects.filter(username=username).exists(): messages.info(request,'Username Taken') return redirect('register') elif User.objects.filter(email=email).exists(): messages.info(request,'Email Taken') return redirect('register') else: user= User.objects.create_user(username=username,password=password,email=email) user.save() return redirect('login') else: messages.info(request,'passwords not matching') return redirect('register') else: return render(request,'register.html') This implementation works correctly. Also, I use csrf_token in both html forms. Now I want to know if there are any security flaws by using these implementation for login. What are the possible ways to make it more stricter. What things will not …