Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django with postgreSQL DB on Docker - django.db.utils.OperationalError: could not connect to server: Connection refused
I am following this tutorial on 'Dockerizing' Django + PgSQL + gunicorn + nginx . Relevant info host machine OS is Ubuntu 20.0.4 LTS Docker-desktop: Docker version 20.10.16, build aa7e414 This is my setup so far: Dockerfile # pull official base image FROM python:3.9.6-alpine # set work directory WORKDIR /usr/src/app ############################# # set environment variables # ############################# # Prevents Python from writing pyc files to disc (equivalent to python -B option) ENV PYTHONDONTWRITEBYTECODE 1 # Prevents Python from buffering stdout and stderr (equivalent to python -u option) ENV PYTHONUNBUFFERED 1 # install psycopg2 dependencies RUN apk update \ && apk add postgresql-dev gcc python3-dev musl-dev # install dependencies RUN pip install --upgrade pip COPY ./my-django-proj/requirements.txt ./my-django-proj/ RUN pip install -r ./my-django-proj/requirements.txt # copy project COPY ./my-django-proj ./my-django-proj compose.yml services: web: build: . command: python my-django-proj/manage.py runserver 0.0.0.0:8000 volumes: - ./my-django-proj/:/usr/src/app/my-django-proj/ ports: - 8000:8000 env_file: - ./my-django-proj/my-django-proj/.env depends_on: - db db: image: postgres:14.3-alpine restart: always container_name: postgres14_3 #user: postgres ports: - 5432:5432 volumes: - postgres_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=myusername - POSTGRES_PASSWORD=thepassword - POSTGRES_DB=thedbname volumes: postgres_data: Output log from sudo docker compose up -d --build postgres14_3 | postgres14_3 | 2022-06-01 12:03:35.017 UTC [1] LOG: starting PostgreSQL 14.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine … -
which of the tools to choose for the backend of a web application? pure java/python django/php laravel [closed]
sup guys, I know some python, and don't know php well and I know java even worse, but I was asked to make a web application with a backend on one of these technologies. But I could not find their comparisons to choose one thing and explain why I chose this one. Anyone who understands the backend can tell me how, what and why would be the best choice? Thank you -
etting ssl_cert_reqs=CERT_OPTIONAL when connecting to redis
I am using redis with Django, and the error message is: Setting ssl_cert_reqs=CERT_OPTIONAL when connecting to redis means that celery might not validate the identity of the redis broker when connecting. This leaves you vulnerable to man in the middle attacks. My settings is as follows, and I am not sure how to make redis use ssl certs to connect to celery: CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": env("REDIS_LOCATION"), "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "PASSWORD": env("REDIS_PASSWORD"), "REDIS_CLIENT_KWARGS": {"ssl_cert_reqs": True}, }, } } -
Django-filter: ModelChoiceFilter with request.user based queryset
I have a Django class based ListView listing objects. These objects can be filtered based on locations. Now I want that the location ModelChoiceFilter only lists locations which are relevant to the current user. Relevant locations are the locations he owns. How can I change the queryset? # models.py from django.db import models from django.conf import settings from rules.contrib.models import RulesModel from django.utils.translation import gettext_lazy as _ class Location(RulesModel): name = models.CharField(_("Name"), max_length=200) owner = models.ForeignKey( settings.AUTH_USER_MODEL, verbose_name=_("Owner"), related_name="location_owner", on_delete=models.CASCADE, help_text=_("Owner can view, change or delete this location."), ) class Object(RulesModel): name = models.CharField(_("Name"), max_length=200) description = models.TextField(_("Description"), blank=True) owner = models.ForeignKey( settings.AUTH_USER_MODEL, verbose_name=_("Owner"), related_name="location_owner", on_delete=models.CASCADE, help_text=_("Owner can view, change or delete this location."), ) location = models.ForeignKey( Location, verbose_name=_("Location"), related_name="object_location", on_delete=models.SET_NULL, null=True, blank=True, ) This is my current filters.py file which shows all the locations to the user. # filters.py from .models import Object import django_filters class ObjectFilter(django_filters.FilterSet): class Meta: model = Object fields = ["location", ] This is the view which by default shows objects the user owns. It's possible to filter further by location. But the location drop-down shows too many entries. # views.py from django.views.generic import ListView from django.contrib.auth.mixins import LoginRequiredMixin from .models import Object from … -
How i can add like on product page
I can like my products from admin panel,and i want to add posibility to like them by url products/item/like,i have view of like but i dont know what i should add to there.This is my views.py class LikeToggleView(AjaxResponseMixin, JSONResponseMixin, FormView): http_method_names = ('post',) form_class = LikeForm product = None @csrf_exempt def dispatch(self, request, *args, **kwargs): product_id = kwargs['product_pk'] try: self.product = Product.objects.get(id=product_id) except Product.DoesNotExist: raise Http404() return super().dispatch(request, *args, **kwargs) def post(self, request, *args, **kwargs): pass this is forms.py class LikeForm(forms.ModelForm): user = forms.ModelChoiceField(User.objects.all(), required=False) product = forms.ModelChoiceField(Product.objects.all()) ip = forms.GenericIPAddressField(required=True) this is models.py class Like(TimeStampedModel): product = models.ForeignKey(Product, related_name='likes') user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='likes') ip = models.GenericIPAddressField(blank=True, null=True) class Meta: unique_together = (('product', 'user'), ('product', 'ip')) def __str__(self): return '{} from {}'.format(self.product, self.user or self.ip) -
How to implement password reset with help of django_rest_passwordreset?
I am trying to implement password reset in my Django (DRF) app. I am using django_rest_passwordreset lib I want this User sends api/password_reset/ -- OK User receives email with password reset link /api/password_reset/? token=23d9633863ede8c491a9b2f1 -- OK (can see this email) User clicks to the password reset link and changing password -- DON'T UNDERSTAND HOW TO IMPLEMENT How can I add the third step? My code urls.py urlpatterns = [ ... path('api/password_reset/', include('django_rest_passwordreset.urls', namespace='password_reset')), ] view.py @receiver(reset_password_token_created) def password_reset_token_created(sender, instance, reset_password_token, *args, **kwargs): email_plaintext_message = "{}?token={}".format(reverse('password_reset:reset-password-request'), reset_password_token.key) send_mail( # title: "Password Reset for {title}".format(title="EDO website"), # message: email_plaintext_message, # from: EMAIL_HOST_USER, # to: [reset_password_token.user.email] ) settings.py EMAIL_HOST = 'smtp.yandex.ru' EMAIL_PORT = 587 EMAIL_HOST_USER = '****@yandex.ru' EMAIL_HOST_PASSWORD = '*************' DEFAULT_FROM_EMAIL = EMAIL_HOST_USER EMAIL_USE_TLS = True -
How to Handel Update , Create , Delete Image Field with Signals?
what I want to do is when I create new Image , the server will rename the photo using the image_name function , on update delete the old and create the new , on delete Only delete the file , deleting is work but others not I want to do it with good way , because I tried to use upload_to with osand pathlib libs to Do it But I think I can create it better with Storages , SO I don't hardcode anything Models : class Product(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=50, null=False, blank=False) describtion = models.TextField() price = models.FloatField() inventory = models.PositiveIntegerField() created_time = models.DateTimeField(auto_now_add=True) last_updated_time = models.DateTimeField(auto_now=True) labels = models.ManyToManyField( Label, through="ProductLabels", through_fields=( "product","label") ) categories = models.ManyToManyField( Category, through="ProductCategories", through_fields=( "product","category") ) objects = ProductManager() def __str__(self) -> str: return self.name def get_absolute_url(self) -> str: return reverse("products:product", kwargs={"pk": self.pk}) @property def photos(self): return ProductImage.objects.filter(product=self) @property def base_photo(self): photos = self.photos if photos: return photos.first().image class ProductImage(models.Model): id = models.AutoField(primary_key=True) image = models.ImageField(storage=select_storage) product = models.ForeignKey(Product, on_delete=models.CASCADE) # base = models.BooleanField(default=True) def __str__(self) -> str: return self.product.name Storages: from django.core.files.storage import FileSystemStorage , Storage from django.conf import settings product_photos_storage = FileSystemStorage(location=f"{settings.MEDIA_ROOT}/products/photos") # TODO add the Remote … -
Get js plugin data into django model
I am trying to use this js plugin https://www.jqueryscript.net/time-clock/appointment-week-view-scheduler.html#google_vignette I added into my project and im able to see it and play with it, but im not able to get the data. How could i retrieve the data from the js and save it into a django model? I am trying but im not able to use get function: $('#example').scheduler('val'); -
Django Problem with a form and making queries
I'm making an lms website. It has classes. Teachers can create new classes and students can add those classes with entering their id and password (if the class has any password). Classes have custom ids and password made by their teachers. The teacher side of the code works fine so I omitted it. But there's a problem in the student part. I have already made a class which requires a password. I enter its id and password in the form and when I submit, it renders the form with the 'message' which has the value: "Invalid id and/or password.". while the password and id match. What is the problem here? <p style="color: red;">{{message}}</p> {% if user.is_teacher %} <form action="{% url 'new_class' %}" method="post"> {% csrf_token %} <div class="form-group"> <input class="form-control" type="text" name="class-name" placeholder="Class Name" maxlength="64" required> </div> <div class="form-check"> <input class="form-check-input" type="checkbox" name="class-type" id="class-type"> <label class="form-check-label" for="class-type"> Private </label> </div> <div class="form-group"> <input class="form-control" type="password" name="class-password" id="class-password" placeholder="Password" style="display: none;" maxlength="16"> </div> <input class="btn btn-primary" type="submit" value="Create"> </form> {% else %} <form action="{% url 'new_class' %}" method="post"> {% csrf_token %} <div class="form-group"> <input class="form-control" type="text" name="class-id" placeholder="Class ID" maxlength="4" required> </div> <div class="form-group"> <p><sub>Leave the password field empty if the … -
Django won't connect to Docker PostgreSQL
Created Dockerized PostgreSQL with the following settings: version: "3.8" services: db: image: postgres restart: always ports: - 5432:5432 environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres This is my settings.py file: DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": "postgres", "USER": "postgres", "PASSWORD": "postgres", "HOST": "db", "PORT": "5432", } } Initialized the container with docker-compose up, image is created and following logs are printed out: db_1 | 2022-06-01 11:45:10.788 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 db_1 | 2022-06-01 11:45:10.788 UTC [1] LOG: listening on IPv6 address "::", port 5432 db_1 | 2022-06-01 11:45:10.791 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" db_1 | 2022-06-01 11:45:10.795 UTC [60] LOG: database system was shut down at 2022-06-01 11:45:10 UTC db_1 | 2022-06-01 11:45:10.799 UTC [1] LOG: database system is ready to accept connections However, when I try to load my data fixtures to Docker Postre image with migrate & loaddata commands, the following error occurs: psycopg2.OperationalError: could not translate host name "db" to address: Unknown host I am able to connect my local PostgreSQL where I previously hosted the app, but Django won't see Docker container for some reason. My system: Python 3.9.0, Django 3.2.8, psycopg2-binary 2.9.2 Any help?? -
Paginate detailview django
i need to paginate my category_detail page,but this view doesnt have list_objects.I have class for DetailView,where i need to add Paginator.Or maybe i can do it only in html template,and thats all? class Category(models.Model): name = models.CharField(_('Name'), max_length=200) slug = models.SlugField(_('Slug'), unique=True) PARAMS = Choices( ('following', 'following'), ('price_to', 'price_to'), ('price_from', 'price_from'), ) def count_of_products(self): return self.pk.count() def __str__(self): return self.slug def get_absolute_url(self, **kwargs): return reverse('products:category_detail', kwargs={'category_slug': self.slug}) this is my views.py class CategoryListView(ActiveTabMixin, ListView): model = Category active_tab = 'category_list' template_name = 'products/category_list.html' def get_ordered_grade_info(self): return [] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['grade_info'] = self.get_ordered_grade_info() return context class CategoryDetailView(DetailView): model = Category slug_url_kwarg = 'category_slug' PARAM_FOLLOWING = 'following' PARAM_PRICE_FROM = 'price_from' PARAM_PRICE_TO = 'price_to' slug_field = 'slug' In my opinion,i need to do paginate def in CategoryDetailView, isnt it? template {% extends "base.html" %} {% block content %} <h2>{{ category.name }}</h2> <div class="list-group"> {% for product in category.products.all %} <a href="{{ product.get_absolute_url }}" class="list-group-item"> <h4 class="list-group-item-heading">{{ product.name }}</h4> <p class="list-group-item-text">{{ product.price }}$</p> <p class="list-group-item-text">Likes {{ product.likes.count }}</p> <p> <img class='img-article' src="{{product.image.url}}"> </p> </a> {% endfor %} </div> {% endblock content %} -
Returning the table using django
I wrote a function that generates an array of strings and an array of integers in views.py. List=["car", "dog", "cat"] Array = [1,4,7] How can I return these values in a form of table on web page using Django? Is it possible to iterate these arrays in template? -
AWS The Cross-Origin-Opener-Policy header has been ignored, because the URL's origin was untrustworthy
I have started a django app on an EC2 instance and I have added my static files(css, js, etc) onto a S3 bucket. After many hours last night I managed to get the static inages to load onto the pages when i viewed the EC2 public address Happy days. But now i keep getting this error: I keep getting this error when i view inspect a web page "The Cross-Origin-Opener-Policy header has been ignored, because the URL's origin was untrustworthy. It was defined either in the final response or a redirect. Please deliver the response using the HTTPS protocol. You can also use the 'localhost' origin instead" And none of my static images are loading. I can't find anything online related to this exact error message, there are some variants which lead to dead ends. does anyone know what is going on? Whats weird is if i run my django app on my personal pc, then the error does not show when i inspect BUT the static images also do not load. When i run the django app on the ec2 instance, then I get the error message with the static images still not loading. So i dont think the … -
hi, which one is better and why, multiple imports from the same model or declare variables in Django?
I was reading Django documentation and what's new in django v4.* and this made me think what way in more code optimised 1 or 2? thanks ------1------ from django.db import models from django.db.models import UniqueConstraint from django.db.models.functions import Lower ------2------ from django.db import models unique_constraint = models.UniqueConstraint lower = models.functions.Lower -
DRF + Djongo: How to access and work with ID from legacy database?
I set up a Django REST Framework (DRF) in combination with djongo, since I'm having a legacy database in MongoDB/Mongo express. Everything runs through a docker container, but I don't think that this is the issue. My model looks like this: from django.db import models ## Event class Event(models.Model): ID = models.AutoField(primary_key=True) date = models.DateField(default=None) name = models.CharField(default=None, max_length=500) locality = models.CharField(default=None, max_length=500) class Meta: ordering = ['ID'] db_table = 'event' Next, my serializer is as follows: from rest_framework import serializers from .models import Event class EventSerializer(serializers.ModelSerializer): class Meta: model = Event fields= "__all__" And the view looks like this: from rest_framework import generics, status from rest_framework.response import Response from rest_framework.decorators import api_view from .serializers import * from .models import * ## Events @api_view(['GET', 'POST']) def event_list(request): if request.method == 'GET': events = Event.objects.all().order_by('ID') event_serializer = EventSerializer(events, many=True) return Response(event_serializer.data) elif request.method == 'POST': event_serializer = EventSerializer(data=request.data) if event_serializer.is_valid(): event_serializer.save() return Response(event_serializer.data, status=status.HTTP_201_CREATED) return Response(event_serializer.errors, status=status.HTTP_400_BAD_REQUEST) As soon as I'm trying to post with import requests endpoint = "http://localhost:8080/event/" get_response = requests.post(endpoint, {"date":"2022-06-01", "name":"Max Musterfrau", "locality":"North America"} ) I'm getting back the error message TypeError: int() argument must be a string, a bytes-like object or a real number, not 'ObjectId' … -
IndexError at /detectWithWebcam list index out of range
Environment: Request Method: GET Request URL: http://127.0.0.1:8000/detectWithWebcam Django Version: 2.2 Python Version: 3.9.7 Installed Applications: ['main', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_filters'] Installed Middleware: ['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'] Traceback: File "C:\Users\INTROVERTED\Downloads\Compressed\FacialRecognitionForPolice-master\venv1\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\INTROVERTED\Downloads\Compressed\FacialRecognitionForPolice-master\venv1\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\Users\INTROVERTED\Downloads\Compressed\FacialRecognitionForPolice-master\venv1\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\INTROVERTED\Downloads\Compressed\FacialRecognitionForPolice-master\FacialRecognitionForPolice-master\main\views.py" in detectWithWebcam 303.encodings[i]=face_recognition.face_encodings(images[i])[0] Exception Type: IndexError at /detectWithWebcam Exception Value: list index out of range -
How to use JWT token in the case of Social authentication. (Django)
Normally JWT flow is when enter Username and password it return a JWT token. using the token we can authenticate APIs. But when we use social authentication how it will happen..? When we use social authentication, for example google, we clicks on login with google >> it give access >> redirect with authorisation code >> it gives open id details like email, first name, last name. If any one have any idea please share. Im using python django. -
duplicate entries is too slow
We have a database with 100.000 artists. But some artists are duplicates. We wan't to run the script below to compare every artist with every artists and make a list with possible duplicates. But this leads to 10 billion comparisons. Any ideas how to make this smarter / faster. artistquery = Artist.objects.filter(mainartist__rank__pos__lt=999, created_at__gt=latestcheckdate).order_by('name').distinct() from difflib import SequenceMatcher for artist in artistquery: checkedartistlist.append(artist.id) ref_artistquery = Artist.objects.all().exclude(id__in=checkedartistlist) for ref_artist in ref_artistquery: similarity = SequenceMatcher(None, artist.name, ref_artist.name).ratio() if similarity > 0.90: SimilarArtist.objects.get_or_create(artist1=artist, artist2=ref_artist) -
django.db.utils.ProgrammingError: cannot cast type integer to date
Hello guys i have some problem with PostgreSQL when i deploy from docker. Error: django.db.utils.ProgrammingError: cannot cast type integer to date [2022-06-01 09:06:04] LINE 1: ...a_playlist" ALTER COLUMN "year" TYPE date USING "year"::date It's my migration file : class Migration(migrations.Migration): dependencies = [ ('multimedia', '0004_track_track'), ] operations = [ migrations.AlterField( model_name='playlist', name='year', field=models.DateField(blank=True, null=True), ), migrations.AlterField( model_name='track', name='year', field=models.DateField(blank=True, null=True), ), ] How can i fix that problem ? Thank you! -
How can i get submit data to my django views from my html and javascript
I recently added a tag-input feature to my form using Javascript but I am unable to get the data from the tag-input I get an integrityError when I submit the form because I can't seem to get the tag-input data. I have also tried an ajax submit function but it also wasn't working I am trying to get the values as JSON so that I can print a list of features later on. views.py garage = request.POST['garage'] telephone = request.POST.get('telephone', False) features = request.GET.get('features') html <label>Property Features: </label> <div class="tag-wrapper"> <div class="tag-content"> <p>Press enter or add a comma after each tag</p> <ul name="features-ul"><input type="text" spellcheck="false" name="features"> </ul> </div> <div class="tag-details"> <p><span>16</span> tags are remaining</p> <button>Clear All Tags</button> </div> </div> </div> javascript const ul = document.querySelector("ul[name=features-ul]"), input = document.querySelector("input[name=features]"), tagNumb = document.querySelector(".tag-details span"); let maxTags = 16, tags = ["coding"]; var features = {"input[name=features]" : tags} countTags(); createTag(); function countTags(){ input.focus(); tagNumb.innerText = maxTags - tags.length; } function createTag(){ ul.querySelectorAll("li").forEach(li => li.remove()); tags.slice().reverse().forEach(tag =>{ let liTag = `<li>${tag} <i class="uit uit-multiply" onclick="remove(this, '${tag}')"></i></li>`; ul.insertAdjacentHTML("afterbegin", liTag); }); countTags(); } function remove(element, tag){ let index = tags.indexOf(tag); tags = [...tags.slice(0, index), ...tags.slice(index + 1)]; element.parentElement.remove(); countTags(); } function addTag(e){ if(e.key == "Enter"){ let … -
Django filter case insensitive
I wrote this Django viewset that allows users to filter and query data from django_filters import rest_framework as filters from rest_framework import viewsets from API.models import Record from API.serializers import RecordSerializer class CountViewSet(viewsets.ReadOnlyModelViewSet): """List of all traffic count Counts""" queryset = Record.objects.all().select_related("count") serializer_class = RecordSerializer filter_backends = (filters.DjangoFilterBackend,) filterset_fields = ( "road", "date", "count_method", "count_method__basic_count_method", "count_method__detailed_count_method", "location", "road__direction", "road__category", "road__junc_start", "road__junc_end", "road__road__name", "date__year", "location__count_point_ref", "road__category__name", "road__junc_start__name", "road__junc_end__name", "road__direction__name", ) And I would like to make it case insensitive and allow searches that contain partially a string so that user can query without knowing the correct “road name” for example: curl -X GET /count/?road__category__name=TA" -H "accept: application/json -
Can't pass parameters in Django, giving MultiValueDictKeyError
I have gone through answers of this type of question but they don't seem relevant for my problem. I have a class defined as follows: class TrainModel(APIView): permission_classes = (IsAuthenticated,) def post(self, request, *args): print("I am here") params = json.loads(request.POST["params"]) print(params) #setup_instance.apply_async((params,), queue="local") fit_model(params, "") model_name = "{}-{}-{}-{}".format( params["match_slug"], params["match_id"], params["model_type"], params["version"]) response = { "success": True, "message": "Model is being trained please wait", "data": {"model_name": model_name} } return JsonResponse(response) It also requires other inputs: params["meta"]["xgb"] params["combined"] And I pass them as follows: import requests import json headers = {'Authorization': 'Token $TOKEN', 'content-type': 'application/json'} url = 'http://somesite.com/train/' params = { "match_id": 14142, "model_type": "xgb", "version": "v2", "match_slug": "csk-vs-kkr-26-mar-2022", "meta": { "xgb": { "alpha": 15, "max_depth": 4, "objective": "reg:linear", "n_estimators": 53, "random_state": 0, "learning_rate": 0.1, "colsample_bytree": 0.4 }, "catboost": { "cat_cols": [ "batting order_lag_1", "venue", "against", "role", "bowlType" ], "eval_metric": "RMSE", "random_seed": 42, "logging_level": "Silent", "loss_function": "RMSE" } }, "image_id": "SOME_ID", "combined": 0 } resp = requests.post(url, params=params, headers=headers) print(resp) I try the same in Postman by putting all these parameters in "Body" (using "raw") but get: Exception Type: MultiValueDictKeyError Exception Value: 'params' Need help. Thanks. -
Django: Sending passwordreset mail using Django-mailjet Package
Please Someone should kindly provide a link to a github repo which has the implementation of Django-Mailjet for sending mails from the app such as passwordreset, mails for new users etc I have gone through the documentation of the django-mailjet package but it's not sufficient for me. Thank you -
Signin with google using django-allauth without using django-admin pannel
here i am using python 3.7 and Django 3.0 where i want to sign in with google to my website and don't want to use the default django admin app. I've acquired the required Google client id and secret, now I'm not able to understand how to configure the django-allauth here is my settings.py file SITE_ID = 1 INSTALLED_APPS = [ ... ... 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google', ] LOGIN_URL = reverse_lazy('core_login') LOGOUT_URL = reverse_lazy('core_logout') LOGIN_REDIRECT_URL = reverse_lazy('login_success') LOGIN_ERROR_URL = reverse_lazy('core_login_error') SOCIALACCOUNT_PROVIDERS = { 'google': { 'SCOPE': [ 'profile', 'email', ], 'AUTH_PARAMS': { 'access_type': 'online', }, "APP": { 'client_id': 'xxxxx', 'secret_key': '*****', } } } AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', 'subscription.authentication.SubscriptionBackend', ) Here i am able to select my email later i am getting this issue Here is the reference image what i am getting error image Please help me so that how can login into my website without using admin panel -
What should i do to stick the footer to be always at the bottom of the page?
I followed this tutorial to create a footer. And i created a footer like this(without any content in body): body{ min-height: 100vh; display: flex; flex-direction: column; } footer{ margin-top: auto; background-color: greenyellow; } .card { max-width: 400px; margin: 0auto; text-align: center; font-family: arial; border-style: solid; border-width: 6px; position: relative; top: 611px; margin-bottom: 33px; margin-right: 33px; float: left; } .card img{ height: 400px; width: 400px; vertical-align: middle; } .price {background-color: #f44336; font-size:22px; border-radius: 3px; position: absolute; bottom: 0px; right: 0px; padding: 3px; } .card button { border: none; color: white; background-color: #000; position: relative ; cursor: pointer; width: 100%; height: 100px; font-size: 44px; align-items: center; } .card button:hover { opacity: .5; background-color: #330; } #id{ background-color: palevioletred; color: white; margin: 0; font-size: 17px; } .number{ width: 50px; height: 50px; background-color: #330; color: yellow; border-radius: 50%; position: absolute; top: -22px; right: -22px; justify-content: center; align-items: center; display: flex; font-size: 22px; } @media (max-width: 1864px){ .card{ max-width: 300px; } .price{ font-size:20px; } .card img{ height: 300px; width: 300px; } {% load static %} <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="{% static 'main.css' %}"> <h1>header</h1> </head> <body style="background-color: #36454F;"> <footer class="footer"> <h3 >hello</h3> </foote> </body> </html> i added some contents to the body of …