dev #10
|
@ -522,14 +522,6 @@
|
||||||
"detail": "django.core.exceptions",
|
"detail": "django.core.exceptions",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"label": "ValidationError",
|
|
||||||
"importPath": "django.core.exceptions",
|
|
||||||
"description": "django.core.exceptions",
|
|
||||||
"isExtraImport": true,
|
|
||||||
"detail": "django.core.exceptions",
|
|
||||||
"documentation": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "django_filters",
|
"label": "django_filters",
|
||||||
"kind": 6,
|
"kind": 6,
|
||||||
|
@ -1133,15 +1125,6 @@
|
||||||
"detail": "back.object.serializers",
|
"detail": "back.object.serializers",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"label": "validate_image_size",
|
|
||||||
"kind": 2,
|
|
||||||
"importPath": "back.object.validators",
|
|
||||||
"description": "back.object.validators",
|
|
||||||
"peekOfCode": "def validate_image_size(image):\n max_size = 2 * 1024 * 1024 # Максимальный размер файла в байтах (2MB)\n if image.file.size > max_size:\n raise ValidationError(f\"Размер файла не должен превышать {max_size / (1024 * 1024)}MB\")",
|
|
||||||
"detail": "back.object.validators",
|
|
||||||
"documentation": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "NumberInFilter",
|
"label": "NumberInFilter",
|
||||||
"kind": 6,
|
"kind": 6,
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||||
<<<<<<< HEAD
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
=======
|
|
||||||
from .validators import validate_image_size
|
|
||||||
>>>>>>> 7a21fd252e5a313c5b0016012151e6a6b25378da
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger("root")
|
logger = logging.getLogger("root")
|
||||||
|
@ -83,7 +79,6 @@ class ClickableArea(models.Model):
|
||||||
Element3D,
|
Element3D,
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
)
|
)
|
||||||
<<<<<<< HEAD
|
|
||||||
image = models.ImageField(
|
image = models.ImageField(
|
||||||
"Картинка",
|
"Картинка",
|
||||||
upload_to=group_based_upload_to,
|
upload_to=group_based_upload_to,
|
||||||
|
@ -94,9 +89,5 @@ class ClickableArea(models.Model):
|
||||||
null=True,
|
null=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
=======
|
|
||||||
image = models.ImageField(upload_to='images/', validators=[validate_image_size], blank=True, null=True)
|
|
||||||
|
|
||||||
>>>>>>> 7a21fd252e5a313c5b0016012151e6a6b25378da
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
|
|
||||||
def validate_image_size(image):
|
|
||||||
max_size = 2 * 1024 * 1024 # Максимальный размер файла в байтах (2MB)
|
|
||||||
if image.file.size > max_size:
|
|
||||||
raise ValidationError(f"Размер файла не должен превышать {max_size / (1024 * 1024)}MB")
|
|
Loading…
Reference in New Issue