I have a very simple model:
class Artist(models.Model):
name = models.CharField(max_length=64, unique=False)
band = models.CharField(max_length=64, unique=False)
instrument = models.CharField(max_length=64, unique=False)
def __unicode__ (self):
return self.name
that I'm using as a model form:
from django.forms import ModelForm
from artistmod.artistcat.models import *
class ArtistForm(ModelForm):
class Meta:
model = Artist
but I can't seem to construct a view that will save the form data to the database. Currently I'm using:
def create_page(request):
if request.method == 'POST':
form = ArtistForm(request.POST)
if form.is_valid():
form.save()
return render_to_response('display.html')
else:
form = ArtistForm()
return render_to_response('create.html', {
'form': form,
})
can anyone help the newbie?