22
33Django Chunk File Upload is an alternative utility that helps you easily edit Django's chunked, drag and drop file uploads.
44
5- <img src =" https://i.ibb.co/9y2SgmS/f-P5-Or-Gkxk0-Ynj00ct-G.webp " alt =" f-P5-Or-Gkxk0-Ynj00ct-G " border = " 0 " >
5+ <img src =" https://i.ibb.co/9y2SgmS/f-P5-Or-Gkxk0-Ynj00ct-G.webp " alt =" f-P5-Or-Gkxk0-Ynj00ct-G " >
66
77Features
88----------
@@ -76,7 +76,8 @@ DJANGO_CHUNK_FILE_UPLOAD = {
7676 " max_width" : 1024 ,
7777 " max_height" : 720 ,
7878 " to_webp" : True , # focus convert image to webp type.
79- }
79+ },
80+ " permission_classes" : (" django_chunk_file_upload.permissions.AllowAny" ,) # default: IsAuthenticated
8081}
8182
8283```
@@ -88,14 +89,14 @@ models.py
8889
8990``` python
9091from django.db import models
91- from django_chunk_file_upload.models import FileManager
92+ from django_chunk_file_upload.models import FileManagerMixin
9293
9394
9495class Tag (models .Model ):
9596 name = models.CharField(max_length = 255 )
9697
9798
98- class YourModel (FileManager ):
99+ class YourModel (FileManagerMixin ):
99100 tags = models.ManyToManyField(Tag)
100101 custom_field = models.CharField(max_length = 255 )
101102
@@ -116,6 +117,7 @@ class YourForm(ChunkedUploadFileForm):
116117
117118views.py
118119
120+ Accepted methods: GET, POST, DELETE (UPDATE, PUT does not work with FormData).
119121``` python
120122from django_chunk_file_upload.views import ChunkedUploadView
121123from django_chunk_file_upload.typed import File
@@ -126,12 +128,18 @@ from .forms import YourForm
126128class CustomChunkedUploadView (ChunkedUploadView ):
127129 form_class = YourForm
128130 permission_classes = (IsAuthenticated,)
131+
129132 # file_class = File # file class
133+ # file_status = app_settings.status # default: PENDING (Used when using background task, you can change it to COMPLETED.)
130134 # optimize = True # default: True
131135 # remove_file_on_update = True # update image on admin page.
132136 # chunk_size = 1024 * 1024 * 2 # custom chunk size upload (default: 2MB).
133137 # upload_to = "custom_folder/%Y/%m/%d" # custom upload folder.
134138 # template_name = "custom_template.html" # custom template
139+
140+ # # Run background task like celery when upload is complete
141+ # def background_task(self, instance):
142+ # pass
135143```
136144
137145custom_template.html
0 commit comments