Category : django

@api_view([‘POST’]) def savetoken(request): if request.method==("POST"): saveserialize=Tokenserialize(data=request.data) if saveserialize.is_valid(): saveserialize.save() return Response(saveserialize.data,status=status.HTTP_201_CREATED) return Response(saveserialize.data,status=status.HTTP_400_BAD_REQUEST) def inserttoken(request): if request.method=="POST": apiId = request.POST.get(‘apiId’) invoiceNumber = request.POST.get(‘invoiceNumber’) totalAmount = request.POST.get(‘totalAmount’) currency = request.POST.get(‘currency’) redirectUrl = request.POST.get(‘redirectUrl’) cancelUrl = request.POST.get(‘cancelUrl’) orderTime = request.POST.get(‘orderTime ‘) tipAmount = request.POST.get(‘tipAmount ‘) tipAllowed = request.POST.get(‘tipAllowed ‘) paymentType = request.POST.get(‘paymentType’) paymentMode = request.POST.get(‘paymentMode’) data = ..

Read more

I want to set an initial value "test" to the field name when I’m uploading a file with a Django. Here is what I tried in views.py: class UploadFile(CreateView): form_class = UploadFileForm template_name = "tool/upload.html" success_url = reverse_lazy(‘tool:index’) fields = [‘file’,] def get(self, request, *args, **kwargs): form = self.form_class() return render(request, self.template_name, {‘form’: form}) def ..

Read more

I am following this tutorial. https://medium.com/free-code-camp/elasticsearch-with-django-the-easy-way-909375bc16cb#.le6690uzj Tutorial is about using elasticsearch with django app. I am stuck when it ask to use bulk_indexing() in shell. I am getting this error ** raise ValueError("You cannot perform API calls on the default index.") ValueError: You cannot perform API calls on the default index.** >>>python manage.py shell Python ..

Read more

I have a view that performs some basic calculations, but sometimes not all fields have values added, so the calculations fail due to trying to do calculations that do exist. Is there a way to say if any fields contain null or blank then pass or do i need to write a if for every ..

Read more

I do e-commerce in django. I have Category model that I want to work with both django.parler and django-MPTT, because I want to make subcategories for category. I’ve done everything like in django-parler documentation to connect these two packages the right way. After saving the model, the following error appears: ImproperlyConfigured at /pl/admin/store/category/ TreeQuerySet class ..

Read more