Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to create models in dijango

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 622
    Comment on it

    To create models in dijango to following thses step in given below:

    Step1- First you check your mysql is proparlly working in your systems.

    Step2- Than DB setting in the in your project like as

    'default': {
    'ENGINE': 'django.db.backends.mysql ', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' , 'oracle'.
    'NAME': 'poll', # Or path to database file if using sqlite3.
    'USER': 'root', # Not used with sqlite3.
    'PASSWORD': 'root', # Not used with sqlite3.
    'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
    'PORT': '3306', # Set to empty string for default. Not used with sqlite3.

    Step3- Than create app name in your mysql database like database name is poll.

    Step4- Than go to the path of your django project like as DAME

    cd /home/sachin/Downloads/Django-1.4/DAMO/

    Step4- Than Create the appname by using command given below

    python startapp poll (appname is your database name like a poll)

    Step5- Than After app creation done write code inside the script like as a

    from django.db import models
        class Person(models.Model):
            first_name = models.CharField(max_length=30)
            last_name = models.CharField(max_length=30)


    Step6- Then write the command for validating the using thsi command given below  

    python validate

    Step7- Than you check to the query works or not using this given below

    python sqlall Person (Person is the table name)

    Step8- Than useing this command to create table in your database

    python syncdb


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: