juliomalegria / django-chunked-upload

Upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted.
MIT No Attribution
214 stars 71 forks source link

can't migrate #7

Closed shaw2thefloor closed 9 years ago

shaw2thefloor commented 9 years ago

Hi there. I hope you don't mind me asking a support question! I've been trying for a few days to get you code working in my project.

I am simply trying to add django-chunked-upload to my django project. I have downloaded the source code, created the egg file and have added it to my INSTALLED_APPS. However, I can't get the model migrated into my database. Everytime I run makemigrations chunked_upload, it states that there are no changes and doesn't do anything. Do you know what I need to do to get this working with django 1.7?

Thanks and Happy Christmas!

juliomalegria commented 9 years ago

Hi @shaw2thefloor,

By default the ChunkedUpload model is abstract. This means that the model won't have a table associated to it.

I implemented it this way because I think some people might need to add some extra fields, and this could be easily done by just inheriting from the (abstract) base model:

class MyChunkedUpload(ChunkedUpload):
    some_string = models.CharField(max_length=64)
    some_fk = models.ForeignKey(MyModel)

But the good news is that I also added a way for you to control whether the model is abstract or not (it's in the README). You only need to add this line in your django project settings.py:

CHUNKED_UPLOAD_ABSTRACT_MODEL = False

After doing that, makemigrations chunked_upload will work.

Thanks for using this project and merry christmas to you too! :)

shaw2thefloor commented 9 years ago

Brilliant! Thanks for the advice and for the code!

shaw2thefloor commented 9 years ago

Hi Julio. Sorry to bother you again!

I followed your advice and got the database table migrated. I also had to change the mimetype to content_type in response.py (as mimetype is deprecated in django 1.7), but I am now getting the error:

{"detail": "Offsets do not match", "offset": 0}

Could I possibly see an example of the jQuery-file-upload code that is working? I'm not sure how I should be adding the upload_id to the javascript chunk, or how to add the md5 checksum at the end.

Thanks for your help.