发布于2023-02-23 23:53 阅读(1090) 评论(0) 点赞(22) 收藏(5)
我正在尝试将 Django 与 Neo4J 集成。为了保存节点,我将提供表格并将节点添加到图中的图中。为了创建模型,我使用了 neomodel 的 StructNode。模型.py
from neomodel import (StructuredNode, StringProperty,
IntegerProperty, RelationshipTo,
OneOrMore)
class Male(StructuredNode):
print('Class for male nodes')
name = StringProperty(unique_index=True, required=True)
surname = StringProperty()
age = IntegerProperty()
country = StringProperty(default='India')
class Female(StructuredNode):
print('Class for female nodes')
name = StringProperty(unique_index=True, required=True)
surname = StringProperty()
age = IntegerProperty()
country = StringProperty(default='US')
ratings = RelationshipTo('Movie', 'HAS_RATED', OneOrMore)
class Movie(StructuredNode):
print('Class for movie nodes')
movieName = StringProperty(unique_index=True, required=True)
forms.py
from django import forms
from .models import Male
class MaleForm(forms.ModelForm):
class Meta:
model = Male
fields = '__all__'
views.py
from django.shortcuts import render
from .forms import MaleForm
def index(request):
form = MaleForm()
if request.method == 'POST':
print(request)
# context = {'form':form}
return render(request, 'crud/index.html', {'form':form})
索引.html
<h3>Customer Form</h3>
<hr>
<form action="" method="post">
{% csrf_token %}
{{form}}
<input type="submit">
</form>
运行应用程序后,出现以下错误。F:\django\graph_project> python manage.py runserver
Class for male nodes
Class for female nodes
Class for movie nodes
Class for male nodes
Class for female nodes
Class for movie nodes
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "C:\software\Anaconda3\lib\site-packages\django\template\utils.py", line 69, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 128, in get_package_libraries
module = import_module(entry[1])
File "C:\software\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\software\Anaconda3\lib\site-packages\django\templatetags\future.py", line 2, in <module>
from django.template.defaulttags import kwarg_re, SsiNode, URLNode
ImportError: cannot import name 'SsiNode' from 'django.template.defaulttags' (C:\software\Anaconda3\lib\site-packages\django\template\defaulttags.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\software\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\software\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\software\Anaconda3\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\software\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 74, in execute
super().execute(*args, **options)
File "C:\software\Anaconda3\lib\site-packages\django\core\management\base.py", line 448, in execute
output = self.handle(*args, **options)
File "C:\software\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 111, in handle
self.run(**options)
File "C:\software\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 118, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\software\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 680, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\software\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 661, in start_django
reloader.run(django_main_thread)
File "C:\software\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 343, in run
autoreload_started.send(sender=self)
File "C:\software\Anaconda3\lib\site-packages\django\dispatch\dispatcher.py", line 176, in send
return [
File "C:\software\Anaconda3\lib\site-packages\django\dispatch\dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "C:\software\Anaconda3\lib\site-packages\django\template\autoreload.py", line 43, in watch_for_template_changes
for directory in get_template_directories():
File "C:\software\Anaconda3\lib\site-packages\django\template\autoreload.py", line 16, in get_template_directories
for backend in engines.all():
File "C:\software\Anaconda3\lib\site-packages\django\template\utils.py", line 94, in all
return [self[alias] for alias in self]
File "C:\software\Anaconda3\lib\site-packages\django\template\utils.py", line 94, in <listcomp>
return [self[alias] for alias in self]
File "C:\software\Anaconda3\lib\site-packages\django\template\utils.py", line 85, in __getitem__
engine = engine_cls(params)
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 24, in __init__
options["libraries"] = self.get_templatetag_libraries(libraries)
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 42, in get_templatetag_libraries
libraries = get_installed_libraries()
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 116, in get_installed_libraries
return {
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 116, in <dictcomp>
return {
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 105, in get_template_tag_modules
for name in get_package_libraries(pkg):
File "C:\software\Anaconda3\lib\site-packages\django\template\backends\django.py", line 130, in get_package_libraries
raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'django.templatetags.future': cannot impor
t name 'SsiNode' from 'django.template.defaulttags' (C:\software\Anaconda3\lib\site-packages\django\template\defaulttags.py)
发现了类似的问题,但对我的情况没有帮助。我是 Django 的初学者,这是我的第二个应用程序,无法理解导致此错误的原因。
作者:黑洞官方问答小能手
链接:https://www.pythonheidong.com/blog/article/1912701/4fe909e87ad7a79bef8f/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!