How do I prepopulate an Admin field from logged-in User info?
I have model.py:
from django.db import models
class News(models.Model):
title = models.CharField(max_length=65)
body = models.TextField()
author = models.CharField(max_length=55)
and I have admin.py:
from django.contrib import admin
from django.contrib.auth.models import User
from newsite.news.models import News
class NewsAdmin(admin.ModelAdmin):
list_display = ('title','author')
search_fields = ['title', 'author']
prepopulated_fields = {'author': (?????)}
admin.site.register(News, NewsAdmin)
I have been struggling trying to figure out how to get the currently logged-in user into that prepopulated_field for author.
Any tips would be appreciated. Thanks.