2👍
✅
You could use the Django test client. The response’s content
contains the html of the page.
from django.test import Client
c = Client()
response = c.get('/mymodel/1')
content = response.content
Source:stackexchange.com