Skip to content

Instantly share code, notes, and snippets.

@Brick85
Last active October 12, 2015 07:48
Show Gist options
  • Save Brick85/3994637 to your computer and use it in GitHub Desktop.
Save Brick85/3994637 to your computer and use it in GitHub Desktop.
Django initial
# settings.py
import os
rel = lambda *x: os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), *x)
gettext = lambda s: s
LANGUAGES = (
('ru', gettext('Russian')),
('en', gettext('English')),
('lv', gettext('Latvian')),
)
ADMIN_LANGUAGE_CODE = 'lv'
MEDIA_ROOT = rel('public', 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = rel('public', 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
rel('static_project'),
)
from django.conf import global_settings
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
"django.core.context_processors.request",
)
# MIDDLEWARE_CLASSES
'django.middleware.locale.LocaleMiddleware',
'forceadminlanguage.middleware.ForceAdminLanguageMiddleware',
# INSTALLED_APPS
'south',
'sitemenu',
'menu',
'qshop',
'qshop.cart',
'easy_thumbnails',
SOUTH_MIGRATION_MODULES = {
'easy_thumbnails': 'ignore',
}
SITEMENU_MENUCLASS = 'menu.models.Menu'
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
PIPELINE_CSS = {
'global': {
'source_filenames': (
'css/includes.less',
),
'output_filename': 'compile/css/project-{0}.min.css'.format(MEDIA_VERSION),
},
}
PIPELINE_JS = {
'global': {
'source_filenames': (
'js/main.js',
),
'output_filename': 'compile/js/project-{0}.min.js'.format(MEDIA_VERSION),
},
}
try:
from settings_local import *
except ImportError:
pass
if not DEBUG:
PIPELINE_COMPILERS = (
'pipeline.compilers.less.LessCompiler',
)
# urls.py
from django.conf.urls.i18n import i18n_patterns
urlpatterns += i18n_patterns('',
url(r'^cart/', include('qshop.cart.urls')),
url(r'^', include('qshop.urls')),
url(r'^', include('sitemenu.urls')),
)
# menu/models.py
from sitemenu.models import SiteMenu
#from easy_thumbnails.fields import ThumbnailerImageField
from django.db import models
from django.utils.translation import ugettext_lazy as _
#from django.core.cache import cache
class Menu(SiteMenu):
pass
#image = ThumbnailerImageField(_('image'), upload_to='menu', resize_source=dict(size=(1024, 1024)), null=True, blank=True)
#def save(self, *args, **kwargs):
#super(Menu, self).save(*args, **kwargs)
#cache.clear()
# menu/admin.py
from django.contrib import admin
from sitemenu.admin import SiteMenuAdmin
from menu.models import Menu
class MenuAdmin(SiteMenuAdmin):
pass
admin.site.register(Menu, MenuAdmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment