Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django tutorial. from . import views

I started to learn Django, I don't know python very well, so please forgive me, if the question is quite stupid).

from . import views

what is "." in this statement? Module's name?

like image 884
Sizuji Avatar asked May 30 '17 12:05

Sizuji


People also ask

How do I import views into Django?

shortcuts import render from django. http import HttpResponse def index(request): return HttpResponse("Hello World!") Now, you can create another app, in your Django project, called my_second_app and you should repeat the above steps for that app too.

What does from import views mean?

It means from the current directory import views.py module.

How will you import view?

From the Views panel, click Manage. Select a view and click the Import option from the horizontal ellipsis next to the Add option. Browse to select the Virtual Machines Distribution content definition XML file and click Import.

What are views used for in Django?

Django views are a key component of applications built with the framework. At their simplest they are a Python function or class that takes a web request and return a web response. Views are used to do things like fetch objects from the database, modify those objects if needed, render forms, return HTML, and much more.


1 Answers

The single dot is a convention from command line applications. It means the current directory. In terms of Django it stands for the directory/module the current file is on.

like image 187
Hubert Grzeskowiak Avatar answered Oct 13 '22 00:10

Hubert Grzeskowiak