# Using static files ## 12.2 # ### 12.2.1 static files to configure and use the settings.py `` `Python STATIC_URL = ' / static / ' # Aliases STATICFILES_DIRS = [ the os.path.join (base_dir, ' static ' ), os.path.join (base_dir, ' static1 ' ), os.path.join (base_dir, ' static2 ' ) ] `` ` placed in the static folder static file, it should look like this: ` `` HTML <Link the rel = " this stylesheet " the href = " / static / CSS / Login / CSS " // Note: No matter what the name is called static files, static files need to find the post, using the alias, not the real name of the folder in the order of the list to find `` ` # ### 12.2.2 Simple examples of login issues form form submission data Note: the boycott action 1. submitted = "" request method = Method, " POST " 2 . All input boxes have the name attribute 3. there are a = input box of the type " the submit " or there is a button Note: submit post data request, the settings in MIDDLEWARE of ' django.middleware.csrf.CsrfViewMiddleware ' commented # ### 12.2.3 App App: - admin.py # Django Admin tools - modles.py # associated with ORM - views.py # write function Creating APP: - command line python manage.py startapp app name - PyCharm: Tools -> RUN manage.py Task -> startapp App Name Registration APP: `` `Python INSTALLED_APPS = [ ... ' app01 ' , ' app01 .apps.App01Config ' , # recommended wording ] `` ` # ### 12.2.4 ORM Django processes used in MySQL database: 1 create a MySQL database 2 configuration settings in, Django links MySQL database: 3 .' Python `` DATABASES = { default: { ' ENGINE ' :' Django.db.backends.mysql ' , # engine ' NAME ' : ' day53 ' , # database name ' HOST ' : ' 127.0.0.1 ' , # ip address ' PORT ' : 3306, # port ' the USER ' : ' root ' # users ' PASSWORD ' : ' 123 ' # Password } } `` ` 4 . In the init file and directory at the same level settings wrote: 5 . `` `Python Import pymysql pymysql.install_as_MySQLdb () ` `` 6 Create a table (written under the app models.py class): 7 . Python `` ` from django.db Import Models class the User (models.Model): username = models.CharField (MAX_LENGTH = 32) # username VARCHAR (32) password = models.CharField (MAX_LENGTH = 32) # password VARCHAR (32) `` ` 8 . commands to perform database migration 1. Python manage.py makemigrations # detection model.py registered under each model's change history record app The migrate Python manage.py 2. # synchronize changes to the database record orm operation `` `Python # acquired all the data in the table RET = models.User.objects.all () # QuerySet that the object list [Object] # Gets an object ( there and only) obj = models.User.objects.get (username = ' Alex ' ) # not obtain or acquire a plurality of given objects # acquired object satisfying the condition ret = models.User.objects.filter (username = ' Alex ' , password = ' ASD ' ) # QuerySet that Object list `