<div><p>You may also want to set <codeclass="docutils literal notranslate"><spanclass="pre">DEBUG</span><spanclass="pre">=</span><spanclass="pre">True</span></code> in your settings file for debugging the website. You will
then see proper tracebacks in the browser rather than just error codes. Note however that this will
<em>leak memory a lot</em> (it stores everything all the time) and is <em>not to be used in production</em>. It’s
recommended to only use <codeclass="docutils literal notranslate"><spanclass="pre">DEBUG</span></code> for active web development and to turn it off otherwise.</p>
<p>A Django (and thus Evennia) website basically consists of three parts, a
<aclass="reference external"href="https://docs.djangoproject.com/en/1.9/topics/http/views/">view</a> an associated
<aclass="reference external"href="https://docs.djangoproject.com/en/1.9/topics/templates/">template</a> and an <codeclass="docutils literal notranslate"><spanclass="pre">urls.py</span></code> file. Think of
the view as the Python back-end and the template as the HTML files you are served, optionally filled
with data from the back-end. The urls file is a sort of mapping that tells Django that if a specific
URL is given in the browser, a particular view should be triggered. You are wise to review the
Django documentation for details on how to use these components.</p>
<p>Evennia’s default website is located in
<aclass="reference external"href="https://github.com/evennia/evennia/tree/master/evennia/web/website">evennia/web/website</a>. In this
folder you’ll find the simple default view as well as subfolders <codeclass="docutils literal notranslate"><spanclass="pre">templates</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">static</span></code>. Static
files are things like images, CSS files and Javascript.</p>
<p>You customize your website from your game directory. In the folder <codeclass="docutils literal notranslate"><spanclass="pre">web</span></code> you’ll find folders
<codeclass="docutils literal notranslate"><spanclass="pre">static</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">templates</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">static_overrides</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">templates_overrides</span></code>. The first two of those are
populated automatically by Django and used to serve the website. You should not edit anything in
them - the change will be lost. To customize the website you’ll need to copy the file you want to
change from the <codeclass="docutils literal notranslate"><spanclass="pre">web/website/template/</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">web/website/static/</span><spanclass="pre">path</span><spanclass="pre">to</span><spanclass="pre">the</span><spanclass="pre">corresponding</span><spanclass="pre">place</span><spanclass="pre">under</span><spanclass="pre">one</span><spanclass="pre">of</span></code>_overrides` directories.</p>
<p>Example: To override or modify <codeclass="docutils literal notranslate"><spanclass="pre">evennia/web/website/template/website/index.html</span></code> you need to
<aclass="reference internal"href="../Howto/Starting/Part5/Web-Tutorial.html"><spanclass="doc std std-doc">Web Tutorial</span></a> for more information.</p>
<p>The Python backend for every HTML page is called a <aclass="reference external"href="https://docs.djangoproject.com/en/1.9/topics/http/views/">Django
view</a>. A view can do all sorts of
functions, but the main one is to update variables data that the page can display, like how your
out-of-the-box website will display statistics about number of users and database objects.</p>
<p>To re-point a given page to a <codeclass="docutils literal notranslate"><spanclass="pre">view.py</span></code> of your own, you need to modify <codeclass="docutils literal notranslate"><spanclass="pre">mygame/web/urls.py</span></code>. An
<aclass="reference external"href="https://docs.djangoproject.com/en/1.9/topics/http/urls/">URL pattern</a> is a <aclass="reference external"href="https://en.wikipedia.org/wiki/Regular_expression">regular
expression</a> that you need to enter in the address
field of your web browser to get to the page in question. If you put your own URL pattern <em>before</em>
the default ones, your own view will be used instead. The file <codeclass="docutils literal notranslate"><spanclass="pre">urls.py</span></code> even marks where you should
<p>Django will always look for a list named <codeclass="docutils literal notranslate"><spanclass="pre">urlpatterns</span></code> which consists of the results of <codeclass="docutils literal notranslate"><spanclass="pre">url()</span></code>
calls. It will use the <em>first</em> match it finds in this list. Above, we add a new URL redirect from
the root of the website. It will now our own function <codeclass="docutils literal notranslate"><spanclass="pre">myview</span></code> from a new module
<div><p>If our game is found on <codeclass="docutils literal notranslate"><spanclass="pre">http://mygame.com</span></code>, the regular expression <codeclass="docutils literal notranslate"><spanclass="pre">"^"</span></code> means we just entered
<codeclass="docutils literal notranslate"><spanclass="pre">mygame.com</span></code> in the address bar. If we had wanted to add a view for <codeclass="docutils literal notranslate"><spanclass="pre">http://mygame.com/awesome</span></code>, the
regular expression would have been <codeclass="docutils literal notranslate"><spanclass="pre">^/awesome</span></code>.</p>
to see the inputs and outputs you must have to define a view. Easiest may be to copy the default
file to <codeclass="docutils literal notranslate"><spanclass="pre">mygame/web</span></code> to have something to modify and expand on.</p>
<p>Restart the server and reload the page in the browser - the website will now use your custom view.
If there are errors, consider turning on <codeclass="docutils literal notranslate"><spanclass="pre">settings.DEBUG</span></code> to see the full tracebacks - in debug mode
you will also log all requests in <codeclass="docutils literal notranslate"><spanclass="pre">mygame/server/logs/http_requests.log</span></code>.</p>
<p>Django comes with a built-in <aclass="reference external"href="https://docs.djangoproject.com/en/1.10/ref/contrib/admin/">admin
website</a>. This is accessible by clicking
the ‘admin’ button from your game website. The admin site allows you to see, edit and create objects
in your database from a graphical interface.</p>
<p>The behavior of default Evennia models are controlled by files <codeclass="docutils literal notranslate"><spanclass="pre">admin.py</span></code> in the Evennia package.
New database models you choose to add yourself (such as in the Web Character View Tutorial) can/will
also have <codeclass="docutils literal notranslate"><spanclass="pre">admin.py</span></code> files. New models are registered to the admin website by a call of
<codeclass="docutils literal notranslate"><spanclass="pre">admin.site.register(model</span><spanclass="pre">class,</span><spanclass="pre">admin</span><spanclass="pre">class)</span></code> inside an <aclass="reference external"href="http://admin.py">admin.py</a> file. It is an error to attempt
to register a model that has already been registered.</p>
<p>To overload Evennia’s admin files you don’t need to modify Evennia itself. To customize you can call
<codeclass="docutils literal notranslate"><spanclass="pre">admin.site.unregister(model</span><spanclass="pre">class)</span></code>, then follow that with <codeclass="docutils literal notranslate"><spanclass="pre">admin.site.register</span></code> in one of your own
<p>Evennia relies on Django for its web features. For details on expanding your web experience, the
<aclass="reference external"href="https://docs.djangoproject.com/en">Django documentation</a> or the <aclass="reference external"href="http://www.djangobook.com/en/2.0/index.html">Django
Book</a> are the main resources to look into. In Django
lingo, the Evennia is a django “project” that consists of Django “applications”. For the sake of web
implementation, the relevant django “applications” in default Evennia are <codeclass="docutils literal notranslate"><spanclass="pre">web/website</span></code> or