How to add a model instance (not from db) to queryset

Let's say I have a model called Schools. And also I have a Schools instance that I don't want to store in my database.

temp_school = Schools(school_id='temp_1')

Also I have all schools

schools = Schools.objects.all()

Now, how can I add my temp_school to the schools, so that I can use it as my new queryset in my view?

You can do this way I don't feel you need 2 queries for such usecases as far as I understand you.

Schools.objects.create(school_id='temp')
School.objects.filter(school_id='temp')
Back to Top