BSD · Django · FreeBSD · FreeBSD 10.0 · Python

Getting Started with Django on FreeBSD 10

Django can be installed using pip. Let’s install the dependencies for Django

pip – Python package manager
sqlite3 – Basic database backend for Django
py27-sqlite3 – Python2.7 library for sqlite3

pkg install python
pkg install py27-pip 
pkg install sqlite3
pkg install py27-sqlite3

Now that we have installed the dependencies, let’s install Django using the following command:

pip install django

We can check the version of Python, Sqlite3 and Django

python --version
sqlite --version
python -c "import django; print(django.get_version())"

We can now generate the project using the following command. This file will create a folder named myproject and will generate necessary files needed for the Django app to work.

django-admin.py startproject myproject

The settings can be edited using the file named settings.py inside the project folder we just created. The default settings use sqlite as the database backend.
We can check the settings by run this command.

cd myproject
python manage.py migrate

The server can be started using the command

python manage.py runserver

The command above, starts Django listening on 127.0.0.1:8000. If we want Django to listen on specific port on all interfaces, we can use the following command

python manage.py runserver 0.0.0.0:8000
Advertisements

One thought on “Getting Started with Django on FreeBSD 10

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s