mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2026-02-24 21:25:19 +00:00
Django migrations and troggle laptops
This commit is contained in:
@@ -32,7 +32,7 @@ handbook/computing/yourlaptop.html
|
||||
<li>Install in <a href="https://docs.microsoft.com/en-us/windows/wsl/install">WSL on Windows 10</a>.
|
||||
<li>Install <a href="https://ubuntu.com/download/desktop">Ubuntu 20.04 LTS</a>.
|
||||
</ul>
|
||||
<p>and familiarise yourself with the directory structure on the expo server, which we will be duplicating (partly) as docmented in <a href="serverconfig.html">The Expo Server</a>. We are not here doing a full install of all the software and scripts on the server, just the minimum to run, test and debug troggle on django.
|
||||
<p>and familiarise yourself with the directory structure on the expo server, which we will be duplicating (partly) as docmented in <a href="serverconfig.html">The Expo Server</a>. We are not here doing a full install of all the software and scripts on the server, just the minimum to run, test and debug troggle on Django.
|
||||
|
||||
<h3>WSL on Windows</h3>
|
||||
<p>The standard documentation for Ubuntu or debian below all works, but you should first skim the
|
||||
@@ -54,7 +54,7 @@ sudo ln -s pip3 pip </code></pre>
|
||||
<p>You will also definitely need sqlite3 even if you are planning to use another
|
||||
database. Sqlite3 is used by the test harness system.
|
||||
<p>Note that when you install survex it installs a shed load of packages that it needs.
|
||||
<p>We do <em>not</em> install django at this point. We will be installing django in a separate virtual
|
||||
<p>We do <em>not</em> install Django at this point. We will be installing Django in a separate virtual
|
||||
environment (a 'venv'), not in the main linux system.
|
||||
|
||||
<h2 id="links">Creating folders and soft links</h2>
|
||||
@@ -82,15 +82,15 @@ ls -tlA expo</pre></code>
|
||||
<img src="Django_Logo-420x180.png" align="right" hspace="20" width='210' alt='django logo'>
|
||||
<p>The important point to note
|
||||
here is that unless you are doing something fairly trivial, or you are a git genius,
|
||||
it is sensible to set up a python virtual environments to hold duplicate copies of both troggle and django code.
|
||||
it is sensible to set up a python virtual environments to hold duplicate copies of both troggle and Django code.
|
||||
Then you will be able to check very quickly that your edited version of troggle runs with old, current
|
||||
and pre-release versions of python and of django;
|
||||
and you will more easily be able to manage problems with incompatible versions of django plugins as installing and upgrading the dependent packages is very fast.
|
||||
and pre-release versions of python and of Django;
|
||||
and you will more easily be able to manage problems with incompatible versions of Django plugins as installing and upgrading the dependent packages is very fast.
|
||||
|
||||
<h3 id="venv">Installing a venv</h3>
|
||||
|
||||
<p>We set up
|
||||
a <var>venv</var> specifically for python 3.7 (which is the standard version on our server which is running unmodified Buster (debian v10) and <a href="https://docs.djangoproject.com/en/3.2/releases/2.2/">django 2.2.19</a>. See the <a href="https://docs.python.org/3.7/library/venv.html">standard python documentation on venv</a> for python 3.7.12. You can upgrade the version of python installed within pip venv but not downgrade. So get that first venv installed right by explicitly stating the python version to create it <var>python3.7 -m venv py37d22</var>.
|
||||
a <var>venv</var> specifically for python 3.7 (which is the standard version on our server which is running unmodified Buster (debian v10) and <a href="https://docs.djangoproject.com/en/3.2/releases/2.2/">Django 2.2.19</a>. See the <a href="https://docs.python.org/3.7/library/venv.html">standard python documentation on venv</a> for python 3.7.12. You can upgrade the version of python installed within pip venv but not downgrade. So get that first venv installed right by explicitly stating the python version to create it <var>python3.7 -m venv py37d22</var>.
|
||||
Note that we are creating it as a sibling folder to /expoweb/ . Note also that up to now we have been using 'sudo ..' but for installing things inside the venv we do not use 'sudo ..':
|
||||
<pre><code>cd ~
|
||||
cd ../expo
|
||||
@@ -99,12 +99,12 @@ cd py37d22
|
||||
source bin/activate
|
||||
pip list -o</pre></code>
|
||||
<p>The last command lists the default packages installed in the venv. This is for comparison later, after we
|
||||
have installed troggle, django and dependencies. You will get a warning that you have an out of date version of pipbut this is as we want: we are using a version of pip appropriate for the older version of python within
|
||||
have installed troggle, Django and dependencies. You will get a warning that you have an out of date version of pipbut this is as we want: we are using a version of pip appropriate for the older version of python within
|
||||
the venv.
|
||||
<img border="1" class="onright" width="150px" src='tricky-troggle.jpg' hspace="20" alt='troggle logo'/></a>
|
||||
|
||||
<h3 id="venv">Installing the troggle dependencies</h3>
|
||||
<p>The first time you do this on a new machine you can't complete the pip installation of django as you have not yet got the
|
||||
<p>The first time you do this on a new machine you can't complete the pip installation of Django as you have not yet got the
|
||||
dependencies appropriate for troggle - because you have not yet cloned the troggle repo. So the first time it is easiest to just create requirements.txt yourself with a text editor. Without using git yourself, you can get the file from the website at <a href="http://expo.survex.com/repositories/troggle/.git/tree/requirements.txt">requirements.txt</a>. If you have already cloned all the repos, then just copy it.
|
||||
<pre><code>cp ../troggle/requirements.txt .</pre></code>
|
||||
where <var>requirements.txt</var> (note the capitalisation of the listed packages) is:
|
||||
@@ -116,7 +116,7 @@ Pillow==5.4.1
|
||||
pytz==2019.1
|
||||
sqlparse==0.2.4
|
||||
Unidecode==1.0.23</pre></code>
|
||||
This will pick up the latest django 2.2.x available, but all the other dependencies are pinned. These
|
||||
This will pick up the latest Django 2.2.x available, but all the other dependencies are pinned. These
|
||||
dependencies are as-standard on debian Buster (10) and you will want to experiment with upgrading them
|
||||
for Bullseye (v11).
|
||||
<p>Once you have the file, install the listed dependencies like this:
|
||||
@@ -131,15 +131,15 @@ see <a href="http://expo.survex.com/prospecting_guide/">/prospecting_guide/</a>)
|
||||
tinymce is the wysiwyg in-browser
|
||||
editor (disabled pending reinstatement)
|
||||
|
||||
<p>This is also documented in the <a href="trogdjangup.html">updating django for troggle page</a>
|
||||
where it describes upgrading and testing with later versions of django.
|
||||
<p>This is also documented in the <a href="trogdjangup.html">updating Django for troggle page</a>
|
||||
where it describes upgrading and testing with later versions of Django.
|
||||
|
||||
<p>If you have not used pip before, read <a href="https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/">this</a>
|
||||
|
||||
|
||||
|
||||
<h3 id="troginstall">Installing troggle</h3>
|
||||
<p>The <var>:troggle:</var> repo is the python source code for troggle. This is what you will be editing. There are over 8,000 lines of python code (excluding comments and blank lines) and over 2,000 lines of HTML/django template code. This is over 600 files in over 400 folders, but only 38MB in size.
|
||||
<p>The <var>:troggle:</var> repo is the python source code for troggle. This is what you will be editing. There are over 8,000 lines of python code (excluding comments and blank lines) and over 2,000 lines of HTML/Django template code. This is over 600 files in over 400 folders, but only 38MB in size.
|
||||
|
||||
<h4>key exchange</h4>
|
||||
<p>Follow this link to <a href="../computing/keyexchange.html">register a key with the expo server</a> to get git access if you have not already cloned the <var>:troggle:</var> repo.
|
||||
@@ -204,6 +204,12 @@ Nearly half the code deals with importing and parsing data, so you need to test
|
||||
<h4>Use git to commit your edits</h4>
|
||||
<p>You need to know git. Sorry, but there it is. See <a href="../computing/repos.html">our git repositories</a> and <a href="../computing/qstart-git.html">our git cheat sheet</a>.
|
||||
|
||||
<h3 id="dbtools">Helpful database tools and scripts</h3>
|
||||
<img class="onleft" width = "100px" src="https://mariadb.com/kb/static/images/logo-2018-black.95f5978ae14d.png">
|
||||
<img class="onright" width = "80px" src="https://sqlite.org/images/sqlite370_banner.gif">
|
||||
<p>The public server uses a <a href="https://mariadb.org/about/">MariaDB SQL database</a> and development is usually done using a single-user <a href="https://sqlite.org/about.html">sqlite database</a> which is a standard Django option.
|
||||
<p>
|
||||
You will find it very, very useful to see what is going on if you look directly at the data in the database (just a single file in the sqlite case) and browse the data in the tables. This is vital when doing Django migrations between Django versions. A light-weight, simple db browser is <a href="https://sqlitebrowser.org/">DB Browser for SQLite</a>. Connecting directly the the MariaDB database with a control panel or <a href="https://www.mysql.com/products/workbench/">workbench</a> gives even more tools and documentation capabilities.
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user