.. index:: Admin ********** Admin Site ********** "One of the most powerful parts of Django is the automatic admin interface. It reads metadata in your model to provide a powerful and production-ready interface that content producers can immediately use to start adding content to the site." -- :djangodocs:`The Django admin site | Django documentation ` After you've created the models it's time to configure the admin site. Configure the admin site ======================== Open file :file:`admin.py` in the directory :file:`marcador` and add the following contents: .. literalinclude:: ../src/mysite/marcador/admin.py :linenos: The attributes in ``BookmarkAdmin`` have the following functions: - ``list_display``: These fields will be shown in the list view. - ``list_editable``: These fields are editable in the list view . - ``list_filter``: These fields can be filtered in the list view based on their values. The filter items will be shown in a column on the right side. - ``search_fields``: These fields can be searched for in the list view based on their values. A search field will be shown above the list. - ``readonly_fields``: These fields are not editable in the detail view. You can find a list of all the configuration possibilities in the documentation of the :djangodocs:`Admin-App `. .. index:: createsuperuser .. _createsuperuser: Create a superuser ================== To create a new superuser run the command :command:`createsuperuser` and fill out the fields that follow: :: $ python manage.py createsuperuser Username (leave blank to use 'keimlink'): admin Email address: Password: Password (again): Superuser created successfully. In the next step, you can login with these login details. Invoke the admin site ===================== Start the development server: .. literalinclude:: runserver.log Now you can visit the admin site at http://127.0.0.1:8000/admin/ and login with the user you created earlier, in order to save some bookmarks. This is how the login form looks like: .. image:: /images/admin/log-in-django-site-admin.* :alt: Admin Login :align: center After logging in you will see the site administration page: .. image:: /images/admin/site-administration-django-site-admin.* :alt: Admin Site Administration :align: center .. raw:: latex \newpage If you click on the "Add" button in the "Bookmarks" row the form below will appear, which you can use to create new bookmarks. Create new tags by clicking on the green plus right beside the tags list. Note that the date created and date updated fields are read-only, as we configured it: .. image:: /images/admin/add-bookmark-django-site-admin.* :alt: Admin Add Bookmark :align: center .. raw:: latex \newpage After clicking the "Save" button you will see this list view - note the list, search and filter options you configured at the beginning of this chapter: .. image:: /images/admin/select-bookmark-to-change-django-site-admin.* :alt: Admin Bookmark List View :align: center Create a few more bookmarks and tags using the "Add bookmark" button at the right top of the list, so that there is enough content for the next chapter in which you will build the frontend. Data from other apps can also be managed in the admin site. You can use the admin to manage :djangodocs:`users and their groups`.