freethrow
freethrow

Reputation: 1108

django simple relation in template

I have more of a logical problem then a programming one. I have a kind of a social networking sites, where users follow each others (similar to Twitter). What would be the best way to check in a template if a user does/doesn't follow another user so I can display a "follow" link accordingly? I was thinking some custom function, like a manager, that checks for the request.user and then returns true or false if there is already a link relation or not.

Upvotes: 0

Views: 51

Answers (1)

dm03514
dm03514

Reputation: 55972

It completely depends on how you implemented your following. There has to be some way to connect a user and their followers. You can just query the model that holds the followers and if count() is greater than 0 display the link.

Upvotes: 2

Related Questions