Git Product home page Git Product logo

django-sample-app's Introduction

django-sample-app

django-sample-app is a minimal sample application to start developing your web project immediately on Django framework.

The sample application comes with:

that are glued together with initializr. And its current requirements.txt file is:

Django==1.8.2
django-compressor==1.5
django-debug-toolbar==1.3.2
django-extensions==1.5.5
ipython==3.2.0
psycopg2==2.6.1
six==1.9.0
sqlparse==0.1.15
wsgiref==0.1.2

Installation

1. virtualenv / virtualenvwrapper

You should already know what is virtualenv, preferably virtualenvwrapper at this stage. So, simply create it for your own project, where projectname is the name of your project:

$ mkvirtualenv --clear projectname

2. Download

Now, you need the django-sample-app project files in your workspace:

$ cd /path/to/your/workspace
$ git clone git://github.com/kirpit/django-sample-app.git projectname && cd projectname

3. Requirements

Right there, you will find the requirements.txt file that has all the great debugging tools, django helpers and some other cool stuff. To install them, simply type:

$ pip install -r requirements.txt

4. Tweaks

wsgi.py

projectname/wsgi.py file is necessary for WSGI gateways (such as uWSGI) to run your Django application and also required from Django itself. You definitely want to change {{ project_name }} value in this file to whatever you name your application (e.g. bookstore.settings).

SECRET_KEY

Go to http://www.miniwebtool.com/django-secret-key-generator/, create your secret key, copy it. Open your projectname/settings/default.py, find SECRET_KEY line, paste your secret key.

Other settings stuff

It is good idea to make a find & replace within this default settings file as there are some "{{ project_name }}" string left such as ROOT_URLCONF or LOCAL_APPS variables.

Main URL root

You also have to config your application URLs, specific to your own needs. For the beginning, the sample app has only one view that you need to modify its namespace from projectname/urls.py, where it imports HomeView.

local.py (development specific) settings file

Copy projectname/settings/local.template.py as local.py into the same directory and modify necessary changes. local.py is always ignored by .gitignore, so this is the machine specific settings mostly for development purposes.

Initialize the database

First set the database engine (PostgreSQL, MySQL, etc..) in your settings files; projectname/settings/default.py and/or projectname/settings/local.py. Of course, remember to install necessary database driver for your engine. Then define your credentials as well. Time to finish it up:

./manage.py migrate

Ready? Go!

./manage.py runserver

or

./manage.py runserver_plus (Requires Werkzeug)

django-sample-app's People

Contributors

kirpit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-sample-app's Issues

Error: pg_config executable not found.

I'm trying to use django-sample-app in conjunction with dockerfiles/django-uwsgi-nginx and I'm getting following error:

Collecting psycopg2==2.6.1 (from -r /home/docker/code/app/requirements.txt (line 6))
  Downloading psycopg2-2.6.1.tar.gz (371kB)
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-arN73d/psycopg2
The command '/bin/sh -c pip install -r /home/docker/code/app/requirements.txt' returned a non-zero code: 1
root@alexus:~/django-uwsgi-nginx# 

How can I resolve missing executable?

Issues runnin pip install

Running the command

$ sudo pip install -r requirements.txt

results in the error message:

Downloading/unpacking django-admin-tools==0.5.1 (from -r requirements.txt (line 3))
  Could not find a version that satisfies the requirement django-admin-tools==0.5.1 (from -r requirements.txt (line 3)) (from versions: 0.4.0)
  Some insecure and unverifiable files were ignored (use --allow-unverified django-admin-tools to allow).
Cleaning up...
No distributions matching the version for django-admin-tools==0.5.1 (from -r requirements.txt (line 3))
Storing debug log for failure in /Users/warnes/.pip/pip.log

Adding the flag "--allow-insecure django-admin-tools" solves the problem.

Serving static files

Hi there,

this is more a newbie question but after many hours spent troubleshooting, and found many un resolved questions on StackOverflow I thought I might ask!

First of all props for the project, as it's very useful for someone that wants to start on django!

