Django Admin Pages使我的模型无法点击

时间:2021-12-14 21:08:58

For some reason, my /admin page has made the models I defined un-editable. This is on my deployed server using apache and postgres. I'm logged in as a superuser and the is showing the links like this:

出于某种原因,我的/ admin页面使我定义的模型不可编辑。这是在我部署的服务器上使用apache和postgres。我以超级用户身份登录,并显示如下链接:

Django Admin Pages使我的模型无法点击

If I look at the same code locally in the development server connected to postgres, it looks like this:

如果我在连接到postgres的开发服务器中本地查看相同的代码,它看起来像这样:

Django Admin Pages使我的模型无法点击

Any idea what could be causing this?

什么可能导致这个?

** Update **

**更新**

So it's not always blocked. I logged in today and I had access for a few actions (I cleaned some bogus email requests from my DB) but then after deleting some rows it got back to the read-only state.

所以它并不总是被阻止。我今天登录了,我可以访问一些操作(我从我的数据库中清除了一些虚假的电子邮件请求)但是在删除了一些行后它又回到了只读状态。

Still no idea what's causing it.

仍然不知道是什么导致了它。

home.models.py:

from django.db import models
from django import forms
from django.utils import timezone

class EmailRequest(models.Model):
    email = models.EmailField()
    created_date = models.DateTimeField(default=timezone.now())


class EmailRequestForm(forms.Form):
    email = forms.EmailField()

home.admin.py:

from django.contrib import admin
from home.models import EmailRequest

class EmailRequestAdmin(admin.ModelAdmin):
    list_display = ('email', 'created_date')

admin.site.register(EmailRequest, EmailRequestAdmin)

2 个解决方案

#1


0  

I don't have a direct answer to your problem, but I do have a few personal insights. First of all, using the Bitnami Django stack is probably a problem. I have used it a couple of times, and I never will again. The setup is definitely NOT ideal, and there is way too little documentation available for it to make your life any easier (wait, wasn't that the whole point of using a Bitnami stack?).

我没有直接回答你的问题,但我确实有一些个人见解。首先,使用Bitnami Django堆栈可能是个问题。我曾经使用过几次,而且我再也不会这样了。设置绝对不是理想的,并且有太少的文档可用于使您的生活更轻松(等等,不是使用Bitnami堆栈的全部意义吗?)。

I would start looking through your logs (apache error log and postgres error logs specifically), I bet there is something in there that will point you in the correct direction.

我会开始查看你的日志(特别是apache错误日志和postgres错误日志),我打赌那里有一些东西可以指向你正确的方向。

I am sure you are running your development server from your local machine which is setup completely differently from the Bitnami stack. The better solution would be to install everything yourself on a barebones Ubuntu server. Then you will have much more familiarity with the setup.

我确信您正在从本地计算机运行您的开发服务器,该计算机的设置与Bitnami堆栈完全不同。更好的解决方案是将自己安装在准系统Ubuntu服务器上。然后,您将更加熟悉设置。

THE BEST THING you can do, is go learn to use Vagrant. This will help you to maintain a local virtual machine instance, which is identical to your EC2 box. You will log into it using ssh just like the EC2 box, and you will be using it externally, just like the EC2 box. The closer you can get your development environment to your production environment, the easier debugging problems like this will be.

你能做的最好的事情就是去学习使用Vagrant。这将帮助您维护本地虚拟机实例,该实例与您的EC2框相同。您将使用ssh登录它,就像EC2框一样,您将在外部使用它,就像EC2框一样。您越接近开发环境到生产环境,这样的调试问题就越容易。

Hope that didn't make your life more difficult (seriously, if you get Vagrant running, your life will become MUCH easier)

希望这不会让你的生活更加艰难(严肃地说,如果你让Vagrant跑步,你的生活会变得更加容易)

#2


0  

See the following solution: No access to models in admin panel with DEBUG=False

请参阅以下解决方案:使用DEBUG = False访问管理面板中的模型

quote:

OK, I've found reason of my problems. It was caused by registering my models in admin panel from files with models definitions. When I moved all my registrations to one external file admin.py, then everything works correctly.

好的,我找到了我的问题的原因。这是因为在具有模型定义的文件中在管理面板中注册我的模型。当我将所有注册移动到一个外部文件admin.py时,一切正常。

#1


0  

I don't have a direct answer to your problem, but I do have a few personal insights. First of all, using the Bitnami Django stack is probably a problem. I have used it a couple of times, and I never will again. The setup is definitely NOT ideal, and there is way too little documentation available for it to make your life any easier (wait, wasn't that the whole point of using a Bitnami stack?).

我没有直接回答你的问题,但我确实有一些个人见解。首先,使用Bitnami Django堆栈可能是个问题。我曾经使用过几次,而且我再也不会这样了。设置绝对不是理想的,并且有太少的文档可用于使您的生活更轻松(等等,不是使用Bitnami堆栈的全部意义吗?)。

I would start looking through your logs (apache error log and postgres error logs specifically), I bet there is something in there that will point you in the correct direction.

我会开始查看你的日志(特别是apache错误日志和postgres错误日志),我打赌那里有一些东西可以指向你正确的方向。

I am sure you are running your development server from your local machine which is setup completely differently from the Bitnami stack. The better solution would be to install everything yourself on a barebones Ubuntu server. Then you will have much more familiarity with the setup.

我确信您正在从本地计算机运行您的开发服务器,该计算机的设置与Bitnami堆栈完全不同。更好的解决方案是将自己安装在准系统Ubuntu服务器上。然后,您将更加熟悉设置。

THE BEST THING you can do, is go learn to use Vagrant. This will help you to maintain a local virtual machine instance, which is identical to your EC2 box. You will log into it using ssh just like the EC2 box, and you will be using it externally, just like the EC2 box. The closer you can get your development environment to your production environment, the easier debugging problems like this will be.

你能做的最好的事情就是去学习使用Vagrant。这将帮助您维护本地虚拟机实例,该实例与您的EC2框相同。您将使用ssh登录它,就像EC2框一样,您将在外部使用它,就像EC2框一样。您越接近开发环境到生产环境,这样的调试问题就越容易。

Hope that didn't make your life more difficult (seriously, if you get Vagrant running, your life will become MUCH easier)

希望这不会让你的生活更加艰难(严肃地说,如果你让Vagrant跑步,你的生活会变得更加容易)

#2


0  

See the following solution: No access to models in admin panel with DEBUG=False

请参阅以下解决方案:使用DEBUG = False访问管理面板中的模型

quote:

OK, I've found reason of my problems. It was caused by registering my models in admin panel from files with models definitions. When I moved all my registrations to one external file admin.py, then everything works correctly.

好的,我找到了我的问题的原因。这是因为在具有模型定义的文件中在管理面板中注册我的模型。当我将所有注册移动到一个外部文件admin.py时,一切正常。