Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Form Inheritance
I am trying to subclass a form and I need to get all args/kwargs from the main form. I know pythonic way but is there something I need to do for Django specifically. Main Form: class BasketLineForm(forms.ModelForm): save_for_later = forms.BooleanField( initial=False, required=False, label=_('Save for Later')) def __init__(self, strategy, *args, **kwargs): super(BasketLineForm, self).__init__(*args, **kwargs) self.instance.strategy = strategy max_allowed_quantity = None num_available = getattr(self.instance.purchase_info.availability, 'num_available', None) basket_max_allowed_quantity = self.instance.basket.max_allowed_quantity()[0] if all([num_available, basket_max_allowed_quantity]): max_allowed_quantity = min(num_available, basket_max_allowed_quantity) else: max_allowed_quantity = num_available or basket_max_allowed_quantity if max_allowed_quantity: self.fields['quantity'].widget.attrs['max'] = max_allowed_quantity def clean_quantity(self): qty = self.cleaned_data['quantity'] if qty > 0: self.check_max_allowed_quantity(qty) self.check_permission(qty) return qty def check_max_allowed_quantity(self, qty): qty_delta = qty - self.instance.quantity is_allowed, reason = self.instance.basket.is_quantity_allowed(qty_delta) if not is_allowed: raise forms.ValidationError(reason) def check_permission(self, qty): policy = self.instance.purchase_info.availability is_available, reason = policy.is_purchase_permitted( quantity=qty) if not is_available: raise forms.ValidationError(reason) class Meta: model = Line fields = ['quantity'] SubForm to Inherit Main Form in different app: class BatteryForm(CoreBasketLineForm): class Meta(CoreBasketLineForm.Meta): model = Batteries fields = ('title', 'price', 'comment') -
how to get value of select field in django without any forms.py
I have only this select field i want to get value of this field .I do not have any forms, i just want to get the data from this field <label>Portal Language:</label> <select name="language"> {% get_available_languages as LANGUAGES %} {% for lang in LANGUAGES %} <option> {{ lang.1 }} </option> {% end for %} </select> -
How to make model property to editable in djagno admin panel
When I tried to add property into the list_editable into the Django admin.py file, I got an error when running the server. <class 'test_project.admin.SalesAdmin'>: (admin.E100) The value of 'list_editable[2]' refers to 'amount', which is not an attribute of 'test_project.Sales'. -
Github Issue and travis returning errors - python
I'm a student participating in Google Code-In. There's a task in which I need to fix this issue on GitHub. My Travis build is failing and here's my PR. An exception need to be raised and I must check for it. I don't really want everything given to me, just some kind of help so that I can move forward. Anything would be welcome, thanks! -
what does get_expiry_age() return in Django
Instead of returning actual seconds left for expiry, request.session.get_expiry_age() returns fixed value=10 set in request.session.set_expiry(10). But when I manually set request.session['var1']=1 in homepage and then try to print this var1 in another view, I get KeyError after 10 seconds, saying 'var1' doesnt exist. So this session does expire after 10 seconds. So ideally if i wait on homapge for 5 seconds and then move to another view, request.session.get_expiry_age() should return 5 seconds instead of 10 seconds. Django doc contradict this observation. Is there any other inbuilt function that can show actual seconds left for session expiry. Thanks -
Django How to send data from view to template
model.py class Peer(models.Model): router = models.ForeignKey(Router, on_delete=models.CASCADE) ipv4_address = models.CharField(max_length=250) remote_as = models.CharField(max_length=250) I have a custom button in Django admin Change form <input type="submit" value="Test Peer" name="_peer-test"> Then in admin.py def response_change(self, request, obj): if "_peer-test" in request.POST: self.message_user(request, "Peer Tested") url = request.POST.get('obj', '/peeringmanager/export') remote_as = obj.remote_as url += "?remote_as={}".format(remote_as) return HttpResponseRedirect(url) So I sent the data (remote_as) from the obj to another view views.py def export(request): remote_as = request.GET.get('remote_as','') selected_peer = Peer.objects.filter(remote_as__exact=remote_as) template= loader.get_template('delete-peer.html') content= { 'selected_peer':selected_peer, } return HttpResponse(template.render(content,request)) Here I want to use remote_as object to get all object in the form related to that Remote_as and sent it to a html. delete-peer.html {% block content %} {% for peer in content %} <p>{{ peer.remote_as }}</p> {% endfor %} {% endblock %} But I don't get any Data in HTML. any Idea? of a better way? -
Django URL Dispatcher not matching unicode slug
I'm currently trying to process a request using unicode-enabled slugs. i.e., '127.0.0.1:8080/æøå/' works fine for the generic ListView: path('<slug>/', ServiceList.as_view(), name='service-list'), but fails on the DetailView with 0 matches in the SQL query: path('<slug>/', ServiceDetail.as_view(), name='service-detail'), No further errors are given. Am I missing some unicode conversion between the request and the database (SQLite3)? -
Dynamically create serializer based on model field value
I have a model like so: class A: name = models.CharField() group = models.ForeignKey('SomeModel', null=True, blank=True) When I serialize this, I would like the serielizer to have different formats based on whether the 'group' field is blank or not. Of course this can be achieved by having different serializers for different formats and calling them as required in the View layer: class TypeASerializer(serializers.ModelSerializer) class Meta: model = A fields = ('id', 'name') class TypeBSerializer(serializers.ModelSerializer) class Meta: model = A fields = ('id', 'name', 'group') But I wanted to handle it in the serializer layer itself and have a single serializer for this. Is that possible? -
What is the simplest way to create Sign Up form without username. (require only email and password)
I want to create SignUp and Login form with only email and password. Also it means I need CustomUser model without username. I know this question is the one someone else already asked but I couldn't find a good and recent resource of this. Is there anyone could help me? I am really having trouble with this... -
How to filter all the details of a particular data field from one model (Product) and populate it into form
I have a 'Product' Model in which all the details of a product is available and I have a 'Order' Model with Foreign Key of Product Model. I want a dropdown list in From.html with all product name of Product model and if I select any one of them then all the details should automatically filled in the input field. I applied this concept on a particular field like this: Product.objects.filter(pname='Lenovo K8 Plus').values('pname','catgry','brand') From.Html <form class="well form-horizontal" method="post" action="{% url 'new_order' %}"> {% csrf_token %} <fieldset> <div class="form-group"> <label class="col-md-4 control-label">Select Product</label> <div class="col-md-6 inputGroupContainer"> <div class="input-group"> <span class="input-group-addon" style="max-width: 100%;"><i class="glyphicon glyphicon-list"></i></span> <select class="selectpicker form-control" name="pname"> {% for n in ListPrdt %} <option>{{n.pname}}</option> {% endfor %} </select> </div> </div> </div> <div class="form-group"> <label class="col-md-4 control-label">Category Name</label> <div class="col-md-6 inputGroupContainer"> <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> {% for n in ListPrdt %} <input id="fullName" name="catgry" placeholder="Full Name" class="form-control" required="true" value="{{n.catgry}}" type="text"> {% endfor %} </div> </div> </div> <div class="form-group"> <label class="col-md-4 control-label">Brand Name</label> <div class="col-md-6 inputGroupContainer"> <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> {% for n in ListPrdt %} <input id="fullName" name="brand" placeholder="Full Name" class="form-control" required="true" value="{{n.brand}}" type="text"> {% endfor %} </div> </div> </div> <div class="form-group"> <label class="col-md-4 control-label">Quantity</label> <div class="col-md-6 inputGroupContainer"> <div … -
wsgi_module not found on windows
The wsgi_module loaded as shown in the log below: [Mon Dec 10 10:39:39.048697 2018] [wsgi:info] [pid 16708:tid 692] mod_wsgi (pid=16708): Python home c:/users/.../appdata/local/programs/python/python37. [Mon Dec 10 10:39:39.048697 2018] [wsgi:info] [pid 16708:tid 692] mod_wsgi (pid=16708): Initializing Python. [Mon Dec 10 10:39:39.081683 2018] [wsgi:info] [pid 16708:tid 692] mod_wsgi (pid=16708): Attach interpreter ''. [Mon Dec 10 10:39:39.084682 2018] [wsgi:info] [pid 16708:tid 692] mod_wsgi (pid=16708): Adding 'E:/projects/python/...' to path. [Mon Dec 10 10:39:39.089662 2018] [wsgi:info] [pid 16708:tid 692] mod_wsgi (pid=16708): Imported 'mod_wsgi'. But at the apache modules, the wsgi_module says, No module file as shown in the picture below: It is my http.conf lines which are associated with the mod_wsgi: LoadFile "c:/users/.../appdata/local/programs/python/python37/python37.dll" LoadModule wsgi_module "c:/users/.../appdata/local/programs/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "c:/users/.../appdata/local/programs/python/python37" WSGIPythonPath "E:/projects/python/..." WSGIScriptAlias /scripts "E:/projects/python/.../.../wsgi.py" DocumentRoot "E:\\projects\\python\\...\\...\\..." <Directory "E:\\projects\\python\\...\\...\\..."> <Files wsgi.py> Allow From all </Files> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options +Indexes +FollowSymLinks +Multiviews +ExecCGI # # AllowOverride controls what directives may … -
Fullcalendar with Django does not save events
I connected the fullcalendar to my django project and now when I save events from the month view, everything works, but as soon as I switch to the day or week display, the events are not saved to the database. However, there are no errors. fullcalendar script <script> $(document).ready(function() { $('#calendar').fullCalendar({ dayClick: function(date, jsEvent, view) { var clickDate = date.format(); $('#start-date').val(clickDate); $('#dialog').dialog('open'); }, eventSources: [ { events: [ {% for i in events %} { title: "{{ i.event_name}}", start: '{{ i.start_date|date:"Y-m-d" }}', end: '{{ i.end_date|date:"Y-m-d" }}', }, {% endfor %} ], } ] }); //add new event $( "#dialog" ).dialog({ autoOpen: false, show: { effect: 'drop', duration: 500 }, hide: { effect: 'clip', duration: 500 } }); $('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' }); }); </script> views.py def event(request): all_events = Events.objects.all() if request.method == 'POST': event_form = ModelEventsForm(request.POST) if event_form.is_valid(): update = event_form.save(commit=False) update.owner = request.user.profile start_date = event_form.cleaned_data['start_date'] update.save() return redirect('events:event') else: event_form = ModelEventsForm() context = { "events": all_events, 'event_form': event_form } return render(request, 'profile/event_management.html', context) models.py class Events(models.Model): owner = models.ForeignKey(Profile, blank=True, null=True, on_delete=models.CASCADE) event_name = models.CharField(max_length=255, null=True, blank=True) start_date = models.DateTimeField(null=True, blank=True) end_date = models.DateTimeField(null=True, blank=True) event_type = models.CharField(max_length=10, null=True, blank=True) -
Danjgo: Unsupported lookup 'case_exact' for CharField or join on the field not permitted
This is the GET request hitting on my server. HTTP GET /testPage/?persona_name=Aman&key_name=country&key_label=My+Country&key_value=India&Save=Submit 500 With the help of this view i am fetching the values from GET request. def PersonaSave(request): persona_name = request.GET.get('persona_name',) persona_key = request.GET.get('key_name',) persona_key_value = request.GET.get('key_value',) persona_key_label = request.GET.get('key_label',) persona_submit = request.GET.get('Save',) return( persona_name , persona_key , persona_key_label , persona_key_value , persona_submit Now following is the function where i am checking whether object with the given persona name exists or not. If it exists then i am updating the values if it is a new persona then i am making new testPersona object. def TestPageView(request): x=PersonaSave(request) persona_name = x[0] persona_key = x[1] persona_key_label=x[2] persona_key_value=x[3] persona_submit=x[4] testPersonaName = TestPersonaName(name=persona_name) testPersonaName.save() if(persona_name is None and persona_key is None and persona_key_label is None and persona_key_value is None): return render(request, 'dashboard/test_page.html') # Below is the function for updating testPersona . elif TestPersonaName.objects.filter(name__case_exact=persona_name).exists(): testpersona = TestPersona.objects.get(name__case_exact=persona_name) if testpersona.key == persona_key: testpersona.label= persona_key_label testpersona.value = persona_key_value testpersona.save() #If persona with new name is detected then saving a new testPersona object. testpersona=TestPersona(name=persona_name,key=persona_key,label=persona_key_label,value=persona_key_value) testpersona.save() return render(request,'dashboard/test_page.html') Following is the error that i am getting. django.core.exceptions.FieldError: Unsupported lookup 'case_exact' for CharField or join on the field not permitted. Below are TestPersona and TestPersonaName models. class TestPersonaName(models.Model): name … -
django rest frame work filter a serializer field
i had django api and its serializer and models... i use filters like this: class OrderFilter(django_filters.FilterSet): class Meta: model = Dealer fields = { 'first_name': ['icontains', 'exact'], 'last_name': ['icontains', 'exact'], 'mobile': ['icontains', 'exact'], 'is_active': ['exact'], 'agent': ['exact'], } all of this fields was django model field but in my serializer i have a SerializerMethodField like this: class DealerListSerializer(serializers.ModelSerializer): online = serializers.SerializerMethodField() def get_online(self, obj): r = Redis.get_instance().conn key = settings.ONLINE_PREFIX.format(obj.id) if r.get(key): return True return False i would like to apply filter on online field. class OrderFilter(django_filters.FilterSet): online = django_filters.rest_framework.BooleanFilter(method='filter_online') def filter_online(self, queryset, name, value): ????? class Meta: model = Dealer fields = { 'first_name': ['icontains', 'exact'], 'last_name': ['icontains', 'exact'], 'mobile': ['icontains', 'exact'], 'is_active': ['exact'], 'agent': ['exact'], 'online': ['exact'], } what should I do? thanks -
to separate search keyword with its response of google search api
Am having many cases here. in google API i first tried sending restricted site parameter suppose 'companysite' and query parameter as 'keyword' then i get response which can be stored easily as for keyword and company name but this type of call increases my api call if am having companysite with many keywords assigned to it,suppose am having a company having 4 keywords to it then i have to give 4 separate api call ,to over come it i used allintext:("keyword1" OR "keyword2")"Weber Automotive" for which i get some api response,but google api gives mixed response for both keywords then how to differenciate the keyword with its response? kindly help -
Django - Q Object much slower than doing separate queries
I have the following model: class Address(models.Model): full_address = models.CharField(max_length=80, db_index=True) alternative_address = models.CharField(max_length=80, db_index=True) I'm querying for a particular address, which can either match full_address or alternative_address. The obvious solution is to use a Q object. But for some reason, using a Q object makes the query much slower. address = '123 Main Street' # This query using Q object takes 500ms (10x slower) addresses = Address.objects.filter(Q(full_address__startswith=address) | Q(alternative_address__startswith=address)).values(...) # This solution, which returns the same results, takes just 50ms addresses1 = Address.objects.filter(full_address__startswith=address) addresses2 = Address.objects.filter(alternative_address__startswith=address) addresses = (addresses1 | addresses2).values(...) Is this supposed to happen? I think using a Q object in this case should be faster, not slower, right? -
Some static images are not loading in Django Templates
I'm working on a project using Django(1.10) in which I need to load some images in Django templates, But I'm wondering some images are loading but some are not loading even exists in the static_root folder. Here are my models: class AddedFile(models.Model): image_name = models.CharField(max_length=3000, blank=True, null=True) file_name = models.CharField(max_length=3000, blank=True, null=True) def __str__(self): return str(self.id) class Products(models.Model): name = models.CharField(max_length=100, blank=True, null=True) description = models.TextField(max_length=200, blank=True, null=True) image = models.ForeignKey(AddedFile, on_delete=models.CASCADE, null=True) category = models.ForeignKey(Categories, on_delete=models.CASCADE, null=True) parent_product_id = models.IntegerField(null=True) product_type = models.CharField(max_length=100, blank=True) regular_price = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True) sale_price = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True) quantity = models.IntegerField(default=0) sku_no = models.CharField(max_length=100, blank=True, null=True) variant = models.CharField(max_length=100, blank=True, null=True) tax_able = models.BooleanField(default=False) enable_flag = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return str(self.id) Here's from views.py: def product_add(request): user_type = '' try: user_type = request.session['user_type'] except Exception as e: print(e) if user_type == 'admin': if request.method == "POST": try: cat_id = request.POST['cat_id'] description = request.POST['description'] img = request.POST['img'] name = request.POST['name'] product_type = request.POST['product_type'] tax_able = request.POST['tax_able'] if product_type == 'simple': regular_price = request.POST['regular_price'] sale_price = request.POST['sale_price'] sku = request.POST['sku'] quantity = request.POST['quantity'] if img: get_img = [] try: directory_base = settings.STATIC_ROOT image = img.split(";base64,") extens = … -
select languages using django get_available_languages
I have a portal language field i want dropbox to select the language.can we use django get_available_languages to implement this. models.py class OtherDetails(models.Model): portal_language = models.CharField(max_length=128) forms.py class OtherDetailsForm(forms.ModelForm): widgets = { 'portal_language': forms.TextInput(attrs={'placeholder': _('Portal language')}), } template.html {{ otherdetails_form.as_p }} -
Assigning current 'User' as foreign key to nested serializers
I am trying to assign current 'User' to two models using nested serializers. class UserAddressSerializer(serializers.ModelSerializer): class Meta: model = UserAddress fields = ('user', 'address_1', 'address_2', 'country', 'state_province', 'city', 'zip_code') class UserProfileSerializer(serializers.ModelSerializer): user_address = UserAddressSerializer() user = serializers.HiddenField(default=serializers.CurrentUserDefault()) class Meta: model = UserProfile fields = ('user', 'first_name', 'middle_name', 'last_name', 'title', 'display_name', 'time_zone', 'user_address', 'default_office') def create(self, validated_data): user = validated_data.pop('user') user_address_data = validated_data.pop('user_address') user_address_object = UserAddress.objects.create( user=user, **user_address_data) user_profile_object = UserProfile.objects.create( user=user, **validated_data) return user What I am getting is this output in Postman. { "user_address": { "user": [ "This field is required." ] } } I want to know a way to pass 'User' to both of these model creation. -
Django create fallback database if entry does not exist in one
Right now, I have two databases, english and native. The functionality I'm trying to achieve is, if an entry does not exist in my native database, it should fall back to the english database to retrieve the data. I know I can do this by explicitly specifying the database name followed by a couple of try except blocks but I was wondering if there was a way to directly configure the database router to do this for me. -
Django - Query based on model fields combined together
Assuming we have an Address model with details of a particular address: class Address(models.Model): street = models.CharField(max_length=100) city = models.CharField(max_length=100) Let's say we want to filter for the following address: my_address = 123 Main Street Toronto Is there some way to combine street and city to perform a query? Like: Address.objects.filter(street + ' ' + city=my_address) This is just an example. Please do not suggest an alternate solution like splitting my_address into street and city. -
what is the best way to do django relational?
I just learn to program Django, and until now when creating models and relation i always write it like this : class Car(models.Model): name = models.CharField(max_length=30) def __str__(self): return self.name class Factory(models.Model): name = models.CharField(max_length=30) car = models.ForeignKey(Car, on_delete=models.PROTECT, null=True) def __str__(self): return self.name but now my models seems cant used when im learning to use admin.StackInline to add extra car when i want to add new data for factory in my admin, is there any problem with my code? what is the best practice for relating a models in Django? thanks -
How create your custom auth system in django?
I want to create login, register and other pages for authentification, but without using User model and not extending it(this is necessarily). How can I do these type of things in django? I'm asking because I can't find any sources with answers for this question, and also I'm just started using django? -
Django CKEditor: ModuleNotFoundError when deploying to Heroku
I'm getting an error in my logs when deploying my Django application to Heroku, but only when using the django-ckeditor package. CKEditor runs just fine locally, and earlier versions of the application work fine both locally and on Heroku without CKEditor, so I know that's the problem. I've retraced my steps and can't figure out where I went wrong. Here are my following logs... Heroku Logs 2018-12-10T03:03:16.513649+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 2018-12-10T03:03:16.513651+00:00 app[web.1]: return self.load_wsgiapp() 2018-12-10T03:03:16.513652+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp 2018-12-10T03:03:16.513654+00:00 app[web.1]: return util.import_app(self.app_uri) 2018-12-10T03:03:16.513656+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app 2018-12-10T03:03:16.513657+00:00 app[web.1]: __import__(module) 2018-12-10T03:03:16.513659+00:00 app[web.1]: File "/app/JayNautic/wsgi.py", line 16, in <module> 2018-12-10T03:03:16.513660+00:00 app[web.1]: application = get_wsgi_application() 2018-12-10T03:03:16.513662+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2018-12-10T03:03:16.513664+00:00 app[web.1]: django.setup(set_prefix=False) 2018-12-10T03:03:16.513665+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup 2018-12-10T03:03:16.513667+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS) 2018-12-10T03:03:16.513669+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate 2018-12-10T03:03:16.513670+00:00 app[web.1]: app_config = AppConfig.create(entry) 2018-12-10T03:03:16.513672+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create 2018-12-10T03:03:16.513674+00:00 app[web.1]: module = import_module(entry) 2018-12-10T03:03:16.513675+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module 2018-12-10T03:03:16.513677+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2018-12-10T03:03:16.513718+00:00 app[web.1]: ModuleNotFoundError: No module named 'ckeditor' 2018-12-10T03:03:16.514092+00:00 app[web.1]: [2018-12-10 03:03:16 +0000] [10] [INFO] Worker exiting (pid: 10) 2018-12-10T03:03:16.517239+00:00 app[web.1]: 2018-12-10T03:03:16.518081+00:00 app[web.1]: [2018-12-10 03:03:16 … -
How to Set up Visual Studio Code to Debug Requests with python and Django?
Python:3.3.5 Django: 1.8 IDE: VSCode Server:Apache 2.4 Mod_wsgi:4.4.6 Test tool:Postman My project like this: /A /B /subfolder test.py manage.py settings.py launch.json: { "name": "Django test", "type": "python", "request": "launch", "console": "integratedTerminal", "pythonPath": "C:/Python33/python.exe", "program": "${workspaceFolder}/B/manage.py", "args": [ "runserver", "--noreload", "--nothreading" ], // "debugOptions": [ // "WaitOnAbnormalExit", // "WaitOnNormalExit", // "RedirectOutput", // "DjangoDebugging" // ], "django": true }, manage.py: if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) I try to set breakpoint at test.py but not working, it can not stop at the breakpoint, I ensure the server is runing and test.py can work, and terminal output don't show error message. When I used postman to post, the status is 200,and test.py return my string "ok".