#forms.py
from django import forms
from django.contrib.admin.widgets import AdminFileWidget


class AgregarGuiaForm(forms.Form):
    year = forms.CharField()
    file = forms.FileField(widget=AdminFileWidget)

#views.py


    try:
        file = guide.get_file().file
        try:
            f = SimpleUploadedFile(file.name, file.read())
            f.url = file.url
            file_data = {'file': f}
        except:
            messages.error(request,"archivo no existe %s" % file.url)
            file_data = {}
    except:
        messages.error(request,"No existe archivo para esta guia")
        
    form1 = AgregarGuiaForm({'year': guide.year}, file_data)

#output: http://img225.imageshack.us/img225/6347/screenshot1qz.png
blog comments powered by Disqus
  1. soequelle reblogged this from zodman
  2. zodman posted this