Im not sure if I am going about this the wrong way.

Trying to learn class based views *sigh* currently seeming more complicated 
and less human readable with no less code currently but I expect most 
people feel that at first.

class HomePage(ListView, BaseFormView):
    template_name = 'index.html'
    queryset = Notes.objects.filter(user=1)
    context_object_name = 'notes'
    form_class = LoginForm
    success_url = '/notes/'

    def get_context_date(self, **kwargs):
        context = super(HomePage, self).get_context_data(**kwargs)
        context['loginform'] = LoginForm
        for kwarg in kwargs:
            context[kwarg] = kwargs[kwarg]
        return context

    def form_valid(self, form, **kwargs):
        """do some form stuff"""
        if "errors with login":
            kwargs['error'] = 'account not active'
            kwargs['error_type2'] = 'check details'
        return self.get_context_data(**kwargs)

what I want to do really is return the errors back to the start as extra 
context, if it was a function I would understand where to send the kwargs.. 
currently I get errors regarding missing the original context that would be 
passed to get_context_data since it is only getting my kwargs and not the 
original. 

Do I need to be adding 

if 'error': 
    error=error
    return render_to_response('template' {'error':error, 'form':form, 
'queryset':queryset})

as well as the original context I need, seems messy.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/f1cCwSjvzFsJ.
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.

Reply via email to