Hi,
I’m sure the answer to this must be simple but try as I might I can’t find it and I’ve been trying for an hour 
Is there a way given either a path /foo.htm or the path name view_foo (I have both) to then get back the HTML rendered for a request to that i.e. what the browser would receive?
This is from within a custom management command so I wouldn’t be using render_to_string or anything like that where I would need the template name, it would be a level removed from that.
I was thinking I might need to manually make a HttpRequest object but then wasn’t sure what to pass it to and I’m trying to stick to the internals of Django rather than falling back to curl or similar.
Thanks,
Ian
The short answer is “yes”, with a number of caveats and “what abouts”.
A view is a function that takes a request and returns a response - it doesn’t really care what calls it.
Do you need to go through the URL, or can you call the view directly?
Do any of these views need middleware to have been exectued?
Are any of these views protected by the authentication mechanisms? (Decorators or mixins)
Are these views purely “GET” requests, or are you looking to “POST” data to them?
(There are probably other issues to consider as well, but these are what just pops off the top of my head.)
I’ve done it thank you, ‘A view is a function that takes a request and returns a response - it doesn’t really care what calls it.’ is the key bit as all the pages run through one function so I simply called that as needed. I was over complicating my thinking as usual!
It’s a very small thing I’m working on and not a very django-y project really but I wanted to leverage all of the templating so no complicated bits involved. I think I should be good to go now thank you 
Ian