Hi, I've been following an online tutorial but been debugging. I've traced my issue to this line in the view function below:
return category(request, category_name_url) Is this view effectively calling another view directly without going via the urls file (in the exception case)? If so can you advise me if this is good or bad practice? Thanks, Andy from rango.forms import PageForm def add_page(request, category_name_url): context = RequestContext(request) category_name = decode_url(category_name_url) if request.method == 'POST': form = PageForm(request.POST) if form.is_valid(): # This time we cannot commit straight away. # Not all fields are automatically populated! page = form.save(commit=False) # Retrieve the associated Category object so we can add it. # Wrap the code in a try block - check if the category actually exists! try: cat = Category.objects.get(name=category_name) page.category = cat except Category.DoesNotExist: # If we get here, the category does not exist. # We render the add_page.html template without a context dictionary. # This will trigger the red text to appear in the template! return render_to_response('rango/add_page.html', {}, context) # Also, create a default value for the number of views. page.views = 0 # With this, we can then save our new model instance. page.save() # Now that the page is saved, display the category instead. return category(request, category_name_url) else: print form.errors else: form = PageForm() return render_to_response( 'rango/add_page.html', {'category_name_url': category_name_url, 'category_name': category_name, 'form': form}, context) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eb10a86f-80fd-415e-8a72-8ba189faeba8%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.