@login_required(login_url='/admin-panel/login/')
def update_news(request, news_id: int):
    try:
        news_sel = News.objects.get(pk=news_id)
    except news.DoesNotExist:
        return redirect('/admin-panel/news')
    news_form = NewsCreate(request.POST, (request.FILES or None), instance=news_sel)
    if news_form.is_valid():
        news_form.save()
        return redirect('/admin-panel/news')
    context = {'ProductForm': news_form, 'ProductModel': news_sel, 'action': 'Обновить'}
    return render(request, 'add-news.html', context)
@login_required(login_url='/admin-panel/login/')
def update_news(request, news_id: int):
    try:
        news_sel = News.objects.get(pk=news_id)
    except news.DoesNotExist:
        return redirect('/admin-panel/news')
    news_form = NewsCreate(request.POST, (request.FILES or None), instance=news_sel)
    if news_form.is_valid():
        news_form.save()
        return redirect('/admin-panel/news')
    context = {'ProductForm': news_form, 'ProductModel': news_sel, 'action': 'Обновить'}
    return render(request, 'add-news.html', context)