分类: Python/Ruby
2009-05-22 16:10:00
(r'^comic/', include('bigcomic.comic.urls')),
(r'^media/(?P
{'document_root': settings.STATIC_PATH}),
(r'^comicviewer/(?P
{'document_root': settings.FLEX_PATH}),
BIGCOMIC_ROOT = os.path.dirname(__file__)
STATIC_PATH = os.path.join(BIGCOMIC_ROOT, 'media')
FLEX_PATH = os.path.join(BIGCOMIC_ROOT, 'comicviewer')
DEFAULT_CHARSET = 'utf8'
#-*-coding:utf-8-*-
class Book(models.Model):
enname = models.CharField(unique=True,max_length=100,null=True,blank=True)
category_id = models.IntegerField(default=1)
createTime = models.DateTimeField(auto_now_add=True)
updateTime = models.DateTimeField(auto_now=True)
comicInfo = models.TextField(null=True,blank=True)
comic = models.ForeignKey(Book)
acg = models.OneToOneField(Acg,primary_key=True)
class Meta:
ordering = ['-browseCount','-updateTime']
class Meta:
ordering = ['-updateTime']
from django.utils import simplejson
return HttpResponse(simplejson.dumps(data))
def json(self):
[book.json() for book in hotList]
hotList = Book.objects.order_by('-browseCount')[:10]
pageNumber = request.POST.get('pageNumber',1)
pageNumber = request.GET.get('pageNumber',1)
pageNumber = request.REQUEST.get('pageNumber',1)
if request.method == 'GET':
book_list = Book.objects.all()
paginator = Paginator(book_list,settings.BIGCOMIC_PAGESIZE)
contacts = paginator.page(pageNumber)
return render_to_response('comic/list.html',{'contacts':contacts})
{% if contacts.has_previous %}
previous
{% endif %}
{% for p in contacts.paginator.page_range %}
{{p}}
{% endfor %}
共有{{ contacts.paginator.num_pages }}页
{% if contacts.has_next %}
next
{% endif %}
q = Q(acg__name__icontains=searchContent) | Q(author__icontains=searchContent) |Q (keyword__icontains=searchContent)
book_list = Book.objects.filter(q)
book = Book.objects.get(pk=book_id)
book.save()
imageUrl = [ viewurl + list for list in os.listdir(localdir)]
imageUrl.sort()
(r'detail/(\d*)/page/(\d*)/$', 'bigcomic.comic.views.detail'),
def detail(request, comicID, pageNumber):
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
@transaction.commit_on_success
def create(request):
TEMPLATE_DIRS = (
os.path.join(BIGCOMIC_ROOT,'templates'),)