How Do I Fetch Article that has #exam and NOT #example in Django? -
i trying fetch articles have "#exam"
ones have "#example"
content = "#exam tomorrow. prepared"
content1 = "#example 1 of ten"
hashtags = article.objects.filter(content__contains = '#exam')
return both content
, content1
, want articles contains #exam
any help appreciated!
an ugly (but simple) hack '#exam ' (note whitespace) instead. of course, instantly breaks there's other character there instead.
a more elegant solution craft regex
query match against #exam
not #example
. however, see regex field lookup entry in django documentation first, because exact look pass vary.
django django-models
No comments:
Post a Comment