Last active
August 29, 2015 14:04
-
-
Save chr0nu5/e07198e7fc7622cc8248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
settings.py | |
FILES_WIDGET_TEMP_DIR = 'temp/files_widget/' | |
FILES_WIDGET_FILES_DIR = 'uploads/files_widget/' | |
THUMBNAIL_DEBUG = True | |
PROJECTNAME = os.path.dirname(__file__) | |
MEDIA_ROOT = os.path.join(PROJECTNAME, 'media') | |
MEDIA_URL = '/media/' | |
STATIC_ROOT = os.path.join(PROJECTNAME, 'static') | |
STATIC_URL = '/static/' | |
ADMIN_MEDIA_ROOT = os.path.join(PROJECTNAME, 'static', 'admin') | |
ADMIN_MEDIA_PREFIX = '/static/admin/' | |
models.py | |
from topnotchdev import files_widget | |
class Cadastro(models.Model): | |
imagens = files_widget.ImagesField() | |
views.py | |
from app.models import Cadastro | |
from django.shortcuts import render | |
def index(request): | |
context = { | |
'objeto':Cadastro.objects.get(pk=10), | |
} | |
return render(request, 'app/index.html',context) | |
index.html (template) | |
{% for imagem in objeto.imagens.all %} | |
<img src="/media/{{ imagem.local_path }}"> | |
{% end for %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment