本文整理匯總了Python中concepts.models.Concept.id方法的典型用法代碼示例。如果您正苦於以下問題:Python Concept.id方法的具體用法?Python Concept.id怎麽用?Python Concept.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類concepts.models.Concept
的用法示例。
在下文中一共展示了Concept.id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_concept
# 需要導入模塊: from concepts.models import Concept [as 別名]
# 或者: from concepts.models.Concept import id [as 別名]
def add_concept(request):
new_con = Concept()
new_con.title = request.POST['title']
new_con.description = request.POST['description']
new_con.pub_date = datetime.datetime.now()
new_con.date_modified = new_con.pub_date
new_con.id = bson.ObjectId()
new_con.author = request.user
cat_assoc = CategoryAssociation()
cat = Category.objects.get(id=request.POST['category_id'])
cat_assoc.category = cat
new_con.categories.append(cat_assoc)
form_properties = get_new_properties(request, True)
for form_property in form_properties:
#ugly upsert (in case its not in db)
Feature.objects(
title=form_property.title,
is_property=True,
property_type=form_property.property_type
).update_one(
set__title=form_property.title,
set__is_property=True,
set__property_type=form_property.property_type,
upsert=True)
new_feature = Feature.objects.filter(
title=form_property.title,
is_property=True,
property_type=form_property.property_type
)[0]
new_property = Property(
feature=new_feature,
property_id=bson.ObjectId(),
value=form_property.value)
new_con.properties.append(new_property)
new_con.save()
return HttpResponseRedirect(reverse('concepts:conceptdetail', args=(new_con.id,)))