Re: ModelForm unique validation is not done right IMHO.

2018-09-24 Thread Protik
Yes, it is working now. Thank you very much. On Monday, September 24, 2018 at 1:43:00 PM UTC+5:30, Todor Velichkov wrote: > > Protik, just use `self.fields['user'].initial = user.id` instead of just > `user`. Just tested it and it work fine. > > On Monday, September 24, 2018 at 9:36:19 AM UTC+3

Re: Slicing on queryset not working when using .last() after queryset

2018-09-24 Thread Vasili Korol
Okay, this seems to produce TypeError in Django 2.0. See here: https://code.djangoproject.com/ticket/22550 -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving

Re: Slicing on queryset not working when using .last() after queryset

2018-09-24 Thread SHIVAM JINDAL
I am facing this on Django 1.9, Python 2.7 On Mon, Sep 24, 2018 at 5:42 PM Vasili Korol wrote: > I can confirm this issue on Django 1.11.15 (Python 3.4.3, MySQL 5.5.61). > Calling 'last()' on a slice produces wrong result: > > >>> News.objects.all().order_by('id')[:5].values('id') > > > >>> New

Re: django makemessages management command

2018-09-24 Thread Claude Paroz
Hi Osama, You can simply do that by including a gettext_noop('your custom string') line anywhere in your code (or in a specific file you create for that purpose). Regards, Claude -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions

Re: Slicing on queryset not working when using .last() after queryset

2018-09-24 Thread Vasili Korol
I can confirm this issue on Django 1.11.15 (Python 3.4.3, MySQL 5.5.61). Calling 'last()' on a slice produces wrong result: >>> News.objects.all().order_by('id')[:5].values('id') >>> News.objects.all().order_by('id')[:5][4].id 5 >>> #But calling 'last' gives us wrong id: >>> News.objects.all()

django makemessages management command

2018-09-24 Thread Osama AbuOmar
About the django *makemessages *management command. I think there should by an option to *NOT *let django comment out manually added translations to the .po files. sometimes I need to manually add a translation definition (msgid, msgstr), these are not in any of my template or python files. and

Slicing on queryset not working when using .last() after queryset

2018-09-24 Thread SHIVAM JINDAL
Hi, I am making a queryset by slicing it to return only first 2 objects but When I am using .last() on this queryset then it is not applying slicing Pharmaceutical.objects.order_by('id').values('id') >>> [{'id': 2L}, {'id': 3L}, {'id': 4L}, {'id': 5L}] >>> Pharmaceutical.objects.order_by('id')[:

Re: ModelForm unique validation is not done right IMHO.

2018-09-24 Thread Todor Velichkov
One more thing I forgot to add I would add a clean_book method on the form and use it to check if the user > already have a book with that name. > You actually can't to this, because this just a simplified example where we have two fields only, what if we have a 3rd one and two of the fields ar

Re: ModelForm unique validation is not done right IMHO.

2018-09-24 Thread Todor Velichkov
> > Then the form will raise a Validation error saying there is already a book > with that user and that name. Confusing the user. > What error message are you gonna put instead? Book with that name already exists? This is even more confusing, because its actually allowed to have more books wit

Re: ModelForm unique validation is not done right IMHO.

2018-09-24 Thread Todor Velichkov
Protik, just use `self.fields['user'].initial = user.id` instead of just `user`. Just tested it and it work fine. On Monday, September 24, 2018 at 9:36:19 AM UTC+3, Protik wrote: > > > Book.objects.filter(user=form.user, name=form.cleaned_data["name"]). > exists() > > This will only work for cr