When a user logs into my site I would like to perform a check on some data and depending on the result, display a custom message to them, rather than the standard message, which is "Welcome back user, you are now logged in".

This message seems to be hardcoded in /views/auth.py. Any suggestions on the best way to go about this?

I'm not really familiar with the actions api yet, which might do the trick for me? but i figure doing it this way might now make it possible to replace the standard message?

asked 09 Nov '10, 23:08

rsp's gravatar image

rsp
41661420
accept rate: 66%

edited 25 Nov '10, 12:22

rickross's gravatar image

rickross ♦♦
12.5k2914972


I'm also trying to figure this out since I don't want to see "Welcome back" to someone who logged in for the first time ever.

I can point out that this message is not hard coded. The code uses the _(), which provides localization through the gettext package. To solve my problem, I went to osqa/locale/en/LC_MESSAGES and edited django.po so

#: forum/views/auth.py:353
#, python-format
msgid "Welcome back %s, you are now logged in"
msgstr "Welcome %s, you are now logged in"

I then read the gettext documentation and did

msgfmt django.po -o django.mo

followed by a restart of the Django instance. That caused the login title to change.

As far as I can tell, the only way to get what you want is to modify views/auth.py . Still, I'm answering this question here since someone looking for what I wanted will likely find you question.

link

answered 25 Nov '10, 05:32

dalke's gravatar image

dalke
3411412
accept rate: 18%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×44
×23
×12
×11
×2

Asked: 09 Nov '10, 23:08

Seen: 897 times

Last updated: 25 Nov '10, 12:22

powered by OSQA