Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSychev2005 committed Jun 3, 2024
1 parent e363ef2 commit 3158dee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions word/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def __init__(self, *args, **kwargs):
instance = kwargs.get('instance')
if instance:
self.fields['text'].initial = instance.text
self.fields['text'].disabled = True
self.fields['language'].initial = instance.language
self.fields['language'].disabled = True
self.fields['translations'].queryset = Translation.objects.all()
self.fields['translations'].initial = instance.translations.all()

Expand Down
6 changes: 3 additions & 3 deletions word/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.shortcuts import render, redirect

from dictionary.models import Dictionary
from .forms import WordForm
from .forms import WordForm, WordEditForm
from .models import Word


Expand Down Expand Up @@ -39,12 +39,12 @@ def update_word(request, word_id):
word = Word.get_by_id(word_id)

if request.method == 'POST':
form = WordForm(request.POST, instance=word)
form = WordEditForm(request.POST, instance=word)
if form.is_valid():
form.save()
return redirect('word:view_word', word_id=word_id)

form = WordForm(instance=word)
form = WordEditForm(instance=word)
return render(request, 'word/edit_word.html',
{'form': form})

Expand Down

0 comments on commit 3158dee

Please sign in to comment.