mmcardle/django_builder

Input is erased on validation and there is no book field

dgleba opened this issue · 2 comments

I created the blogapp with Post and Book models with a foreign key so that each post could refer to a book.

In the pictures below there are two issues.

  1. The foreign key is required but no field is on the template to create it with a dropdown or anything.

  2. When the save button is pressed, the validation message comes up saying book_id is required. The problem is that all input in fields has been erased.

2020-10-04 11_47_27-643082186-reded446@ad - AnyDesk

2020-10-04 11_47_46-643082186-reded446@ad - AnyDesk

@dgleba I will take a look

Are you able to reproduce the problem that all input in all fields has been erased when the validation message appears?

I have another app that has a javascript popup like the picture below. I can't figure out how to find docs/posts on what drives the difference. They are both modelforms. The views both say 'generic' in them, although they have slightly different imports and syntax.

image

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Import Generic View for listing (r operation)
from django.views.generic import ListView, DetailView
# Import Generic View for creating, updating and deleting (cud operations)
from django.views.generic.edit import CreateView, UpdateView, DeleteView

# Resolving URLs
from django.urls import reverse_lazy
# Import Book Model
from book.models import Book
# Import Book Form
from book.forms import BookForm

# Create View
class BookCreate(CreateView):
    model = Book
    form_class = BookForm
    # Setting returning URL
    success_url = reverse_lazy('book_list')