M
M
ma3xak2018-05-29 15:37:28
Django
ma3xak, 2018-05-29 15:37:28

How to draw a form on all pages?

How can I draw the form on all pages of the site, as an example I use these urls and views

from django.shortcuts import render
from .models import *
from django import forms
from .forms import callMeForm

# Create your views here.

def home(request):
  slide = HomeSlider.objects.filter(is_active=True)
  return render(request, 'home/home.html', {	'slide': slide,})

def call(request):
  if request.method == 'POST':
    zvonok = callMeForm(request.POST)
    if zvonok.is_valid():
      zvonok.save()
    else:
      return render(request, 'sms_signup/errors.html', locals())
  else:
    zvonok = callMeForm()
    return render(request, 'home/home.html', {'zvonok':zvonok})

from django.conf.urls import url, include
from . import views

urlpatterns = [
  url(r'^$', views.home, name='home'),
  url(r'^zvonok', views.call, name = 'call')
]

However, the problem here is that the form is called from only one usrl

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2018-05-29
@sim3x

Move to a function that will accept the request and submit the form
Call the function in the required views

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question