My Django project is currently deployed in a test remote server using nginx/gunicorn/supervisor.
I try to update minor change 'on the fly' remotly.
I have a field with expected format: XXX-YY-000
I have added Jquery field mask on a field (AAA-AA-999) and want the user be able to enter lowercase but want to store result in database in uppercase
Moreover, I have form validation:
So I modify by code entries using upper() method
Locally, it works but on remote server it doesn't work. I don't know how to 'debug' to see what is pass to my patient_code_is_valid function...
forms.py
def clean_ran_num(self):
data = self.cleaned_data['ran_num'].upper()
if len(data) != 10:
raise forms.ValidationError(_("Error on Patient code number format (example: XXX-YY-000)"))
if not patient_code_is_valid(data):
raise forms.ValidationError(_("Error on Patient code number: country code does not correspond to site code"))
return data
models.py
def patient_code_is_valid(code):
site = code[4:6].upper()
pays = code[:3].upper()
site_list = [s.sit_abr for s in Site.objects.all()]
pays_list = [p.pay_abr for p in Pays.objects.all()]
if site in site_list and pays in pays_list:
a = Site.objects.get(sit_abr = site).reg.pay.pay_ide
b = Pays.objects.get(pay_abr = pays).pay_ide
if a == b:
return True
return False
only had to restart server to have modfication kaken into account sudo supervisorctl restart myproject
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.