Hi Group... below you will see a code snippet which records a testimonial submitted off of a form into the database. Here's my setup...
I'm hosting at webfaction with 3 instances of django running with 3 sites, 4 sites and 4 sites (only way I can avoid running over my RAM allotment). The sites use flatpages and sites. This code is in each website with the exception of the siteid it writes to the database. The code submits fine to the database but the wrong siteid # is recorded. Can you think of anything that might be causing this. In this example below, I even have the siteid hardcoded in the section where django actually saves to the database.... help greatly appreciated... --- #import django routines and template tags from django.http import * from django.shortcuts import get_object_or_404, render_to_response from django.template.loader import render_to_string from django.template import RequestContext from django.template import Template, Context from django.core.mail import send_mail, EmailMultiAlternatives from django.contrib.sites.models import Site #import date and time python functions from time import * from datetime import datetime from testimonials.forms import * from testimonials.models import Testimonial # THIS VIEW HANDLES THE TESTIMONIAL FORM. def DoTestimonialForm (request): if request.method =='POST': form = TestimonialForm (request.POST) # set an instance of the form if form is submitted if form.is_valid(): #if there are no errors in the form data do the following mydata=Testimonial ( testimony=request.POST.get ('Testimony',''), name =request.POST.get('Name',''), active = 0, postdate=datetime.now(), siteid=1,) mydata.save() # send email notification to site admin about the new testimonial #textmessage = render_to_string ('email_text.html', context_instance=RequestContext(request)) textmessage = 'A new testimonial at www....com has been posted for your review from a customer named ' + request.POST.get('Name','') from_email='i...@....com' to_email=['....@gmail.com'] subject = 'A new testimonial has been posted for your review' send_mail (subject,textmessage,from_email,to_email) return HttpResponseRedirect ('/thankyou/') else: #form is not valid so return to step 1 and show errors return render_to_response("submit.html", {'form': form},context_instance=RequestContext(request)) else: # load the form to the template form=TestimonialForm() return render_to_response("submit.html",{'form': form}, context_instance=RequestContext(request)) 65,0-1 Bot --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---