Z
Z
Zuzupoj2020-05-01 14:54:05
Django
Zuzupoj, 2020-05-01 14:54:05

Why doesn't ModelAdmin work?

from django.contrib import admin
from django.urls import path
from django.shortcuts import render
from .models import Question , Out_questiom
admin.site.register(Question) 

class SendAnswerAdmin(admin.ModelAdmin):
  def get_urls(self):
    urls = super().get_urls()
    my_urls = [
      path('answer/',self.admin_site.admin_view(self.answer_get)),
      path('answer/create/', self.admin_site.admin_view(self.answer_out)),
    ]
    return my_urls + urls
  def answer_get(self,request):
    question_list = Question.objects.order_by('date_time_create')
    return render(request,'admin/answer_admin_change.html')
  
  def answer_out(self,request):
    if request.method == "POST":
      answer_question = Question.objects.order_by('date_time_create')
      text_answer = request.POST.get("text_answer")
      send_mail('Ответ', text_answer, 'xxx',
        [answer_question.email], fail_silently=False)
      new_answer = Out_answer(
        email_answer = answer_question.email,
        name_person_answer = answer_question.name_person,
        theme_question_answer = answer_question.theme_question,
        full_text_answer = text_answer,
        full_text_answer_old = answer_question.full_text_answer,
        created_time_quest_old = answer_question.created_time_quest,
      )
      answer_question.delete()
      new_answer.save()
admin.site.register(Out_questiom , SendAnswerAdmin)


I just don't understand, I seriously admit that I'm stupid and helpless. py manage.py runserver runs without error,
but when I try to go to 127.0.0.1:8000/admin/question/sendanswer/answer it gives me a 404 error. In the console of information 0. Help.

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