I've read the other posts on here about form data not saving, but can't seem to pinpoint my own problem. Have a feeling its something really basic I'm missing. Really appreciate the help thanks.
#model
class AboutMe(models.Model):
title = models.CharField(max_length=30)
user = models.ForeignKey(User)
post = models.TextField()
created = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return self.title
#form
class AboutMeForm(forms.ModelForm):
class Meta:
model = AboutMe
fields = ['title', 'post']
#view
def post_line(request):
if request.method == 'POST':
form = AboutMeForm(request.POST)
if form.is_valid():
new_about = form.save(commit=False)
new_about.user = request.user
new_about.save()
return HttpResponseRedirect('index.html')
else:
form = AboutMeForm()
return render_to_response('post_line.html', locals(), context_instance=RequestContext(request))
#template:
<div class="post_line">
<form enctype="multipart/form-data" action='.' method="post">{% csrf_token %}
{{ form.as_table }}
<input type="submit" name="submit" value="post" />
</form>
</div>