Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

16 Further improving the UI

scotwk edited this page May 10, 2015 · 6 revisions

We want to be able to display all the user's notes to them on each page (creating or editing a note).

A second mixin

To do this we'll make a mixin that edits the context sent to the template to include all the user's notes.

from .models import Note

...

class NoteMixin(object):
   def get_context_data(self, **kwargs):
       context = super(NoteMixin, self).get_context_data(**kwargs)

       context.update({
          'notes': Note.objects.filter(owner=self.request.user).order_by('-pub_date'),
       })
       
       return context

Get new templates

Download the new templates:

cd note
wget https://github.com/sixfeetup/ElevenNote/raw/master/templates-ch16.zip
unzip templates-ch16.zip   # If prompted to replace, say (Y)es
cd ..