I am trying to use ViewerJS in a Django 1.8.2 application. However, the link I am using will not render the PDF. I have the ViewerJS folder under static/js/ and my PDF under static/pdf/docs/. Here is the link I'm using:
Preview
The error I am receiving is a 404. Django passes back an error message "Directory indexes are not allowed here.".
Request Method: GET
Request URL: http://localhost:8000/static/js/ViewerJS/
Raised by: django.contrib.staticfiles.views.serve
If I go to localhost:8000/static/pdf/docs/agreement.pdf in my browser then the PDF downloads just fine. If I go to localhost:8000/static/js/ViewerJS/pdf.js then the pdf.js file downloads just fine. So I'm not sure why it isn't working.
Django's static server is only for development, and is purposely limited. As the error says, it doesn't deal with directory indexes.
You could probably make this work by making the link go directly to /static/js/ViewerJS/index.html.
I have just the same problem. I am trying to access a file located at static/gutenberg/docs/files/something.pdf in Django
The url I created is
"http://localhost:8000/static/gutenberg/js/ViewerJS/index.html/#/static/gutenberg/docs/files/something.pdf".
Inspite of adding index.html to the complete it wouldn't work.I am not sure why.
The path is right because I am able to download the file when I run "/static/gutenberg/docs/files/something.pdf" on my browser.
Related
first time question.
I have been playing with Django and needed a photo gallery, and made a basic one, then found starcross gallery (https://github.com/Starcross/django-starcross-gallery). It works really nice and easy to put into my app, but from what I can tell its made for dragging and dropping images in, or by adding them from the django-admin page.
I need to be able to add photos from an external script. I haven't dealt with ImageField before. I was able to import the gallery.models in my api views file, and make it so I can POST and add those ok. But I have been pulling my hair out trying to get actual images to upload.
From looking around, I found I think how to do it with curl (I make my requests with curl then port it to python), and it gave me CSRF issues with a 403 Forbidden.
How can I upload an image and bind it to an album, externally with curl or Python?
Thanks
While I have the images stored into my 'img' file it isn't showing up inside of my virtual environment, I will provide a screenshot of both the images inside of my file plus the virtual environment folder structure. Below is the error message.
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/static/projects/img/todo.png
'projects\img\todo.png' could not be found
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
It would've been much better if you included your urls.py and setting.py but I'm guessing you have not set the static root, in any case by reading this django doc page you should be able to figure it out.
I have a Django project in which the HTML page has a simple GitHub link.
Github
When I click on it, the URL it gets redirected to is "localhost/app/github.com"
Can you please explain why is it happening and what should I do to correct it?
This has nothing to do with Django, but is standard HTML.
You need to put the full URL, including protocol:
Github
I am trying to create a link that allows a user to download a zip file that's been generated earlier in the python script. The script then writes an HTML link to a web page. The user should be able to click the link and download their zip file.
import os,sys
downloadZip = ("http://<server>/folder/structure/here/" + zipFileName + ".zip")
print """<h3><a href="{}" download>Download zip file</a></h3>""".format(downloadZip)
The result is a link that when clicked opens a 404 page. I've noticed that on that page, it displays
Physical Path C:\inetpub\wwwroot\inputted\path\here\file.zip
I am testing this on the same server the processing is occurring on. I wouldn't think that should make a difference, but here I am. The end result should be a zip file downloaded to the user's pc.
Not sure if this would be helpful or not but I have noticed that some 'server package apps' disallow the execution/download of certain filetypes. I had a similar thing happen years ago.
To test if this is the case, create a new folder in your web directory and add an index.html page with some random writing (to identify that you have the correct page). Quickly try to access this page.
Next create a .zip file, put it in the same folder as the index.html file you just created, and add a Download link on the index.html page.
Now revisit the page, and try to download the file you created. If it works then there is a problem elsewhere, if it doesn't then whatever server package application you are using probably set Apache to block .zip files by default. Hope this helps buddy :)
I'm deploying my first Django app on a BlueHost shared server. It is a simple site powered by Django-CMS, and portions of it are working, however there are some deal-breaking quirks.
A main recurring one reads TypeError, a float is required. The exception location each time is .../python/lib/python2.7/site-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 391. For example, I run into it when trying to load a page which includes {% cms_toolbar %} in the template, pressing "save and continue editing" when creating a page, or trying to delete a page through the admin interface.
I don't know if this is related, but nothing happens when I select a plugin from the "Available Plugins" drop-down while editing a page and press "Add Plugin".
Has anyone had any experience with this error, or have any ideas how to fix it?
As I wondered, the problem was that I was accessing the site using my temporary link from BlueHost, which the function throwing the error could not handle.
When my clients finally pointed their domain name at the server this problem and a few others (CSS inconsistencies in the Django admin, trouble with .htaccess) disappeared. Everything is up now and working fine.