首先,我创建了我的数据库.
create database mydb;
Run Code Online (Sandbox Code Playgroud)
我在安装的应用程序中添加"南".然后,我转到本教程:http: //south.aeracode.org/docs/tutorial/part1.html
教程告诉我这样做:
$ py manage.py schemamigration wall --initial
>>> Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate wall
Run Code Online (Sandbox Code Playgroud)
好的,现在我迁移了.
$ py manage.py migrate wall
Run Code Online (Sandbox Code Playgroud)
但它给了我这个错误......
django.db.utils.DatabaseError: (1146, "Table 'fable.south_migrationhistory' doesn't exist")
Run Code Online (Sandbox Code Playgroud)
所以我使用谷歌(这永远不会奏效,因此问#2我的870度的问题.),我得到这个页面:http://groups.google.com/group/south-users/browse_thread/thread/d4c83f821dd2ca1c
好的,所以我按照说明进行操作
>> Drop database mydb;
>> Create database mydb;
$ rm -rf ./wall/migrations
$ py manage.py syncdb
Run Code Online (Sandbox Code Playgroud)
但是当我运行syncdb时,Django会创建一堆表.是的,它创建了south_migrationhistory表,但它也创建了我的应用程序表.
Synced:
> django.contrib.admin
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.messages
> south
> fable.notification
> …Run Code Online (Sandbox Code Playgroud) IntegrityError或任何其他错误中恢复的正确方法,这些错误可能会导致我的交易失败而不使用手动事务控制?在我的应用程序中,我遇到了IntegrityError我想从中恢复的问题,这搞砸了以后的数据库活动,让我:
DatabaseError: current transaction is aborted, commands ignored until end of transaction block`
Run Code Online (Sandbox Code Playgroud)
对于忽略后的所有数据库活动IntegrityErrors.
这段代码应该重现我看到的错误
from django.db import transaction
try:
MyModel.save() # Do a bad save that will raise IntegrityError
except IntegrityError:
pass
MyModel.objects.all() # raises DatabaseError: current transaction is aborted, commands ignored until end of transaction block
Run Code Online (Sandbox Code Playgroud)
根据文档,从a恢复的解决方案IntegrityError是通过回滚事务.但是下面的代码导致了一个TransactionManagementError.
from django.db import transaction
try:
MyModel.save()
except IntegrityError:
transaction.rollback() # raises TransactionManagementError: This code isn't under transaction management …Run Code Online (Sandbox Code Playgroud) 前一阵子我做了一个剑道股票图表,它运作得很好.然后我的同事经历了并且正在抛光前端的所有样式,我想这可能就是为什么我的股票图表的导航器出现的原因如下:
我在div上的样式我们称之为.kendoStockChart是:
color: #2E2E2E;
display: block;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
height: 513.328125px;
line-height: normal;
position: relative;
width: 805.640625px;
Run Code Online (Sandbox Code Playgroud)
我真的希望我错过了一些明显的东西,任何提示或尝试答案都表示赞赏!
编辑:对不起那些一直试图帮助我的人,自从我打开这个以来已经离开办公室几个星期了,如果我很快就回去修理它会告诉你.
之前我正在使用pyinstaller尝试使用twisted作为可执行文件获取我的应用程序,但执行时出现此错误:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
exec code in m.__dict__
File "client_test.py", line 2, in <module>
File "/usr/local/lib/python2.7/dist-packages/Twisted-13.0.0-py2.7-linux-x86_64.egg/twisted/__init__.py", line 53, in <module>
_checkRequirements()
File "/usr/local/lib/python2.7/dist-packages/Twisted-13.0.0-py2.7-linux-x86_64.egg/twisted/__init__.py", line 37, in _checkRequirements
raise ImportError(required + ": no module named zope.interface.")
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
Run Code Online (Sandbox Code Playgroud)
那么,我尝试使用cx_freeze,但我得到确切同样的错误,即使在使用'namespace_packages': ['zope']像这样的例子.
从我构建可执行文件的地方,我可以打开一个python解释器并成功导入zope.interface,然后我安装它easy_install,然后运行pip install -U zope.interface,这没有任何影响.
这是我setup.py的cx_freeze:
import sys
from cx_Freeze import setup, Executable
# …Run Code Online (Sandbox Code Playgroud) 我不能发送python中的电子邮件与身体作为多部分电子邮件.我尝试过的所有内容都将所有内容都作为附件,我无法将文本或html显示在正文中.
msg = MIMEMultipart()
if msg_mime_type == 'text' or not msg_mime_type:
new_body = MIMEText(body, 'text')
elif msg_mime_type == 'image':
new_body = MIMEImage(body)
elif msg_mime_type == 'html':
new_body = MIMEText(body, 'html')
new_body.add_header('Content-Disposition', 'inline', filename='body')
msg.set_payload(new_body) #also tried msg.attach(new_body)
Run Code Online (Sandbox Code Playgroud)
我需要使用一个,Multipart所以我也可以添加附件,但为了简单起见我保留了代码.
python ×5
django ×2
css ×1
cx-freeze ×1
django-south ×1
email ×1
html5 ×1
ide ×1
javascript ×1
kendo-ui ×1
migration ×1
mime ×1
postgresql ×1
pycharm ×1
pyinstaller ×1
smtp ×1
transactions ×1
twisted ×1