Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:23:54+00:00 2026-05-26T23:23:54+00:00

The documentation for Django QuerySet API explains how to filter results using field lookups.

  • 0

The documentation for Django QuerySet API explains how to filter results using field lookups. The problem I have is that this approach requires the left hand operand to be a field and I need it to be an expression, to achieve the equivalent of (' ' || tagnames || ' ') LIKE '% xyz %'.

What’s the best way to do this? To clarify what I mean by “best”: I’m hoping for something that will be independent of the actual database used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:23:55+00:00Added an answer on May 26, 2026 at 11:23 pm

    One way you can accomplish this is the following (not sure if it’s necessarily the best way):

    from django.db.models import Q
    
    ...filter(Q(tag_name__startswith=tag_value+' ') | Q(tag_name__contains=' '+tag_value+' ') | Q(tag_name__endswith=' '+tag_value))
    

    Also, you can always just use the actual SQL you’re wanting to use with the raw method.

    SomeModel.objects.raw('SELECT * FROM my_table')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django's views documentation states that the default 500 view passes no variables to this
I read filter and exclude from django documentation but I want to know that
django nonrel's documentation states: you have to manually write code for merging the results
The Django documentation gives examples for using annotate() to produce aggregate results based on
I am having problems using django-tagging . I try to follow the documentation but
I'm totally new to django, and I'm using its documentation to get help on
Is it possible to combine a Django Haystack search with built-in QuerySet filter operations,
This example is from the Django documentation . Given the (Django) database model: class
I've been scanning through Django documentation, and Google search results, all afternoon and I'm
I'm using django-filter to drill down and would like to create breadcrumbs for each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.