python - Django insert into list if doesn't contain it -
i want insert notifications list, 1 notification of each type. , have this:
result initial query (i guess list queryset), named notifications
:
[<notification: should first>, <notification: new link>]
and restriction have is:
for(note in notification): if len(note.region.all()) == 0 , (note.notificationtype.priority not in notifications): notifications.append(note)
my question is, how inside notifications list attribute notificationtype.priority see number isn't inside notifications
list.
if question, can try :
notificationspiorities = set([note.notificationtype.priority note in notifications ]) for(note in notification): if len(note.region.all()) == 0 , (note.notificationtype.priority not in notificationspiorities ): notifications.append(note) notificationspiorities.add(note.notificationtype.priority)
also, may need rename variables. can't tell sure notification
, notifications
. 1 list display, , 1 list retrieve query ?
Comments
Post a Comment