Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images url not defined? #1

Closed
arruda opened this issue Sep 23, 2015 · 2 comments · Fixed by #3
Closed

Images url not defined? #1

arruda opened this issue Sep 23, 2015 · 2 comments · Fixed by #3
Assignees

Comments

@arruda
Copy link
Contributor

arruda commented Sep 23, 2015

Hi there, I just tried creating a new django project and configuring the Puput as standalone to work, but when I upload a image it points to a 404 url.
The images appear in the folders /images/ and also in the /original_images/ inside my project root dir.

I was searching for something on this and saw that there is this ^images/ url from Wagtail: http://docs.wagtail.io/en/v1.1/topics/images/using_images_outside_wagtail.html#setup that you need to add the your urls.py

And, after searching inside Puput urls.py I saw that in the case when you are not using Puput as a wagtail pluging, the images url is not added: https://github.com/APSL/puput/blob/master/puput/urls.py#L26

I'm not sure if the images url is another thing that has nothing to do with the Wagtail Images url, or if it's just missing from the puput.urls.py in the standalone config mode.

@marctc
Copy link
Collaborator

marctc commented Sep 23, 2015

Hi Felipe,

The link that you provide me it's a Wagtail tool to generate image URLs in the image preview on the image edit page (good to know that exist this, BTW) but it has nothing to do with the issue that you have.

It seems that you didn't configured properly the staticfiles/medias urls in your main urls.py. The official Wagtail documentation provides an example of how to do that:

http://docs.wagtail.io/en/v1.1/advanced_topics/settings.html#urls-py

Try this and tell me if putting this fixs your problem.

Maybe I would have to update Puput's documentation to tell people who are setting up Puput as standalone app that have to put this urls in his project.

@arruda
Copy link
Contributor Author

arruda commented Sep 27, 2015

Hi @marctc, thanks, for the fast reply.
What you said made it work, I've completely forgot about MEDIA_ROOT/URL settings, so after adding both of them and making django serve them in dev, everything started working 😄

I agree, that it would be a great idea to put this info in the documentation. Both the changes in the urls.py:

if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += staticfiles_urlpatterns()  # tell gunicorn where static files are in dev mode
    urlpatterns += static(settings.MEDIA_URL + 'images/', document_root=os.path.join(settings.MEDIA_ROOT, 'images'))
    urlpatterns += patterns(
        '',
        (r'^favicon\.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'blog/images/favicon.ico'))
    )

And the setting of MEDIA_ROOT and MEDIA_URL, that by default are not been added to the settings.py by django's start_project anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants