Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为django配置postgressql时出错_Django_Postgresql - Fatal编程技术网

为django配置postgressql时出错

为django配置postgressql时出错,django,postgresql,Django,Postgresql,我已经使用postgresql在我的django应用程序中实现了全文搜索。但是,当我按下搜索按钮时,我得到一个错误: ProgrammingError at /blog/search/ function similarity(character varying, unknown) does not exist LINE 1: SELECT COUNT(*) FROM (SELECT SIMILARITY("blog_post"."title",...

我已经使用postgresql在我的django应用程序中实现了全文搜索。但是,当我按下搜索按钮时,我得到一个错误:

ProgrammingError at /blog/search/
function similarity(character varying, unknown) does not exist
LINE 1: SELECT COUNT(*) FROM (SELECT SIMILARITY("blog_post"."title",...
                                     ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
我不知道错误在哪里,所以如果你需要任何文件,我会编辑这个问题。
请帮帮我,我猜你忘记安装扩展了。要使用django安装,请在应用程序的迁移目录中创建一个名为pg_trgm.py的文件:

from django.db import migrations

class Migration(migrations.Migration):
    dependencies = [
        ('myapp', <last migration filename here>),
    ]
    operations = [
        migrations.RunSQL('CREATE EXTENSION IF NOT EXISTS pg_trgm'),
    ]

请记住替换为最近一次迁移的文件名。

我猜您忘记安装扩展名了。要使用django安装,请在应用程序的迁移目录中创建一个名为pg_trgm.py的文件:

from django.db import migrations

class Migration(migrations.Migration):
    dependencies = [
        ('myapp', <last migration filename here>),
    ]
    operations = [
        migrations.RunSQL('CREATE EXTENSION IF NOT EXISTS pg_trgm'),
    ]

请记住替换为最近一次迁移的文件名。

这可能会有所帮助。这不使用django。我正在使用django作为我的应用程序。你应该在问题中添加更多调试细节!!!这可能会有所帮助。这不使用django。我正在使用django作为我的应用程序。你应该在问题中添加更多调试细节!!!这很好用。但是你能告诉我一个永久的解决方案吗。我必须在每个django项目中重复这个步骤,我不想这样做。谢谢你的帮助,这很好用。但是你能告诉我一个永久的解决方案吗。我必须在每个django项目中重复这个步骤,我不想这样做。谢谢你的帮助