P
P
PyChan2020-07-09 13:21:11
Django
PyChan, 2020-07-09 13:21:11

Why doesn't the site 127.0.0.1 allow a connection to be established?

The site starts normally, but as soon as I go to another page, an error occurs. Site 127.0.0.1 is blocked.
Site 127.0.0.1 does not allow connection. And in the terminal it writes "GET /app/add_program/0 HTTP/1.1" 200 11950"
In views.py:

def add_new_program(request, id):
    id = int(id)
    if request.method != 'POST':
        if id == 0:
            formCat = AddCat
            formProgram = AddProgram
        else:
            formCat = AddCat(Cats.objects.filter(id=id))
            formProgram = AddProgram(Cats.objects.select_related('programs').get(id=id))
    else:
        formCat = AddCat(request.POST)
        formProgram = AddProgram(request.POST)
        if formCat.is_valid() and formProgram.is_valid():
            cat = formCat.save(commit=False)
            cat.program_set.add(formProgram.save())
    print('no mistakes')
    return render(request, 'add_program.html', {'formCat': formCat, 'formProgram': formProgram})


The problem was solved very easily! I changed the button class in html

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