Nisanth Reddy
Nisanth Reddy

Reputation: 45

render() missing 1 required positional argument: 'template_name'

The following screenshot contains the code of my views.py code:

screenshot

I am getting the error:

render() missing 1 required positional argument: 'template_name'

while running the url from pycharm.

Any ideas why this is happening?

Upvotes: 0

Views: 14651

Answers (3)

Subhodeep Chandra
Subhodeep Chandra

Reputation: 17

check out this screenshot

you can use either render(request, "template_name") or redirect('/template_name/') i've used redirect('/') to redirect to the same page

Upvotes: 0

Power Invincible
Power Invincible

Reputation: 26

Look at your django settings.py "TEMPLATES" DIRS configure is ok.

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates')],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
        ],
    },
},]

Upvotes: 0

Ines Tlili
Ines Tlili

Reputation: 810

First argument of render() is missing, update it like this :

return render (request,'blabla.html')

Upvotes: 17

Related Questions