Somehow previous was a little tricky, but finally the admin screen can be displayed.
In addition, since you gave me the latest version of the document, I will refer to it from this time. http://docs.djangoproject.jp/en/latest/intro/tutorial01.html
If you log in to the admin page with the default settings, there is an item called "Auth", and there are "Groups" and "Users" in it. To display your application Polls here and edit it from the administration screen, edit admin.py in the polls directory.
admin.py ######
from django.contrib import admin
from polls.models import Poll #Import
admin.site.register(Poll) #Register on the admin screen
This will add it. Can be added / edited / deleted. I tried adding a Question from here. Date and Time use the shortcuts for Today and Now. Then, the current date and time are correct (although I do not check the number of seconds).
Since it is deducted by 9 hours, it seems that this is the date and time considered by the world standard, but if so, should both be wrong? On the contrary, it seems unnatural that only Today Now when Poll is added is properly engaged with Japanese time.
That said, it's not very important for now, so I'll postpone the fix.
How to sort the forms admin.py ######
class PollAdmin(admin.ModelAdmin):
fields = ['pub_date', 'question'] #fields is probably the default variable name
#Specify the item name registered in the database by putting it in the array
admin.site.register(Poll, PollAdmin)
#Get the data with the first argument and create it based on the second argument?
If you have a lot of forms, you can split them with fieldsets
class PollAdmin(admin.ModelAdmin):
fieldsets = [
# (“Heading”,{‘fields’:["item","item"]})It seems to be written
(None,{'fields': ['question']}), #None has no heading
('Date information',{'fields': ['pub_date'],'classes': ['collapse']}),
#classes specifies HTML classes. collapse is a folding function
]
Is the HTML class here the same as \
Recommended Posts