I am trying to understand this piece of code written in python in a Django App
from . import views
I haven't come across anything like this in the python documentation. Can somebody explain ?
I am trying to understand this piece of code written in python in a Django App
from . import views
I haven't come across anything like this in the python documentation. Can somebody explain ?
It's a relative import. It lets you import modules from the same package without specifying the package name. So, if you're in the foo.views module, instead of:
from foo.models import Model
you can do:
from .models import Model
This lets you change the package name without refactoring all the imports in that package.