Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can't debug in VS Code for Django?
When I use VS Code IDE to debug, I get an error message: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? Why? How do I fix it? Thanks. -
Openstack Trove - Polling request timed out
We are trying to deploy OpenStack environment for our application and while deploying trove service we are facing the below error: File "/usr/lib/python3/dist-packages/trove/common/utils.py", line 207, in wait_for_task return polling_task.wait() File "/usr/lib/python3/dist-packages/eventlet/event.py", line 125, in wait result = hub.switch() File "/usr/lib/python3/dist-packages/eventlet/hubs/hub.py", line 313, in switch return self.greenlet.switch() File "/usr/lib/python3/dist-packages/oslo_service/loopingcall.py", line 154, in _run_loop idle = idle_for_func(result, self._elapsed(watch)) File "/usr/lib/python3/dist-packages/oslo_service/loopingcall.py", line 349, in _idle_for raise LoopingCallTimeOut( oslo_service.loopingcall.LoopingCallTimeOut: Looping call timed out after 870.99 seconds During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/trove/taskmanager/models.py", line 434, in wait_for_instance utils.poll_until(self._service_is_active, File "/usr/lib/python3/dist-packages/trove/common/utils.py", line 223, in poll_until return wait_for_task(task) File "/usr/lib/python3/dist-packages/trove/common/utils.py", line 209, in wait_for_task raise exception.PollTimeOut trove.common.exception.PollTimeOut: Polling request timed out.``` -
TypeError at /mark_your_attendance Can't parse 'center'. Sequence item with index 0 has a wrong type
Hello guys! i am working on attendance system using Face Recognition, i have trained the captured images once want to mark the attendance it gives me following error, i have used django at backend. TypeError at /mark_your_attendance Can't parse 'center'. Sequence item with index 0 has a wrong type Request Method: GET Request URL: http://127.0.0.1:8000/mark_your_attendance Django Version: 2.2.2 Exception Type: TypeError Exception Value: Can't parse 'center'. Sequence item with index 0 has a wrong type Exception Location: /home/saifullah/Desktop/attendance/attendance-system/env/lib/python3.8/site-packages/imutils/face_utils/facealigner.py in align, line 68 Python Executable: /home/saifullah/Desktop/attendance/attendance-system/env/bin/python3 Python Version: 3.8.10 Python Path: ['/home/saifullah/Desktop/attendance/attendance-system', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/saifullah/Desktop/attendance/attendance-system/env/lib/python3.8/site-packages'] Hereby i am sharing the code can anyone please help how to solve it. Code def mark_your_attendance(request): detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor( 'face_recognition_data/shape_predictor_68_face_landmarks.dat') # Add path to the shape predictor ######CHANGE TO RELATIVE PATH LATER svc_save_path = "face_recognition_data/svc.sav" with open(svc_save_path, 'rb') as f: svc = pickle.load(f) fa = FaceAligner(predictor, desiredFaceWidth=96) encoder = LabelEncoder() encoder.classes_ = np.load('face_recognition_data/classes.npy') faces_encodings = np.zeros((1, 128)) no_of_faces = len(svc.predict_proba(faces_encodings)[0]) count = dict() present = dict() log_time = dict() start = dict() for i in range(no_of_faces): count[encoder.inverse_transform([i])[0]] = 0 present[encoder.inverse_transform([i])[0]] = False vs = VideoStream(src=0).start() sampleNum = 0 while(True): frame = vs.read() frame = imutils.resize(frame, width=800) gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces … -
How to override excel file before saving on disk in django-import-export?
I used django-import-export for exporting excel files. I want to add an extra row including our company name before the actual data. Actual data: id name 1 Jack 2 Sara ... ... My desired output: An extra row before the header including "This excel has been created by Our Brand". How can I modify the generated excel file before saving on disk? -
whilw performing CURD operation i got error. Using the URLconf defined in Student.urls, Django tried these URL patterns, in this order:
Using the URLconf defined in Student.urls, Django tried these URL patterns, in this order: admin/ emp [name='emp'] show [name='show'] edit/int:roll_no [name='edit'] update/int:roll_no [name='update'] delete/int:roll_no [name='delete'] The current path, update/, didn’t match any of these. While Performing django CURD operation I got above error.. my code from main( student urls.py):- from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('stud_details.urls')) from app stud_details(urls.py) from stud_details import views urlpatterns = [ path('',views.index), path("emp",views.emp, name='emp'), path("show",views.show, name='show'), path("edit/<int:roll_no>",views.edit, name='edit'), path("update/<int:roll_no>",views.update, name='update'), path("delete/<int:roll_no>",views.destroy, name='delete') from views.py: from stud_details.forms import Stud_form from stud_details.models import Stud_class def emp(request): if request.method == "POST": form = Stud_form(request.POST) if form.is_valid(): try: form.save() return redirect('/show') except: pass else: form = Stud_class() return render(request,'index.html',{'form':form}) def show(request): students = Stud_class.objects.all() return render(request,"show.html",{'students':students}) def index(request): return render(request,"index.html") def edit(request, roll_no): students = Stud_class.objects.get(roll_no=roll_no) return render(request,'edit.html', {'students':students}) def update(request, roll_no): students = Stud_class.objects.get(roll_no=roll_no) form = Stud_form(request.POST, instance = students) if form.is_valid(): form.save() return redirect("/show") return render(request, 'edit.html', {'Stud_class': employee}) def destroy(request, roll_no): students = Stud_class.objects.get(roll_no=roll_no) students.delete() return redirect("/show") What I'm doing wrong -
My django project keeps blinking and loading
my project was working before but now that cleaned my cache it keeps blinking. It keeps loading with no end in sight. The table in my project appears and disappears again and again blinking. The navbar and thead are fine but my tbody keeps doing it. Does anyone know how to fix this? -
Q : run a python function in Django project but output repeat result
I want to detect the number of files when run a django project.But there are two output results in terminal . def fileChecker(path): print('Child process %s.' % os.getpid()) dirs = os.listdir(path) size = len(dirs) while True : tdirs = os.listdir(path) if len(tdirs) > size : print( 'folder contains %s files '%( len(tdirs) ) ) size = len(tdirs) dirs = tdirs def main(): """Run administrative tasks.""" print('Child process %s.' % os.getpid()) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'parkSystem.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': print('Parent process %s.' % os.getpid()) p1 = Process( target=main ) p2 = Process( target=fileChecker, args=('.\\pictures\\car_img',)) p1.start() p2.start() p1.join() p2.join() the terminal like this : enter image description here -
How to streamline code with a for statement
I am trying to find the number of students enrolled by teacher. The code below produces the result I want. However, the code seems to be inefficiently long. I tried to simplify the code by using a "for" functiib, but couldn't solve it, so I posted a question to the experts for help. The number registered in SPECIAL CLASS must be obtained separately. The register condition is student with 1 entered in the day field. monthly_kwargs = { 'jan': Count('student_id', filter=Q(register_date__gte='2022-01-01', register_date__lte='2022-01-31')), 'feb': Count('student_id', filter=Q(register_date__gte='2022-02-01', register_date__lte='2022-02-28')), 'mar': Count('student_id', filter=Q(register_date__gte='2022-03-01', register_date__lte='2022-03-31')), 'apr': Count('student_id', filter=Q(register_date__gte='2022-04-01', register_date__lte='2022-04-30')), 'may': Count('student_id', filter=Q(register_date__gte='2022-05-01', register_date__lte='2022-05-31')), 'jun': Count('student_id', filter=Q(register_date__gte='2022-06-01', register_date__lte='2022-06-30')), 'jul': Count('student_id', filter=Q(register_date__gte='2022-07-01', register_date__lte='2022-07-31')), 'aug': Count('student_id', filter=Q(register_date__gte='2022-08-01', register_date__lte='2022-08-31')), 'sept': Count('student_id', filter=Q(register_date__gte='2022-09-01', register_date__lte='2022-09-30')), 'oct': Count('student_id', filter=Q(register_date__gte='2022-10-01', register_date__lte='2022-10-31')), 'nov': Count('student_id', filter=Q(register_date__gte='2022-11-01', register_date__lte='2022-11-30')), 'dec': Count('student_id', filter=Q(register_date__gte='2022-12-01', register_date__lte='2022-12-31')), 'total': Count('student_id', filter=Q(register_date__year=today.year)), 'SPECIAL_jan': Count('student_id', filter=Q(register_date__gte='2022-01-01', register_date__lte='2022-01-31', student__class__id__in=SPECIAL)), 'SPECIAL_feb': Count('student_id', filter=Q(register_date__gte='2022-02-01', register_date__lte='2022-02-28', student__class__id__in=SPECIAL)), 'SPECIAL_mar': Count('student_id', filter=Q(register_date__gte='2022-03-01', register_date__lte='2022-03-31', student__class__id__in=SPECIAL)), 'SPECIAL_apr': Count('student_id', filter=Q(register_date__gte='2022-04-01', register_date__lte='2022-04-30', student__class__id__in=SPECIAL)), 'SPECIAL_may': Count('student_id', filter=Q(register_date__gte='2022-05-01', register_date__lte='2022-05-31', student__class__id__in=SPECIAL)), 'SPECIAL_jun': Count('student_id', filter=Q(register_date__gte='2022-06-01', register_date__lte='2022-06-30', student__class__id__in=SPECIAL)), 'SPECIAL_jul': Count('student_id', filter=Q(register_date__gte='2022-07-01', register_date__lte='2022-07-31', student__class__id__in=SPECIAL)), 'SPECIAL_aug': Count('student_id', filter=Q(register_date__gte='2022-08-01', register_date__lte='2022-08-31', student__class__id__in=SPECIAL)), 'SPECIAL_sept': Count('student_id', filter=Q(register_date__gte='2022-09-01', register_date__lte='2022-09-30', student__class__id__in=SPECIAL)), 'SPECIAL_oct': Count('student_id', filter=Q(register_date__gte='2022-10-01', register_date__lte='2022-10-31', student__class__id__in=SPECIAL)), 'SPECIAL_nov': Count('student_id', filter=Q(register_date__gte='2022-11-01', register_date__lte='2022-11-30', student__class__id__in=SPECIAL)), 'SPECIAL_dec': Count('student_id', filter=Q(register_date__gte='2022-12-01', register_date__lte='2022-12-31', student__class__id__in=SPECIAL)), 'SPECIAL_total': Count('student_id', filter=Q(register_date__year=today.year, student__class__id__in=SPECIAL)) } value_list_args = ['teacher__first_name', 'jan', 'feb', 'mar', … -
SocialApp matching query does not exist (Django)
I am trying social logins with Google and I configured localhost:8000/admin/ with the following details: socialapp . provider: Name: Client id: App ID, or consumer key Key: Secret: etc . In settings.py: INSTALLED_APPS = [ 'blog.apps.BlogConfig', 'users.apps.UsersConfig', 'crispy_forms', 'django.contrib.admin', 'django.contrib.sites', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'ckeditor', 'ckeditor_uploader', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google', ] SOCIALACCOUNT_PROVIDERS = { 'google': { 'SCOPE': [ 'profile', 'email', ], 'AUTH_PARAMS': { 'access_type': 'offline', } } } I set SITE_ID = 2 When I go to: http://127.0.0.1:8000/login/google/login/ I get: Error : `SocialApp matching query does not exist. Can anyone help me? -
i want to get all product of specific merchant in html here is my code
i want to get all product of specific merchant in html here is my code so these should i write in html to get the products that merchant uploaded class ProductList(ListView): model=Product template_name="merchant/product_list.html" paginate_by=3 def get_queryset(self): filter_val=self.request.GET.get("filter","") order_by=self.request.GET.get("orderby","id") if filter_val!="": products=Product.objects.filter(Q(added_by_merchant__contains=filter_val) | Q(product_description__contains=filter_val)).order_by(order_by) else: products=Product.objects.all().order_by(order_by) # Product.MerchantUser.objects.all(user=MerchantUser) product_list=[] for product in products: product_media=ProductMedia.objects.filter(product_id=product.id,media_type=1,is_active=1).first() product_list.append({"product":product,"media":product_media}) return product_list def get_context_data(self,**kwargs): context=super(ProductList,self).get_context_data(**kwargs) context["filter"]=self.request.GET.get("filter","") context["orderby"]=self.request.GET.get("orderby","id") context["all_table_fields"]=Product._meta.get_fields() return context -
How to create multiple model instances with Django Rest Framework using generics?
I would like to save and update multiple instances using the Django Rest Framework with one API call, using generics. I have tried the solutions proposed for the following links, but I would very much appreciate some help. Create several objects at once with Django Framework Generic Views How to save multiple objects with Django Rest Framework Django Rest Framework Doc for serializing multiple objects # serializers.py class AssetSerializer(serializers.ModelSerializer): class Meta: model = Asset fields = '__all__' #fields = ('id', 'name', 'amount') # views.py class CreateAssetView(generics.CreateAPIView): serializer_class = AssetSerializer(many=True) def perform_create(self, serializer): serializer.save(user=self.request.user) # urls.py urlpatterns = [ ... path('create_asset', CreateAssetView.as_view()), ] -
Auto-submit django form without causing infinite loop
I have an issue on my app that I can't work out the best way to approach the solution. I'm learning Django and have little to no experience in Javascript so any help will be appreciated. This may be a design flaw, so am open to other ideas. Problem When a user reaches their dashboard page for the first time, they would need to select the currency rate on a form they want to view their data in e.g USD, AUD, GBP etc. Once they submit their currency, their dashboard will become active and viewable. I would like this selection to remain submitted on refresh/load or auto submit on refresh/load. Hence, that currency will remain, unless the user submits another currency. See before/after images for context (ignore values as they are inaccurate): Attempted solution I have tried using Javascript to auto submit on load which causes and infinite loop. I have read to use action to redirect to another page but i need it to stay on the same page. Unless this can be configured to only submit once after refresh/load I don't think this will work <script type="text/javascript"> $(document).ready(function() { window.document.forms['currency_choice'].submit(); }); </script> <div class="container"> <div> <span> <h1>My Dashboard</h1> … -
Django QuerySet exists() returns True for empty set?
Something curious I found recently is that exists() evaluates to True for an empty QuerySet: In [1]: MyModel.objects.all() Out [1]: <QuerySet []> In [2]: MyModel.objects.all().exists() Out [2]: True When used with filter(), I get the expected result: In [3]: MyModel.objects.filter(id=1).exists() Out [3]: False This is behaving contrary to how I would expect as the empty QuerySet returned by the filter() is equivalent to MyModel.objects.all() which is empty. Why does this happen? It seems inconsistent. -
how do I add an item to the cart without the page reloading?
So I wanna add an item to the cart without the page reloading every time, I've used ajax in a previous project and the response time wasn't pretty, so is there a better way to go about this, that won't be slow? if so, how would I fix this? also not the best with javascript so if u can explain stuff a bit, I would really appreciate your help, thx! link to the rest main code: https://gist.github.com/StackingUser/34b682b6da9f918c29b85d6b09216352 template: {% load static %} <link rel="stylesheet" href="{% static 'store/css/shop.css' %}" type="text/css"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript"> var user = '{{request.user}}' function getToken(name) { let cookieValue = null; if (document.cookie && document.cookie !== '') { const cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { const cookie = cookies[i].trim(); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) === (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } const csrftoken = getToken('csrftoken'); function getCookie(name) { // Split cookie string and get all individual name=value pairs in an array var cookieArr = document.cookie.split(";"); // Loop through the array elements for(var i = 0; i < … -
Toggle Switch Button using HTMX
is there any method to use Toggle Switch Button with HTMX? if there, I need to pass a value to another button like my previous question. the Toggle Button is named 'Toggle' and have two (on/off) values and I need to pass them as: <button class="btn btn-primary" hx-get="{% url 'plotlybar' %}" hx-include="[name='fields'],[name='Toggle']" hx-target="#plotlybar"> Plot the bar Well Serv </button> My previous question So how to get this Button with HTMX All my best -
How to add serializer for Django with ManyToManyField with through
models.py looks like this from django.db import models class Sauce(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name class Sandwich(models.Model): name = models.CharField(max_length=100) sauces = models.ManyToManyField(Sauce, through='SauceQuantity') def __str__(self): return self.name class SauceQuantity(models.Model): sauce = models.ForeignKey(Sauce, on_delete=models.CASCADE) sandwich = models.ForeignKey(Sandwich, on_delete=models.CASCADE) extra_sauce = models.BooleanField(default=False) def __str__(self): return "{}_{}".format(self.sandwich.__str__(), self.sauce.__str__()) How would I create a serializer for SauceQuantity so I can add and read SauceQuantity? I looked through the docs but I am still confused. Thanks! -
Django: How to run a celery task only on start up?
I have a django app that uses celery to run tasks. Sometimes, I have a "hard shutdown" and a bunch of models aren't cleaned up. I created a task called clean_up that I want to run on start up. Here is the tasks.py from my_app.core import utils from celery import shared_task @shared_task def clean_up(): f_name = clean_up.__name__ utils.clean_up() Here is what celery.py looks like: import os from celery import Celery from celery.schedules import crontab from datetime import timedelta os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_app.settings") app = Celery("proj") app.config_from_object("django.conf:settings", namespace="CELERY") # Load task modules from all registered Django apps. app.autodiscover_tasks() app.conf.beat_schedule = { "runs-on-startup": { "task": "my_app.core.tasks.clean_up", "schedule": timedelta(days=1000), }, } @app.task(bind=True) def debug_task(self): print(f"Request: {self.request!r}") How can I change celery.py to run clean_up only on start up? Extra info: this is in a docker compose, so by "hard shutdown" I mean docker compose down By "on start up" I mean docker compose up -
I am getting the error NoReverseMatch at /blog/view/None/
I am makeing a blog with Django. When I try to go to a specific blog post I get this error NoReverseMatch at /blog/view/None/ Reverse for 'blog_like' not found. 'blog_like' is not a valid view function or pattern name. I don't know what is causing this issue at all. Any help would be appreciated full error: File "C:\Users\sekoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\template\loader_tags.py", line 62, in render result = block.nodelist.render(context) File "C:\Users\sekoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\template\base.py", line 938, in render bit = node.render_annotated(context) File "C:\Users\sekoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\template\base.py", line 905, in render_annotated return self.render(context) File "C:\Users\sekoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\template\defaulttags.py", line 446, in render url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app) File "C:\Users\sekoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\urls\base.py", line 86, in reverse return resolver._reverse_with_prefix(view, prefix, *args, **kwargs) File "C:\Users\sekoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\urls\resolvers.py", line 694, in _reverse_with_prefix raise NoReverseMatch(msg) django.urls.exceptions.NoReverseMatch: Reverse for 'blog_like' not found. 'blog_like' is not a valid view function or pattern name. [24/Apr/2022 17:30:28] "GET /blog/view/None/ HTTP/1.1" 500 155689 views.py from django.shortcuts import render, reverse from django.http import HttpResponseRedirect from django.views import generic from . import models from django.contrib.auth import get_user_model User = get_user_model() from django.urls import reverse_lazy from django.contrib.auth.mixins import LoginRequiredMixin # Create your views here. class create_blog_post(generic.CreateView, LoginRequiredMixin): model = models.Blog_Post template_name = 'blog_app/creat_post.html' fields = ('post_title', 'blog_content') success_url = reverse_lazy('blog_app:all') class view_blog_post(generic.ListView): model = models.Blog_Post template_name = 'blog_app/view_post.html' class delet_blog_post(generic.DeleteView, … -
DJANGO : TypeError: view must be a callable or a list/tuple in the case of include()
i am getting below error in django: File "C:\Users\USER\Desktop\Python\CarRentalSystem\system\urls.py", line 6, in url(r'^$', 'system.views.home', name = "home"), File "C:\Users\USER\Desktop\Python\lib\site-packages\django\conf\urls_init_.py", line 13, in url return re_path(regex, view, kwargs, name) File "C:\Users\USER\Desktop\Python\lib\site-packages\django\urls\conf.py", line 73, in _path raise TypeError('view must be a callable or a list/tuple in the case of include().') TypeError: view must be a callable or a list/tuple in the case of include(). -
How to disable Preselection from List_display Django Admin
Hi I want to disable the preselection from django admin, here is my code model.py from django.contrib import admin from django.db import models class Person(models.Model): option4 = models.CharField(max_length=50) option5 = models.CharField(max_length=50) option6 = models.CharField(max_length=50) option7 = models.CharField(max_length=50) admin.py class PersonAdmin(admin.ModelAdmin): list_display = ('option4', 'option5','option6','option') In this picture you can see the preselected the options by default , i do not want to that,how to disable preselction. enter image description here -
How to build a docker image (without docker compose) of a django app and use an existing mysql container
I have a "point of sales" application in Django that uses a mysql database. I followed this Docker guide: Python getting started guide In order to setup the mysql container I created a couple of volumes and its network: docker volume create mysql docker volume create mysql_config docker network create mysqlnet My Dockerfile looks like this: (I don't want to use docker-compose yet becouse I want to learn the bases) Dockerfile # syntax=docker/dockerfile:1 FROM python:3.8-slim-buster RUN apt update RUN apt upgrade -y RUN apt dist-upgrade RUN apt-get install procps -y RUN apt install curl -y RUN apt install net-tools -y WORKDIR /home/pos COPY requirements.txt ./. RUN pip3 install -r requirements.txt COPY ./src ./src CMD ["python", "./src/manage.py", "runserver", "0.0.0.0:8000"] And in the Django project my database settings and requirements looks like: settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'point-of-sales', 'USER': 'root', 'PASSWORD': 'r00t', 'HOST': 'localhost', 'PORT': '3307' } } requirements.txt # Django django>=3.1,<3.2 # DRF djangorestframework>=3.12,<3.13 # Databases mysqlclient What I want is to build an image of the Django application that I could run and attach to the mysql network. The problem is that I can't build the image of my django app becouse it throws the following … -
Azure python library return web app configurations
I am trying to deep dive into azure python sdk to retrieve and control all my resources in azure, but I am having hard time to find any valid documentation on the following issue. using this code: resource_client = ResourceManagementClient(credentials, subscription_id) web_client = WebSiteManagementClient(credential=credentials, subscription_id=subscription_id) rg_subscription = resource_client.resource_groups.list() web_apps_test = [] for rg in list(rg_subscription): for site in web_client.web_apps.list_by_resource_group(rg.name): print(site) I am able to return all my azure web app service. Which is great, but what I would like to have more is to be able for each web app, to return its configurations so I can extract specific values from it. I have been looking around since yesterday but I am having some problems to find the right documentation, code or GitHub project to achieve this. Just to give a practical example of what I am looking for, is this: Using azure cli, I can run the command az webapp config show --name <webapp-name> -g <resource-group-name> and I will get all the configurations for the specific web app. I was wondering if there is any python library to achieve this using python. Can anyone help to solve this please?any help would be much appreciated. And please if my question … -
Django Allauth - allow to sign up again if email is unverified
Suppose, user A tries to sign up with an email not of their own (user's B email). He fails to verify it and hence fails to sign in. Some time later user B encounters the site and tries to sign up, but they fail as well with a message "A user is already registered with this e-mail address." From what I see in admin site, it is true, the user instance is actually created, even though the email is unverified. Is there a way to easily allow user B to sign up (i.e. overwrite the unverified user instance)? Or what is the standard way of dealing with this situation? -
change password in django rest framework
I am working on change password function for an API. My code runs fine locally. The problem is that when testing in postman I have to connect it using the login token. But in login, I have two passwords refresh and access. How should I configure Postman to give me access? I was advised to use Bearer and accept allow_classes = [permissions.IsAuthenticated] but when doing so, the login stops working and still cannot give access to password change. -
Retrieve stripe session id at success page
I am using stripe with django and I want to pass some information I received from the checkout session to success page. After reading the documentation https://stripe.com/docs/payments/checkout/custom-success-page#modify-success-url I modified success url to MY_DOMAIN = 'http://127.0.0.1:8000/orders' success_url=MY_DOMAIN + '/success?session_id={CHECKOUT_SESSION_ID}', cancel_url=YOUR_DOMAIN + '/cancel/', metadata={ "price_id": price_id, } ) def Success(request): session = stripe.checkout.Session.retrieve('session_id') return render(request, 'orders/success.html') But this gives me an error: Invalid checkout.session id: session_id If I manually put instead of "session_id" the actual id that is printed in the url everything works fine. So my question is what should I write instead of 'session_id' in order to retrieve the session?