0% found this document useful (0 votes)
30 views1 page

Orm Lauch

The document provides instructions for setting up an empty Django project, including installing Django, creating a project and app, configuring settings, generating migrations, and querying models without running the development server. Key steps are to install Django, create a project and app with models, configure the settings file, make and apply migrations, and import Django settings to query models from Python code without starting the server.

Uploaded by

kritvladislav98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Orm Lauch

The document provides instructions for setting up an empty Django project, including installing Django, creating a project and app, configuring settings, generating migrations, and querying models without running the development server. Key steps are to install Django, create a project and app with models, configure the settings file, make and apply migrations, and import Django settings to query models from Python code without starting the server.

Uploaded by

kritvladislav98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

in empty project:

1. Install django ("pip install django")


2. Check django ("django-admin --version")
3. Create new project ("django-admin startproject 'project name' . 'dot means that
project are in current directory'")
4. From 'project name' move settings.py in project directory
5. Delete 'project name' package
6. In manage.py change "'project name'.settings" to -> "settings"
7. Configure settings.py to work only with databases (delete unnecesary data) and
change BASE_DIR = ... .parent.parent
to -> BASE_DIR = ... .parent
8. USE_TZ = False
9. python manage.py startapp 'name of app'
10. In 'name of app' dir leave only models.py and __init__.py
11. In settings.py write "'name of app'," in INSTALLED_APPS
in models.py:
1. class 'name of class' (models.Models):
2. Write fields: 'name of field' = models.CharField(max_lenght = 255)
migrations:
1. python manage.py makemigrations 'name of app'
2. python manage.py migrate
queryset:
1. Without server (magic):
create a init_django_orm:
-----------------------------
import sys
import os
import django

sys.dont_write_bytecode = True
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
django.setup()
------------------------------------------------------------
2. in main: import init_django_orm # noqa: F401
3. from 'name of app'.models import 'name of class'
4. print('name of class'.objects.all())
in settings of pycharm:
1. select django support

You might also like