On the Sys admin side, as I would like to have a production website in the future and I'm testing it.

Why while serving the website through Nginx and uWSGI, pointing to the static correctly
I still see a "broken" (of css and js) site?

at first I had the nginx config wrong, now I get no errors but still can't see the website properly.

Do I have to delete local.py and just keep default.py?
are there any specific permissions to be added?
Everything is run and owned by www-data, socket permissions on 774
Thanks a lot!

here some info of the setup

manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:
/home/django/sample/static

root@bananapi /home/django # tree -d sample
sample
├── media
├── sample
│   ├── home
│   └── settings
├── static
│   ├── admin
│   │   ├── css
│   │   ├── img
│   │   │   └── gis
│   │   └── js
│   │   └── admin
│   ├── CACHE
│   │   ├── css
│   │   └── js
│   ├── css
│   ├── django_extensions
│   │   ├── css
│   │   ├── img
│   │   └── js
│   ├── images
│   ├── js
│   ├── libs
│   │   ├── bootstrap-3.3.5
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   └── js
│   │   ├── font-awesome-4.3.0
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   ├── less
│   │   │   └── scss
│   │   ├── jquery
│   │   │   └── 2.1.0
│   │   └── modernizr
│   │   └── 2.6.2
│   └── media
├── static-assets
│   ├── css
│   ├── images
│   ├── js
│   ├── libs
│   │   ├── bootstrap-3.3.5
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   └── js
│   │   ├── font-awesome-4.3.0
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   ├── less
│   │   │   └── scss
│   │   ├── jquery
│   │   │   └── 2.1.0
│   │   └── modernizr
│   │   └── 2.6.2
│   └── media -> ../media/
└── templates

nginx.conf

upstream sample {
server unix:/home/django/sample/sample.sock;
}

server {
listen 80;
server_name bananapi;
access_log off;

    location /static/ {
       alias /home/django/sample/static/;
    }

    location /media/ {
       alias /home/django/sample/media/;
    }

    location / {
       root /home/django/sample;
       uwsgi_pass   sample;
       include /etc/nginx/uwsgi_params;
       uwsgi_send_timeout 300;
       uwsgi_read_timeout 300;
       proxy_pass http://unix:/home/django/sample/sample.sock;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

wsgiref causing install issues

I believe the last line of requirements.txt can be removed:
wsgiref==0.1.2

This is included with Python 3 (and crashes the pip install on Python 3)

CSS and JS files giving 404

Hi there, I've just setup the project, everything seems to work, except for the bootstrap...
"Static" files are giving 404 :

curzel@curzels-laptop:~/Desktop/dev/enasco/cfrm/dj/dj$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
June 05, 2015 - 00:39:42
Django version 1.7.3, using settings 'settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Jun/2015 00:39:45] "GET / HTTP/1.1" 200 5783
[05/Jun/2015 00:39:45] "GET /static/libs/bootstrap/3.3.1/css/bootstrap-theme.min.css HTTP/1.1" 404 4459
[05/Jun/2015 00:39:45] "GET /static/css/main.css HTTP/1.1" 404 4459
[05/Jun/2015 00:39:45] "GET /static/libs/bootstrap/3.3.1/css/bootstrap.min.css HTTP/1.1" 404 4459
[05/Jun/2015 00:39:45] "GET /static/libs/font-awesome/4.2.0/css/font-awesome.min.css HTTP/1.1" 404 4459
[05/Jun/2015 00:39:45] "GET /static/libs/modernizr/2.6.2/modernizr-2.6.2.min.js HTTP/1.1" 404 4459
[05/Jun/2015 00:39:45] "GET /static/libs/bootstrap/3.1.1/js/bootstrap.min.js HTTP/1.1" 404 4459
[05/Jun/2015 00:39:45] "GET /static/js/main.js HTTP/1.1" 404 4459

I've then tried to edit "STATIC_URL" parameter in settigns/default.py, using several diffent pathes such as "/static-assets/", "/myprojectdir/static/", "/myprojectdir/static-assets/"...
They seems to not work :(

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.