django问题

1、IntegrityError

IntegrityError at /admin/users/userprofile/add/
(1452, 'Cannot add or update a child row: a foreign key constraint fails (`mx`.`django_admin_log`, CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')

数据库设置中取消外键约束:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        ...'OPTIONS': {
            "init_command": "SET foreign_key_checks = 0;",
        }
    }
}

 2、用作auth.user的UserProfile的用户表中通过命令行修改用户密码:

  a = UserProfile.objects.all()[0]

  a.set_passward('123456789')

  a.save()

3、模版标签目录名:templatetags,该目录是一个包

  如果模版中load模版文件不行,就把该包放到某个应用中

渐变 --> 突变
原文地址:https://www.cnblogs.com/lybpy/p/8267589.html