X
X
XisterONE2017-06-26 14:41:51
Django
XisterONE, 2017-06-26 14:41:51

How to auto-complete the servants field when adding a task?

forms

class TaskForm(forms.ModelForm):
    class Meta:
        model = Task
        fields = ('name', 'description', 'category')

views
def task_new(request):
    if request.method == "POST":
        form = TaskForm(request.POST)
        if form.is_valid():
            task = form.save(commit=False)
            task.user = request.user
            task.created = timezone.now()
            task.save()
    else:
        form = TaskForm()
    return render(request, 'post_new.html', locals())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2017-06-26
@sim3x

Override save in model

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question