Go to content Go to menu

Here’s a workspace I put together recently to help me learn Django:

When you first crank it up, it probably won’t do much of anything. You’ll need to follow along with the Django Tutorial to get your feet wet. Here’s what you get when you run lando start: a Python appserver, with Django installed, and a PostgreSQL database.

You’ll be learning as you go. You will find these Lando tooling commands helpful:

lando django-admin
runs arbitrary django-admin commands on the appserver
lando python
runs python commands on the appserver
lando logs -f
lets you follow the logs of the appserver and database
lando psql
lets you run the psql client for the Postgresql database
lando db-import filename
lets you import a database dump into the database
shows you all the other Lando commands that are available
lando django-admin check
will attempt to validate your Django project configuration, by far the most helpful command you can run when you’re getting started

I’m sharing this Django seed environment early, because I was asked about it by someone else in the Lando community. I haven’t tested it, though it is based on an environment I have used in the past. I will probably update this article after I get a chance to play with it a bit.

Oh, yeah, now I remember! The Django tutorial has a bit of a bug. I was meaning to report it and make a PR to fix it. This workspace includes a project which has gone as far as creating a new project, and then creating the polls app. The tutorial directs you to change the site/app/urls.py file, which disables the default home page (with the fun rocket blasting off image). So, the “fix,” which is included in my seed project environment, is to add a path for the root

Not elegant, but it works. For the record, the tutorial does eventually get around to the topic of home pages.

I feel like I’m dropping you in the deep end of the pool. This environment I’ve made almost works out of the box. There are enough tools at your disposal to get things working. But, you’ll end up reading a lot of docs, and learning a lot about Lando and Django along the way. It’s OK, it’ll be fun. You’ll thank me, I think?

Here’s a quick thing I did for a couple of my colleagues, to demo writing a Lando environment from scratch. I grabbed the latest copy of Omeka-S and unzipped the file, then wrote the following .lando.yml file

name: omeka-s
recipe: lamp
  php: '7.3'
  webroot: .
  database: mysql:5.7
  xdebug: false

And then I modified the config/database.ini file to use the default DB credentials used by Lando:

user     = "lamp"
password = "lamp"
dbname   = "lamp"
host     = "database"

And then I ran lando start and followed along with the rest of the Omeka S install guide.

Lando tells you the URL you need to visit after your site comes up:

Waiting until database service is ready...
Scanning to determine which services are ready... Please standby...


Your app has started up correctly.
Here are some vitals:

 NAME            omeka-s
 LOCATION        /Users/hpotting/workspace/lando-omeka-s
 SERVICES        appserver, database
 APPSERVER URLS  https://localhost:32825

Any of those URLs work fine.