-
Notifications
You must be signed in to change notification settings - Fork 21
Developing myRobogals on Windows
Here's how to install a local development copy of myRobogals on Windows.
Pre-requisites We currently use Django 1.7.11 with Python 2.7.13. For maximum compatibility with what's running on the live server, it's recommended that you use these versions too. You will need these items to be installed on your machine in order to run myRobogals
- Python
- Django
- pytz
- tinymce
- (Optional) Sequel Pro
- (Optional) mySQL
- (Optional) mysql-python
Fork the myRobogals repository from Github to create your own copy of it, then check out that copy. The following pages may be helpful:
Install the latest version of Python 2 off the official Python website. At the current time of writing, it is v2.7.13, and is what the production site is running off. When downloaded, double click on the installer and accept the default install path C:\Python27 to simplify the installation process.
After instaling, we will need to add Python to system's PATH environment variable. To do this, go to Control Panel -> System -> Advanced system settings. Under the Advanced tab, click on Environment Variables... Add ;C:\Python27;C:\Python27\Scripts to the end of the Path variable depending on whether or not you want Python installed for all the users on the computer or just yourself. Click Ok and close the windows. To test whether you've installed Python properly, open up a Command Window and type in python --version to confirm. If installed correctly, it will output the current Python version.
Instead of installing the Django requirements on your computer which may have version and references collisions with what you've previously installed, it is best to use a virtual environment which counteracts this issue. Virtualenv creates a dedicated environment for each Django project we create and is considered a best practice. We will isntall both virtualenv and virtualenvwrapper.
pip install virtualenvwrapper-win
Create our new virtual environment in any directory you want as long as it's not in the myRobogals folders.
mkvirtualenv venv
The virtual environment will be activated automatically and you’ll see (venv) next to the command prompt. If you start a new command prompt, you’ll need to activate the environment again in any folder by
workon venv.
Make sure your venv is activated before installing Django and myRobogals requirements. This is to ensure that packages do not get mismanaged and stay in their own virtual environments. Now go to the cloned myRobogals directory and instal the required dependencies list under requirements.txt by typing into Command Prompt
cd (myRobogals folder path)
pip install -r requirements.txt
In the "myrobogals" directory inside the "myrobogals" directory (yes you read that correctly), make a copy of the file "settings.py.sample" and rename it to "settings.py"
Edit the file and fill in the path to your myRobogals directory at the top of the file. This is to ensure that everything gets the proper path references in your project.
Find where DATABASES is defined and enter in your mySQL credentials to ensure that Django has access to the database. For those who want to use sqlite (or other databases), comment out the one for mySQL and uncomment the one for sqlite.
To create a sample database with a some mock users, chapters and workshops, first navigate to the directory containing the file manage.py. Create database structure by typing:
python manage.py migrate
Delete the timezone information, otherwise conflicts will occur when loading the sample data
python manage.py shell
In the python shell command line enter the following:
from myrobogals.rgmain.models import Timezone
Timezone.objects.all().delete()
quit()
Load in sample data
python manage.py loaddata sampledata
If you've got all the previous steps completed without failing you should be able to then type
python manage.py runserver
The development server will now be running on http://127.0.0.1:8000/ - click there and you'll see your very own local copy of myRobogals.
You can log in with the username "admin" and password "test" to get started. This account has admin privileges, so go ahead and create your own. All the other sample users have the password "abc123".
Now get coding, and contribute your changes back to us as a "Pull Request" on Github!
- Activate your myRobogals virtual environment (see above)
- Update your fork from the original repo to ensure you are working off the latest code
- Install/upgrade required Python packages using 'pip install --upgrade -r requirements.txt'
- Run 'python manage.py migrate' to ensure your local database structure is up to date
Error information will be listed here once reported. If found, please report them to Sing (firew0rks) or the wiki directly!