Home > Net >  "from django.shortcuts import render" gets me an error (red wavy line)
"from django.shortcuts import render" gets me an error (red wavy line)

Time:09-17

I have a decent amount of experience with Django, but recently I opened one of my old Django projects and realized there was something wrong with it. I looked through the files and I found that there were red wavy lines under: from django.shortcuts import render, from django.views import View, indicating that there is an error. I did not change anything I do not know what caused it. When I run the server I also get an error saying "name 'request' is not defined". Pleae help, here is the code:

from django.shortcuts import render from django.views import View

class Index(View): #creating different methods def get(self, requst, *args, **kwargs): return render(request, 'landing/index.html')

CodePudding user response:

Do you use virtual enviroment and have all required packages installed (e.g. django).

Does "venv" directory or something like that exist in your project? If so, activate it by .\venv\Script\activate on Windows or 'source venv/bin/activate' on linux.

If it doesn't exist, create it with e.g. virtualenv, activate it and install packages via pip

CodePudding user response:

Hmm, that is odd, but try this:

import django.shortcuts.render as render
  • Related