我无法配置我的pip.conf文件以规定PIP应该从https://pypi.python.org/simple/而不是http://pypi.python.org/simple/查找下载
我有一个相关的问题发布PIP无法找到满足SQLAlchemy要求的任何下载,其中有几个人诊断出了什么问题.但是我无法解决问题.
我打开我的pip.conf文件位于/home/user/.pip/pip.conf使用pip配置文件文档我添加了下面.文件中没有其他内容.
[global]
timeout = 60
find-links = https://pypi.python.org/simple/
[install]
find-links = https://pypi.python.org/simple/
Run Code Online (Sandbox Code Playgroud)
保存退出后没有变化.我仍然无法运行pip install等命令
$ sudo pip install SQLAlchemy
Downloading/unpacking SQLAlchemy
Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement SQLAlchemy
No distributions at all found for SQLAlchemy
Storing complete log in /home/user/.pip/pip.log
Run Code Online (Sandbox Code Playgroud)
我的设置
我试图将我添加到我的jQuery元素的值保存SurveyWizardForm到class Person(models.Model):我的数据库中.
我的表单中的所有其他元素都是以正常方式创建的,方法是在forms.py中创建必要的字段和小部件,并在models.py中创建每个问题的数据.因此,它们都会自动运行并保存正确的数据.
但是我已经SurveyWizardForm在某些页面上定制了我,以允许用户通过jQuery滑块提交图像的评级.
我的问题是我似乎无法将此值存储在我的Person模型中.
问题:如何将滑块的值存储到slider_valuePerson模型中?
到目前为止,我所有的尝试都只是在模型/数据库中创建了一个新条目,它不存储我在Form/views.py中的值.我担心我没有正确地将这两个部分连接在一起.
任何帮助深表感谢.谢谢
slider_two.js
这将hidden1使用my jQuery滑块的值更新隐藏的表单字段
if($(this).attr("id") == "one")
$("#hidden1").val((ui.value > 0 ? '+' : '') + ui.value);
Run Code Online (Sandbox Code Playgroud)
wizard_form.html
value="0"当用户移动上面创建的滑块slider_two.js(未显示)时更新
<input type="hidden" name="slider_value" value="0" id="hidden1"/>
<script src="{% static "survey/js/slider_two.js" %}"></script>
Run Code Online (Sandbox Code Playgroud)
views.py
我可以将值读入views.py中
slider_value = self.request.POST.get('slider_value')
if slider_value is not None:
instruction_task_values.insert(0, slider_value)
logger.debug('\n\n\nThis is your instruction_task_values in 1 %s', instruction_task_values)
Run Code Online (Sandbox Code Playgroud)
这适用于每次打印到我的日志时正确的值
models.py
这意味着在DB中创建字段以存储滑块的值.我创建的所有其他条目都正常工作并保存.
class Person(models.Model):
slider_value = models.IntegerField(null=True, blank=True, max_length=1000)
Run Code Online (Sandbox Code Playgroud)
forms.py …
我无法让我的 SessionWizardView 工作。当我提交最后一步时,向导跳回第一步,不执行done方法。
视图.py
class CvWizardView(CookieWizardView):
form_list = [InfoPersonalForm, PresentacionForm]
template_name = 'postulantes/cv_wizard.html'
def done(self, form_list, **kwargs):
return HttpResponseRedirect(reverse('wizard_done'))
Run Code Online (Sandbox Code Playgroud)
urls.py
url(r'^wizard/$', CvWizardView.as_view() , name="wizard"),
Run Code Online (Sandbox Code Playgroud)
html
{% extends "base.html" %}
{% load i18n %}
{% block extra_head %}
{{ wizard.form.media }}
{% endblock %}
{% block content %}
<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>
<form action="" method="post">{% csrf_token %}
<table>
{{ wizard.management_form }}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form }} …Run Code Online (Sandbox Code Playgroud) 我有一个JavaScript函数,该函数可使用显示给用户的图像文件名来更新隐藏在字段中的内容。在具有单个图像和单个隐藏字段的页面上,此方法效果很好。我正在尝试对其进行自定义,以便可以在单个页面上使用它来更新多个隐藏字段,具体取决于它们是否存在。
以前我曾尝试从我的手机中调用单独的函数onload用分号分隔。它适用于第一页/隐藏字段,但是当第二页上的第一个隐藏字段不可用时,它一直显示错误。
在这种尝试中,我试图将单个函数与if语句链接到隐藏字段的id一起使用,但是不幸的是,我似乎无法使它在任何页面/隐藏字段上都能正常工作
谁能告诉我我要去哪里错了?我相信可以这样做,但是我没有任何结果。谢谢
电流输出
<input id="id_9-slider_one_image" name="9-slider_one_image" type="hidden" />
<input id="id_10-slider_two_image" name="10-slider_two_image" type="hidden" />
<input id="id_11-slider_three_image" name="11-slider_three_image" type="hidden" />
Run Code Online (Sandbox Code Playgroud)
期望的输出
<input id="id_9-slider_one_image" name="9-slider_one_image" type="hidden" value="P1DP.jpg"/>
<input id="id_10-slider_two_image" name="10-slider_two_image" type="hidden" value="P6D6.jpg"/>
<input id="id_11-slider_three_image" name="11-slider_three_image" type="hidden" value="P3D3.jpg"/>
Run Code Online (Sandbox Code Playgroud)
我的密码
<div class="image_rating">
<img src="{% static "survey/images/pathone/" %}{{display_image}}" value="{{display_image}}" onload="updateInput(this)"/>
</div>
<script type="text/javascript">
function updateInput(ish) {
var valueAttribute = ish.getAttribute("value");
if($(this).attr("id") == "id_9-slider_one_image")
document.getElementById("id_9-slider_one_image").setAttribute(
"value", valueAttribute);
if($(this).attr("id") == "id_10-slider_two_image")
document.getElementById("id_10-slider_two_image").setAttribute(
"value", valueAttribute);
if($(this).attr("id") == "id_11-slider_three_image")
document.getElementById("id_11-slider_three_image").setAttribute(
"value", valueAttribute);
}
</script>
Run Code Online (Sandbox Code Playgroud) 我正在使用SessionWizardView在多个页面上划分一个小调查.
我的问题是,调查的每个页面的数据都保存在我的数据库中的不同行上,其中一个页面上有多个输入字段,信息将保存在同一行中.这使我的数据库非常麻烦.
我将问题以我的save()功能这是越来越每当有一个执行form我的form_list,因此增加每次在数据库中的新行.
def done(self, form_list, **kwargs):
for form in form_list:
form.save()
return render(self.request, 'Return_to_Prolific_Academic.html', {
'form_data': [form.cleaned_data for form in form_list],
})
Run Code Online (Sandbox Code Playgroud)
我试图直接在form_list上执行save form_list.save()但是我收到错误:
'list'对象没有属性'save'
我也试过两个join(),chain()看看我是否可以将所有form实例连接起来,看看我是否可以同时保存它们但是不成功.
我想简化我当前的解决方案,以便每个参与者的数据都保存在数据库的一行中,任何人都可以告诉我如何去做吗?谢谢
编辑
我的一些models.py和forms.py的示例
models.py
class Person(models.Model):
....
....
sender = models.EmailField(null=True, blank=True, verbose_name='What is your email address?')
birthdate = models.DateField(null=True, blank=True) #overwritten in forms.py so passed no more arguments
SEX = (
('1', 'Male'),
('2', 'Female'))
sex = models.CharField(null=True, blank=True, …Run Code Online (Sandbox Code Playgroud) 是否可以编写一个模板标签来检查列表的内容?
目前我从5到13进行了以下检查,但这非常详细,我需要做9次.
{% if wizard.steps.current == '5' %}
<img src="{% static "survey/images/pathtwo/" %}{{display_image}}"/>
<section>
<span class="tooltip"></span>
<div id="slider"></div>
<span class="volume"></span>
</section>
{% endif %}
{% if wizard.steps.current == '6' %}
<img src="{% static "survey/images/pathtwo/" %}{{display_image}}"/>
<section>
<span class="tooltip"></span>
<div id="slider"></div>
<span class="volume"></span>
</section>
{% endif %}
...
...
Run Code Online (Sandbox Code Playgroud)
我试过了
{% if wizard.steps.current in ['5','6','7','8','9','10','11','12','13'] %}
<img src="{% static "survey/images/paththree/" %}{{display_image}}" />
<section>
<span class="tooltip"></span>
<div id="slider"></div>
<span class="volume"></span>
</section>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
但是得到一个错误
例外值:无法解析余数:'['5','6','7','8','9','10','11','12','13']'来自' [ '5', '6', '7', '8', '9', …
这可能是一个noob问题,但我想知道将Python添加到Twitter Bootstrap(我只是在学习)
任何人都可以给我一些我应该拥有的文件夹结构的想法吗?我假设我的Python文件夹与我的Bootstrap项目文件夹处于同一级别?
例如
MyProject/
|-- Python/
| |-- bin
| | |-- app.py
| |-- docs
| |-- sessions
| |-- tests
| | |-- project_tests.py
|
|-- bootstrap/
| |-- css
| | |-- bootstrap.css
| | |-- bootstrap.min.css
| |
| |-- js
| | |-- bootstrap.js
| | |-- bootstrap.min.js
| |-- img
| | |-- glyphicon-halflings.png.
| | |-- glyphicon-halflings.png.
Run Code Online (Sandbox Code Playgroud)
我直接从下载站点获得了bootstrap文件结构,我在这里看到关于设置Python目录的最佳方法的这个问题
一如既往,先谢谢.
我最近更新到Python 2.7以便开始使用Django "Django需要Python,特别是Python 2.6.5 - 2.7.x".
因此,当我通过优秀的LPTHW练习46时,我需要安装一些我一直使用的工具
应该很容易,我以前做过这一切......
当我在终端中运行python时,我得到以下内容.注意:Python 2.7.5
$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Code Online (Sandbox Code Playgroud)
当我输入"哪个python"时我得到了
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Run Code Online (Sandbox Code Playgroud)
但是当我尝试安装distribute,nose或virtualenv时,我得到以下错误.注意Python/2.6
$ sudo pip install distribute
Exception:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/pip-1.3.1-py2.6.egg/pip/basecommand.py", line 139, in main
status = self.run(options, …Run Code Online (Sandbox Code Playgroud) 这是这个问题的第三次迭代,因为错误已经解决(在一些人的感激帮助下)。为了避免对到底发生了什么感到困惑,我认为有必要重新发布更新的详细信息。
我正在使用 Django 1.6.4。
我正在尝试将django-countries 应用程序与 Django 一起使用,但未显示下拉列表。我没有收到任何错误,但下面的 Survey.html 页面未显示 ISO 3166-1 国家/地区列表的预期下拉列表。
我通过 pip 在项目的虚拟环境中安装了 django-countries 2.1.2。它已添加到已安装的应用程序中
已安装的应用程序
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
'survey',
'django_countries',
)
Run Code Online (Sandbox Code Playgroud)
模型.py
from django.db import models
from django_countries.fields import CountryField
class Person(models.Model):
country = CountryField()
def __unicode__(self):
return self.country
Run Code Online (Sandbox Code Playgroud)
视图.py
from django.shortcuts import render
from django.db import models
from django_countries.fields import CountryField
from models import SexChoice, AgeChoice, RelationshipStatusChoice, Person
def survey(request):
age = AgeChoice()
sex = …Run Code Online (Sandbox Code Playgroud) 我最近将YADR软件包安装到了iTerm2上。但是,安装后,在[ruby2.1.2 ...]我键入的每一行的右侧都会出现RVM提示符。
有什么办法可以摆脱这个?

https://www.dropbox.com/s/hbix1kufao0supe/Screen%20Shot%202014-10-01%20at%2012.50.33%20PM.png?dl=0
django ×6
python ×5
django-forms ×2
forms ×2
django-views ×1
html ×1
iterm2 ×1
javascript ×1
jquery ×1
pip ×1
python-2.7 ×1
ruby ×1
rvm ×1
terminal ×1
wizard ×1
zsh ×1