超级简单的问题:我通过干草堆的“开始”文档(使用嗖!我使用pip安装了python-who和haystack(第一次使用它)),我根本无法运行python manage.py rebuild_index 。我收到这个错误:
python manage.py rebuild_index
Unknown command: 'rebuild_index'
Type 'manage.py help' for usage
我在settings.py的INSTALLED_APPS中列出了'haystack',所以this solution似乎不适合我。我运行“import haystack”时也没有导入导入错误,所以它确实存在。我在我现有的项目中尝试了这个,以及为此而制作的一个全新的对象,我无法让它工作。
但是,当我在python manage.py shell
之后导入haystack并尝试haystack.__version__
时,我得到“AttributeError:'module'对象没有属性' version '”。如果我尝试haystack.management
,我会收到类似的错误:它没有管理属性。
一定是超级简单的东西,我很想念。感谢您阅读本文!
答案 0 :(得分:18)
您是否安装了错误的东西?这件事(令人尴尬)就在今天发生在我身上。确保安装'django-haystack'而不仅仅是'haystack'(你必须删除'haystack',因为它与'django-haystack'冲突)。
答案 1 :(得分:2)
你的Python路径中有干草堆的路径吗? (PYTHONPATH
shell变量或sys.path
Python列表。)
您运行了python manage.py syncdb
吗?
python manage.py shell
后跟import haystack
工作吗?
在import haystack
之后,您对haystack.__version__
有什么看法?
在同一个shell中,键入以下内容。你有没有错误?
haystack.management.commands
haystack.management.commands.rebuild_index
haystack.management.commands.rebuild_index.Command.help
答案 2 :(得分:1)
我遇到了与您相同的错误,并通过删除旧的.egg并直接从最新版本安装来修复它。您可以使用easy_install:
easy_install https://github.com/toastdriven/django-haystack/zipball/v1.2.4
希望这有帮助!
答案 3 :(得分:0)
我遇到了同样的问题 - 无论出于何种原因,pip中的干草堆版本已经过时(过去是v 0.6)。要使用django-haystack,请查看v1。 source
使用
编译和安装python setup.py build
python setup.py install
希望有所帮助!
答案 4 :(得分:0)
我遇到了同样的问题,并且没有在settings.py中设置HAYSTACK_SITECONF。
答案 5 :(得分:0)
而不是使用CREATE TABLE ActivitySummary
(
id int identity(1,1),
activity_date date,
activity varchar(100),
paid_time decimal(5,2),
unpaid_time decimal(5,2),
total_time decimal(5,2)
)
CREATE TABLE ActivitySummary_STG
(
id int identity(1,1),
activity_date date,
activity varchar(100),
paid_time decimal(5,2),
unpaid_time decimal(5,2),
total_time decimal(5,2)
)
GO
-- Simulate import of Excel sheet into staging table
truncate table ActivitySummary_STG;
GO
INSERT INTO ActivitySummary_STG (activity_date, activity, paid_time, unpaid_time, total_time)
select '8/14/17',null,null,null,null
UNION ALL
select null,'001 Lunch',0,4.4,4.4
UNION ALL
select null,'002 Break',4.2,0,4.2
UNION ALL
select null,'007 System Down',7.45,0,7.45
UNION ALL
select null,'019 End of Work Day',0.02,0,0.02
UNION ALL
select '8/15/17',null,null,null,null
UNION ALL
select null,'001 Lunch',0,4.45,4.45
UNION ALL
select null,'002 Break',6.53,0,6.53
UNION ALL
select null,'007 System Down',0.51,0,0.51
UNION ALL
select null,'019 End of Work Day',0.02,0,0.02
GO
-- Code to massage data
declare @table_count int = (select COALESCE(count(id),0) from ActivitySummary_STG);
declare @counter int = 1;
declare @activity_date date,
@current_date date;
WHILE (@table_count > 0 AND @counter <= @table_count)
BEGIN
select @activity_date = activity_date
from ActivitySummary_STG
where id = @counter;
if (@activity_date is not null)
BEGIN
set @current_date = @activity_date;
delete from ActivitySummary_STG
where id = @counter;
END
else
BEGIN
update ActivitySummary_STG SET
activity_date = @current_date
where id = @counter;
END
set @counter += 1;
END
INSERT INTO ActivitySummary (activity_date, activity, paid_time, unpaid_time, total_time)
select activity_date, activity, paid_time, unpaid_time, total_time
from ActivitySummary_STG;
truncate table ActivitySummary_STG;
GO
select * from ActivitySummary;
尝试使用$('.button').click(function () {
if ($('.one').hasClass('left')) {
$('.one').addClass('right');
$('.one').removeClass('left');
} else {
$('.one').addClass('left');
$('.one').removeClass('right');
}
})
答案 6 :(得分:0)
pip uninstall haystack
和
pip install django-haystack