我在Django 1.8中写了一篇简单的文章发布网站。 这是我想要滑动的模型:
[Head| List]
现在我想在头版上滑动文章预告片。我是Django和JS的新手,所以想知道如何最好地制作这样的滑块?
我用Google搜索并查看了Django包,但找不到任何可以让我开始的东西。非常感谢您的提示。
更新:以下是我希望将其连接到轮播滑块的视图:
class Article(models.Model):
nid = models.IntegerField(default=0)
headimage = ImageWithThumbsField(upload_to='images', blank=True, sizes=((200,200),(400,400)))
title = models.CharField(max_length=100)
author = models.CharField(max_length=100, blank=True)
body = models.TextField()
teaser = models.TextField('teaser', blank=True)
created=models.DateTimeField(default=datetime.datetime.now)
pub_date=models.DateTimeField(default=datetime.datetime.now)
categories = models.ManyToManyField(Category, blank=True)
tags = TaggableManager()
答案 0 :(得分:4)
You didn't posted your js+html so here is an example library. Carousel
If you investigate, you see that you can link images in a single html. So if you want to do this in django way, you must pass your model to template and iterate items and create the html that you need.
Here is a start point example by using the linked javascript:
views.py ==>
:host
template.html ==>
hosts << {name: host, mac: eth, ip: address}
javascript part ==>
file = File.new("new_computers.json", "w")
file.puts JSON.pretty_generate(hosts)
And next time remember that this is a Q&A site, please try something before asking a question and share this with us.