Data Science Explorer

Django Common Command Words That You Must Know 본문

Django

Django Common Command Words That You Must Know

grace21110 2023. 8. 2. 08:37
반응형

Django Project Set-up 

  • Create a new Django project

This command will create a new Django project with the given project name.

django-admin startproject <project_name>

 

  • Create an app

This command will create a new Django application within the project directory. 

django-admin startapp <app_name>


Development and Testing

  • Run the development server

This command will start the development server for your Django project.

python manage.py runserver


Database Tasks 

  • Prepare the database for migrations 

This command will prepare the database for migrations for your Django project.

python manage.py makemigrations

 

  • Make the database migrations

This command will run any pending database migrations for your Django project.

python manage.py migrate

 

  • Show previous migrations

This command will show you the list of previous migrations for each app within your project.

python manage.py showmigrations

 

  • Unapply migrations 

This command will help revert back to a previously migrated version. 

  • Tip: use the "showmigrations" command to see the previous migrations.

python manage.py migrate [app_name] [migration_name]


Admin tasks

  • Create a superuser

This command will create a new superuser account for your Django project. If the password is too common, Django will give a prompt but allow you to override it. 

python manage.py createsuperuser

 

  • Change user password

This command will change the password of a given user.

python manage.py changepassword [username]


Testing 

  • Run test

This command will run the Django test suite based on tests defined in the test.py file within your project/app.

python manage.py runtests

 

 

'Django' 카테고리의 다른 글

How Django Works  (0) 2023.08.03
What is Django?  (0) 2023.08.02