0
我正在使用带有信号的django 1.6。 我有模型Events
与字段is_cyclic
,我想运行信号只为一个,当前对象。但似乎我的代码经过的所有对象,我得到一个错误:仅针对当前对象的呼叫信号
maximum recursion depth exceeded while calling a Python object
这里是我的信号
@receiver(post_save, sender=Events)
def my_callback(sender, created, instance, *args, **kwargs):
db_name = args[0] if len(args) else 'events'
print('using %s' % db_name)
list = loader.get_template('events/event_list_item.html')
list_small = loader.get_template('events/event_list_item_small.html')
setattr(instance, 'is_cyclic', list.render(Context({'e': instance})))
setattr(instance, 'is_cyclic', list_small.render(Context({'e': instance})))
instance.save(using=db_name)
好:)谢谢你开我的眼睛:) – Mark