Query a model and save output to another model

Is there a way to query a model and then save the output of the query to a different model?

Yes. Create a new instance of the new model with values from the fields retrieved from the query.

Do you know where I can find guidance on doing that?

Sure, see Creating Objects and Retrieving Objects.

I have tried that method but I cannot access the information within the Queryset after it is created.

Have you worked your way through either the official Django Tutorial or the Django Girls tutorial? If you haven’t that should be your first step - both show you how to access data retrieved from a queryset.

Beyond that, you could post the code you’re trying to use - we might be able to point out where the mistakes are.

1 Like