Setting Up Wagtail for Development on Windows: A Step-by-Step Guide
Tags: django, djangocms, wagtai, python
Published: 2023-10-06 10:42:03

Hello! I'm currently an Outreachy applicant in the contribution stage.  I'm a Django developer excited about Wagtail projects. In this article, I'll show you how to set up Wagtail on your Windows machine, sharing what I've learned so far. 

**Prerequisites**
Before starting, make sure your Windows system has the following installed:

- Git installed.
- Python installed.
- node version 18.0.0 installed.

**Windows Subsystem for Linux(WSL) Installation Guide.**

On your Windows machine, do the following;

1. Open settings > apps> > optional features > more Windows features >.
2. Enable WSL and reboot your system.
3. Visit the Microsoft store. Install Ubuntu and follow the prompts, take note of the password requested as you will use it quite often.

**Wagtail Installation Guide.**

1. Fork the repository by clicking on this [link](https://github.com/wagtail/wagtail/fork).

2. From your Ubuntu terminal, create a directory and enter into that directory, create a virtual environment and activate it. 
    ```
mkdir wagtail && cd wagtail
python3 -m venv venv
source venv/bin/activate
    ```
2. Copy the URL of your fork of the repository, just like I did in the picture below. 

    ![Image showing how to copy the URL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucb2jzxmiysehti7icn3.jpg)
    
3. Clone your copy of the repository.
    ```
git clone https://github.com/Chidera6/wagtail.git #[YOUR_FORKED_REPO_URL]
cd wagtail
    ```
4. Install the necessary dependencies.
    ```
pip install -e ."[testing,docs]" -U
    ```
5. Install the tool chain for building static assets and compile the assets.
    ```
npm ci
npm run build
    ```
6. Run migrations for the test models using the code below.     
    ```
django-admin makemigrations --settings=wagtail.test.settings
    ```
7.  Start the server with the code below. You should see this file- `ui_tests.db` in `/wagtail/test/`, if everything went well.

    ```
export DJANGO_SETTINGS_MODULE=wagtail.test.settings_ui
./wagtail/test/manage.py migrate #Create the tables.
./wagtail/test/manage.py createcachetable #create a cache table
./wagtail/test/manage.py runserver 0:8000 #starts the server
    ```
8. In another terminal, and with your virtual environment activated, compile the UI component.
    ```
npm run storybook
    ```
9. Now, when you visit the URL http://localhost:8000 in your browser, you should see the output below indicating that the server is running successfully.

 
![Image showing the output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssrg8h6phlqzt4x09ky0.jpg)

**Note**

The official Wagtail documentation offers different setup guides based on your goals.
If this guide did not capture what you wanted, you could look it up for clarity.

**Feedback and Corrections**
I aim for accuracy in this guide. If you find any errors or have suggestions for improvement, please get in touch with me at onumajurubenedicta@gmail.com.


**Conclusion**
Congratulations! You've successfully enabled Wagtail for development on your Windows OS. Happy coding!

**References**
[Wagtail documentation](https://docs.wagtail.org/en/latest/contributing/developing.html)
[Wagtail repository](https://github.com/wagtail/wagtail)