fix soft-delete-manager
This commit is contained in:
19
apps/authentication/migrations/0045_alter_user_username.py
Normal file
19
apps/authentication/migrations/0045_alter_user_username.py
Normal 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'),
|
||||
),
|
||||
]
|
||||
@@ -3,6 +3,7 @@ from django.db import models
|
||||
|
||||
class SoftDeleteManager(models.Manager):
|
||||
""" manager for get all records with trash=False in whole project """
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(trash=False)
|
||||
|
||||
@@ -10,3 +11,5 @@ class SoftDeleteManager(models.Manager):
|
||||
""" get all records, also deleted ones """
|
||||
return super().get_queryset().all()
|
||||
|
||||
def get_by_natural_key(self, username):
|
||||
return self.get_queryset().get(username=username)
|
||||
|
||||
@@ -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: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-11-01 08:44:37,286] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
|
||||
Reference in New Issue
Block a user