Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How Can I Automatically Create Profile For Guest User During PIN Activation
I am working on an Event Ticketing Application in Django where guest would need a Recharge PIN to be validated on the portal for booking or reserving a seat in an event they bought PIN for. And I also want these guests to be authenticated so I can be able to management Authorization on them too. In my Models I have a Profile Model where I am using signals to automatically create user profile upon Admin User Creation, and I also have three User Groups in the Create New User Form with Privileges assigned accordingly; Organizer, Staff and Guest are the groups. I have also developed a Django CreateUserForm class using UserCreationForm module in my forms.py where I have a Drop Down of all these group for the Admin to add Users (Registration Page is accessible by Admin only) using Admin dashboard. My problem is that I want each PIN that is Validated by Guest to be able to create his/her Profile immediately the PIN Validated using Signals but I don't know how to do it. I am confused with my CreateUserForm class since all the groups are listed in Drop down. Don't know how to use conditionals inside the … -
Django DecimalField min value validation error
I need a decimal field in my form with a minimal value of 0.20, maximal value of 20 with 2 decimal places as you can see in the code bellow. forms.DecimalField(min_value=0.20, max_value=20.00, max_digits=4, decimal_places=2, initial=1) The problem occures when you put 0.20 in, because you get a validation error: Ensure this value is greater than or equal to 0.20. I'm using python 3.10 and Django 4.0.4 -
Why is image serializer feild not returning link format
Is there any update on image field serializer? I was trying to server an image api to the frontend. My serializer is not returning image link instead its returning the path relative to the base dir of the django-project models.py def upload_to(instance, filename): return 'profiles/{filename}'.format(filename=filename) class Picture(models.Model): image = models.ImageField(upload_to=upload_to) serializer class PictureSerializer(serializers.ModelSerializer): class Meta: model = Picture fields = ['image'] **serializer.data result ** [ { "image": "/media/profiles/quiz-app-.jpg" }, { "image": "/media/profiles/coding2.jpg" }, { "image": "/media/profiles/dummy_2s9CyV8.jpg" } ] instead of the above result I want something like a link in return [ { "image": "http://127.0.0.1:8000/api/media/profiles/quiz-app-.jpg" }, { "image": "http://127.0.0.1:8000/api/media/profiles/coding2.jpg" }, { "image": "http://127.0.0.1:8000/api/media/profiles/dummy_2s9CyV8.jpg" } ] -
Calling viewset from another route
I use Django rest-framework which fetch the items from tables and return serialized json, when calling like this below localhost/api/mixs?id=12 Source code. class MixViewSet(viewsets.ModelViewSet): serializer_class = MixSerializer filter_backends = [django_filters.rest_framework.DjangoFilterBackend] filter_fields = ["id","user"] filterset_fields = ['id'] search_fields = ['id'] def list(self,request,*args,**kwargs): queryset = self.filter_queryset(self.get_queryset()) serializer = self.get_serializer(queryset, many=True) custom_data = { 'items': serializer.data } custom_data.update({ 'meta':{"api":"Mix"} }) return Response(custom_data) def get_queryset(self): queryset = Mix.objects.all() ids = self.request.query_params.get('ids') if ids is not None: id_arr = ids.split(',') if len(id_arr) > 0: queryset = queryset.filter(id__in=id_arr) u_key = self.request.query_params.get('u_key') if u_key is not None: queryset = queryset.filter(u_key=u_key) return queryset Now, I want to use this function from another method. For example def createMix(request): #do something and make Mix m = Mix(detail={},user=1) m.save() print(m.id) ### for example 13 #Now I want to do the equivalent thing #to `localhost/api/mixs?id=13` # returning the data id=13 When calling this url localhost/myapp/createsong The program do something and insert data in Mix table. then do the equivalent thing to localhost/api/mixs?id=13 Is it possible? Or my idea is correct? -
Why does command prompt throws" Syntax Error: Generator expression must be parenthesized " while creating a Django App named Authentication?
I am new to Django and was trying to make a Django project inside the virtualenv to learn but getting following error on python manage.py startapp Authentication: python manage.py startapp Authentication Traceback (most recent call last): File "C:\Users\Prompt\Desktop\Django\manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "D:\anaconda\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line utility.execute() File "D:\anaconda\lib\site-packages\django\core\management\__init__.py", line 337, in execute django.setup() File "D:\anaconda\lib\site-packages\django\__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "D:\anaconda\lib\site-packages\django\apps\registry.py", line 85, in populate app_config = AppConfig.create(entry) File "D:\anaconda\lib\site-packages\django\apps\config.py", line 94, in create module = import_module(entry) File "D:\anaconda\lib\importlib\__init__.py", line 127, in import_module 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 "D:\anaconda\lib\site-packages\django\contrib\admin\__init__.py", line 4, in <module> from django.contrib.admin.filters import ( File "D:\anaconda\lib\site-packages\django\contrib\admin\filters.py", line 10, in <module> from django.contrib.admin.options import IncorrectLookupParameters File "D:\anaconda\lib\site-packages\django\contrib\admin\options.py", line 12, in <module> from django.contrib.admin import helpers, widgets File "D:\anaconda\lib\site-packages\django\contrib\admin\widgets.py", line 151 '%s=%s' % (k, v) for k, v in params.items(), ^ SyntaxError: Generator expression must be parenthesized -
I want to set a limit for the rows only upto 5 rows which will get added from the django.models admin panel
I have a table in my models file and I want to design it such that there is a limit to only 5 rows in the table. When the limit is exceeded error has to show and input should not take.I am new to Django so if anyone had a suggestion on how to do this, it would be greatly appreciated! -
Import app model with multiple Django apps error ModuleNotFoundError: No module named 'apps'
So I have a problem importing a model from a different app in same Django project. My files are structured as follows: /project /apps __init__.py /app1 __init__.py models.py ... /non_app_dir __init__.py work.py ... /core __init.py settings.py urls.py wsgi.py ... manage.py In my settings.py, I have this: INSTALLED_APPS = [ ... 'apps.app1', 'apps.non_app_dir', ... ] Ok, so in my work.py (from non_app_dir), I try to import a model from models.py (from app1) like below: from apps.app1.models import MyModel def testModel(): test = MyModel.objects.all() print(test) but i get the following error ModuleNotFoundError: No module named 'apps' Any solutions to this? -
drf_yasg swagger_auto_schema move from views
In my project's views classes I use swagger_auto_schema decorator to customize swagger possible responses. My question is this: "Is this a way to move all these decorators from my class based views to other place like module or python file?". I'm asking this question because swagger_auto_schema decorators sometimes take up most of the code of my views, and it's getting hard to read them. example: class ArticleListCreateAPIView(ListCreateAPIView): queryset = Article.objects.all() serializer_class = ArticleSerializer def get_serializer_class(self): if self.request.method == "GET": return ArticleResponseSerializer return super().get_serializer_class() @swagger_auto_schema( responses={ status.HTTP_201_CREATED: openapi.Response( description="Successful article create", schema=ArticleResponseSerializer, ), status.HTTP_400_BAD_REQUEST: openapi.Response( description="Data serialization failed. Incorrect data.", schema=DetailResponseSerializer ), status.HTTP_409_CONFLICT: openapi.Response( description="Media-file is already bouned to some other model", schema=DetailResponseSerializer ) } ) def post(self, request, *args, **kwargs): ... Maybe I should stop using swagger_auto_schema and replace it by some other structures? -
How to use django-hijack from api
I have follow the django-hijack installation process but unfortunately the usage demonstration is using the django template. But like most current applications, my application uses Django Rest Framework and has a javascript application for the front end. I can't find a solution to impersonate an user from the front-end. I've tried to do a POST while logged in as an admin on /hijack/5 or /hijack/acquire/5 where 5is the ID of the user I want to impersonate but I got a 404 error on my POST. So my question is how to impersonate an user while an admin with Django when using a javascript front end application ? I'm open to other projects than django-hijack if this one is not compatible. -
javascript - fetching data from webserver only getting 'redirected' response from cors
So I managed to make my first api accessable locally. However when I try to fetch data like I would normally (url to phpscript to get data from db), I only get a Response telling me that I was successfully redirected. In wich way should I change my fetch function to make this work? script.js async function getTop10() { let url = 'http://192.168.2.131:81/stern'; try { let res = await fetch(url); console.log(res); return await res.json(); } catch (error) { console.log(error); } } getTop10(); Response Response {type: 'cors', url: 'http://192.168.2.131:81/stern/', redirected: true, status: 200, ok: true, …} body: (...) bodyUsed: true headers: Headers {} ok: true redirected: true status: 200 statusText: "OK" type: "cors" url: "http://192.168.2.131:81/stern/" [[Prototype]]: Response Sample dataset from the url [ [ "Nach", 20 ], [ "In", 16 ], [ "Sie", 15 ], [ "Die", 14 ], [ "So", 10 ], [ "Putin", 10 ], [ "Das", 9 ], [ "Ukraine", 9 ], [ "Deutschland", 9 ], [ "Der", 8 ] ] -
CSS Grid not working in dynamically generated items with Django jinja templating?
I am new to Django and ran into this issue. so basically I am making an app where I have to display rooms on the main home page. The rooms are generated dynamically and are stored in the database that are fetched for the home page like this (in the views.py) def home(request): return render(request, 'base/index.html', {'rooms':rooms}) then the index.html will display the data in the form of cards using jinja for loop, something like this, just ignore the classes and all that, they are just dummy images, here I am using tailwind-css for styling {% for room in rooms %} <div class="grid grid-cols-1 md:grid-cols-3 border-4 border-red-400 lg:grid-cols-4 sm:grid-cols-2 gap-10"> <div class="rounded overflow-hidden border-4 border-red-400 shadow-lg"> <a href="/room/{{room.id}}"> <div class="relative"> <img class="w-full" src="https://images.pexels.com/photos/196667/pexels-photo-196667.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="Sunset in the mountains"> <div class="hover:bg-transparent transition duration-300 absolute bottom-0 top-0 right-0 left-0 bg-gray-900 opacity-25"> </div> <a href="#!"> <div class="absolute bottom-0 left-0 bg-indigo-600 px-4 py-2 text-white text-sm hover:bg-white hover:text-indigo-600 transition duration-500 ease-in-out"> {{room.id}} </div> </a> <a href="!#"> <div class="text-sm absolute top-0 right-0 bg-indigo-600 px-4 text-white rounded-full h-16 w-16 flex flex-col items-center justify-center mt-3 mr-3 hover:bg-white hover:text-indigo-600 transition duration-500 ease-in-out"> <span class="font-bold">27</span> <small>March</small> </div> </a> </div> </a> <div class="px-6 py-4"> <a href="#" class="font-semibold text-lg inline-block hover:text-indigo-600 transition duration-500 … -
Django Rest Framework - DataError: integer out of range
I'm creating an Urban Dictionary style website where I have one django model: class Term(models.Model): term_name=models.CharField(max_length=100) definition=models.TextField() example=models.ImageField(blank=True) uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) tags = TaggableManager(blank=True) def __str__(self): return self.term_name I'm using taggit to add tags, but when I test out adding tags through the Django Rest Framework, I get an error reading: Internal Server Error: /api/glossary/a9cc167c-f5c2-11ec-a11a-1e4794e8627e Traceback (most recent call last): File "/Users/almoni/.local/share/virtualenvs/screenplayrules_django-lZL7DxO_/lib/python3.9/site-packages/django/db/models/query.py", line 657, in get_or_create return self.get(**kwargs), False File "/Users/almoni/.local/share/virtualenvs/screenplayrules_django-lZL7DxO_/lib/python3.9/site-packages/django/db/models/query.py", line 496, in get raise self.model.DoesNotExist( taggit.models.TaggedItem.DoesNotExist: TaggedItem matching query does not exist. followed by a ton of File errors then: django.db.utils.DataError: integer out of range My process before getting this error was to just test out tags = TaggableManager(blank=True) I had in my Term model. So I went over to localhost:8000 and tried to PUT a tag: Once I clicked put I get the error I previously showed in my terminal and this page error: I'm still pretty new to django and have never used taggit before, so I'm a bit confused here. -
Database query failing in django views when using filter
Just going through the Django tutorial and am playing around and testing stuff. My question is, how come the following line works and lets me go to page no problem: test = Choice.choices.all() While the following filter line gives me the error message ValueError: too many values to unpack (expected 2) test = Choice.choices.get("question_id=6") Even when I try the following two lines it doesn't work. No idea what's happening or why test = Choice.choices.get("question_id=6")[0] test = Choice.choices.get("question_id=6")[0].question_text I feel like i need to really understand what's going on and why so I can actually do proper queries in the future -
how to use django python framework with MERN Stack technology to create a web application?
I am working on a MERN Stack project. My frontend is designed in javascript with Reactjs and is connnected to a backend designed in javascript with Expressjs, MongoDB, Nodejs. However, I would like to connect my frontend to Django so that he can send him data and he will send him the data obtained on the web. However, when I search the internet I see full stack tutorials with Reactjs and Django or Reactjs in MERN Stack. However, my frontend needs Django to do a specific task and others MERN technologies namely MongoDB, Nodejs, Expressjs to do other tasks. I don't know if and how I can use Django with MERN. I searched the internet if my frontend could have two backends, but I didn't get any relevant results. Because my problem is that I can easily pass data from the frontend to Django and Django can easily send this data back to the frontend despite using MERN technology. -
How to pass and update data into different tables in a single post function in Django Rest Framework
I have two models named TokenDetails and TimeInterval.I have to post a time into TokenDetails models as bookingtime and in TimeInterval I have a field status which by default is True and if the bookingtime field in TokenDetails is todays date i have to change the status of TimeInterval into False TokenDetails.models.py class TokenDetail(models.Model): customername=models.ForeignKey('accounts.User', on_delete=models.CASCADE,null=True) bookingdate=models.DateField(default=datetime.date.today) bookingtime=models.ForeignKey('vendor.TimeInterval',on_delete=models.CASCADE,null=True) servicename=models.ForeignKey('vendor.ServiceDetail',on_delete=models.CASCADE,null=True) vendorname=models.ForeignKey('vendor.VendorDetail',on_delete=models.CASCADE,null=True) TimeInterval.models.py class TimeInterval(models.Model): timeinterval=models.TimeField(default=None) serviceid=models.ForeignKey('ServiceDetail',on_delete=models.CASCADE,null=True) userid=models.ForeignKey('accounts.User',on_delete=models.CASCADE,null=True) status=models.BooleanField(default=True) def __str__(self): return str(self.timeinterval) views.py @api_view(['POST']) def tokendetailsAdd(request): if request.method=='POST': customername=request.data.get('customerid') custname=User.objects.get(id=customername) bkngdate=request.data.get('bookingdate') bookingtime=request.data.get('bookingtime') bkngtime=TimeInterval.objects.get(id=bookingtime) servicename=request.data.get('servicename') srvcname=ServiceDetail.objects.get(id=servicename) vendorname=request.data.get('vendorname') vndrname=VendorDetail.objects.get(id=vendorname) sts=request.data.get('status') status=TimeInterval.objects.get(status=sts) TokenDetail.objects.create( customername=custname, bookingdate=bkngdate, bookingtime=bkngtime, servicename=srvcname, vendorname=vndrname, ) return Response('token registered') -
How do I prevent an admin (superuser) from changing/updating other user’s password?
I have a custom method for all users to reset password. It sends the password reset email to the user, user then click on password rest link and then resets his/her password. So, I want users to reset password only this way and don’t want any admin to reset any user password from Django Administration page. How do I prevent admin from changing/updating any other user’s password? I don’t have any custom Admin Model yet. If this requires me to create a custom Admin model, please explain a bit, what things I will have to keep in the model to keep all the other functionality same as default Admin Model? Just a slight change required and that is not to let admin change any other user’s password. -
Microsoft django logout
[I want to perform Microsoft logout from my Django application, I have logged IN my user and now I am sending few parameters 'tenant':'ec0a1000-3407-4d2f-81f9-dfd1179718dc', 'client_id' : 'f03b5c74-f63f-4bbd-a920-70c91b201c97', 'code' : code, 'client_secret' : '2hv8Q~oHdAeVS-DdmaJA6vZAaH8PzM.Inoeddb_P', 'redirect_uri' : 'http://localhost:8000/callback', 'scope' : 'user.read', 'grant_type' : 'authorization_code', but I got this error so can you please tell me the solution of this error. ]1 -
In Django admin list, link the model which doesn't have relationship with object
I have two models which doesn't have foreign key as relation but has the username column common. class User(models.Model): password = models.CharField(max_length=255) email = models.EmailField(unique=True, blank=True) username = models.CharField(max_length=255) class SessionUser(models.Model): username = models.CharField(max_length=255) last_login = models.DateTimeField(auto_now=True) I wanted to list all users in Django admin and once clicked on individual object it should list all the session of user. How can we link the object which doesn't have foregien key relationship? -
Getting error by setting a Dynamic Task Scheduling With Django-celery-beat
I'm setting up Dynamic cron based on the model creation to create another model object error im getting is Cannot assign "(<CrontabSchedule: 0 0 27 1 * (m/h/dM/MY/d) UTC>, True)": "PeriodicTask.crontab" must be a "CrontabSchedule" instance. this is my code where a periodic task will be created by creating this model import json from django.utils import timezone import uuid from django.db import models from django_celery_beat.models import CrontabSchedule, PeriodicTask # Create your models here. class Rule(models.Model): rule_id = models.UUIDField( primary_key = False, default = uuid.uuid4, editable = True) name = models.CharField('r=Rule Name',max_length=255,blank=True,null=True) compliance_frequency = models.CharField(max_length=40,choices=(('QUARTERLY','QUARTERLY'), ('MONTHLY','MONTHLY'),('YEARLY','YEARLY')),default='YEARLY') applicable_from = models.DateField(default=timezone.now) applicable_to = models.DateField(null=True,blank=True) task = models.OneToOneField( PeriodicTask, on_delete=models.CASCADE, null=True, blank=True ) def setup_task(self): self.task = PeriodicTask.objects.create( name=self.name, task='create_compliance', crontab=self.crontab_schedule, args=json.dumps([self.id,self.name,self.compliance_frequency]), start_time= timezone.now(), ) self.save() @property def crontab_schedule(self): if self.compliance_frequency == "QUARTERLY": return CrontabSchedule.objects.get_or_create(minute='0',hour='0',day_of_week='*', day_of_month='27',month_of_year='3,6,9,12') if self.compliance_frequency == "MONTHLY": return CrontabSchedule.objects.get_or_create(minute='0',hour='0',day_of_week='*', day_of_month='27',month_of_year='*') if self.compliance_frequency == 'YEARLY': return CrontabSchedule.objects.get_or_create(minute='0',hour='0',day_of_week='*', day_of_month='27',month_of_year='1') raise NotImplementedError( '''Interval Schedule for {interval} is not added.'''.format( interval=self.compliance_frequency. value)) now using signal.py i'm triggering the setup_task to setup the task from django.db.models.signals import post_save from django.dispatch import receiver from .models import Rule @receiver(post_save,sender=Rule) def create_periodic_task(sender, instance, created, **kwargs): if created: instance.setup_task() instance.task.enabled = True instance.task.save() print('signal working') then using trigger a task … -
Encoding a hyperlink in CSV formatted file doesn't work
The problem is here; f'=HYPERLINK("http://{os.getenv("OPTION_HOST_IP)}:8000/test/opt?sec={final_list[1]}&st={summary_row[4]}&exp={summary_row[1]}&cp={final_list[6]}", "Daily")'] This just returns text in LibreOffice What should I do? The other article told me to use double quotes ,but that doesn't work for me either. -
Axios/Django rest, cant filter with question mark
I'm having very stupid problem: I can't get to filter data I'm getting from django rest by any means. Using "/?something=value" does not thin out the results obtained, I'm still getting all the results. I tried using "param", but it basically does same thing and is still not working. I don't know if I'm missing something, but even when I go to views of my database it is not working. async created() { try { const response = await axios.get("http://127.0.0.1:8000/api/comments/?article=" + this.id); let tmp = response.data this.comments = tmp this.error = '' } catch(err) { this.error=err } } this is how it looks in django rest view -
Django LoginRequiredMixin not working as intented
The LoginRequiredMixin is not working as intended for the class based view below, I was able to access the webpage regardless of login status, but it should have redirected the unauthorized users to the login page. Where have I gone wrong? from django.shortcuts import render, redirect from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import FormView from .forms import UpdatePortfolio # Create your views here. class UpdatePortfolioView(LoginRequiredMixin, FormView): login_url = 'users:login' redirect_field_name = 'mainpage:update' form = UpdatePortfolio template_name = 'mainpage/updateportfolio.html' def get_object(self): # return self.request.user.id return self.request.user.pk def get(self, request, *args, **kwargs): form = self.form_class return render(request, self.template_name, {'form': form}) -
django-river: example of change in state from a view
I am trying to use django-river to track and control the flow of objects in my application. In particular, I have objects representing document that will pass from the author to a reviewer and then on to a production team, ideally based on a view controlled by a button press. I was intending to have an owner field that could be changed to indicate who currently 'has' the document. Can someone please give me a short example of how this might work? Thank you! -
Two models have a foreign key to a third model - can I make an inline based on that foreign key?
While designing Django admin panel, I recently stumbled upon a following situation: I have three models: class A(models.Model): id_a = models.AutoField(primary_key=True) some_data = models.CharField(max_length=255, blank=True, null=True) id_c = models.ForeignKey('C', models.PROTECT, db_column='id_c') class B(models.Model): id_b = models.AutoField(primary_key=True) some_data = models.CharField(max_length=255, blank=True, null=True) id_c = models.ForeignKey('C', models.PROTECT, db_column='id_c') class C(models.Model): id_c = models.AutoField(primary_key=True) some_data = models.CharField(max_length=255, blank=True, null=True) As you can see, two of the models have a foreign key to the third. What i need to do is to create inline of model B in model A. It should be possible, since they share a foreign key to model C. (So what I want is: when I look at entity of model A in admin panel, I should have inlines of all the B entities, that have the same 'id_c', as the A entity I'm looking at.) So i tried it like this (in admin.py): class InlineB(admin.StackedInline): model = B extra = 1 @admin.register(A) class AdminPanel_A(SimpleHistoryAdmin): list_display = ['some_data'] inlines = [InlineB] But when doing it like this I get the error: B has no ForeignKey to A. Which of course is true, but those two models do have a ForeignKey in common, which I'm sure could be used to make … -
Django DRF how to validate captcha response for server side
I amusing nextjs as my frontend. I am struggling to validate server site captcha response. I want data will be not inserted in my database until captcha verification sucess. I tried drf-recaptcha package. Here is my code: settings.py INSTALLED_APPS = ['rest_framework_recaptcha',] #included in my installed app DRF_RECAPTCHA_SECRET_KEY = '< my_secrect key>' serializers.py from rest_framework_recaptcha import ReCaptchaField class ContactSerializer(serializers.ModelSerializer): recaptcha = ReCaptchaField() class Meta: model = Contact fields = '__all__' my API views.py @api_view(['POST', 'GET']) def contact_forms_api(request): if request.method == 'POST': ''' Begin reCAPTCHA validation ''' recaptcha_response = request.POST.get('g-recaptcha-response') url = 'https://www.google.com/recaptcha/api/siteverify' values = { 'secret': settings.GOOGLE_RECAPTCHA_SECRET_KEY, 'response': recaptcha_response } data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) result = json.load(response) ''' End reCAPTCHA validation ''' if result['success']: data = request.data serializer = ContactSerializer(data=data) if serializer.is_valid(): serializer.save() print(serializer.data) return Response({ 'status': True, 'message': 'sucess' }) return Response({ 'status': False, 'message': serializer.errors }) here is my nexjs code: I am using this package in my frontend application. here my code sometings look like: <form onSubmit={SubmitContact}> <input type="text"/> <ReCAPTCHA sitekey="my_captcha site ke=y" onChange={handleRecaptcha} /> <form> here is my SubmitContact function look like this: const res = await axios.post(url,data,{headers: headers} )