DJango memo: From the beginning (editing the management screen) There is a mystery

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

Include your application in the admin page

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).

However, for some reason, the date and time of History is strange.

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.

Customize admin form

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 \

? (If so, CSS can also be applied) It seems that Javascript is also used in the page, but why can't I find the JS file anywhere?

Recommended Posts

DJango memo: From the beginning (editing the management screen) There is a mystery
DJango Memo: From the beginning (more edits to the management screen)
DJango memo: From the beginning (using the management screen) my addictive point
DJango Memo: From the beginning (creating a view)
DJango Memo: From the beginning (Error screen settings)
DJango Memo: From the beginning (preparation)
DJango Memo: From the beginning (model settings)
DJango Note: From the beginning (using a generic view)
DJango Note: From the beginning (creating a view from a template)
DJango Note: From the beginning (form processing)
Throw GQL with a numeric ID from the App Engine management screen
Is there a contradiction between the party that protects the people from NHK and the party that protects NHK from the people?
Transit to the update screen with the Django a tag
Django memo # 1 from scratch
DJango Note: From the beginning (simplification and splitting of URLConf)
Log in to the fortigate (6.0) management screen from selenium-try to log out
The story of a Django model field disappearing from a class
Is there a bias in the numbers that appear in the Fibonacci numbers?
Is there a secret to the frequency of pi numbers?
Create a Django login screen
The image is a slug
Python will fail if there is a space after the backslash
Development of WEB application using Django [Add data from management screen]
[Django] Correct the plural form of the model name on the management screen