minimal-django-file-upload-example icon indicating copy to clipboard operation
minimal-django-file-upload-example copied to clipboard

Implementation of the project

Open reemaRaven opened this issue 7 years ago • 7 comments

I have implemented the sample project. But cannot see the results after clicking upload button. See attachment. https://drive.google.com/drive/folders/19yIF1S4YnLbUuJGvkV7k8av5jamWKikm?usp=sharing

reemaRaven avatar Nov 20 '18 12:11 reemaRaven

Hi!

Which upload-example version are you using? I assume v2.0 but could you confirm?

The http 405 error refers that the method is not allowed. This probably is a problem with routes.

Did you customize the example code in any way?

To which URL does your upload form point to? I mean, what is the value of action attribute of your form element?

Hope this helps you further.

axelpale avatar Nov 20 '18 14:11 axelpale

Hi! Thanks for the quick response. Yes it is Django 2.1 . If you will check the same drive link, I have attached the zip of the project. https://drive.google.com/open?id=19yIF1S4YnLbUuJGvkV7k8av5jamWKikm

(tmp_yr0cz.zip , password is in the zip_pass.txt file) Only difference between your project and my implementation is that your project name is "myproject" within which there is myapp. In mine, the project name is "app" and app within it is "myapp".

I haven't customized it in anyway yet. I dont see a form action on the button in your code either. Am I missing something?

Thanks!

reemaRaven avatar Nov 20 '18 18:11 reemaRaven

I had two more questions :

  1. In the settings.py , when I add below, MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/'

Am I also supposed to create a media folder for it? If so, what should be the absolute path for it.

  1. Within models.py,

    class Document(models.Model): docfile = models.FileField(upload_to='documents/%Y/%m/%d')

Am I supposed to have a documents folder already? If so, what should be the absolute path for it.

reemaRaven avatar Nov 20 '18 19:11 reemaRaven

Unfortunately I do not have much time to look into it, but there is some that could take you further:

  • The most recent upload-example is for v2.0. There is no upload-example for v2.1 yet. You have Django v2.1 so it might cause issues.
  • Does your line 21 in myproject/urls.py point to myapp.urls or app.urls?
  • Does your situation change if you rename your app dir to myapp like in the upload-example?
  • By action attribute of the form element I refer to this line. It does not have much to do with the button.
  • About upload_to parameter, the documentation says "the string value will be appended to your MEDIA_ROOT path". The documentation is your friend in these matters.

axelpale avatar Nov 20 '18 20:11 axelpale

Hi,

found the issue. Please update your myproject/myproject/urls.py with a home redirector (third line). That way, after upload, it will redirect to the same page.

urlpatterns = [ path('admin/', admin.site.urls), path('myapp/', include('myapp.urls')) path('',views.list, name='list') ]

thanks a lot!

reemaRaven avatar Nov 20 '18 20:11 reemaRaven

Hi, great! Let us keep this issue open, as a reminder, until that thing gets fixed. Thanks!

axelpale avatar Nov 20 '18 21:11 axelpale

Yeah Sure! This is great help. Thanks!

reemaRaven avatar Nov 21 '18 05:11 reemaRaven