Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
7455cfa1
Commit
7455cfa1
authored
Oct 06, 2016
by
Diederik van der Boor
Browse files
The `upload_to` hack is no longer needed on Django 1.7+
parent
22bac883
Changes
1
Show whitespace changes
Inline
Side-by-side
private_storage/fields.py
View file @
7455cfa1
#-*- coding: utf-8 -*-
#-*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
os
import
os
import
django
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.core.files.uploadedfile
import
UploadedFile
from
django.core.files.uploadedfile
import
UploadedFile
from
django.db
import
models
from
django.db
import
models
...
@@ -30,7 +32,7 @@ class PrivateFileField(models.FileField):
...
@@ -30,7 +32,7 @@ class PrivateFileField(models.FileField):
self
.
max_file_size
=
kwargs
.
pop
(
"max_file_size"
,
None
)
self
.
max_file_size
=
kwargs
.
pop
(
"max_file_size"
,
None
)
kwargs
.
setdefault
(
'storage'
,
private_storage
)
kwargs
.
setdefault
(
'storage'
,
private_storage
)
if
self
.
_upload
:
if
self
.
_upload
and
django
.
VERSION
<
(
1
,
7
)
:
kwargs
.
setdefault
(
'upload_to'
,
'uploads'
)
# shut up warnings from Django 1.6- model validation
kwargs
.
setdefault
(
'upload_to'
,
'uploads'
)
# shut up warnings from Django 1.6- model validation
super
(
PrivateFileField
,
self
).
__init__
(
*
args
,
**
kwargs
)
super
(
PrivateFileField
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment