Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.contrib.auth import get_user_model
from django.db import models

from django_stubs_ext.db.models import TypedModelMeta

User = get_user_model()


Expand Down Expand Up @@ -31,7 +33,7 @@ def __str__(self):
filename_with_extension = f"{self.name}.{self.extension}"
return f"UserFile<{reprlib.repr(filename_with_extension)}>"

class Meta:
class Meta(TypedModelMeta):
verbose_name = "Файл"
verbose_name_plural = "Файлы"
ordering = ["datetime_uploaded"]
2 changes: 1 addition & 1 deletion files/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from files.models import UserFile


class UserFileSerializer(ModelSerializer):
class UserFileSerializer(ModelSerializer[UserFile]):
class Meta:
model = UserFile
fields = [
Expand Down
3 changes: 2 additions & 1 deletion industries/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django_stubs_ext.db.models import TypedModelMeta


class Industry(models.Model):
Expand All @@ -20,7 +21,7 @@ class Industry(models.Model):
def __str__(self):
return f"Industry<{self.id}> - {self.name}"

class Meta:
class Meta(TypedModelMeta):
verbose_name = "Индустрия"
verbose_name_plural = "Индустрии"
ordering = ["name"]
3 changes: 2 additions & 1 deletion industries/serializers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django_stubs_ext.db.models import TypedModelMeta
from rest_framework import serializers

from industries.models import Industry


class IndustrySerializer(serializers.ModelSerializer):
class Meta:
class Meta(TypedModelMeta):
model = Industry
fields = ["id", "name", "datetime_created"]
2 changes: 1 addition & 1 deletion industries/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_industry_update_with_wrong_data(self):

self.assertEqual(response.status_code, 400)

def _user_create(self):
def _user_create(self) -> CustomUser:
request = self.factory.post("auth/users/", USER_CREATE_DATA)
response = self.user_list_view(request)
user_id = response.data["id"]
Expand Down