Giter Site home page Giter Site logo

boutique's Introduction

Boutique

Small e-commerce solution implemented in Django for educational purposes.

The code here might not be optimal, or even correct. It is only intended to show off Django features and the best practise to setup a Django project.

This file contains what is needed to setup the project and run the server.

Some understanding of python and familiarity with web frameworks is assumed.

Environments

Boutique can run in three different environments:

  • Development
  • Test
  • Production

These environments has their own requirements file and settings file so you have to make sure you are using the correct environment.

Installing

Create a virtual environment and install the needed requirements

$ mkvirtualenv boutique
$ pip install -r requirements/development.txt

Enable your environment

Run this in your shell to use the development settings:

$ export DJANGO_SETTINGS_MODULE=boutique.settings.development

This export can be handy to put in your venvs postactivate script

Setting up database

Development environment is using pythons built in sqlite support. All that is needed is:

$ python manage.py syncdb --migrate

Select Yes when prompted to create an account, and enter what you whish to use.

Importing demo data

This step is optional, but if you want products in your shop, run this:

$ python manage.py loaddata ../fixtures/catalogue.json

Running tests

To run the unit tests

$ python manage.py test --settings=boutique.settings.test

To run check code coverage

coverage run --source='.' manage.py test --settings=boutique.settings.test
coverage report

Running

Run the local development server by issuing:

$ python manage.py runserver

Now you should have a working server listening to port 8000 on your local interface.

Production

When running in production, more precaution is made, and you have to export the projects secret as an environment variable, as well as selecting the correct settings file

$ export SECRET_KEY="-clxsvc7x0)%8is&4h0#acmpz91aszs%v-f29t893xf5g-@64z"
$ export DJANGO_SETTINGS_MODULE=boutique.settings.development

Static files must be served by another entity than the Django application. There is a management command to run to collect all static resources and put those in another directory:

$ python manage.py collectstatic

Then you should NEVER EVER use the debug server in production, instead run django in a wsgi container using gunicorn or uwsgi

$ gunicorn --log-file=boutique.log -b 127.0.0.1:8000 -D \
-w 2 --pid boutique.pid boutique.wsgi:application

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.