I am trying to create message before submitting the page, but i do not know why the message not rendering , can anyone help me to correct it.
form.py
class NameForm(forms.ModelForm):
translated_names = TranslationField()
class Meta:
fields = "__all__"
model = models.Name
admin.py
class NameAdmin(MasterDataBaseAdmin):
form = forms.NameForm
inlines = [AddressInline, RegistrationTypeInline]
queryset = models.Name.objects.prefetch_related(
"names", "name__id", "registrationstype")
views.py
class NameViewSet(viewsets.ReadOnlyModelViewSet):
queryset = models.Name.objects.supported().prefetch_related("names",
"registrationstype")
serializer_class = serializers.NameSerializer
def nametype(request):
form = Form(request.POST)
if form.is_valid():
return render(request, 'templates\ view2.html', form)
view2.html
<script>
$(document).on('click', '.name', function(){
return confirm('Are you sure you want to update this?');
})
</script>
CodePudding user response:
check the class name in your view2.html
CodePudding user response:
at your tag add
<form onsubmit="return confirm('Are you sure you want to update this?');">