Django plantilla / ver problemas con carrusel

OK, así que aquí está el trato:

Esto es actualmente en lo que estoy trabajando:

Introduzca la descripción de la imagen aquí

¿Ves las dos flechas en la parte superior? Ahí es donde debe estar un carrusel de imágenes. Sin embargo, no hay imágenes en este carrusel. Es decir, hasta que haga clic en el botón ‘Subir’.

Usé viejas capturas de pantalla para probar las subidas.

Por lo tanto, mi objective es hacer que las imágenes aparezcan en la primera página antes de que haga clic en el botón “cargar”

¿Como puedo solucionar este problema?

Mi código:

Index.html

{% extends 'webportal/defaults.html' %} {% block body %} {% include 'webportal/carousel.html' %} 

So far we have been able to establish what the user tables will be have created or are in process of creating the ability to create, update, destroy users.

For now this ability is limited to the main user table, however the models will be easily extended to other tables as they are needed

Also not a lot of thought has gone into styling yet, we know that the page is suppose to resemble the parent organizations page. Right now we have been more focused on getting each individual component working. Later we will merge them into a whole.

{% include 'webportal/info_row.html' with one=one two=two three=three %} {% endblock %}

Carrusel.html:

 {% load staticfiles %} {% load filename %} 
{% csrf_token %}

{{ form.non_field_errors }}

{{ form.docfile.label_tag }} {{ form.docfile.help_text }}

{{ form.docfile.errors }} {{ form.docfile }}

Vistas.py:

 from django.shortcuts import render from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth import authenticate, login from webportal.views.authentication import LoginForm from django.shortcuts import render_to_response from django.template import RequestContext from django.http import HttpResponseRedirect from django.http import HttpResponse from django.core.urlresolvers import reverse from django.conf import settings from webportal.forms.forms import DocumentForm from webportal.models import Document, DeleteForm is_server = True def delete(request, my_id): Deleted=get_object_or_404(Document, docfile=my_id) if request.method=='POST': form=DeleteForm(request.POST, instance=Deleted) if form.is_valid(): Deleted.delete() return HttpResponseRedirect('http://127.0.0.1:8000/alzheimers/') else: form=DeleteForm(instance=Deleted) return render_to_response( 'webportal/index.html', {'documents': documents, 'form': form,}, context_instance=RequestContext(request) ) # Redirect to the document list after POST def carousel(request): # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile = request.FILES['docfile']) newdoc.save() # Redirect to the document list after POST return HttpResponseRedirect('http://127.0.0.1:8000/alzheimers/') else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() #documents=DocumentForm(). # Render list page with the documents and the form return render_to_response( 'webportal/index.html', {'documents': documents, 'form': form,}, context_instance=RequestContext(request) ) 

Models.py:

 class Document(models.Model): docfile = models.ImageField(upload_to='webportal/static/img/') class DeleteForm(ModelForm): class Meta: model=Document fields=[] 

Forms.py:

 class DocumentForm(forms.Form): docfile = forms.ImageField(label='Select a file', help_text='max. 42 megabytes') 

No me sorprendería si lo que estoy tratando de hacer es imposible. Si hay una manera de hacer esto, ¿involucra a Ajax?

Los archivos .py son código Python. En Python, los principales espacios en blanco son importantes .

En Views.py , la función de carousel no contiene código de Python válido:

 def carousel(request): # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile = request.FILES['docfile']) newdoc.save() # Redirect to the document list after POST return HttpResponseRedirect('http://127.0.0.1:8000/alzheimers/') else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() #documents=DocumentForm(). # Render list page with the documents and the form return render_to_response( 'webportal/index.html', {'documents': documents, 'form': form,}, context_instance=RequestContext(request) ) 

En su lugar, probablemente debería ser:

 def carousel(request): # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile = request.FILES['docfile']) newdoc.save() # Redirect to the document list after POST return HttpResponseRedirect('http://127.0.0.1:8000/alzheimers/') else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() #documents=DocumentForm(). # Render list page with the documents and the form return render_to_response( 'webportal/index.html', {'documents': documents, 'form': form,}, context_instance=RequestContext(request) ) 

Pero no está claro si la else parte pertenece a la primera o la segunda if construye.