Thank you for the point in the right direction. In the end i now have:

@models.permalink
def get_absolute_url(self):
    return ('c_viewcontact', [str(self.id)])


class ContactForm(ModelForm):
    class Meta:
        model = Contacts
        fields = ('contact_type', 'firstname', 'surname', 'notes')

def addcontact(request, template_name='addcontact.html'):
    if request.POST:
        form = ContactForm(request.POST)
        saved_form = form.save()
        contact_id = saved_form
        # If the save was successful, redirect to another page
        redirect_url = get_absolute_url(contact_id)
        return HttpResponseRedirect(redirect_url)
    else:
        form = ContactForm()
        return render_to_response(template_name, {
        'form': form, }, context_instance=RequestContext(request))

c_viewcontact being the name of the view.

Again, thank you for your help, it's much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to