Creating Table/BD with Django?

Asked

Viewed 584 times

1

I use python 3.4 and the latest version of Django, I am using the command "python Manage.py sqall" but does not recognize the sqall command. (I’m trying to create a table in Bd, and already insert the data correctly).

1 answer

1


Daniel for your table to be created it is necessary that your app is properly mapped inside your file py Settings.

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'exemplo'

]

The command is used to make the migration correctly python manage.py makemigrations for him to collect all the changes made to his project, finally call python manage.py migrate for changes to be applied in the database.
In this stage, if your table does not exist, the migrate will take care of it.

To better understand the subject of a read in the documentation initial. I quote here a fragment from the source to make it clear:

The migrate command checks the INSTALLED_APPS configuration and creates any database table required according to the database settings in your mysite/Settings.py file.

  • it returns "No Migrations to Aply". And I tested it in a Git functional code from a friend of mine....

  • In this case, probably the tables have already been created, you have access to the bank ? Could you update your question with an example of code ? is easier to analyze

  • 1

    Before executing the cameo migrate, you should make known about the modifications you made to your code, in terms of database structure. To inform, you use the command makemigrations, without running this command before, you can change the structure and then run migrate and he will continue to report in Migrations to apply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.