How can I filter SearchQuerySet results based on a specifice model and an ID

1k views Asked by At

This is the model, in which I want to search

class itemType(models.Model):
  partNumber = models.CharField(max_length = 12, null = True)
  designation = models.CharField(max_length = 200, null = True)
  timeCreate = models.DateTimeField() #auto update field, done in save method
  timeEdit = models.DateTimeField() #auto update field, done in save method

This is the view, I want to use to prepare my results

def itemtypedetails(request, itemtype_id):
  result = SearchQuerySet.models(itemType)
  #how can I filter the ID??
  return render_to_response('itemtypedetails.html', locals())

What I want is that my results are based on the model (itemType) and the ID of an itemType (itemtype_id).

I don't understand how to combine these two filters.
thanks for helping

1

There are 1 answers

1
SoWa On BEST ANSWER

Try to use .filter('your condition here')

result = SearchQuerySet.filter(ID=7).models(itemType)