Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.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 Pythonywhere_Django_Sqlite - Fatal编程技术网

操作错误没有这样的列DJANGO Pythonywhere

操作错误没有这样的列DJANGO Pythonywhere,django,sqlite,Django,Sqlite,所以我改变了我的模式。我添加了添加图片的可能性。它可以在我的电脑上正常工作,但当我试图在互联网上的Python上应用它时,它不能正常工作。甚至在管理面板中,我也不能添加配方。我已尝试删除迁移并再次迁移,但没有帮助。。现在互联网上的网站不起作用,但在我的本地服务器上一切都很好。。我不知道如何修理它 我的网站: 我的模型: from django.db import models class Ingredient(models.Model): ingredient_name = model

所以我改变了我的模式。我添加了添加图片的可能性。它可以在我的电脑上正常工作,但当我试图在互联网上的Python上应用它时,它不能正常工作。甚至在管理面板中,我也不能添加配方。我已尝试删除迁移并再次迁移,但没有帮助。。现在互联网上的网站不起作用,但在我的本地服务器上一切都很好。。我不知道如何修理它

我的网站:

我的模型:

from django.db import models


class Ingredient(models.Model):

  ingredient_name = models.CharField(max_length=250)

  def __str__(self):
    return self.ingredient_name


class Recipe(models.Model):

  recipe_name = models.CharField(max_length=250)
  preparation = models.CharField(max_length=1000)
  ingredients = models.ManyToManyField(Ingredient)
  recipe_image = models.ImageField(upload_to='images/', default='')


  def __str__(self):
    return self.recipe_name
模板:

<body>
    <div id=container>
      <h1><a href="/">Wróć do strony głównej</a></h1>


    {% if results %}
      {% for drink in results %}
          <p><b>{{ drink.recipe_name }}</b></p>
          <p><u>Preparation:</u> {{ drink.preparation }}</p>
          <p><u>Ingredients:</u>
            {% for ingredient in drink.ingredients.all %}
              {{ingredient.ingredient_name}}{% if not forloop.last %},{% endif %}
            {% endfor %}
          </p>
          <p><img src="{{drink.recipe_image.url}}" alt="{{drink.recipe_name}}"</p>
      {% endfor %}

    {% else %}
      Such ingredients do not exist
    {% endif %}
  </div>
  </body>

{%if结果%}
{结果中饮料的百分比%}
{{drink.recipe_name}

准备:{drink.Preparation}

成分: {%用于饮料中的配料。配料。所有%} {{component.component_name}{%if非forloop.last%},{%endif%} {%endfor%}

{%endfor%} {%else%} 这些成分并不存在 {%endif%}
Django将停止并抱怨模型中声明的字段尚未出现在数据库架构中。请在模型中注释ImageField定义,或者运行python3 manage.py makemigrations和python3 manage.py migrate。

我这样做了,但在internet上没有任何帮助。在我的本地服务器上,它工作正常。请在shell中仔细检查。1) manage.py dbshell 2).架构表\u NAME是其中的字段recipe\u映像吗?当我尝试在Windows shell中管理.py dbshell时,我得到建议[3,常规]:未找到命令manage.py,但该命令确实存在于当前位置。默认情况下,Windows PowerShell不会从当前位置加载命令。如果您信任此命令,请改为键入:“.\manage.py”。有关详细信息,请参阅“获取有关\u命令\u优先级的帮助”。删除迁移没有帮助-现在您的数据库和迁移文件彼此不同步。如果您仍在开发项目,最简单的解决方案是将数据库放到Python Anywhere上,然后在新数据库上运行migrate。在删除数据库之前,请备份数据库中所需的任何数据。您的意思是我现在应该删除我的Pythonywhere网站,并创建一个新网站吗?我建议您删除数据库,而不是网站。使用sqlite,您可以通过删除
db.sqlite3
文件来实现这一点。如果您需要任何数据,请首先备份它。我在我的计算机上的myp项目中看到此文件夹db.sqlite3。我在PythonyWhere或我的git上看不到此文件。。所以我不清楚:(回溯显示的是
sqlite3
,所以应该有一个数据库文件。它通常不会签入git。您的
DATABASES
设置会告诉您文件的名称,默认情况下它是
db.sqlite3
。如果您找不到该文件,恐怕我没有任何其他建议。
<body>
    <div id=container>
      <h1><a href="/">Wróć do strony głównej</a></h1>


    {% if results %}
      {% for drink in results %}
          <p><b>{{ drink.recipe_name }}</b></p>
          <p><u>Preparation:</u> {{ drink.preparation }}</p>
          <p><u>Ingredients:</u>
            {% for ingredient in drink.ingredients.all %}
              {{ingredient.ingredient_name}}{% if not forloop.last %},{% endif %}
            {% endfor %}
          </p>
          <p><img src="{{drink.recipe_image.url}}" alt="{{drink.recipe_name}}"</p>
      {% endfor %}

    {% else %}
      Such ingredients do not exist
    {% endif %}
  </div>
  </body>