Can someone point me in the right direction on how to use Django-filer? I have installed the necessary tools for the filer to work and I get the Filer tab in the admin interface, but when I upload an image to the app I am not able to get the preview thumbimage. The image is also uploaded to the Media_root path(Public files default path). What else have I missed?
Had a similar problem. I had missed that when easy_thumbnails is automatically pulled in by pip, you still have to explicitly add it to your INSTALLED_APPS in settings.py.
I spotted this because when I was uploading images, they weren't appearing in the clipboard, and when inspecting the response from the upload, there was an internal server error complaining that an easy_thumbnails table wasn't available.
tl;dr; check you added easy_thumbnails to your settings and did a migration / syncdb
Take a look in your urls.py. You should have the following code in it:
if settings.DEBUG:
urlpatterns += patterns('', (
r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))
Cheers
Related
I've a little issue concerning the configuration of Django and Apache on AWS Lightsail.
I followed this guide: https://aws.amazon.com/it/getting-started/hands-on/deploy-python-application/
point 5) Host the application using Apache
I configured all the files just like the guide states (obviously using the name of my prj instead of "template").
Everything is working except the static files: ie. I see my website without any css/img/js files.
Must I add something in urls.py? in settings.py? I feel I've tried everything...
How can I correctly configure Apache? For me it's the first time dealing with Django and Apache, and I cannot find a guide that works for my situation.
This is my tree of the prj:
tree-prj-img
Thank you,
Manuel
Ok, I found the solution.. I just spent all night for just few lines of code ahah
I add the following lines to my file urls.py:
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
I'm in the process of setting up my views in Django, but I'm confused about how to link it to my pageOne.html page so it shows that instead of the "Welcome" page. Currently, when I run the server using python manage.py runserver 127.0.0.2:8001 I get an error message that says "Template Does Not Exist at" pageOne.html.
I've set
TEMPLATE_DIRS = (os.path.join(os.path.dirname(BASE_DIR), "static", "templates"))
I've also tried
TEMPLATE_DIRS = ('/Users/andrewnguyen/Desktop/Websites/gale/python/techExercise/templates',)
but that hasn't really worked either.
Update:
Here's a screenshot. I imagine that my error is somewhere in my urls, settings or views.py. I've changed the path to my TEMPLATE_DIRS as mentioned in the comment below. That did not work. I've included an image of my file structure on Imgur: http://imgur.com/kR1xcGJ
Your TEMPLATE_DIRS settings should look like this:
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, "templates"),
)
Update
After looking at that screenshot you posted, I can say you've made a lot of mistakes.
The templates folder is inside the static folder.
Move the templates folder out of the static folder.
There's a mistake in the return statement of your view.
It should look like this:
return render(request, 'pageOne.html')
There's no need to prepend /static/templates/ to the template name. Django automatically looks for templates in your settings' TEMPLATE_DIRS path.
And finally, nothing you're doing is very difficult. All these mistakes are caused by ignorance, since everything is mentioned elaborately in the docs. Please read them carefully.
I installed Django and enabled the admin site. When I go to the admin page, I get the following
The image does not look the official Django tutorial. In settings.py I updated TEMPLATE_DIRS with the correct path.
TEMPLATE_DIRS = (
"/var/www/mysite/templates/admin"
)
I also tried restarting Apache many times. Any suggestions on what I might be doing wrong? Thank you.
It's an issued related to static files rather than templates:
https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
Use the developer tools on your browser to looks at what requests are being made. Most likely some static files like CSS, etc. are not being served up.
I'm writing a basic Django application. For testing / development purposes I'm trying to serve the static content of the website using Django's development server as per http://docs.djangoproject.com/en/dev/howto/static-files/#howto-static-files.
My urls.py contains:
(r'^admin/(.*)', admin.site.root),
(r'^(?P<page_name>\S*)$', 'Blah.content.views.index'),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': 'C:/Users/My User/workspace/Blah/media',
'show_indexes': True})
However, when I try to access a file such as http://localhost:8000/static/images/Logo.jpg Django gives me a 404 error claiming that "No Page matches the given query."
When I try to access a file such as http://localhost:8000/static/images/Blah%20Logo.jpg it serves the file!
What's going on?
You have wrong patterns order in urls.py.
When you try to retrieve path without space it matches:
(r'^(?P<page_name>\S*)$', 'Blah.content.views.index'),
not static.serve and of course you have not such page, But when you try to access path with space it matches proper static.serve pattern because it is more generic and allows spaces.
To solve this problem just swap those patterns.
EDIT: Issue solved, answered it below. Lame error. Blah
So I upgraded to Django 1.1 and for the life of me I can't figure out what I'm missing. Here is my traceback:
http://dpaste.com/37391/ - This happens on any page I try to go to.
I've modified my urls.py to include the admin in the new method:
from django.contrib import admin
admin.autodiscover()
.... urlpatterns declaration
(r'^admin/', include(admin.site.urls)),
I've tried fidgeting with paths and the like but nothing fixes my problem and I can't figure it out.
Has something major changed since Django 1.1 alpha -> Django 1.1 beta that I am missing? Apart from the admin I can't see what else is new. Are urls still stored in a urls.py within each app?
Thanks for the help in advance, this is beyond frustrating.
I figured it out. I was missing a urls.py that I referenced (for some reason, SVN said it was in the repo but it never was fetched on an update) and it simply said could not find urls (with no reference to notes.urls which WAS missing) so it got very confusing.
Either way, fixed -- Awesome!
try this:
(r'^admin/(.*)', admin.site.root),
More info
What is the value of your ROOT_URLCONF in your settings.py file? Is the file named by that setting on your python path?
Are you using the development server or what?