class ArticleWithoutAuthorSerializer(ArticleSerializer):
# Prevent author field serialization and endless nesting
author = None
class AuthorSerializer(ModelSerializer):
articles = SerializerMethodField()
def get_articles(self, author):
# Five recently posted articles
articles = author.article_set.order_by('-published')[:5]
return ArticleWithoutAuthorSerializer(articles, many=True).data
class Meta:
model = Author
Mark,
Попытка этот пример:
$(document).ready(function(){
$(".objectDrag").draggable({helper:'clone'});
$("#garbageCollector").droppable({
accept: ".objectDrag",
drop: function(event,ui){
console.log("Item was Dropped");
$(this).append($(ui.draggable).clone());
}
});
});
И HTML похож на это
<div class="objectDrag"
style="width:10%; color:white;border:black 1px solid; background-color:#00A">Drag me</div>
<div id="garbageCollector" style="width:100%; height:400px; background-color:#333; color:white;"> Drop items on me</div>
Чтобы перетащить клон/копию, установите аргумент withDataAndEvents
в true:
$(this).append($(ui.draggable).clone(*true*));