From 2e540e8109e87f668ec38a8f75c329bf0499e1fa Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Mon, 27 Oct 2025 16:50:20 +0330 Subject: [PATCH] change user validation from national_code to user name --- apps/authentication/api/v1/serializers/serializer.py | 8 ++++---- logs/django_requests.log | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/authentication/api/v1/serializers/serializer.py b/apps/authentication/api/v1/serializers/serializer.py index 77a4402..a71f3fb 100644 --- a/apps/authentication/api/v1/serializers/serializer.py +++ b/apps/authentication/api/v1/serializers/serializer.py @@ -109,17 +109,17 @@ class UserSerializer(serializers.ModelSerializer): def validate(self, attrs): mobile = attrs['mobile'] - national_code = attrs['national_code'] + username = attrs['username'] if not self.instance: - if self.Meta.model.objects.filter(Q(mobile=mobile) | Q(national_code=national_code)).exists(): + if self.Meta.model.objects.filter(Q(mobile=mobile) | Q(username=username)).exists(): raise UserExistException() elif self.instance: if self.instance.mobile != mobile: if self.Meta.model.objects.filter(mobile=mobile).exists(): raise UserExistException() - if self.instance.national_code != national_code: - if self.Meta.model.objects.filter(national_code=national_code).exists(): + if self.instance.username != username: + if self.Meta.model.objects.filter(username=username).exists(): raise UserExistException() return attrs diff --git a/logs/django_requests.log b/logs/django_requests.log index a19b04e..543bd9e 100644 --- a/logs/django_requests.log +++ b/logs/django_requests.log @@ -39,3 +39,7 @@ [2025-10-27 16:26:54,114] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\core\api.py changed, reloading. [2025-10-27 16:26:55,924] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader [2025-10-27 16:37:24,219] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authorization\api\v1\api.py changed, reloading. +[2025-10-27 16:37:26,220] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-10-27 16:47:09,174] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading. +[2025-10-27 16:47:13,725] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-10-27 16:49:53,321] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading.