Django 内联在开发服务器上工作,但不在 Apache 测试服务器上工作?

发布于 2024-11-18 12:41:13 字数 1713 浏览 3 评论 0原文

我遇到的问题是内联管理功能在不同的环境中表现不同。

在开发中,当编辑技术时,我会在底部找到一个链接,可以根据需要添加更多滚动修改器,从而完美运行。

在测试中,我得到一个滚动修改器,没有添加更多的链接,并且它默默地无法保存我对滚动修改器所做的任何更改。

相同的代码部署到两个环境。你知道这里可能发生什么吗?

开发服务器配置(实际上是桌面)

  • Gentoo Linux
  • Django 1.3
  • SQLLite3 数据库(本地存储)
  • Django 内置开发服务器
  • Python 2.6.6

测试服务器配置

  • SuSE Linux 11.4
  • Django 1.3(也尝试使用 Django 1.2.5)
  • PostgreSQL 9.0.3
  • Apache2 2.2.17
  • Python 2.7

附录 A - 模型代码

class Technology(models.Model):
  categories = (
     ('weap' , 'Weaponry'),
     ('equip', 'Equipment'),
     ('cons' , 'Construction'),
     ('ammo' , 'Ammunition'),
   )

  name = models.CharField(max_length=40)
  category = models.CharField(max_length=8, choices=categories)
  urlname = models.CharField(max_length=20)
  description = models.TextField()
  base_difficulty = models.IntegerField()
  tier = models.IntegerField()
  show = models.BooleanField()

  def __unicode__(self):
    return self.name

class TechnologyRollModifier(models.Model):
  technology = models.ForeignKey(Technology)
  modifier   = models.IntegerField(default=2)
  condition  = models.CharField(max_length=120)

附录 B - 管理代码

from django.contrib import admin
from solaris.warbook import models

class TechnologyRollModifierInline(admin.StackedInline):
  model = models.TechnologyRollModifier
  extra = 0

class TechnologyAdmin(admin.ModelAdmin):
  fields = ['name', 'urlname', 'description', 'tier', 'category', 'base_difficulty', 'show']
  inlines = [TechnologyRollModifierInline,]

admin.site.register(models.Technology, TechnologyAdmin)

I'm having an issue where the Inline Admin functionality is behaving differently in different environments.

In Dev, when editing a technology I get a link at the bottom to add more Roll Modifiers as needed that works flawlessly.

In Test, I get a single roll modifier with no link to add more and it silently fails to save any changes I make to the roll modifier.

The same code is deployed to both environments. Any ideas what might be going on here?

Dev Server Configuration (actually a Desktop)

  • Gentoo Linux
  • Django 1.3
  • SQLLite3 Database (locally stored)
  • Django built-in development server
  • Python 2.6.6

Test Server Configuration

  • SuSE Linux 11.4
  • Django 1.3 (also tried with Django 1.2.5)
  • PostgreSQL 9.0.3
  • Apache2 2.2.17
  • Python 2.7

Appendix A - Model Code

class Technology(models.Model):
  categories = (
     ('weap' , 'Weaponry'),
     ('equip', 'Equipment'),
     ('cons' , 'Construction'),
     ('ammo' , 'Ammunition'),
   )

  name = models.CharField(max_length=40)
  category = models.CharField(max_length=8, choices=categories)
  urlname = models.CharField(max_length=20)
  description = models.TextField()
  base_difficulty = models.IntegerField()
  tier = models.IntegerField()
  show = models.BooleanField()

  def __unicode__(self):
    return self.name

class TechnologyRollModifier(models.Model):
  technology = models.ForeignKey(Technology)
  modifier   = models.IntegerField(default=2)
  condition  = models.CharField(max_length=120)

Appendix B - Admin Code

from django.contrib import admin
from solaris.warbook import models

class TechnologyRollModifierInline(admin.StackedInline):
  model = models.TechnologyRollModifier
  extra = 0

class TechnologyAdmin(admin.ModelAdmin):
  fields = ['name', 'urlname', 'description', 'tier', 'category', 'base_difficulty', 'show']
  inlines = [TechnologyRollModifierInline,]

admin.site.register(models.Technology, TechnologyAdmin)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必在意 2024-11-25 12:41:13

想通了。不久前,我将 Django 管理文件复制到 /var/www/media/admin 并将别名 /media/ 复制到 /var/www/media/

这意味着它正在提供旧媒体文件 - 给我工作 CSS / 图像但默默地找不到 JavaScript - StackedInline 管理界面依赖它来完成其工作。

我看到的单个 TechnologyRollModifier 是隐藏模板,实际上并没有记录任何要输入其中的数据。

又一个谜团解开了……

Figured it out. Some time ago I'd copied the Django admin files to /var/www/media/admin and aliases /media/ to /var/www/media/

Which means it was serving up the old media files - giving me working CSS / images but silently failing to find the JavaScript - which the StackedInline admin interface relies upon to do its work.

The single TechnologyRollModifier I saw was meant to be the hidden template and did not actually record any data meant to be entered into it.

Another mystery solved....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文