Skip to content

Commit

Permalink
Merge pull request #83 from vladignatyev/master
Browse files Browse the repository at this point in the history
Django 1.7, straight-forward demo, use virtualenv and requirements
  • Loading branch information
elo80ka committed Feb 21, 2015
2 parents aaa288d + e902aac commit f7018f0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 37 deletions.
16 changes: 8 additions & 8 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ The demo project is a Django project, showing different ways to
use the plugin. To run the project, you'll need Python_ and Django_.
For instructions on installing them, see their respective sites.

You'll also need PySQLite_ - if you've got Python 2.5 and above, this
is already included in the standard library.

Once you've set up Django, run the following commands to set up the
database and start the development server::
Once you've got the source code, run the following commands to set up the
SQLite3 database and start the development server::

cd demo
python ./manage.py syncdb
python ./manage.py runserver
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
chmod a+x manage.py
./manage.py syncdb
./manage.py runserver

You can now browse to ``http://localhost:8000/`` and view the examples.

.. _Python: http://python.org/
.. _Django: http://www.djangoproject.com/
.. _PySQLite: http://oss.itsystementwicklung.de/trac/pysqlite
3 changes: 2 additions & 1 deletion demo/example/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf.urls.defaults import *

from django.conf.urls import patterns, url, include
from example.forms import AutoCompleteOrderedItemForm, OrderedItemForm, ContactFormset, MaxFiveContactsFormset, EmptyContactFormset, EventFormset
from example.forms import AutoCompleteSelectFieldForm

Expand Down
15 changes: 7 additions & 8 deletions demo/manage.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)

if __name__ == "__main__":
execute_manager(settings)
import os
import sys
from django.core.management import execute_from_command_line

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
execute_from_command_line(sys.argv)

2 changes: 2 additions & 0 deletions demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Django==1.7.1
django-ajax-selects==1.3.5
2 changes: 1 addition & 1 deletion demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'demo.urls'
ROOT_URLCONF = 'urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
Expand Down
22 changes: 10 additions & 12 deletions demo/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ <h1 class="title">Examples</h1>
of each, to see how they work:
</p>
<ul>
<li><a href="{% url example_table %}">Basic Formset (Table layout)</a></li>
<li><a href="{% url example_stacked %}">Basic Formset (DIV layout)</a></li>
<li><a href="{% url example_inline_formset %}">Inline Formset</a></li>
<li><a href="{% url example_inline_autocomplete %}">Inline Formset (using jQuery Autocomplete)</a></li>
{% comment %}<li><a href="{% url example_inline_ajax_selects %}">Inline Formset (using Django Ajax Selects)</a></li>{% endcomment %}
<li><a href="{% url example_admin_widget %}">Basic Formset with Admin Widget</a></li>
<li><a href="{% url example_multiple_formsets %}">Multiple formsets on the same page</a></li>
<li><a href="{% url example_form_template %}">Formset with `extra = 0` (pre Django 1.2)</a></li>
{% if not is_pre12 %}
<li><a href="{% url example_empty_form %}">Formset with `extra = 0` (Django 1.2+)</a></li>
<li><a href="{% url example_max_forms %}">Limit allowed forms</a></li>
{% endif %}
<li><a href="{% url 'example_table' %}">Basic Formset (Table layout)</a></li>
<li><a href="{% url 'example_stacked' %}">Basic Formset (DIV layout)</a></li>
<li><a href="{% url 'example_inline_formset' %}">Inline Formset</a></li>
<li><a href="{% url 'example_inline_autocomplete' %}">Inline Formset (using jQuery Autocomplete)</a></li>
{% comment %}<li><a href="{% url 'example_inline_ajax_selects' %}">Inline Formset (using Django Ajax Selects)</a></li>{% endcomment %}
<li><a href="{% url 'example_admin_widget' %}">Basic Formset with Admin Widget</a></li>
<li><a href="{% url 'example_multiple_formsets' %}">Multiple formsets on the same page</a></li>
<li><a href="{% url 'example_form_template' %}">Formset with `extra = 0` (pre Django 1.2)</a></li>
<li><a href="{% url 'example_empty_form' %}">Formset with `extra = 0` (Django 1.2+)</a></li>
<li><a href="{% url 'example_max_forms' %}">Limit allowed forms</a></li>
</ul>
</div>
</div>
Expand Down
12 changes: 5 additions & 7 deletions demo/urls.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import django
from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
from django.views.generic.simple import direct_to_template
from django.views.generic import TemplateView
from django.conf.urls import patterns, url, include

major, minor = django.VERSION[:2]
is_pre12 = (major <= 1 and minor < 2)

urlpatterns = patterns('',
(r'^$', direct_to_template, {'template': 'index.html', 'extra_context': dict(is_pre12=is_pre12)}),
(r'^examples/', include('example.urls')),
url(r'^$', TemplateView.as_view(template_name='index.html')),
url(r'^examples/', include('example.urls')),
)

try:
import ajax_select
# If django-ajax-selects is installed, include its URLs:
urlpatterns += patterns('',
(r'^ajax-select/', include('ajax_select.urls'))
url(r'^ajax-select/', include('ajax_select.urls'))
)
except ImportError:
pass
Expand Down

0 comments on commit f7018f0

Please sign in to comment.