Note that there are some explanatory texts on larger screens.

plurals
  1. POproviding initial data to django model
    primarykey
    data
    text
    <p>how to popolate table with initial data. ?? i have read this : [1] <a href="https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data" rel="nofollow">https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data</a></p> <p>direc tree :</p> <pre> |-- manage.py |-- mydb |-- QAapp | |-- __init__.py | |-- __init__.pyc | |-- migrations | | |-- 0001_initial.py | | |-- 0001_initial.pyc | | |-- 0002_auto__add_report__add_questioncontainer.py | | |-- 0002_auto__add_report__add_questioncontainer.pyc | | |-- __init__.py | | `-- __init__.pyc | |-- models.py | |-- models.pyc | |-- sql | | |-- questioncontainer.sql | | `-- scrap.py | |-- tests.py | `-- views.py `-- QAsite |-- __init__.py |-- __init__.pyc |-- settings.py |-- settings.pyc |-- urls.py `-- wsgi.py </pre> <p>Model file :</p> <pre><code>from django.db import models class QuestionContainer(models.Model): topic = models.CharField(max_length=100) subtopic = models.CharField(max_length=100) question = models.TextField() options = models.TextField() correct_answer = models.CharField(max_length=50) total_attempts = models.IntegerField() solved = models.IntegerField() level = models.IntegerField() class Report(models.Model): name = models.CharField(max_length=200) email = models.EmailField() content = models.TextField() QuestionContainer = models.ForeignKey(QuestionContainer) </code></pre> <p>questioncontainer.sql contains </p> <pre><code>INSERT INTO QAapp_QuestionContainer (topic,subtopic,question,options,correct_answer,total_attempts,solved,level) VALUES ('general-aptitude','age-problems','The Average age of a class of 22 students in 21 years. The average increases by 1 when the teachers age also included. What is the age of the teacher?','A. 44 C. 41 B. 43 D. 40','[A]',0,0,0); </code></pre> <p>Problem is : do i need to add something to manage.py [or] execute some command from shell [or] any other thing in order to populate table with those insert querys ??</p> <p>I have tried :<br/> python manage.py sqlall<br/> python manage.py syncdb<br/></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload