0

I am writing a Django management command that visits a few pages, logged in as a superuser, and saves the results to a set of .html files.

Right now I'm just using the requests library and running the command with the development server running. Is there an easy way to generate the HTML from a view response so I do without actual HTTP requests?

I could create a request object from scratch but that seems like more overhead than the current solution. I was hoping for something simple.

2 Answers 2

1

Django has a RequestFactory which seems to suit your needs.

Sign up to request clarification or add additional context in comments.

Comments

0

While it's not exactly meant for this purpose, an option would be to use the testing framework's Client to fake a request to the url - be sure to use client.login() before making your requests, to ensure you have superuser capabilities.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.