This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/api/service/<product_id>/vote/<any(up,down):direction>') | |
@xhr_required | |
@login_required | |
def api_service_vote(product_id, direction): | |
''' thi api need for vote up/down the services''' | |
product = Product.query.get_or_404(product_id) | |
query = Product_Vote.query.filter(Product_Vote.voter_id == g.user.id, | |
Product_Vote.product_id == product.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Предполагая m2m такого вида | |
class Tag(model.Model): | |
text = model.CharField() | |
class News(models.Model): | |
tags = models.ManyToManyField(Tag) | |
def index(request): | |
# Текущий мастер умеет инвалидировать по событиям на связанных моделях, |