Why does the 2nd statement below not work even though it is functionally equivalent to the 1st?
from django.shortcuts import render # works
import django.shortcuts.render as render # doesn't work

The error is telling you why: render isn't a module.
An example that might make it clearer - lets try to import a function from the math module:
>>> import math.pow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pow
>>> from math import pow
>>>
The pow function isn't a module, but the symbol (i.e. the function) can be imported from the module (math).
render() in django.shortcuts is a function. It's not a module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With