I am working on a form process with multiple levels of submission. The first is a front facing form with a general set of questions that are to be followed up by someone after the form is submitted (the form submits and entry to the DB). To cut down on the amount of hunting that those who will be reviewing the forms have to do I'd like to be able to retrieve the ID for the newly created DB entry and attach it to a url that points directly to that entry in the django admin.
I have the email logic set up so that the form submits all of the information via email to an individual. In the email is the link to the admin. So far it just goes to a full list of entries: ex. http://mydjango.site.com/admin/projects/app/model_name/ID I can easily send everything up to the ID. How do i retrieve the ID from the submitted form. Since this is adding an entry to the DB it has to be creating an ID somewhere. Here is my view: def short_form(request): if request.method == 'POST': form = ArtistFormFinal(request.POST, request.FILES) if form.is_valid(): name = form.cleaned_data['name'] year_created = form.cleaned_data['year_created'] home_city = form.cleaned_data['home_city'] home_state = form.cleaned_data['home_state'] genre = form.cleaned_data['genre'] email_address = form.cleaned_data['email_address'] phone_number = form.cleaned_data['phone_number'] website = form.cleaned_data['website'] audio = form.cleaned_data['audio_file'] subject = 'Static artists submission from %s' % (name) message = render_to_string('static/short_email.txt', { 'name': name, 'year_created': year_created, 'home_city': home_city, 'genre': genre, 'home_state': home_state, 'email_address': email_address, 'phone_number': phone_number, 'website': website, 'audio': audio }) recipients = ['ntankers...@opubco.com', 'crobi...@opubco.com'] send_mail(subject, message, email_address, recipients, fail_silently=False) form.save() return HttpResponseRedirect('thanks') else: form = ArtistFormFinal() return render_to_response('static/artist_short.html', {'form':form}) -- 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.