fix soft-delete-manager

This commit is contained in:
2025-11-01 08:46:00 +03:30
parent 99c6c3c34d
commit 364a15acf8
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-11-01 05:12
import django.contrib.auth.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('authentication', '0044_remove_username_unique'),
]
operations = [
migrations.AlterField(
model_name='user',
name='username',
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username'),
),
]

View File

@@ -3,6 +3,7 @@ from django.db import models
class SoftDeleteManager(models.Manager): class SoftDeleteManager(models.Manager):
""" manager for get all records with trash=False in whole project """ """ manager for get all records with trash=False in whole project """
def get_queryset(self): def get_queryset(self):
return super().get_queryset().filter(trash=False) return super().get_queryset().filter(trash=False)
@@ -10,3 +11,5 @@ class SoftDeleteManager(models.Manager):
""" get all records, also deleted ones """ """ get all records, also deleted ones """
return super().get_queryset().all() return super().get_queryset().all()
def get_by_natural_key(self, username):
return self.get_queryset().get(username=username)

View File

@@ -597,3 +597,4 @@ AssertionError: .validate() should return the validated data
[2025-10-29 17:34:48,818] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader [2025-10-29 17:34:48,818] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
[2025-10-29 17:41:23,861] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\models.py changed, reloading. [2025-10-29 17:41:23,861] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\models.py changed, reloading.
[2025-10-29 17:41:27,025] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader [2025-10-29 17:41:27,025] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
[2025-11-01 08:44:37,286] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader