S
S
sergey199408082017-05-17 15:33:46
Django
sergey19940808, 2017-05-17 15:33:46

Django, how to write an edit view?

You need to get user data from the database with a GET request.

@login_required()
    def edit_my_draft(request, username):
        title = 'Редактирование записи в черновике'
        user = get_object_or_404(User, username=username)

       if request.method != 'POST':
           form = DraftForm(instance=user)

How to do it? That is, you need to load data from the records table, but for the user who logged in. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question