Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django通知设置问题_Python_Django - Fatal编程技术网

Python Django通知设置问题

Python Django通知设置问题,python,django,Python,Django,我是django的新手,我刚刚在我的项目中安装了django通知。现在我已经设置好了,安装好了,并添加了这个信号 notify_send = request.user.profile.get_absolute_url() notify.send(notify_send, recipient=pending_like, verb='Sent you a friend request' ) 当一些用户喜欢另一个用户时,这种方法非常有效,因此我可以查看/inbox/notifications/,然后

我是django的新手,我刚刚在我的项目中安装了django通知。现在我已经设置好了,安装好了,并添加了这个信号

notify_send = request.user.profile.get_absolute_url()
notify.send(notify_send, recipient=pending_like, verb='Sent you a friend request' )
当一些用户喜欢另一个用户时,这种方法非常有效,因此我可以查看/inbox/notifications/,然后看到通知

汤姆史密斯给你发了一个朋友请求

一分钟前

“没有”

因此,它工作得非常完美,但是我如何使它成为可点击的,并且查看它的人可以点击名称进入他的个人资料?这是动作对象吗?无代表什么?抱歉,如果这让人困惑,但我无法理解它

我有一个名为profiles的profile应用程序

class Profile(models.Model):
    user = models.OneToOneField(User)
    location = models.CharField(max_length=120, choices=LOCATIONS,null=True, blank=True)
    picture = models.ImageField(upload_to=upload_location, null=True, blank=True)


    def __unicode__(self): 
        return self.user.username


    def get_absolute_url(self):
        url = reverse("profile", kwargs={"username": self.user.username})
        return url

    def like_link(self):
        url = reverse("like_user", kwargs={"id": self.user.id})
        return url`
我的错误代码是:

/like/13/'unicode'对象的AttributeError没有属性“\u meta” 请求方法:获取

在追踪中

notify.send(notify\u send,recipient=pending\u like,verb='send's) 好友请求')

actor\u content\u type=ContentType.objects.get\u for\u model(actor)


提前感谢您的帮助。

一种方法是为每个配置文件定义一个(在
配置文件
模型中),然后在
通知中使用它。发送

notify_send = (request.user.profile, ...)
但是在通知中,而不是在tomsmith中,您将有到tomsmith的链接

编辑

重新定义您的
\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

def __unicode__(self): 
    return self.user.get_absolute_url(self)

我认为“None”表示您在“notify.send”方法调用中遗漏了一些参数或提供了一个参数,其中参数值为null(在python中为None)。谢谢“但是我现在得到的错误是'unicode'对象没有属性'\u meta',这是get_absolute_url
def get_absolute_url(self):url=reverse(“profile”,kwargs={“username”:self.user.username})返回url
@caldf try
def get_absolute\u url(self):
返回反向('profile',args=[self.user.username])
很抱歉,这是一个痛苦的doru,但没有用。这是我的个人资料模型<代码>类配置文件(models.Model):user=models.OneToOneField(user)location=models.CharField(max_length=120,choices=LOCATIONS,null=True,blank=True)picture=models.ImageField(upload_=upload_location,null=True,blank=True)def_uunicode_u(self):返回self.user.username def get_绝对值url(self):url=reverse(“配置文件”,kargs={“username”:self.user.username})返回url定义like_link(self):url=reverse(“like_user”,kwargs={“id”:self.user.id})返回url