Skip to content Skip to sidebar Skip to footer

How Import A Function From Another View With Django?

I have this folder hierarchy: |---- saga |---- core |---- views.py |---- study_time |---- views.py On my study_time/views.py, I have this functions: def

Solution 1:

You've defined a nested function. That simply isn't visible outside the containing function; in fact, making it invisible from outside is pretty much the only good reason for defining nested functions in Python. Don't do that; move it outside the study_time function.

(Also, don't use double-underscore prefixes like that. They don't make any sense outside a class; and even there you should rarely if ever use them.)

Solution 2:

The inner function is not accessible,because it is local code for that function only. It is not generic for all in the views.py . So make a distinction on this.

Go through this for better understanding!! https://realpython.com/blog/python/inner-functions-what-are-they-good-for/

Happy coding!!

Post a Comment for "How Import A Function From Another View With Django?"