1. 程式人生 > >Django 資料模型增刪改查

Django 資料模型增刪改查

增:

    if request.method == 'POST':
        name = request.POST.get('name','')
        user_message = UserMessage()
        user_message.name = name
        user_message.save()

查:

    all_message = UserMessage.objects.filter(name='test')

刪:

    all_message = UserMessage.objects.filter(name='test')
    all_message.delete()