These are chat archives for django/django

9th
Oct 2017
MilanRgm
@MilanRgm
Oct 09 2017 03:11 UTC
I am trying to create a follower system where user can get to follow investor not between user and user but between user and investor. However I am getting an error.

class Investor(models.Model):
    investor = models.ForeignKey(User, on_delete=models.CASCADE)
    name = models.CharField(max_length=200, blank=False,
                            null=False, help_text='Full Name')
    followers = models.ManyToManyField(
        User, related_name='followers', blank=True)

       @classmethod
    def follow_investor(cls, investor, follower):
        investor, created = cls.objects.get_or_create(investor=investor)
        investor.followers.add(follower)

    @classmethod
    def unfollow_investor(cls, investor, follower):
        investor, created = cls.objects.get_or_create(investor=investor)
        investor.followers.remove(follower)



url(r'^investor/(?P<action>.+)/(?P<slug>[-\w]+)$',
    views.follow_unfollow_investor, name="follow-unfollow-investor"),


def follow_unfollow_investor(request, action, slug=None):
    follower = request.user
    investor = Investor.objects.get(slug=slug)
    if action == "add":
        Investor.follow_investor(investor, follower)
    elif action == "remove":
        Investor.unfollow_investor(user, follower)
    return redirect('/')
ValueError: Cannot query "": Must be "User" instance.
MilanRgm
@MilanRgm
Oct 09 2017 10:33 UTC
I have posted my question on SO either but waiting for help :) https://stackoverflow.com/questions/46643537/valueerror-cannot-query-must-be-user-instance
Jesse Hodge
@Chameleon87
Oct 09 2017 17:30 UTC
Screen Shot 2017-10-09 at 12.27.40 PM.png
cannot for the life of me figure out why this isn't printing anything or creating the message object
Fabian
@fabiand93
Oct 09 2017 22:10 UTC
I'm looking for someone that could enlighten me with django multiprocessing