1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #26058 -- Removed deprecated FileField.get_directory_name()/get_filename().

This commit is contained in:
Tim Graham
2016-12-31 12:36:25 -05:00
parent 58d3d14aea
commit 0dfc5479a8
3 changed files with 3 additions and 46 deletions

View File

@@ -1,7 +1,5 @@
import datetime
import os
import posixpath
import warnings
from django import forms
from django.core import checks
@@ -12,7 +10,6 @@ from django.core.validators import validate_image_file_extension
from django.db.models import signals
from django.db.models.fields import Field
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_str, force_text
from django.utils.translation import ugettext_lazy as _
@@ -301,22 +298,6 @@ class FileField(Field):
super(FileField, self).contribute_to_class(cls, name, **kwargs)
setattr(cls, self.name, self.descriptor_class(self))
def get_directory_name(self):
warnings.warn(
'FileField now delegates file name and folder processing to the '
'storage. get_directory_name() will be removed in Django 2.0.',
RemovedInDjango20Warning, stacklevel=2
)
return os.path.normpath(force_text(datetime.datetime.now().strftime(force_str(self.upload_to))))
def get_filename(self, filename):
warnings.warn(
'FileField now delegates file name and folder processing to the '
'storage. get_filename() will be removed in Django 2.0.',
RemovedInDjango20Warning, stacklevel=2
)
return os.path.normpath(self.storage.get_valid_name(os.path.basename(filename)))
def generate_filename(self, instance, filename):
"""
Apply (if callable) or prepend (if a string) upload_to to the filename,