我在安装mysql-python时遇到问题.创建一个新的virtualenv,并在安装mysql-python时...这里是错误消息:
(env)$ pip install mysql-python
Collecting mysql-python
...
clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr /local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)
使用自制软件,我安装了:
已经尝试brew link但酿造拒绝这样做.
操作系统是MacOS Sierra.
有人可以帮忙吗?谢谢!
我正在尝试创建一个表单,其中两个字段都是可选的,但是在设置null和blank. 我究竟做错了什么?
错误
super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'blank'
Run Code Online (Sandbox Code Playgroud)
表格.py
class EditProfile(forms.Form):
"""
A form that lets a user change their profile information
"""
first_name = forms.CharField(
label=("Fornavn"),
strip=False,
blank=True,
null=True
)
last_name = forms.CharField(
label=("Efternavn"),
strip=False,
blank=True,
null=True,
)
def __init__(self, user, *args, **kwargs):
self.user = user
super().__init__(*args, **kwargs)
def save(self, commit=True):
first_name = self.cleaned_data["first_name"]
last_name = self.cleaned_data["last_name"]
self.user.first_name = first_name
self.user.last_name = last_name
if commit:
self.user.save()
return self.user
Run Code Online (Sandbox Code Playgroud) 我有这个模型:
class Article(models.Model):
draft=models.BooleanField()
public= models.IntegerField()
class PopularArticle(models.Model):
article=models.ForeignKey(Article)
priority= models.IntegerField()
Run Code Online (Sandbox Code Playgroud)
现在我想这样过滤:
PopularArticle.objects.filter(article.public=True,article.draft=False)
Run Code Online (Sandbox Code Playgroud)
换句话说,我想确保那些未处于草稿且已发表的热门文章。
我怎样才能做到这一点?