0% found this document useful (0 votes)
81 views

Django CMD

The document provides instructions for common Django commands: 1) python manage.py runserver runs the development web server. 2) python manage.py makemigrations and python manage.py migrate manage database migrations. 3) python manage.py collectstatic collects static files. 4) python manage.py startapp creates a new application. 5) python manage.py startproject creates a new project.

Uploaded by

suresh
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

Django CMD

The document provides instructions for common Django commands: 1) python manage.py runserver runs the development web server. 2) python manage.py makemigrations and python manage.py migrate manage database migrations. 3) python manage.py collectstatic collects static files. 4) python manage.py startapp creates a new application. 5) python manage.py startproject creates a new project.

Uploaded by

suresh
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1) python manage.

py runserver
2) python manage.py makemigrations
3) python manage.py migrate
4)python manage.py collectstatic
5) python manage.py startapp
6) python manage.py startproject

Download ZIP
Django Command Notes
Raw

django-command

>python manage.py runserver

# then you can view the page here: (http://127.0.0.1:8000/)

#How to start the python interpreter:

#(You can then run python commands)

>python

#How to create a new site

#run this command in the same directory you want the site created.

>django-admin.py startproject mysite

#if you dont have the path setup go to the directory and type this on dos:

c:\Python27\Scripts\django-admin.py startproject project_name

#To create an app, type this in the site directory:

>python manage.py startapp books


#How to start the interpreter with django template settings

>python manage.py shell

#How to find out the django version and find out if django is running on your
server:

>import django

>django.VERSION

#To quit the python interpreter and go back to dos#

>quit()

###Django database Notes###

#To Validate the models:

>python manage.py validate

#To run the SQL command for the app books (This does not create the database):

>python manage.py sqlall books

#If the last commands looks good, here is the command to sync the db and create it:

>python manage.py syncdb

###SQLite3 Notes###

#Just create a database file in your windows directory, you dont need to go through
sqlite3 or the console commands to do that.

#When you install SQLite, make sure its in your windows path so you can execute the
SQLite in the command prompt.
#To open a db in sqlite3, go to the directory of your db and type in:

>sqlite3 [name of your db]

#SQLite3 comes with Python, you dont need to install from my experience.

#Download the sqlite-shell program to run the console here:

http://www.sqlite.org/download.html

#You need to get into the console to create a database table and ultimately save it
to a file.

#When you run the console exe program, you get a dos prompt with the "sqlite>"
prompt,

#this means you can initiate sqlite commands.

#type this for a list of commands inside the sqlite console:

.help

#This is how it could work for sqlite, which does not allow to modify a column
directly (http://www.sqlite.org/lang_altertable.html):

ALTER TABLE books_book RENAME TO tmp_books_book;

CREATE TABLE "books_book" ( "id" integer NOT NULL PRIMARY KEY, "title" varchar(100)
NOT NULL, "publisher_id" integer NOT NULL REFERENCES "books_publisher" ("id"),
"publication_date" date NULL );

INSERT INTO books_book(id, title, publisher_id, publication_date) SELECT id, title,


publisher_id, publication_date FROM tmp_books_book;

DROP TABLE tmp_books_book;

You might also like