Home > front end >  Django importing of module
Django importing of module

Time:01-06

I am just going through some Django code:

from django.shortcuts import render

I have few question regarding this:

  • This render thing how do we know this needs to be imported from django.shortcuts?
  • Can we see render it lies in this folder django.shortcuts,?
  • Where is this located on a drive django.shortcuts ?

thank you!

CodePudding user response:

  • This render thing how do we know this needs to be imported from django.shortcuts?

The main way for you to know what these functions are by referring to the documentation. When you've used it several times, you'll understand what function to use according to the situation. Django has one of the best documentations I've seen for any project. The specific topic you're looking for is here.

  • Can we see render it lies in this folder django.shortcuts,?
  • Where is this located on a drive django.shortcuts ?

Actually, if you want to see how it works, you can. Django library code is not in your project directory. It's in the site-packages directory. If you're using a virtual environment (which you should), django.shortcuts can be found at <virtual_env_dir>/lib/python3.x/site-packages/django/shortcuts.py.

However, if you want to find a function for a particular purpose, I recommend trying the online documentation first, before diving into the source code.

Kudos on being curious!

  •  Tags:  
  • Related