I am (still) new to Django and a novice at relational databases, so I
am having some problems. I've read and read, but can't sort this out.
I have a customer enter data into a form. The model is here:
class Order_Info(models.Model):
date_stamp = models.DateTimeField(auto_now_add=True)
year = models.IntegerField()
period = models.IntegerField(editable=False, blank=True, null=True)
direction = models.CharField(max_length=20,
choices=direction_choices)
email = models.EmailField("Email Address")
I save the session data in this view:
def order(request):
if request.method == 'POST':
form = OrderForm(request.POST)
if form.is_valid():
current_order = form.save()
order_info = Context({'order_info': current_order})
request.session['order_info'] = order_info
return HttpResponseRedirect('/pdf_test/')
Then redirect them to the page called pdf_test where I want to use the
session data to lookup and display data from the model named Chart:
class Chart(models.Model):
ch_period = models.IntegerField()
ch_direction = models.CharField(max_length=20)
general = models.CharField(max_length=200)
top_left = models.CharField(max_length=20)
top_center = models.CharField(max_length=20)
top_right = models.CharField(max_length=20)
mid_left = models.CharField(max_length=20)
mid_center = models.CharField(max_length=20)
mid_right = models.CharField(max_length=20)
low_left = models.CharField(max_length=20)
low_center = models.CharField(max_length=20)
low_right = models.CharField(max_length=20)
My view for pdf_test is where I encounter problems:
def pdf_test(request):
order_info = request.session['order_info']
p = order_info.period
c = Context({'chart': Chart.objects.filter(ch_period = p)})
return render_to_response('pdf_test.html', order_info, c)
No matter what I try, I can't seem to extract period from that
order_info data. Can anybody tell me what I'm doing wrong?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.