INSTALLED_APPS += (
'constance',
'constance.backends.database', )
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
}
}
CONSTANCE_DATABASE_CACHE_BACKEND = 'default'
CONSTANCE_CONFIG = {
'FOO': ('bar', 'FOO should be bar'),
}
posts = BlogPost.objects.\
order_by('-dPostDataCreate', 'kBlogAuthorUser__id').\
select_related()
for post in posts:
print post.kBlogAuthorUser.kDjangoUser.username
images = models.ManyToManyField(Image, related_name="auto_list")
main_image = models.OneToOneField(Image, related_name="auto")
Может есть механизмы для организации такого в самой СУБД (postgresql)?
markdown.markdown(text)
{{text|markdown:"safe,footnotes,tables"}}
class Meta:
db_table = 'comments'
fields = ['text']
def addcomment(request, article_id):
form = CommentForm(request.POST or None )
if form.is_valid():
comment = form.save(commit=False)
comment.comments_article = Article.objects.get(id=article_id)
form.save()
# почитай reverse
return redirect('/articles/get/%s/' % article_id)
return render(request, 'template.html', {'form': form})
moderation_status = (...,
(999, 'Ревизия для показа') )
Banner:
name
text
image
moderation_status
def get_absolute_url(self):
return reverse(.....)