Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Protik
I am using Django 1.11. Further, adding a new book with user field disabled results in the following error: [image: Selection_046.png] I have attached the code to reproduce the error. On Monday, September 24, 2018 at 1:59:31 AM UTC+5:30, Todor Velichkov wrote: > > First thought: What is your

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Protik
I am using Django 1.11. Further, adding a new book with user field disabled results in the following error: [image: Selection_046.png] I have attached the code to reproduce the error. On Monday, September 24, 2018 at 1:59:31 AM UTC+5:30, Todor Velichkov wrote: > > First thought: What is your

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Protik
I am using Django 1.11. Further, adding a new book without disabling the user field results in the following error: [image: Selection_046.png] I have attached the code to reproduce this error. On Monday, September 24, 2018 at 1:59:31 AM UTC+5:30, Todor Velichkov wrote: > > First thought: What

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Todor Velichkov
First thought: What is your Django version? The `disabled` attribute was added in Django 1.9. However by looking at your code (w/o testing anything) after `form.is_valid()` you should only call `form.save()`, no need to do `commit=False` and manually assigning user, you have already done that

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Protik
On Sunday, September 23, 2018 at 11:55:41 PM UTC+5:30, Protik wrote: > > Hi, Todor > > I have tested this solution and It looks like it works only when you don't > disable the field (i.e the last line in the BookForm's `__init__()` method. > My views looks like this: > > > > def

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Protik
Hi, Todor I have tested this solution and It looks like it works only when you don't disable the field (i.e the last line in the BookForm's `__init__()` method. My views looks like this: def book_add(request): user = get_object_or_404(User, id=1) if request.method == 'POST':

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Todor Velichkov
You can use the `disabled ` attribute on form fields with a combination of HiddenInput Using the Book example from the first comment it will look like this:

Re: ModelForm unique validation is not done right IMHO.

2018-09-23 Thread Protik
Hi Todor I am experiencing the same problem. Can you please post the possible solution? On Tuesday, October 10, 2017 at 8:26:32 AM UTC+5:30, Todor Velichkov wrote: > > It does? Can you give me a link to that please? >> > > Pard me, it does not explicitly say to set values programmatically, but