Michael Ackerman
unread,May 19, 2012, 10:55:11 AM5/19/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
I have a generic view:
class create_ticket(CreateView):
model = ticket
form_class = ticket_form
template_name = "create_ticket.html"
success_url = "/tickets/thanks/"
and a form:
class ticket_form(ModelForm):
class Meta:
model = ticket
fields = ('title','description','picture')
But when I try to submit the data, it get a "This field is required" for the picture, so I think I'm missing something in order to take in the picture.
and for reference:
#create_ticket.html:
{% extends "base.html" %}
{% block main %}
<form action="" method="post">{% csrf_token %}
{{ form.as_table}}
<input type="submit" value="Submit" />
</form>
{% endblock %}
#models.py
class ticket(models.Model):
title = models.CharField(max_length = 100)
date_created = models.DateTimeField(auto_now_add=True)
description = models.TextField()
ranking = models.PositiveIntegerField(default=0)
picture = models.ImageField(
upload_to ='pictures' )
def __unicode__(self):
return self.title
All help is appreciated, thank you.