On Feb 16, 4:55 am, Anderson Borges <andersondbor...@gmail.com> wrote: > Hey guys > I am learning django and I have a question > I have a table in my database call SettingsUser so how can I load this table > to all views on my application?
I just don't understand what "loading a table" is supposed to mean. If you want to make some object (model instance or whatever) available to all your templates, a context processor will do the job. If you want to make it available to all your views, you can use a middleware and attach the relevant object(s) to the request object. Now given the name ("settingsuser") I suspect it's a kind of "per-user settings" stuff. If so, the SettingsUser model should have a foreignkey on User, and then you can just follow the reversed relationship, ie: # youmodels.py class UserSetting(models.Model): user = models.ForeignKey(User, related_name="settings") parrot_is_dead = models.BooleanField(u"Is user's parrot dead ?", default=True) # yourviews.py def something(request, *args, **kw): print request.user.settings.all() HTH -- You received this message because you are subscribed to the Google Groups "Django users" group. 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.