1

I have several notifications that can be sent out from my Django application for users. These users are managed with the django.contrib.auth app.

I need to keep track for each whether the user has specified he/she wants to get that notification.

Where should I save this information?

I was going to create my own custom table but I've seen perhaps I can save that information somewhere in the auth module?

Stan
  • 8,710
  • 2
  • 29
  • 31
user391986
  • 29,536
  • 39
  • 126
  • 205
  • exact duplicate: http://stackoverflow.com/questions/2886987/adding-custom-fields-to-users-in-django ... and well explained in the doc... – Stefano Dec 16 '11 at 11:04

1 Answers1

9

User Profiles are a good way to go.

https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Set up a model with a OneToOneField to your User object as described and you have easy access to an arbitrary table of extra information.

PS: Heed the note about the fact that profiles are not automatically created. There is an example about how to use a Signal to automatically create one whenever a User is created.

Yuji 'Tomita' Tomita
  • 115,817
  • 29
  • 282
  • 245
  • +1 for a very, very common and important use case. OneToOneField makes it nice and easy. Just be conscious when using profiles that foreign keys can point to either the actual user or its profile (and related_name for any foreign key from the profile will point to the profile, not the user). Seems obvious but can cause fun issues if you're not careful. – kungphu Dec 16 '11 at 01:24