Django管理模型未在生产中显示

bogh5gae  于 2022-12-14  发布在  Go
关注(0)|答案(1)|浏览(168)

我已经把我的django项目投入生产。每次添加一个管理模型,它不会更新,并显示在我的管理面板上。迁移和collectstatic命令都进行得很好。我试图源修复,但我只是不能让它工作。在本地服务器工作完全正常。
下面是我的代码:
models.py

class PostImage(models.Model):
    image = models.ImageField(null=False, blank=False, upload_to="images", default="default.png")
    image_title = models.CharField(max_length=100, null=False, blank=False, default="")
    
    def __str__(self):
        return self.image_title
        

class BlogPost(models.Model):
    blog_title = models.CharField(max_length=255, null=True, blank=True)
    blog_article = QuillField(null=True, blank=True)
    blog_image = models.ImageField(null=True, blank=True, upload_to="images", default="default.png")
    blog_date = models.DateField(auto_now_add=True)

    def __str__(self):
        return self.blog_title

class EnterImage(models.Model):
    enter_image = models.ImageField(null=True, blank=True, upload_to="images", default="default.png")
    enter_image_title = models.CharField(max_length=100, null=False, blank=False, default="")
    
    def __str__(self):
        return self.enter_image_title
        
class QuillPost(models.Model):
    content = QuillField()
    
    def __str__(self):
        return self.content
        
class AboutMe(models.Model):
    about_image = models.ImageField(null=True, blank=True, upload_to="images", default="default.png")
    about_image_title = models.CharField(max_length=100, null=False, blank=False, default="")
    
    def __str__(self):
        return self.about_image_title

urls.py

from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('martinhensonphotography.urls')),
]

urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.MEDIA_ROOT)

admin.py

from django.contrib import admin
from . models import PostImage, EnterImage, BlogPost, QuillPost, AboutMe

# Register your models here.

admin.site.register(PostImage)
admin.site.register(BlogPost)
admin.site.register(EnterImage)
admin.site.register(QuillPost)
admin.site.register(AboutMe)

应用程序

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'martinhensonphotography.apps.MartinhensonphotographyConfig',
    'crispy_forms',
    'django_quill',
    'ckeditor',
    'ckeditor_uploader',
7kqas0il

7kqas0il1#

你能把你的设置代码(已安装的应用程序)部分的问题,这将有所帮助。

相关问题