因此,对于heroku,我无法使用数据库sqlite3
作为数据库,因此我尝试将其切换为Postgre
,并且遇到了一个问题,该问题也源于在Heroku上部署我的个人网站。我遇到了很多麻烦,不知道如何解决。
我正在尝试将项目面板添加到我的网站,但是每当我将此HTML添加到网站时,我都不会出现关联错误。我相信这是因为我改用了PostgreSQL,但不知道为什么是问题所在。有人,请帮忙!
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'chrisrosales',
'PASSWORD': 'notgonnashowlol',
'HOST': 'localhost',
'PORT': '5432',
}
}
问题在于这个投资组合...
<section id="portfolio" class="pfblock">
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<div class="pfblock-header wow fadeInUp">
<h2 class="pfblock-title">My works</h2>
<div class="pfblock-line"></div>
<div class="pfblock-subtitle">
</div>
</div>
</div>
</div><!-- .row -->
<div class="row">
{% for project in list_projects|slice:":2" %}
<div class="card col-xs-12 col-sm-5 col-md-5">
<div class="grid wow zoomIn">
<figure class="effect-bubba"><a href="{{ project.url }}" target="_blank">
{% with 'Django-Personal-Website/images/'|add:project.img_name as image_static %}
<img class="card-img-top" src="{% static image_static %}"></a>
{% endwith %}
</figure>
<div class="card-block">
<h2 class="card-title">{{ project.title }}</h2>
<p class="card-text">{{ project.description }}</p>
<div class="tools">
{% for tool in project.tools.split %}
<span>{{ tool }}</span>
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div><!-- .contaier -->
</section>
这是错误消息
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response
response = response.render()
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\response.py", line 106, in render
self.content = self.rendered_content
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\response.py", line 83, in rendered_content
content = template.render(context, self._request)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\backends\django.py", line 61, in render
return self.template.render(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\base.py", line 171, in render
return self._render(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\base.py", line 937, in render
bit = node.render_annotated(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\base.py", line 904, in render_annotated
return self.render(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\loader_tags.py", line 53, in render
result = self.nodelist.render(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\base.py", line 937, in render
bit = node.render_annotated(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\base.py", line 904, in render_annotated
return self.render(context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\template\defaulttags.py", line 166, in render
len_values = len(values)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\models\query.py", line 256, in __len__
self._fetch_all()
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\models\query.py", line 1242, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\models\query.py", line 55, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\models\sql\compiler.py", line 1100, in execute_sql
cursor.execute(sql, params)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\backends\utils.py", line 99, in execute
return super().execute(sql, params)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\silen\Documents\Projects\Django-Personal-Website\virtualenv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "Django-Personal-Website_project" does not exist
LINE 1: ..."Django-Personal-Website_project"."img_name" FROM "Django-Pe...