To be continued

urls: store address
model: define variables and other information in the database
view: store method, link to html

day21: store the addition of student information and view
test2: output hello. You can enter admin, add student information
helloworld: insert a piece of data into the network database; output hello and hellogirl

Create admin user user:
python manage.py createsuperuser

When the execution of python manag.py makemigrations has been unsuccessful, the solution:
1. Force execution: python manag.py makemigrations appName
2. Enter the command line, mysql -u root -p
show databases
use database name
delete from django_migrations where app= 'app name'
Note: Entering navicat to manually delete all tables does not delete the data generated when makemigrations is executed. The data is hidden and needs to execute the above command to delete it completely

The django list does not display specific values, but displays the solution as object
1. Select the type, all displayed as object, not specific class values
​​2. After many attempts, it is found that the models.py code needs to be modified. The original code is as follows:
class Type(models.Model):
consumption_type = models.CharField('Location name', max_length=50)

class Meta:
     db_table = 'consump_type'

Modified code:
class Type(models.Model):
consumption_type = models.CharField('Location name', max_length=50)

class Meta:
     db_table = 'consump_type'

def __str__(self):
    return self.consumption_type

Set cookies, parameters and corresponding key names and values
​​res.set_cookie("name", 123)

django learning record - cmd method plug-in data report: "RuntimeWarning: DateTimeField Event.start_time received a naive datetime
December 22, 2016 10:17:56
Readings: 850
When inserting data through CMD, because the data contains a date type, so Will report: RuntimeWarning: DateTimeField Event.starttime received a naive datetime (2016-09-02 10:20:00) while time zone support is active. Error.

Error reason: It is related to UTC (Universal Standard Time).

Workaround: set in the .../settings.py file: USE_TZ = False

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325520630&siteId=291194637