Reputation: 75
I am currently working on a science django blog. I've finished coding it all and I realized that the models items overview and content don't appear in my django.admin. Here's an image so you can see.
I know there are other threads related to it. However, I couldn't find the solution in those.
Models.py:
class Post(models.Model):
title = models.CharField(max_length=100)
overview = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)
content = HTMLField()
author = models.ForeignKey(Author, on_delete=models.CASCADE)
thumbnail = models.ImageField()
categories = models.ManyToManyField(Category)
featured = models.BooleanField()
previous_post = models.ForeignKey(
'self', related_name='previous', on_delete=models.SET_NULL, blank=True, null=True)
next_post = models.ForeignKey(
'self', related_name='next', on_delete=models.SET_NULL, blank=True, null=True)
Admin.py:
from django.contrib import admin
from .models import Author, Category, Post, Comment, PostView
# Register your models here.
admin.site.register(Author)
admin.site.register(Category)
admin.site.register(Post)
Settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'crispy_forms',
'tinymce',
'marketing',
'posts'
]
And urls.py:
urlpatterns = [
path('admin/', admin.site.urls),
By the way, the models.py is in the app Posts. Just in case somebody needs this information.
The other models work perfectly. It’s just the overview and the content
Upvotes: 0
Views: 47
Reputation: 1270
Use this :-
content = models.TextField()
Instead of :-
content = HTMLField()
AND then make migrations, migrate
Upvotes: 1