Hello,
I'm wanting to select a record from my Discounter class that contains
a certain string from another string. My Discounter class looks like
this:
class Discounter(models.Model):
code = models.CharField(maxlength=100)
In my view I get a variable called 'message'. I want to search
through all my Discounter records and get the record (if any) that's
code field is within my message string.
For example let's say that that I have a Discounter record who's code
value is '123'. And let's say that our 'message' variable contains
the string 'This is a test 123 This is a test'. I would then want the
Discounter record whose code is '123' to be returned. However I'm not
sure how to do this. Here is my QuerySet:
Discounter.objects.get(code__##????????##=message)
Using the contains or exact filters do not work, because my code
variable is not going to contain the entire message contents. How do
i find out if my code string is within my message string?
I'm thinking that I might have to create a for loop, which loops
through every Discounter record and checks to see if the 'code'
variable is in the 'message variable.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---