- messages are bound up with a logged in user. they actually have their own class: django.contrib.auth.models.Message with a FK to users.
- messages get added to the user directly: (e.g. this was taken from
create_update.create_object)
request.user.message_set.create(message=ugettext("The %(verbose_name)s was created successfully.") % {"verbose_name": model._meta.verbose_name})
- the very next time a page is rendered "messages" will be available as a variable in the template. use it or lose it. it will be consumed whether you display it or not.
- part of the "magic" (to me) was where this was coming from. global_settings.TEMPLATE_CONTEXT_PROCESSORS has 'django.core.context_processors.auth'
- when RequestContext is instantiated for a request to be used in a template it loops over the items in TEMPLATE_CONTEXT_PROCESSORS one of which is the function auth from above which returns a dictionary of 'user', 'messages', 'perms'
Not so magical now, but interesting.
No comments:
Post a Comment