小编dvc*_*dvc的帖子

mac osx 10.9.2上的mysql-python:错误:命令'/ usr/bin/clang'失败,退出状态为1

我想将我的django应用程序从sqlite移植到mysql.

但是当我尝试安装mysql-python时,它给了我这个错误:错误:命令'/ usr/bin/clang'失败,退出状态为1

我环顾四周寻找线索并尝试了这个似乎适用于大多数人的解决方案:

sudo su export CFLAGS = -Qunused-arguments export CPPFLAGS = -Qunused-arguments pip install MySQL-python

完整的错误日志在这里:

pip install MySQL-python
Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python

Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python
    building '_mysql' extension
    /usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64
    xcrun: error: active developer path ("/Users/deeptichopra/Desktop/Applications and Softwares/Xcode.app/Contents/Developer") does not exist, use xcode-select to change
    error: command …
Run Code Online (Sandbox Code Playgroud)

python mysql macos mysql-python

10
推荐指数
1
解决办法
1万
查看次数

elasticsearch异常ConnectionError

我正在制作一个Django应用程序.它使用带有弹性搜索的Haystack作为后端.

我跑的时候

./manage.py rebuild_index
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

中止.',错误(61,'连接被拒绝')))由:ProtocolError(('Connection aborted.',error(61,'Connection refused')))

可能是什么导致了这个?

日志:

./manage.py rebuild_index
No handlers could be found for logger "django_facebook.models"

WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
Failed to clear Elasticsearch index: ConnectionError(('Connection aborted.', error(61, 'Connection refused'))) caused by: ProtocolError(('Connection …
Run Code Online (Sandbox Code Playgroud)

python django django-haystack elasticsearch

7
推荐指数
1
解决办法
2万
查看次数

Django manytomany字段,如何检查80%子集/匹配?

我有一个带烹饪食谱的Django数据库.我想查询所有拥有至少80%成分的用户来制作食谱.我该如何实现这一目标?

或者我如何查询缺少配方的1种成分的用户?

models.py

class ingredient(models.Model):
    id = models.AutoField("id",max_length = 100, primary_key=True)
    name=models.CharField("Ingredient", max_length=100)

    def __unicode__ (self):
        return self.name

class user(models.Model):
    id = models.AutoField("id",max_length = 100, primary_key=True
    ingredient = models.ManyToManyField(ingredient,blank=True)

    def __unicode__ (self):
        return str(self.id)

class recipe(models.Model):
    id = models.AutoField("id", max_length=100, primary_key=True)
    recipe_ingredient = models.ManyToManyField(ingredient,related_name='recipe_ingredient',blank=True)

    def __unicode__ (self):
        return self.id
Run Code Online (Sandbox Code Playgroud)

python django manytomanyfield

7
推荐指数
1
解决办法
122
查看次数

Django 管理员每次点击后都要求登录

我正在开发一个托管在 Heroku 上的 Django 应用程序。我可以使用我的用户名和密码登录到管理员。但是在每次单击(或几秒钟后的每次单击)时,它都会将我再次重定向到登录页面,并?next=/admin/model添加到 url。事实上,有时它会在让我查看管理控制台之前多次要求登录。此行为不会反映在本地部署中。管理员在本地工作得很好。

我尝试了这里提到的建议:https : //docs.djangoproject.com/en/1.8/faq/admin/#i-can-t-log-in-when-i-enter-a-valid-username-and- password-it-just-brings-up-the-login-page-again-with-no-error-messages。但这无济于事。

任何线索我可能做错了什么?

这是我的settings.py:

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin', …
Run Code Online (Sandbox Code Playgroud)

python django heroku django-admin

6
推荐指数
3
解决办法
1890
查看次数