0

I make a searchqueryset with haystack in django and I have a query set:

results = SearchQuerySet().auto_query(q)

What I need is to add an item to each object of that query set. What I have is something like this:

results[0].object.name
results[0].object.age

etc. When I get this queryset in my views I want to add an item to each value maybe something like"x_number" and assign it. So when I retrieve de values of each item I have:

results[0].object.name
results[0].object.age
results[0].object.x_number

(Obviously x_number may have a value to... thats what I need to do actually)

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Marco
  • 315
  • 1
  • 3
  • 13

1 Answers1

0

In a SearchQuerySet, .object is just a reference to a model.

If you want to add a field, you can define it on your model, then assign it as you please. If you want to dynamically add a field to a model, that has been discussed here Creation of dynamic model fields in django.

Community
  • 1
  • 1
Kai
  • 269
  • 2
  • 4