我在尝试https://github.com/zhebrak/django-statsy
中的exemple
文件时遇到了一些问题
OperationalError at /
no such table: example_post
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.11.5
Exception Type: OperationalError
Exception Value: no such table: example_post
Exception Location: /home/jeremie/.virtualenvs/statsy/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py in execute_sql, line 894
Python Executable: /home/jeremie/.virtualenvs/statsy/bin/python
Python Version: 2.7.12
Python Path:
['/home/jeremie/django-statsy',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/plat-x86_64-linux-gnu',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-tk',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-old',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/jeremie/.virtualenvs/statsy/local/lib/python2.7/site-packages',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/site-packages',
'/home/jeremie/django-statsy']
Server time: Fri, 15 Sep 2017 15:13:34 -0500
这是我到目前为止所做的:
git clone https://github.com/zhebrak/django-statsy.git
mkvirtualenv statsy
cd django-statsy
workon statsy
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
我只想进入example
文件内部以查看结果类型并测试应用程序本身。为什么我有这个问题?如果我使用Django 1.10
和python 2.7
?
┌─╼ [~/django-statsy]
└────╼ python2.7 manage.py makemigrations example
Migrations for 'example':
example/migrations/0001_initial.py
- Create model Post
┌─╼ [~/django-statsy]
└────╼ python2.7 manage.py migrate example
Operations to perform:
Apply all migrations: example
Running migrations:
Applying example.0001_initial... OK
以下是我运行localhost:8000
:image
我怎样才能测出给出的例子?
答案 0 :(得分:0)
根据您在评论中的回复,看起来您还没有创建example_post
数据库表。您需要将example
添加到设置文件中的INSTALLED_APPS
列表中,然后运行数据库迁移过程:
./manage.py makemigrations
./manage.py migrate
如果example
应用程序不在INSTALLED_APPS
中,则无法创建数据库迁移文件,因此无法创建表格。