Show choosen option in a notification Feed, Django

Posted by apoo on Stack Overflow See other posts from Stack Overflow or by apoo
Published on 2010-12-22T01:26:39Z Indexed on 2010/12/22 1:54 UTC
Read the original article Hit count: 585

Hey

I have a model where :

LIST_OPTIONS = (
                ('cheap','cheap'),
                ('expensive','expensive'),
                ('normal', 'normal'),
    )

then I have assigned the LIST_OPTIONS to nature variable. nature = models.CharField(max_length=15, choices=LIST_OPTIONS, null=False, blank=False).

then I save it:

if self.pk:
        new=False
    else:
        new=True
    super(Listing, self).save(force_insert, force_update)

    if new and notification:
        notification.send(User.objects.all().exclude(id=self.owner.id),
            "listing_new",
            {'listing':self, },
        )

then in my management.py:

def create_notice_types(app, created_models,verbosity, **kwargs):
    notification.create_notice_type("listing_new", _("New Listing"),
            _("someone has posted a new listing"), default=2)

and now in my notice.html I want to show to users different sentences based on the options that they have choose so something like this:

 LINK href="{{ listing.owner.get_absolute_url }} {{listing.owner}}

      {% ifequal listing.nature "For Sale" %}
   created a {{ listing.nature }} listing, <a href="{{ listing.get_absolute_url }}">{{listing.title}}</a>.

    {% ifequals listing.equal "Give Away"%}
    is {{ listing.nature }} , LINK href="{{ listing.get_absolute_url }}" {{listing.title}}.

     {% ifequal listing.equal "Looking For"%}
     is {{ listing.nature }} , LINK href="{{ listing.get_absolute_url }}" {{listing.title}}

   {% endifequal %}      
   {% endifequal %}   
   {% endifequal %}   

Could you please help me out with this. Thank you

© Stack Overflow or respective owner

Related posts about django

Related posts about templates