I'm trying to use the test client to verify my views, but when I check the templates and contexts I get 'None' returned instead of the context dict or the template. I do get the correct content and status code however. I was hoping someone could give me some tips. Here is some example code:
#views def home(request): t = Template("{{info}}") c = Context({'info':'Sales Home Page'}) return HttpResponse(t.render(c)) def addProduct(request): if request.method == 'POST': form = forms.ProductForm(request.POST) if form.is_valid(): try: p = db.models.Product(**form.cleaned_data) db.session.commit() c = Context({'type': 'Product', 'entry': p, 'time': datetime.datetime.now().strftime ("%Y-%m-%d %H:%M:%S")}) t = loader.get_template("product_added.html") return HttpResponse(t.render(c), status=201) except: db.session.rollback() status=206 else: status=204 else: status=200 c = Context({'title': 'New Product', }) t = loader.get_template("newproduct.html") return HttpResponse(t.render(c), status=status) Notes: I'm not using the django DRM (I'm using SQLAlchemy), but to me that seems irrelevant (I may be wrong). I'm attempting to access the response as follows: from django.test.client import Client c=Client() r = c.get("/url/to/home") #Access views.home r.content #Returns correct content r.context #returns None r.template #returns None r = c.post("/url/to/add/product", {'name':'testProd','units':'testUnits','notes':'no notes'}) r.status_code #returns 201 correctly r.content #Returns correct content r.context #returns None r.template #returns None # This post adds testProd to the product table correctly I would greatly appreciate any suggestions, tips, hints or help of any kind. Thanks, Mike --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---