About me

Saturday, May 12, 2018

learn python django chap 2(Database Setup)

Friends this is the continuation from its previous post so i kindly recommend you to read that post i have made this very simple even a complete beginner can learn it and if you are beginner in python then you need to learn python i have made that blog also for that click this link

                               Database Setup

                   It is a python django project which is the continuation from the first part which is given on the sidebar please view that so you can understand this post after that open up mysite/settings.py. It’s a normal Python module with module-level variables representing Django settings. 


DEBUG = True


                                        There is an option as above This option lets you set if your project is in debug mode or not. Debug mode lets you get more information about your project's error. Never set it to ‘True’ for a live project. However, this has to be set to ‘True’ if you want the Django light server to serve static files. Do it only in the development mode.
                     
             
DATABASES = {
   'default': {
      'ENGINE': 'django.db.backends.sqlite3',
      'NAME': 'database.sql',
      'USER': '',
      'PASSWORD': '',
      'HOST': '',
      'PORT': '',
   }
 
              By default it uses SQLite. SQLite is included in Python, so you won’t
need to install anything else to support your database. but if you wish you can 
change the database as you wish like postgresql and  f you wish to use another 
database, install the appropriate database binding and change the following keys in the
DATABASES 'default' item to match your database connection settings
 
             
  • ENGINE – Either 'django.db.backends.sqlite3', 'django.db.backends.postgresql', 'django.db.backends.mysql', or 'django.db.backends.oracle'.
  • NAME – The name of your database. If you’re using SQLite, the database will be a file on your computer; in that case, NAME should be the full absolute path, including filename, of that file. The default value, os.path.join(BASE_DIR, 'db.sqlite3'), will store the file in your project directory.
 
 You can also set others options like: TIME_ZONE, LANGUAGE_CODE, TEMPLATE…
 If you are not using SQLite as your database, additional settings such as USER,
 PASSWORD, and HOST must be added. 

 INSTALLED_APPS setting at the top of the file. That holds the names of all Django 
applications that are activated in this Django instance. Apps can be used in 
multiple projects, and you can package and distribute them for use by others in
their projects.By default,INSTALLED_APPS contains the following apps, all of which
come with Django:
 
 
  • django.contrib.admin – The admin site. You’ll use it shortly.
  • django.contrib.auth – An authentication system.
  • django.contrib.contenttypes – A framework for content types.
  • django.contrib.sessions – A session framework.
  • django.contrib.messages – A messaging framework.
  • django.contrib.staticfiles – A framework for managing static files.
 
 These applications are included by default as a convenience for the common case.
 we have our "myproj" application, now we need to register it with our 
 Django project "myproject". To do so, update INSTALLED_APPS tuple in the
 settings.py file of your project (add your app name)
 Some of these applications make use of at least one database table, though,
so we need to create the tables in the database before we can use them. To do
that, run the following command:

                    
$ python manage.py migrate

 
 The migrate command looks at the INSTALLED_APP setting
and creates any necessary database tables according to the database settings
in your pysite/settings.py file and the database migrations shipped
with the app. You’ll see a message for each migration it applies.
 If you’re interested, run the command-line client for your
database and type \dt (PostgreSQL), SHOW TABLES; (MySQL), .schema
(SQLite), or SELECT TABLE_NAME FROM USER_TABLES; (Oracle) to display the
tables Django created.
 
 

THANKS FOR VIEWING MY BLOG NEXT POST IS ON "CREATING MODELS" HOPE YOU LIKE THIS BLOG PLEASE COMMENT YOUR SUGGESTIONS AND SHARE THIS BLOG TO YOUR FRIENDS AND DON'T FORGET TO FOLLOW THIS BLOG

 
 
 
 
 
 

2 comments:

  1. I like your blog, I read this blog please update more content on python, further check it once at
    web design services
    website designers in hyderabad

    ReplyDelete
  2. Automated Forex Trading :roboforex login Is An Automated Forex Investing Software. It Is An Algorithmic Trading Software That Provides Automated Forex Trading Signals.

    ReplyDelete