Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
DRF- how to return field which is not included in model in response
I have view: class SomeView(APIView): def get(self,request): serializer = serializers.SomeViewSerializer return Response({'result_url': ???}) and serializer: class SomeViewSerializer(serializers.Serializer): url = serializers.SerializerMethodField() def get_url(self): res_id = genetare_url(self.id) return res_id in this case url is not part of any model, but I want to return only this (result of get_url) in response, but I couldn't figure out how to write it in view above. any help will be appriciated, thank you -
How to validate the fields by combining lambda and regx?
I want to get a username and password from the user, which should be validated as a function as follows Terms and conditions for input: Password length greater than or equal to 6. Username length greater than or equal to 4. No one is allowed to join with 'test' and 'codecup' usernames. A user whose password consists only of numbers is not allowed to join. def check_registration_rules(**kwargs): li = list() for user,passwd in kwargs.items(): # print(passwd) # print(user) if user == 'test' or user == 'codecup': continue elif len(user) < 4: continue elif str(passwd).isdigit(): continue elif len(passwd) < 6: continue else: li.append(user) return li print(check_registration_rules(username='p', sadegh='He3@lsa')) Now, instead of these nested conditions, I want to use a combination of lambda and regex library -
AttributeError: 'function' object has no attribute 'as_view'
when i am trying to implement class view it showing the below error Thanks in Advance views.py---- - from re import template import django from django.shortcuts import render from django.views.generic import ListView from .models import Post def PostListView(ListView): model = Post template_name = 'blog/home.html' context_object_name = 'posts' ordering = ['-date_posted'] urls.py----- - from django.urls import path from .views import PostListView from . import views urlpatterns = [ path('', PostListView.as_view(),name="blog-home"), path('about/', views.about,name="blog-about"), ] error------ - return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/Users/kundan/Documents/CodeHub/Python Framework/DjangoWeb/blogspot/blog/urls.py", line 7, in <module> path('', PostListView.as_view(),name="blog-home"), AttributeError: 'function' object has no attribute 'as_view' -
Is it possible to manually change ID value of primary key in Django Model through serializers?
Is it somehow possible to manually change ID value in AutoField (primary key) through serializer? I found this in documentation of Django: https://docs.djangoproject.com/en/4.0/ref/models/instances/#auto-incrementing-primary-keys, but I have no idea how to do this including serializers. My task is: If post with given ID does not exists, fetch post from external API and save it. Model: from django.db import models class Post(models.Model): id = models.AutoField(primary_key=True) user_id = models.IntegerField(default=1) title = models.CharField(max_length=200) body = models.CharField(max_length=500) My serializer: from rest_framework import serializers from .models import Post class PostSerializer(serializers.ModelSerializer): class Meta: model = Post fields = ['id', 'user_id', 'title', 'body'] My view: @api_view(['GET', 'PUT', 'DELETE']) def post_detail_id(request, id): try: post = Post.objects.get(pk=id) except Post.DoesNotExist: #-----------------------------------------------------------# found_post = search_post(id) #fetch post from external API if request.method == "GET" and found_post is not None: serializer = PostSerializer(data=found_post) if serializer.is_valid(): serializer.save() return Response(status=status.HTTP_201_CREATED) #-----------------------------------------------------------# return Response(status=status.HTTP_404_NOT_FOUND) return post_detail(request, "id", post) #method to handle CRUD Post structure: { "user_id": 1, "id": 1, "title": "Blabla", "body": "Lorem Ipsum" }, This implementation fetch post with given ID from API, then saves it, but with different ID. Are there any better ways to do this? Let me know below! -
Can't figure out problem with Django forms
I want to create a custom form in Django, but I keep getting an error with error_messages option. I'm not sure what is wrong. from django import forms class ReviewForm(forms.Form): user_name = forms.CharField(label="Your Name", max_length=100, error_messages={ "required": "Your name must not be empty!", "max_length": "Please, enter a shorter name!" }) The error message messages.update(error_messages or {}) ValueError: dictionary update sequence element #0 has length 0; 2 is required -
How can I add two complex statements in a correct way for queryset.filter in Django?
I am filtering my Article viewset on Django. The code below works fine, from django.contrib.auth.models import User from rest_framework.authtoken.models import Token from rest_framework import serializers, viewsets,filters from rest_framework.permissions import IsAuthenticated from rest_framework import generics from url_filter.integrations.drf import DjangoFilterBackend class ArticleFilterBackEnd(filters.BaseFilterBackend): def filter_queryset(self, request, queryset, view): return queryset.filter( article__author__followers__author=request.user ) But I also want to use queryset.exclude() inside the same loop and filter where article__author__followers__issilent= True when statement is in same loop with request.user so it does not point out to any other followers loop. How can I do it? -
get true file url after user uploads in django
here is the problem. in my project user is going to upload an excel file and right after that the app must take it and read it using pandas. file is uploaded in media/projects/%Y/%m/%d/: views.py: if request.method == 'POST' and request.FILES['createdatabase']: user = request.user data = request.FILES['createdatabase'] new = NewProject( user=user, data=data, ) new.save() models.py: from django.db import models from django.contrib.auth.models import User class NewProject(models.Model): user = models.ForeignKey(User, on_delete=models.DO_NOTHING) data = models.FileField(blank=True, upload_to='projects/%Y/%m/%d/') u = models.TextField(blank=True) v = models.TextField(blank=True) w = models.TextField(blank=True) u, v, and w are in the data file that the user uploads and the app must read it. when I want to read the file in pandas using the read_excel() method, it needs the file URL. using data.url or data.path does not work seems it just says the file name or the wrong path media/datafilename.xlsx. the true file URL must be something like media/2022/07/01/datafilename.xlsx. also, some files might have the same names that are uploaded by the users. so the Django just adds a random string to it. but data.url and data.path print the main name of the file. not the changed one. any help will be appreciated. -
Django channels websocket ValueError: No route found for path 'ws//'
I am currently trying to make a chat application using the Django channel tutorial as a base for the project. I am currently having a problem in which the WebSocket is disconnecting and Handshaking. I am new to Django and WebSocket. chat/routing.py from django.urls import re_path from . import consumers websocket_urlpatterns = [ re_path(r'ws/(?P<room_name>\w+)/$', consumers.ChatConsumer.as_asgi()), ] chat/urls.py from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), path('<str:room_name>/', views.room, name='room'), ] mysite/urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('', include('chat.urls')), path('admin/', admin.site.urls), path("auth/", include("django.contrib.auth.urls")), ] chat/consumers.py import json from asgiref.sync import async_to_sync from channels.generic.websocket import WebsocketConsumer from .models import Room, Message class ChatConsumer(WebsocketConsumer): def __init__(self, *args, **kwargs): super().__init__(args, kwargs) self.room_name = None self.room_group_name = None self.room = None self.user = None def connect(self): self.room_name = self.scope['url_route']['kwargs']['room_name'] self.room_group_name = self.room_name self.room = Room.objects.get(name=self.room_name) self.user = self.scope['user'] # connection has to be accepted self.accept() # join the room group async_to_sync(self.channel_layer.group_add)( self.room_group_name, self.channel_name, ) if self.user.is_authenticated: # send the join event to the room async_to_sync(self.channel_layer.group_send)( self.room_group_name, { 'type': 'user_join', 'user': self.user.username, } ) self.room.online.add(self.user) def disconnect(self, close_code): async_to_sync(self.channel_layer.group_discard)( self.room_group_name, self.channel_name, ) if self.user.is_authenticated: # send the leave event to the room async_to_sync(self.channel_layer.group_send)( self.room_group_name, … -
How to make docker-compoe ".env" file take precedence over shell env vars?
I would like my docker-compose.yml file to use the ".env" file in the same directory as the "docker-compose.yml" file to set some envrionment variables and for those to take precedence for any other env vars set in the shell. Right now I have $ echo $DB_USER tommyboy and in my .env file I have $ cat .env DB_NAME=directory_data DB_USER=myuser DB_PASS=mypass DB_SERVICE=postgres DB_PORT=5432 I have this in my docker-compose.yml file ... version: '3' services: postgres: image: postgres:10.5 ports: - 5105:5432 environment: POSTGRES_DB: directory_data POSTGRES_USER: ${DB_USER} POSTGRES_PASSWORD: password web: restart: always build: ./web ports: # to access the container from outside - "8000:8000" environment: DEBUG: 'true' SERVICE_CREDS_JSON_FILE: '/my-app/credentials.json' DB_SERVICE: host.docker.internal DB_NAME: directory_data DB_USER: ${DB_USER} DB_PASS: password DB_PORT: 5432 command: /usr/local/bin/gunicorn directory.wsgi:application --reload -w 2 -b :8000 volumes: - ./web/:/app depends_on: - postgres In my Python 3/Django 3 project, I have this in my application's settings.py file DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': os.environ['DB_NAME'], 'USER': os.environ['DB_USER'], 'PASSWORD': os.environ['DB_PASS'], 'HOST': os.environ['DB_SERVICE'], 'PORT': os.environ['DB_PORT'] } } However when I run my project, using "docker-compose up", I see maps-web-1 | File "/usr/local/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection maps-web-1 | connection = Database.connect(**conn_params) maps-web-1 | File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect maps-web-1 | conn = _connect(dsn, … -
How do I run an existing Django file?
I downloaded a folder with multiple python files in the form of a Django project for a course and I am unable to run it. Usually, when you create a Django project it is created within the terminal with the line django-admin startproject web_project . and then python manage.py migrate is used and then the line python manage.py runserver to start a server. How do I start a server to run my project? When I use django-admin startproject web_project ., it creates a new project which I don't want. When I use python manage.py migrate or python manage.py runserver it says: Command 'python' not found, did you mean: command 'python3' from deb python3 command 'python' from deb python-is-python3 But even when I used python3 manage.py migrate or python3 manage.py runserver instead and it returned: python3: can't open file 'manage.py': [Errno 2] No such file or directory -
twilio call back status
hello I am doing an app which users can call some numbers anyway this is the idea, I want to know how can I take the status of this calls to make changes in my template such as 'complated or not completed' I am using django 'python' this is my views def callsender(request): phoneNumber = request.GET['phone'] if not phoneNumber: msg = 'Missing phone number value' return JsonResponse({'error': msg}) try: account_sid = settings.TWILIO_ACCOUNT_SID auth_token = settings.TWILIO_AUTH_TOKEN client = Client(account_sid, auth_token) except Exception as e: msg = 'Missing configuration variable: {0}'.format(e) return JsonResponse({'error': msg}) try: call = client.calls.create( # twiml='<Response><Say>Ahoy, Wake up!</Say><Play>https://demo.twilio.com/docs/classic.mp3</Play></Response>', # url='http://demo.twilio.com/docs/classic.mp3', to=phoneNumber, from_=settings.TWILIO_NUMBER, url='http://127.0.0.1/voice', status_callback = 'https://crimson-cod-9776.twil.io/status_callback', status_callback_method='POST', status_callback_event=['initiated','ringing','answered','completed'], ) except Exception as e: message = e.msg if hasattr(e, 'msg') else str(e) return JsonResponse({'error': message}) print(call.sid) return JsonResponse({'message': 'Call incoming!'}) the function I have created wouldn't help on anything, the idea is like this after the people answered my app users I want to write completed instead of the button 'call constumer' -
No Django POST data when sent over a form?
I am on a development server (no CSRF protection), sending over login data to Django via a web form (Django: 127.0.0.1:8000). HTML: <!DOCTYPE html> <html> <head> <title>Log In</title> <meta charset="utf-8"> </head> <body> <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script> <header> </header> <script> $("document").ready(function () { $("header").load("static/header.html"); }) </script> <div id="loginbox"> <h3>Log In</h3> <form action="http://127.0.0.1:8000" method="post"> <input type="text" id="uname"><br> <input type="password" id="pass"><br> <button id="login" type="submit">Log In</button></br> </form> <a href="signup.html">Sign Up</a><br> <a href="forgotCredentials.html">Forgot Username/Password?</a> </div> </body> </html> Django: from django.shortcuts import render # Create your views here. from django.contrib.auth import authenticate, login from django.views.decorators.csrf import csrf_exempt from django.http import HttpResponse @csrf_exempt def index(request): uname = request.POST.get("uname") passwd = request.POST.get("pass") print(uname + " pass " + passwd) user = authenticate(username=uname, password=passwd) if user is not None: login(request, user) return render(request, "taxnow/index.html") return render(request, "taxnow/Login.html") I'm pretty sure that the POST data is not being transmitted (TypeError: unsupported operand type(s) for +: 'NoneType' and 'str') in the print statement, but I can't figure out why. (The HTML is on localhost and the django is on 127.0.0.1:8000 as mentioned previously.) Is there any reason for this? -
how can integrate voice calls in django rest framework
I know about Twillio, but it is not free There is some open source SI servers like FreeSWITCH, Kamailio, OpenSIPS but I'm quite confused how integrate it in django (there is a android app with backend on drf with possibility of voice calls in it) -
Django navlink URL are not working and receiving no error
enter image description here I have used django URL on navlink for some reasons unable to click on them and there is no error returning just nothing is happening. <nav class="main-nav"> <!-- ***** Logo Start ***** --> <a href={% url 'home_page' %} class="logo"> <img src={% static "assets/images/templatemo-eduwell.png" %} alt="EduWellTemplate"> </a> <!-- ***** Logo End ***** --> <!-- ***** Menu Start ***** --> <ul class="nav"> <li class="scroll-to-section"><a href={% url 'home_page' %} class="active">Home</a></li> <li class="scroll-to-section"><a href={% url 'services' %}>Services</a></li> <li class="scroll-to-section"><a href={% url 'contact_us' %}>Contact Us</a></li> <li class="scroll-to-section"><a href={% url 'home_page' %}>Login</a></li> <li class="scroll-to-section"><a href={% url 'home_page' %}>Buy now</a></li> </ul> <a class='menu-trigger'> <span>Menu</span> </a> <!-- ***** Menu End ***** --> </nav> urlpatterns = [ path('admin/', admin.site.urls), path('', views.home_page, name='home_page'), path('about-us/', views.about_us, name='about_us'), path('contact-us/', views.contact_us, name='contact_us'), path('services/', views.our_services, name='services') ] -
React i18next fails to load translation after in build
I don't know why react i18next display loading namespace fails on the debug console. I tried many suggestions without success. I'm using the react build folder inside Django project. It works fine on localhost:3000 only which is crazy but once i try to use the build folder I get the above error on the debug console i18n.js : import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import Backend from 'i18next-http-backend'; import LanguageDetector from 'i18next-browser-languagedetector'; // don't want to use this? // have a look at the Quick start guide // for passing in lng and translations on init const Languages = ['ar', 'en', 'fr'] i18n .use(Backend) .use(LanguageDetector) .use(initReactI18next) // passes i18n down to react-i18next .init({ lng: 'en', react: { useSuspense: true, }, // the translations // (tip move them in a JSON file and import them, // or even better, manage them via a UI: https://react.i18next.com/guides/multiple-translation-files#manage-your-translations-with-a-management-gui) supported: ["en", "fr", "ar"], fallbackLng: "en", detection: { order: ['path', 'cookie', 'htmlTag', 'localStorage', 'subdomain'], caches: ['cookie'], }, debug: true, whitelist: Languages, interpolation: { escapeValue: false, // not needed for react as it escapes by default }, nsSeperator: false, keySeperator: false, backend: { loadPath: '/locales/{{lng}}/{{ns}}.json', }, }); export default i18n; index.js : import … -
Why does Django ORM do operations on my timestamp field even if I didn't setup TIME_ZONE and USE_TZ in my settings.py
Django ORM seems to be converting my timestamp in a weird way and I'm not sure why. Currently, our app doesn't have the settings TIME_ZONE and USE_TZ. There wasn't any need so far so we didn't use it. Now, I'm trying to show some specific timestamp details while we don't have the settings mentioned above The insert to the database (postgresql) works ok. the field that I'm using is timestamp with time zone. The timezone set in my local DB is "Asia/Singapore" db value is: "2022-07-01 23:09:14.253877+08" which is correct. Now, if I try to retrieve this value, what I get from the Django object is: 2022-07-01 10:09:14.253877. which is totally of and not even close to UTC. The timestamp value got converted to a different timezone (like for MST which is -7 from UTC). But it's actually not following any pattern since I also had some test data added at 1:11:00PM but the stamp retrieved from the Django ORM is 00:11:28.848820 To summarize, my question is how does Django ORM treat a timestamp value if TIME_ZONE and USE_TZ settings are not configured. I was naive to expect that it will retrieve the value as is from the database but … -
Django Rest Framework"detail": "Method \"GET\" not allowed."
I;m trying to build api by using django rest framework but I got the issue. @api_view(['PUT', ]) def api_update_blog_view(request, title): try: post = Post.objects.get(title=title) except Post.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) if request.method == 'PUT': serializer = PostSerializer(post, data=request.data) data = {} if serializer.is_valid(): serializer.save() data["success"] = "update successful" return Response (data=data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) urlpatterns = [ path('<str:title>/update', api_update_blog_view, name="update"), ] When I'm trying to update post I can see "detail": "Method "GET" not allowed." error. Where is the issue ? -
django startproject problem in python everywhere
I have been struggling with this problem in python everywhere. how could I resolve it? -
how to add an image in a django project?
I created a search bar in a Django project and I want to add an image to it. The code for this search bar is in the templates folder listed by Django. Here is the code: /*For search bar*/ input { background-image:url(" images/loup.png "); background-position:left; background-repeat:no-repeat; padding-left:18px; width:175px; } ... ... <input type="search" name="search" placeholder="Search here..." autofocus x-webkit-speech/> In the same templates folder, I created an images folder which contained the image to display in the bar. But when I run my Django server, the search bar shows on a page, but the image does not. In order for Django to list the image path on the hard drive, I took inspiration from this question and the Django documentation and I added to my urls.py file this: urlpatterns +=static(settings.IMAGE_URL, document_root=settings.IMAGE_ROOT) and this to my settings.py file: IMAGE_URL = 'templates/images/' IMAGE_ROOT = os.path.join(BASE_DIR,'images') the STATIC_URL variable being already defined in my settings.py file. I moved my images folder into the staticfiles folder generated by Django. The error still reoccurs. Even when I change the path of my image in my index.html file: background-image:url(" ../staticfiles/images/loup.png "); -
Render in Django without return
I like to write code for a website using django where the user can make a request to a backend. Since the request takes some time to get the answer from the backed, I like to render the same page to include a loading animation. For this purpose, I set a variable "show_loading" on "true" to display the loading animation via the hmtl-file. The code is as follows: views.py def UploadView(request): show_loading = True context["show_loading"] = show_loading render(request,'UPLOAD.html',context) data = {} #something else happening, just logical operations return render(request,'UPLOAD.html',context) UPLOAD.html: {% if show_loading %} <div class="loader"> <div class="inner one"></div> <div class="inner two"></div> <div class="inner three"></div> </div> {% endif %} The problem is that the render function is not working by the first render line (without return) but with the second render line (with return). So the question is, does render always need return or what I am doing wrong here, that the render does not work without return? Thanks for your help in this matter. PS: I wish not to use javascript or something else, I like to use the django function with context -
Use dataset registed in on pipelines in AML
I was following the SDK v2 Python tutorial in order to create a pipeline job with my own assets. I notice that in this tutorial they let you use a csv file that can be downloaded but Im trying to use a registered dataset that I already registered by my own. The problem that I facing is that I dont know where I need to specify the dataset. The funny part is that at the beginning they create this dataset like this: credit_data = ml_client.data.create_or_update(credit_data) print( f"Dataset with name {credit_data.name} was registered to workspace, the dataset version is {credit_data.version}" ) But the only part where they refer to this dataset is on the last part where they # the line: registered_model_name = "credit_defaults_model" # Let's instantiate the pipeline with the parameters of our choice pipeline = credit_defaults_pipeline( # pipeline_job_data_input=credit_data, pipeline_job_data_input=Input(type="uri_file", path=web_path), pipeline_job_test_train_ratio=0.2, pipeline_job_learning_rate=0.25, pipeline_job_registered_model_name=registered_model_name, ) For me this means that I can use this data like this (a already registered dataset), the problem is that I don't know where I need to do the changes (I know that in the data_prep.py and in the code below but I don´t know where else) and I don't know how to set this: … -
if file and not file._committed: AttributeError: 'Template' object has no attribute '_committed'
Here I want to create or get an entry from DB. The problem is when I'm referring to the template inside media/templates/emails/nice.html. I'm unable to get that and getting the error mentioned in the title. my template settings in setting.py is following; TEMPLATE_DIR = BASE_DIR / 'media/templates' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATE_DIR,], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] Next I;m working in accounts/test.py # CREATE Template data = { "user":user, "platform_subscriber":project, "name": "Test one", "html_template": loader.get_template("emails/nice.html") } email_template, created = EmailTemplate.objects.custom_get_or_create(data) print("The key",email_template) self.email_template = email_template.id error; if file and not file._committed: AttributeError: 'Template' object has no attribute '_committed' ---------------------------------------------------------------------- Ran 1 test in 3.440s -
Responsive List django
Good afternoon ! I'm building a "Family Tree" website using django python but I have one problem, this is computer list my list when i use computer, if I use my mobile phone i have this problem mobile list. I use library django-mptt who bulid this list: <ul class="root"> {% recursetree GT %} <br><li> <details open class="detail"> <summary><a href="{% url 'person-detail' node.id %}?id={{node.id}}">{{ node.name }} </a><span><sup>{% if node.date_birthday|date:'d.m' == '01.01' %} ({{node.date_birthday|date:'Y'}} - {{node.date_death|date:'Y'}} г.г) {% else %}({{node.date_birthday|date:'d.m.Y'}} - {{node.date_death|date:'d.m.Y'}} г.г){% endif %}</sup></span></summary> {% if not node.is_leaf_node %} <ul class="children"> <a href="#">{{ children }}</a </ul> {% endif %} </details> </li> {% endrecursetree %} How can I make a responsive list using CSS or JS so that it displays correctly on the phone ? -
Update a datetime field in django using an ajax call
I have a Profile model assigned to a user which contains the field : consent = models.DateTimeField(default=timezone.now, blank=True, null=True) I have created a switch in frontend in which the user gives consent for data tracking or no and and ajax call for handling the response. It seems to work fine , it is printing the correct outputs but the datetime does not save in the database. Any idea what is wrong? def user_consent(request): edited_user = request.user # if no user is specified, then we take the signed in user if request.is_ajax and request.method == "GET" : value = request.GET['toggle'] print(value) if value == 'true': edited_user.profile.consent = timezone.now() edited_user.save() print(edited_user.profile.consent) return JsonResponse({"ok": "no errors"}, status=200) else: edited_user.profile.consent = None edited_user.save() print(edited_user.profile.consent) return JsonResponse({"ok": "no errors"}, status=200) return JsonResponse({"error": "there was an error"}, status=400) The outputs im getting in console : [01/Jul/2022 14:53:50] "GET /users/consent?toggle=false HTTP/1.1" 200 19 true 2022-07-01 14:53:51.911242+00:00 [01/Jul/2022 14:53:51] "GET /users/consent?toggle=true HTTP/1.1" 200 19 false None [01/Jul/2022 14:53:53] "GET /users/consent?toggle=false HTTP/1.1" 200 19 true 2022-07-01 14:53:55.522132+00:00 [01/Jul/2022 14:53:55] "GET /users/consent?toggle=true HTTP/1.1" 200 19 false None [01/Jul/2022 14:55:08] "GET /users/consent?toggle=false HTTP/1.1" 200 19 -
Name xmlrpc is not defined
Im trying to extract data from odoo using xml-rpc api. import xmlrpc.client url = "https://xxxxxx.odoo.com/" db = "xxxxxxx" username = " " password = "" common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url)) However it said that name 'xmlrpc' is not defined, it is very weird since xmlrpclib is part of the standard library in Python, i dont need to install it. Can you suggest solution for this? Thanks.