The Web Admin¶
The Evennia Web admin is a customized Django admin site
used for manipulating the game database using a graphical interface. You
have to be logged into the site to use it. It then appears as an
the top of your website. You can also go to http://localhost:4001/admin when
Almost all actions done in the admin can also be done in-game by use of Admin- or Builder-commands.
The admin is pretty self-explanatory - you can see lists of each object type, create new instances of each type and also add new Attributes/tags them. The admin frontpage will give a summary of all relevant entities and how they are used.
There are a few use cases that requires some additional explanation though.
Adding objects to Attributes¶
value field of an Attribute is pickled into a special form. This is usually not
something you need to worry about (the admin will pickle/unpickle) the value
for you), except if you want to store a database-object in an attribute. Such
objects are actually stored as a
tuple with object-unique data.
Find the object you want to add to the Attribute. At the bottom of the first section you’ll find the field Serialized string. This string shows a Python tuple like
('__packed_dbobj__', ('objects', 'objectdb'), '2021:05:15-08:59:30:624660', 358)
Mark and copy this tuple-string to your clipboard exactly as it stands (parentheses and all).
Go to the entity that should have the new Attribute and create the Attribute. In its
valuefield, paste the tuple-string you copied before. Save!
If you want to store multiple objects in, say, a list, you can do so by literally typing a python list
[tuple, tuple, tuple, ...]where you paste in the serialized tuple-strings with commas. At some point it’s probably easier to do this in code though …
Building with the Admin¶
It’s possible (if probably not very practical at scale) to build and describe rooms in the Admin.
Objectof a Room-typeclass with a suitable room-name.
Set an Attribute ‘desc’ on the room - the value of this Attribute is the room’s description.
type‘alias’ to add room-aliases (no type for regular tags)
Exittypeclass, so create one.
The exit has
Locationof the room you just created.
Destinationset to where the exit leads to.
Set a ‘desc’ Attribute, this is shown if someone looks at the exit.
type‘alias’ are alternative names users can use to go through this exit.
Grant others access to the admin¶
The access to the admin is controlled by the
Staff status flag on the
Account. Without this flag set, even superusers will not even see the admin
link on the web page. The staff-status has no in-game equivalence.
Only Superusers can change the
Superuser status flag, and grant new
permissions to accounts. The superuser is the only permission level that is
also relevant in-game.
User Permissions and
Groups found on the
admin page only affects the admin - they have no connection to the in-game
Permissions (Player, Builder, Admin etc).
For a staffer with
Staff status to be able to actually do anything, the
superuser must grant at least some permissions for them on their Account. This
can also be good in order to limit mistakes. It can be a good idea to not allow
Can delete Account permission, for example.
If you grant staff-status and permissions to an Account and they still cannot access the admin’s content, try reloading the server.
If a staff member has access to the in-game ``py`` command, they can just as well have their admin ``Superuser status`` set too. The reason is that ``py`` grants them all the power they need to set the ``is_superuser`` flag on their account manually. There is a reason access to the ``py`` command must be considered carefully ...
Customizing the web admin¶
Customizing the admin is a big topic and something beyond the scope of this documentation. See the official Django docs for the details. This is just a brief summary.
See the Website page for an overview of the components going into generating a web page. The Django admin uses the same principle except that Django provides a lot of tools to automate the admin-generation for us.
Admin templates are found in
evennia/web/templates/admin/ but you’ll find
this is relatively empty. This is because most of the templates are just
inherited directly from their original location in the Django package
django/contrib/admin/templates/). So if you wanted to override one you’d have
to copy it from there into your
mygame/templates/admin/ folder. Same is true
for CSS files.
The admin site’s backend code (the views) is found in
is organized into
These automatically use the underlying database models to generate useful views
for us without us havint go code the forms etc ourselves.
The top level
AdminSite (the admin configuration referenced in django docs)
is found in
Change the title of the admin¶
By default the admin’s title is
Evennia web admin. To change this, add the
following to your
# in mygame/web/urls.py # ... from django.conf.admin import site #... site.site_header = "My great game admin"
Reload the server and the admin’s title header will have changed.