Skip to content

Instantly share code, notes, and snippets.

@maxg203
maxg203 / see_friends_example.md
Last active October 16, 2018 22:41
Find the corresponding users that added a given user as a friend.
class Friend(models.Model):
    users = models.ManyToManyField(User)
    current_user = models.ForeignKey(User, related_name='owner', null=True)

    @classmethod
    def who_added_user(cls, user):
        users = []
        for friend in cls.objects.all():
 if user in friend.users.all():
@maxg203
maxg203 / deployment_cheatsheet.md
Last active May 25, 2017 12:18
Apache Server Admin and Deployment