tags:

views:

18

answers:

2

How can I access multiple variables at different positions? How does %s have to look like at inseration point and how at the end to correctly insert the variables.

Thanks!

Here is the code:

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>

            </body>
        </html>''' % ( title, email, image
        )
    return HttpResponse(output)
A: 

Your question is a little bit hard to grasp, but take a look at the Python docs

zwip
A: 

not sure what you are asking. do you just want to insert multiple values in your string?

"value 1 is %s, value 2 is %s." % (value1, value2)
second
That was it. Thanks!
MacPython