Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How do I get my serializer to return data from a dependent field in my model?
I'm using Django 2 and Python 3.7. I have these models set up. One (Coop) is dependent on the other (CoopType) using Many-To-Many ... class CoopTypeManager(models.Manager): def get_by_natural_key(self, name): return self.get_or_create(name=name)[0] class CoopType(models.Model): name = models.CharField(max_length=200, null=False, unique=True) objects = CoopTypeManager() class CoopManager(models.Manager): # Look up by coop type def get_by_type(self, type): qset = Coop.objects.filter(type__name=type, enabled=True) return qset # Look up coops by a partial name (case insensitive) def find_by_name(self, partial_name): queryset = Coop.objects.filter(name__icontains=partial_name, enabled=True) print(queryset.query) return queryset # Meant to look up coops case-insensitively by part of a type def contains_type(self, types_arr): filter = Q( *[('type__name__icontains', type) for type in types_arr], _connector=Q.OR ) queryset = Coop.objects.filter(filter, enabled=True) return queryset class Coop(models.Model): objects = CoopManager() name = models.CharField(max_length=250, null=False) types = models.ManyToManyField(CoopType) address = AddressField(on_delete=models.CASCADE) enabled = models.BooleanField(default=True, null=False) phone = PhoneNumberField(null=True) email = models.EmailField(null=True) web_site = models.TextField() I have the following serializers set up, designed to return the data in JSON form ... class CoopTypeField(serializers.PrimaryKeyRelatedField): queryset = CoopType.objects def to_internal_value(self, data): if type(data) == dict: cooptype, created = CoopType.objects.get_or_create(**data) # Replace the dict with the ID of the newly obtained object data = cooptype.pk return super().to_internal_value(data) ... class CoopTypeSerializer(serializers.ModelSerializer): class Meta: model = CoopType fields = ['id', 'name'] def … -
Is there a more efficient substitute to my code?
please help give me a more efficient substitute to my code -
'Cannot query Conversationt, Use a query set for Profile'
I'm trying to query my Conversation objects, and get a convo object that may be already created or may not be already created between the two users. Then, I want to get_or_create one passing in the two users. Now, I'm getting a 'cannot query conversation object. Use profile' ... not sure why this is. I should be returning a list that I can pluck in or if it can't get it, it should create it. Conversation object has a ManyToMany field called Members. Profile is my user model that I created. **error ** ValueError at /message/2/ Cannot use QuerySet for "Conversation": Use a QuerySet for "Profile". Request Method: GET Request URL: http://localhost:8000/message/2/ Django Version: 2.2.3 Exception Type: ValueError Exception Value: Cannot use QuerySet for "Conversation": Use a QuerySet for "Profile". Exception Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/sql/query.py in check_related_objects, line 1081 Python Executable: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 Python Version: 3.7.3 Python Path: ['/Users/papichulo/Documents/DatingAppCustom', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/papichulo/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages'] views.py/Message def message (request, profile_id): other_user = get_object_or_404(Profile,id=profile_id) members_query = Conversation.objects.filter(members= request.user).filter(members= other_user) conversation, created = Conversation.objects.get_or_create( members = members_query) if request.method == 'POST': form = MessageForm(request.POST, instance= request.user, sender=request.user, conversation = conversation, message=message, date=date) if form.is_valid(): form.save() return redirect ('dating_app:messages.html') else: conversation, created = Conversation.objects.get_or_create( members= [request.user, other_user]) … -
Update instances of ModelFormset
In my django app two models are connecetd by manytomany relation and I am using modelformset_fatory to create a form like this Views.py def post(request): tform = TeamForm() pform = modelformset_factory(Player, form=PlayerForm, extra = 1) pform = pform(request.POST or None, queryset = Player.objects.filter(id__isnull = True)) if request.method == 'POST': t = Team() tform = TeamForm(request.POST, instance=t) if tform.is_valid() and pform.is_valid(): tform.save() instances = pform.save(commit=False) for i in instances: player = Player() player.pname = i.pname player.hscore = i.age player.age = i.hscore player.save() t.player.add(player) t.save() return redirect('/exams/dashboard/') else: print('invalid data') return render(request, 'team/team_create.html', {'exform': tform, 'exformset': pform}) This is working perfectly fine but the problem occurs when I try to update the form, I am able to initialize the form with the data but when I create a new player instance in form it does not get saved. Update function: def update(request, pk = None): team = Team.objects.get(id = pk) tform = TeamForm(instance = team) pform = modelformset_factory(Player, form=PlayerForm, extra=0) print("players", Player.objects.filter(team=team)) pform = pform(request.POST or None, queryset=Player.objects.filter(team=team)) if request.method == 'POST': tform = TeamForm(request.POST, instance=team) print("tform ", tform) print("pform ", pform) if tform.is_valid() and pform.is_valid(): tform.save() pform.save() return redirect('/exams/dashboard/') else: print('invalid data') return render(request, 'team/team_create.html', {'exform': tform, 'exformset': pform}) Do I … -
Django Deploy to heroku: Application Error
I deployed my Django project to heroku. It deployed successfully but the page shown Application error. In logs on heroku error be like this. 2020-04-24T05:34:09.500250+00:00 app[web.1]: [2020-04-24 05:34:09 +0000] [4] [INFO] Using worker: sync 2020-04-24T05:34:09.506988+00:00 app[web.1]: [2020-04-24 05:34:09 +0000] [10] [INFO] Booting worker with pid: 10 2020-04-24T05:34:09.532649+00:00 app[web.1]: [2020-04-24 05:34:09 +0000] [11] [INFO] Booting worker with pid: 11 2020-04-24T05:34:10.051702+00:00 heroku[web.1]: State changed from starting to up 2020-04-24T05:34:20.000000+00:00 app[api]: Build succeeded 2020-04-24T05:34:26.126726+00:00 app[web.1]: [2020-04-24 05:34:26 +0000] [4] [INFO] Shutting down: Master 2020-04-24T05:34:41.808971+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dashboard-retail.herokuapp.com request_id=f5feaeba-075f-4dc7-a637-fe6b271f0d67 fwd="125.24.11.115" dyno=web.1 connect=1ms service=30003ms status=503 bytes=0 protocol=https 2020-04-24T05:34:42.096139+00:00 app[web.1]: [2020-04-24 05:34:42 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:10) In Procfile,I set like this web: gunicorn myWeb.wsgi --log-file - Help me please. Thank. -
Django CSRF check failing with an Ajax GET request
I followed the instructions of this tutorial https://simpleisbetterthancomplex.com/tutorial/2016/08/29/how-to-work-with-ajax-request-with-django.html to check "User already exists or not" but Django still rejecting my POST request. I could use some help complying with Django's CSRF protection mechanism via my AJAX post. I've followed the directions here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ But it didnt help me. It is my result in console: {% extends 'base.html' %} {% block title %} Register {% endblock %} {% load crispy_forms_tags %} {% block body %} <div class="container"> <h1 class="text-center">Regiser</h1> <form class="form-group" method="POST" data-validate-username-url = "{% url 'validate_username' %}"> {% csrf_token %} {{ form|crispy }} <input type="submit" name="Register" class="btn btn-primary text-center" value="Register"> </form> </div> {% endblock %} {% block script %} <script> function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var 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; } function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); } $(document).ready(function() { var csrftoken = getCookie('csrftoken'); $.ajaxSetup({ beforeSend: function(xhr, settings) … -
How to generate a derived field in a model in Django which is dependent on fields of other models?
Here are my models in models.py class Purchase(models.Model): Purchase_id = models.AutoField(verbose_name='Purchase ID',primary_key=True) Employee_id = models.ForeignKey(Employee, on_delete= models.CASCADE,verbose_name='Employee ID') Distributor_id = models.ForeignKey(Distributor, on_delete= models.CASCADE,verbose_name='Distributor ID') Date_of_Purchase= models.DateField(verbose_name='Date Of Puchase',validators=[datevalid]) Discount_in_percentage = models.FloatField(verbose_name='Discount(in percent)',validators=[nonneg,MaxValueValidator(100,'Discount can not be more than 100%%')]) Tax_in_percentage = models.FloatField(verbose_name='Tax(in percent)',validators=[nonneg]) Total_amount = models.FloatField(verbose_name='Total Amount',validators=[nonneg]) Products=models.ManyToManyField(Products,through='Purchase_Consists_of') objects = models.Manager() def __str__(self): return str(self.Purchase_id) class Meta: verbose_name_plural='Purchase' db_table='Purchase' class Products(models.Model): Prod_code = models.AutoField(verbose_name='Product Code',primary_key=True) Product_name = models.CharField(verbose_name='Product Name',max_length=100) Quantity = models.CharField(verbose_name='Quantity(kg/L)',max_length=20) Rate = models.FloatField(verbose_name='Rate(per unit)',validators=[nonneg]) Colour = models.CharField(verbose_name='Colour', max_length=50) Product_description = models.CharField(verbose_name='Product Description', max_length=50) Stock_level = models.IntegerField(verbose_name='Stock Level',validators=[nonneg]) Shelf_life = models.IntegerField(verbose_name='Shelf Life',null=True,blank=True,validators=[nonneg]) objects = models.Manager() def __str__(self): return str(self.Prod_code) class Meta: verbose_name_plural='Product' db_table='Products' class Purchase_Consists_of(models.Model): Purchase_id = models.ForeignKey(Purchase, on_delete= models.CASCADE,verbose_name='Purchase ID') Prod_code = models.ForeignKey(Products, on_delete= models.CASCADE,verbose_name='Product Code') Quantity=models.CharField(verbose_name='Quantity',max_length=20) objects = models.Manager() def __str__(self): return str(self.Purchase_id) class Meta: verbose_name_plural='Purchase Consists of' db_table='Purchase_Consists_Of' unique_together=(('Purchase_id'),('Prod_code'),) I want the Total_amount in Purchase model to be calculated automatically and saved in the database when I input the values of Rate and Quantity in Products and Purchase_Consists_Of tables. The relationship is like this: Purchase.Total_amount=Products.Rate*Purchase_Consists_Of.Quantity. Is there any way to do this?? -
Unable to start project server while using infinite while loop in python task schedule
If I'm using schedule module to execute a function for a pre-defned times used the following code to achieve this, but using this infinite while loop unable start project server. Please help me to solve this issue. import schedule import time def test(): # code write here # function executes for every 10 mins schedule.every(10).minutes.do(test()) while True: schedule.run_pending() time.sleep(1) -
Django login form not authenticating/showing authentication
I've successfully embedded my login form onto my base.html page, which works and will lead the user into thesite if correct credentials are entered. However, when incorrect credentials are entered, the Django authentication which I assume would display "Incorrect username entered" or "Incorrect password entered" do not appear. Instead, you just get redirected to the page again with empty fields. Can someone help me as to why the Django authentication isn't working correctly? My login form code in my base.html file <form method="post" action="/login/"> {% csrf_token %} <div class="row justify-content-center"> <div id="login-box" > <div class="form-group"> <div class="login-text mb-2" >Login for Access</div> <p> <label for="id_username">Username</label> <input class="form-control" id="id_username" name="username" autofocus="" type="text" required> </p> <p> <label for="id_password">Password</label> <input class="form-control" id="id_password" name="password" type="password" required> </p> <button type="submit" class="btn btn-primary mt-2 mb-2">Login</button> </div> <a href="#" data-toggle="tooltip" data-placement="bottom" title=" Please contact your IT Administrator at college for information on how to reset your password">Forgot Password?</a> </div> </div> </form> --> </div> This is what is shown when incorrect credentials are entered. Here. And this is what the user is redirected to. Here. -
Docker: Django: netstat shows the 8000 port where lsof not shows
I found that on any system to know the ports listening we can check by using netstat -tulpn | grep 'LISTEN' OR lsof -i -P -n | grep 'LISTEN' I have docker container running django server using manage.py runserver 0.0.0.0:8000 So i wanted to check the ports listening on the docker using netstat and lsof inside the docker. Only netstat shows that 8000 is listening but not lsof why The image below shows the commands run inside the docker -
Google login using OpenID Connect in a React and Django web application
I'm new to React, Python and Django and trying to add to my web app the option to login with Google. The security aspect is very important to me so I make sure I understand and implement everything correctly according to Google OpenID Connect Documentation, but I run into all kinds of questions that I can't find any answers to them on the web. and hope you can help me to uderstand and find the right solutions. My web app composed from two main components: A frontend SPA based on React. A backend rest API server based on Django. As I understand, in such case, the reccomended grant type is authorization code. because I have a backend server that can fetch the token directly from Google without exposing it to the client browser. I started with the frontend part: Google recommend using their Google Sign-In, but I'm not sure how I use it in a React component. So I searched online and found the following implementation react-google-login. I tried using it and it worked, but when I started to check it a little more deeply I found that its not following Google OpenID Connect Documentation. I can't make it work … -
Queries with one item in the list in `__in` are extremely slow. Otherwise, super fast
I am retrieving event_id's by name with the code below: events = Events.objects.values_list('event__id', flat=True). \ filter(name__in=names).distinct() Everything is working great except when names consist of just one name. If I change my code to: events = Events.objects.values_list('event__id', flat=True). \ filter(name__in=names + ['x']).distinct() Once again, it becomes super fast. I am seriously going crazy cause this makes no sense. I used print(events.query) and it uses the same query basically, just the list changes. How is this possible? The execution time with one name in the list lasts for 30-60secs, otherwise it takes just 100-1000ms. The amount of event_ids don't change dramatically, so it's not the size issue. -
ValueError: <Registration: 749>" needs to have a value for field "id" before this many-to-many relationship can be used
I'm building a race registration application in django and I'm having trouble saving a many2many field of my model in a CreateView generic view. I am excluding the event field from the view because it allows you to select an event rather than having it automatically generated from the slug in the url. I was able to get the event object based on the URL using the slug in the get_context_data method. I have also tried form.instance.event = event in the form_valid method but it doesn't seem to be working here. I haven't worked with many2many fields before and I'm currently at a snag. Any help is greatly appreciated. I am receiving a ValueError: "" needs to have a value for field "id" before this many-to-many relationship can be used. views.py class RegistrationCreateView(CreateView): model = Registration fields = ['car_year', 'car_manufacture', 'car_model', 'race_number', 'race_class'] def get_context_data(self, *args, **kwargs): slug = self.kwargs['slug'] event = Event.objects.get(slug=slug) context = super().get_context_data(**kwargs) context['slug'] = slug context['event'] = event return context def form_valid(self, form): form.instance.driver = self.request.user try: event = Event.objects.get(id=self.request.POST['event']) except: event = None print("test") form.instance.event.add(event) return super().form_valid(form) urls.py from django.urls import path from . import views app_name = "events" urlpatterns = [ path( route='add/', view=views.EventCreateView.as_view(), … -
Get column names where searched value was found in Django
I have query that performs full text search on several columns (including on columns of models related using FK) in Django: from django.contrib.postgres.search import SearchVector, SearchQuery, SearchRank class TaskManager(models.Manager): def search_by_text(self, text: str): search_vector = SearchVector( "task_type__name", "order__registration_number", "order__report_number", "car_owner_name", "task_number", "order__customer_order_number", "order__customer_owner", "order__report_type__value", ) search_query = SearchQuery(text) return self.get_queryset().annotate( rank=SearchRank(search_vector, search_query) ).order_by("rank") How can I get not only found records but also column names where searched value was found for each record? Example: >>> Entry.objects.search_by_text("some value")[0].columns_matched ["task_type__name", "task_number"] I'm using Postgresql 10.12 and Django 2.2.10. -
TypeError: __str__ returned non-string (type int), error in Django application
My model is given below. class Year(models.Model): INT_CHOICES = [(x, x) for x in range(1, 14)] year=models.PositiveIntegerField(choices=INT_CHOICES, primary_key=True) student_count= models.IntegerField() assignment_count = models.IntegerField() tutor=models.CharField(max_length=200) def publish(self): self.save() def __str__(self): return self.year When i run the below code in python shell the following error occurs. There are some duplicate data in the Year table. I added those before making 'year' a primary key. >>> Year.objects.all() Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/agusmathew/myvenv/lib/python3.6/site-packages/django/db/models/query.py", line 253, in __repr__ return '<%s %r>' % (self.__class__.__name__, data) File "/Users/agusmathew/myvenv/lib/python3.6/site-packages/django/db/models/base.py", line 519, in __repr__ return '<%s: %s>' % (self.__class__.__name__, self) TypeError: __str__ returned non-string (type int) -
Calculate Age in Django Model with database connection
I have seen many examples of calculating age in a django model (such as this question). However, most do not have a connection to a database and are simply empty models to be used in pushing to a database. To simplify my example, I have a django model of records of people connected to a SQL Server. I want to, when I query from the DB, also calculate the current age of the person. If I call age in my view, I get the following error: Cannot resolve keyword 'age' into field How can I do this, even though age is not a current database field? class Person(model.Model) personid = models.IntegerField(db_column='PersonId', primary_key=True) birth_date = models.DateField(db_column='DOB') @property def get_age(self): return relativedelta(self.birth_date.days, datetime.date.now()).years def save(self, *args, **kwargs): self.age = self.get_age() super(Person, self).save(*args, **kwargs) -
Problem with updating the css file used in my Django project
I am creating my first Django project and I want to create a css stylesheet for my project. The css file that I want to use is /static/css/main.css. I load the static file in my base.html template using: {% load static %} <head> <link rel="stylesheet" href="{% static 'css/main.css' %}"> </head> The problem is that when I edit and save the main.css file, no change is visible on any of the webpages. When I checked the url 127.0.0.0:8000/static/css/main.css, it shows the css file, but only the old version before I edited it. I tried restarting both the development server and my virtualenv and making sure that I have saved the changes, but neither resolved the issue. When I viewed the page source code and clicked on the link to the css stylesheet, it still showed the old version on the url 127.0.0.0:8000/static/css/main.css. When I add styling inside the <style></style> tags, it works just fine. How do I make it so that it shows the new version of the css file? -
Django for loop checkboxes with same 'name', and then wanting to delete multiple instances
So in my Django template I have the following: upload_file.html <tbody> {% for file in files %} <tr> <td><a href="{{ file.file.url }}" download> {{ file.file }} </a></td> <td style="width: 185px;">{{ file.날짜 }}</td> <td style="width: 80px;">{{ file.file.size|filesizeformat }}</td> <td> <form method="POST" action="{% url 'delete_file' file.pk %}"> //want to change part like this<input type="checkbox" class="btn btn-danger btn-sm">Delete</input> {% csrf_token %} <button type="submit" class="btn btn-danger btn-sm">Delete</button> </form> </td> </tr> {% endfor %} </tbody> Which prints out a list of the members on the webpage, each with a submitbutton next to them. When I want to delete members I use a view in views.py def delete_file(request, pk): if request.method == 'POST': file = File.objects.get(pk=pk) file.delete() return redirect('upload_file') in urls.py path('files/'<'int:pk'>'/', views.delete_file, name='delete_file'), -
How to execute a binary file using shell Script inside a Docker Container?
I am running a Django app inside a Docker Container. I am calling a shell script to execute some tasks (I call this shell script using a python function not as docker command). It works fine when I am running it without the container. Both the shell file and Binary files are in the same directory. Following is the Sell script ./dsk -nb-cores 1 -max-memory 300 ./dsk2ascii Error showing was line 16: ./dsk: Is a directory line 17: ./dsk2ascii: No such file or directory -
Pass "form_class" to CreateView from url
It is possible to pass template to a Generic View from URL? path('address/', ListView.as_view(template_name='template.html')) But if I try doing it with form_class I get an error path('address/', CreateView.as_view(form_class='CreateForm')), I understand I can override it inside the class, but is it possible to do from URL? -
Django:SESSION_COOKIE_AGE is not working in Brave browser
settins.py SESSION_COOKIE_AGE = 6 I just set a SESSION_COOKIE_AGE that current log-in user will logout after 6 second.This is working in all famous browsers but in brave browser it is not working.Even after closing the brave browser user is logIn but Why this is only happen in brave browser. -
Difference between current datetime and DateTimeField
I'm been trying to get the difference between a DateTimeField and the current datetime Below is how I currently query objects: comment = Comment.objects.filter(ticket=ticket) The above query returns: comment user date_added I would like to compute the time that has passed since the comment was posted (like this -> ) I tried the code below but I'm getting the following: AttributeError: 'datetime.time' object has no attribute 'split' comment = Comment.objects.filter(ticket=ticket).annotate(duration=Func(F(datetime.datetime.now()) - F('comment_date_added'), function='age')) I'm thinking of extracting the date values as showing in https://docs.djangoproject.com/en/3.0/ref/models/database-functions/ and handle the calculation of the time difference on the frontend but I was wondering if I missed something or if there are better ways to solve this. Any help is much appreciated. -
Multiple language Api
What is the best way to implement a multi language http api with django and django rest framework? we have a client that can be use by people with different languages,in our app we have entities with detail, we want that detail be available in different languages per user by their preferences. Should I use different table for different languages?or there is a framework related solution?or an software architecture for this problem? Thank you. -
Django Rest Framework Email Validation invalid
I want to update a "employee" instance by sending PUT requests to Django Rest Framework. The Put requests fail due to failed email validation. model.py: class Employee(models.Model): Employees_id = models.AutoField('ID', primary_key=True) Employees_acn = models.CharField('Mitarbeiternummer', max_length=10) Employees_first = models.CharField('Vorname', max_length=200) Employees_last = models.CharField('Nachname', max_length=200) Employees_mail = models.EmailField('E-Mail', null=True, blank=True) Employees_deleted = models.BooleanField('Gelöscht', default=False) serializer.py: class EmployeeSerializer(serializers.ModelSerializer): class Meta: model = Employee fields = '__all__' views.py: class Employee(APIView): permission_classes = [IsAuthenticated,BelongsToClient] serializer_class = EmployeeSerializer def put(self, request, pk, format=None): try: employee = EmployeeModel.objects.filter(Employees_deleted= False).get(pk=pk) except EmployeeModel.DoesNotExist: return HttpResponse(status = 404) serializer = EmployeeSerializer(employee, data=request.data) if serializer.is_valid(): serializer.save() return Response(status=status.HTTP_200_OK) print(serializer.errors) return Response(serializer.data,status=status.HTTP_400_BAD_REQUEST) The failure doesn't depend on which email address I enter. All request I've tried failed. This is the error message (serializer.errors): {'Employees_mail': [ErrorDetail(string='Enter a valid email address.', code='invalid')]} I have no validation in my serializers class. Why do I get this validation error? Do I have to make any settings? -
Issue while hitting the external domain URL from Ajax
I have an API url http://127.0.0.1:5000/ that inputs image file and return the json value. Following is my HTML code, <form action="" enctype="multipart/form-data" id="myform" method="post"> {% csrf_token %} <br><br> <input type="file" id="file" name="file"/><br><br> <button type="button" class="btn btn-primary" id="add">Add To Table</button> </form> and here my ajax Code, <script> $("#add").click(function () { var files = $("#file")[0].files[0]; var fd = new FormData(); fd.append('file','files'); $.ajax({ url : "http://127.0.0.1:5000/", crossDomain : true, dataType : "jsonp", enctype: 'multipart/form-data', processData: false, contentType: false, cache: false, timeout: 600000, data : fd, success : function (data) { alert(data); } }); }); </script> When I execute the above code, in the console of Chrome, I can find this internal error. jquery-3.1.1.min.js:4 GET http://127.0.0.1:5000/?callback=jQuery31105839558115979158_1587729619868&[object%20FormData]&_=1587729619869 net::ERR_ABORTED 500 (INTERNAL SERVER ERROR) Can any one tell me why this error occuring and how can I resolve this ? Forgive me, I'm new to Ajax and rest APIs. Thanks.