setup a database in django
<p>I followed the django doc and went through the polls example. I have a sqlite db 'nameinfodb'. I want to access it by search last name online.
I setup models.py as </p>

<pre><code>class Infotable(models.Model):
    pid_text = models.CharField(max_length=200)
    lname_text = models.CharField(max_length=200)
    fname_text = models.CharField(max_length=200)
    affs_text = models.CharField(max_length=2000)
    idlist_text = models.CharField(max_length=2000)
    def __str__(self):
        return self
</code></pre>

<p>I copied name.info.db to where db.sqlite3 locates, changed settings.py:</p>

<pre><code>DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'name.info.db'),
    }
}
</code></pre>

<p>Then I run  </p>

<pre><code>python manage.py migrate  
python manage.py makemigrations pidb
</code></pre>

<p>Then I checked if I did correctly</p>

<pre><code>$ python manage.py sqlmigrate pidb 0001

BEGIN;
--
-- Create model Choice
--
CREATE TABLE "pidb_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL);
--
-- Create model Question
--
CREATE TABLE "pidb_question" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "question_text" varchar(200) NOT NULL, "pub_date" datetime NOT NULL);
--
-- Add field question to choice
--
ALTER TABLE "pidb_choice" RENAME TO "pidb_choice__old";
CREATE TABLE "pidb_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL, "question_id" integer NOT NULL REFERENCES "pidb_question" ("id"));
INSERT INTO "pidb_choice" ("id", "question_id", "choice_text", "votes") SELECT "id", NULL, "choice_text", "votes" FROM "pidb_choice__old";
DROP TABLE "pidb_choice__old";
CREATE INDEX "pidb_choice_7aa0f6ee" ON "pidb_choice" ("question_id");

COMMIT;
</code></pre>

<p>I didn't see any information about the new database, all I see is the example polls data. Did I do anything wrong here? All I need to do is connect to name.info.db, and access it by last name. Thanks!</p>

<p>You need to do it the other way around:</p>

<pre><code>python manage.py makemigrations pidb
python manage.py migrate
</code></pre>

<p><a href="https://docs.djangoproject.com/en/1.10/intro/tutorial02/#activating-models" rel="nofollow">See this part</a> of the tutorial for more information</p>

python django database