If I want to insert a variable %s into this
<p><img src= %s alt="tetris"/></p>
I have the problem that if I use "%s"
, it wont recognize it as the placholder it is.
But if just use %s
it wont link to my image.
Is there a way around this?
I tried to insert the url that is inserted there like this in the database ''/url/''
.
But that wont do the trick either.
Any suggestions?
@thomas:
from django.http import HttpResponse
from django.contrib.auth.models import User
from favorites.models import *
def main_page_favorites(request):
title = Favorite.objects.get(id=1).title.upper()
email = User.objects.get(username='Me').email
image = Hyperlink.objects.get(id=3).url
output = '''
<html>
<head>
<title>
Connecting to the model
</title>
</head>
<body>
<h1>
Connecting to the model
</h1>
We will use this model to connect to the model!
<p>Here is the title of the first favorite: %s</p>
<p>Here is your email: %s </p>
<p>Here is the url: %s </p>
<p>Here is the url embedded in an image: <p><img src= %s alt="tetris"/></p>
</body>
</html>''' % (
title, email, image, image
)
return HttpResponse(output)