通过 django 的 admin.py 和 django-address 添加地址到模型
我的 django 应用程序出现问题。我正在尝试添加具有地址字段的餐厅模型,并且我正在使用 django-address< /a> 帮助我解决这个问题。所以,我的餐厅模型看起来像这样:
class Restaurant(models.Model):
name = models.CharField(max_length=64)
address = AddressField(on_delete = models.CASCADE, default = None)
但是,当我使用 admin.py 添加特定餐厅时,它不允许我这样做。如下面的屏幕截图所示,我输入一个字符,然后它不允许我编辑它:
< img src="https://i.sstatic.net/8Va3o.png" alt="Screenshot of admin.py">
我已经能够自己添加特定地址,但我不知道如何将这些地址连接到具体餐厅。有人对如何解决这个问题有任何想法吗?或者,有没有人有任何好的解决方法,我可以在不使用 admin.py 的情况下添加一些特定的餐厅?
I am having a problem with my django app. I am trying to add a model of restaurants that has an address field, and I am using django-address to help me with this. So, my Restaurant model looks like this:
class Restaurant(models.Model):
name = models.CharField(max_length=64)
address = AddressField(on_delete = models.CASCADE, default = None)
However, when I go to add a specific restaurant using admin.py, it doesn't let me. As shown in the screenshot below, I type in one character and then it does not allow me to edit it:
I have been able to add specific addresses themselves, but I can't figure out how to connect these addresses to a specific restaurant. Does anyone have any ideas about how to fix this? Or, does anyone have any nice work-arounds where I can add some specific restaurants without using admin.py?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论