python - Django notification giving error for other model -


The following code is working for the comment code.

django import django.db from django.db # removes this if-block, you also have edit notifications for the comments: import .contrib.sites.models from django.db.models Notification def new_comment (this example, created, ** kwargs) is not imported if prompted as a sign from the Site Notification Import Model: Return is not a reference: {'Comment': Example, 'Site': Site. Objects.Getacurant ())} Recipient = [] For example, the recipient is given a comment Also add all users to comment on the object .__ class__ objects.for_model (instance.content_object): comment.user if the recipient and not comment.user = instance.user: recipients.append (comment.user) # If commented object a user then it does not include that isinstance (informed Instance.content_object, models.get_model ( 'auth', 'user')): # If the post has a comment which recipients it instance.content_object = instance. User and instance.content_object not in recipients: recipients.append (instance.content_object) notif ication.send (recipients 'Friends_invite' reference) signal .post_save.connect (new_comment, this = models.get_model ( 'comment', 'comment'))

But when we break Commenting the custome model, the time to record the same code in the model to give this error. Import from Django.contrib.sites.models from django.db import model import from import django.db.models as imported import signals from site import notification model as DEF. Create_notice_types (application, Created_models, verbiage, ** kwargs): notification.create_notice_type ( "friends_invite", _ ( "invitation") _ ( "you have received an invitation")) Notificationkcreate_notice_type ( "Friends_accept", _ ( "acceptance") _ ( "an invitation ACC have been sent by Pted")) Signalskpost_syncdbkconnect (Create_notice_types, the = notification) def New_comment (in this instance, built, ** kwargs): # this if Removes the block, so you want to edit the comment, even if not created: refund no reference = {'gufeed_feedcomment': ud The hijacking, recipients} = [] # to add recipients (instance.content_object) of the same object note to all users class __ objects.for_model comment .__ example: comment.user if the recipient and not in the comments. .user = instance.user: recipients.append (comment.user) # If the object of the comment is notified if a user isinstance (instance.content_object, models.get_model ('authentication', 'user')): # he not the one who re-joined comments to recipients if instance.content_object = instance.user and instance.content_object recipients: recipients.append (instance.content_object) notification.send (recipients, 'friends_invite', context) Signals.post_save.connect (new_comment, this = models.get_model ('gufeed_feedcomment', 'FeedHottPoint'))

Note: We already have this Attributes are taking friends_invite information types

Error: / gufeed / comment on AttributeError / add / 'manager' object is not a property 'for_model'


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -