------------
Outside of Django_ and the Python_ standard libraries, the only
-required dependencies are `django-taggit`_ (docs__) and
+required dependencies are Grappelli_, `django-taggit`_ (docs__) and
`python-markdown`_.
__ dt2-docs_
a stand-alone service, you can use the example project written up in
`example`. Set up the project (once)::
+ $ python example/manage.py collectstatic
$ python example/manage.py syncdb
See the `Django documentation`_ for more details.
.. _Django: https://www.djangoproject.com/
.. _Git: http://git-scm.com/
.. _cookbook: http://physics.drexel.edu/~wking/code/git/gitweb.cgi?p=cookbook.git
+.. _Grappelli: https://github.com/sehmaschine/django-grappelli
.. _django-taggit: https://github.com/alex/django-taggit
.. _dt2-docs: http://django-taggit.readthedocs.org/en/latest/
.. _python-markdown: http://pypi.python.org/pypi/Markdown
from django.contrib import admin
from django.db import models as django_models
-import models
+from . import models
class IngredientInline (admin.TabularInline):
model = models.Ingredient
+ sortable_field_name = 'position'
extra = 0
-
class IngredientBlockAdmin (admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['name']}),
class IngredientBlockInline (admin.TabularInline):
model = models.IngredientBlock
fieldsets = [
- (None, {'fields': ['name']}),
+ (None, {'fields': ['name', 'position']}),
]
+ sortable_field_name = 'position'
inlines = [IngredientInline]
-
list_display = ['name']
extra = 0
show_edit_link = True # https://code.djangoproject.com/ticket/13163
class IngredientBlock (Directions):
name = models.CharField(max_length=200)
recipe = models.ForeignKey(Recipe)
+ position = models.PositiveIntegerField()
class Meta:
- ordering = ['recipe', 'name']
+ ordering = ['recipe', 'position']
def __unicode__(self):
return u'{0.name}'.format(self)
name = models.CharField(max_length=200)
note = models.CharField(max_length=200, null=True, blank=True)
block = models.ForeignKey(IngredientBlock)
+ position = models.PositiveIntegerField()
+
+ class Meta:
+ ordering = ['block', 'position']
def __unicode__(self):
fmt = '{i.name}'
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls), name='admin'),
+ url(r'^grappelli/', include('grappelli.urls'), name='admin'),
url(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to',
kwargs={'url': settings.STATIC_URL + 'cookbook.ico'}),
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = ''
+STATIC_ROOT = os.path.join(DATA_DIRECTORY, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
-ADMIN_MEDIA_PREFIX = '/static/admin/'
+#ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
+ADMIN_MEDIA_PREFIX = STATIC_URL + 'grappelli/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- os.path.join(DATA_DIRECTORY, 'media'),
- os.path.join(DATA_DIRECTORY, 'static'),
)
# List of finder classes that know how to find static files in
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- os.path.join(DATA_DIRECTORY, 'template'),
)
INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
+ 'grappelli',
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',