1. 创建超级用户
from django.contrib import admin #Django自动在admin.py文件中导入
from index.models import Book, Author,UserInfo #这个需要我们自己导入相应的模型类(数据表)
admin.site.register([Book,Author,UserInfo])
3. django_admin_log数据表
Admin 应用在数据库迁移的过程中只创建了 django_admin_log 一张表 ,用于记录通过管理后台完成的对 Model
的增删改操作,如下所示,是数据库迁移过程中生成的所有数据表:
mysql> show tables;
+----------------------------+
| Tables_in_bookstoredb |
+----------------------------+
| auth_group |
| auth_group_permissions |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| django_admin_log |
| django_content_type |
| django_migrations |
| django_session |
| index_author |
| index_book |
| index_userinfo |
+----------------------------+
13 rows in set (0.00 sec)
我们可以使用desc
命令查看 django_admin_log 表结构, 如下所示:
mysql> desc django_admin_log;
+-----------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+----------------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| action_time | datetime(6) | NO | | NULL | |
| object_id | longtext | YES | | NULL | |
| object_repr | varchar(200) | NO | | NULL | |
| action_flag | smallint(5) unsigned | NO | | NULL | |
| change_message | longtext | NO | | NULL | |
| content_type_id | int(11) | YES | MUL | NULL | |
| user_id | int(11) | NO | MUL | NULL | |
+-----------------+----------------------+------+-----+---------+----------------+
8 rows in set (0.01 sec)
这些字段含义只做简单了解即可,如下所示:
-
id 是自增的主键字;
-
action_time:datetime 类型,保存操作发生的日期和时间;
-
object_id:longtext 类型,保存修改对象的主键;
-
object_repr:varchar 类型,保存修改后的对象执行 repr 函数的值,repr 是 Python 的内置函数,用于将对象转换为字符串;
-
action_flag:无符号 smallint 类型,用于记录操作类型 ADDITION(值为1,表示添加)、CHANGE(值为 2,表示更新)、DELETION(值为 3,表示删除);
-
change_message:longtext 类型,用于保存修改对象的详细描述;
-
content_type_id:int 类型,外键关联 ContentType 对象;
-
user_id:int类型,外键关键User对象(默认值),记录执行操作的用户。
I‘m trying to get google maps on an application on my android device. I was testing how it works so i started with adding a simple map. However when i try to run it it gives me this error.
Cannot reload AVD list: cvc-complex-type.2.4.d: Invalid content was found starting with element ‘d:skin‘. No child element is expected at this point. Error parsing /Applications/Android Studio.app/sdk/system-images/android-22/android-wear/armeabi-v7a/devices.xml cvc-complex-type.2.4.d: Invalid content was found starting with element ‘d:skin‘. No child element is expected at this point. Error parsing /Applications/Android Studio.app/sdk/system-images/android-22/android-wear/x86/devices.xm
解决方式:
点击工具栏上的 SDK Manager ---- 找到Android Wear ARM 和 Intel images 选项, 选中删除即可 !