Framework/Django
list + create
유로파니
2021. 1. 6. 10:35
def list_and_create(request):
"""
SalesCusCreate & List View
"""
form = CustomerForm(request.POST)
if request.method == 'POST' and form.is_valid():
form.save()
objects = Customer.objects.order_by('id')
if request.GET.get('search'):
search = request.GET.get('search')
objects = objects.filter(customer__icontains=search)
return render(request, 'sales/admin/customer_form.html', {'form': form, 'objects': objects})