Re: Arrayfield constraint issue in 4.1

2022-12-12 Thread Manjusha
I think default should be assigned like this

 default=[ ] or
default= list()


But I'm junior so may I don't know well

On Mon, 12 Dec 2022, 03:13 James Gillard,  wrote:

> The callable list is indeed assigned as the default for the ArrayField, as
> documented here:
> https://docs.djangoproject.com/en/4.1/ref/contrib/postgres/fields/#django.contrib.postgres.fields.ArrayField
>
> The original issue has already had a patch merged, which will be released
> in 4.1.5, see the fix here:
> https://docs.djangoproject.com/en/dev/releases/4.1.5/
>
> On Sunday, 11 December 2022 at 18:02:24 UTC manjushak...@gmail.com wrote:
>
>> Hello Sir, I need to understand the form.py  file because , what  is the
>> only list you have assigned as default in arrayfield, is it the method
>> list() ?
>>
>>
>> On Sat, Dec 10, 2022 at 10:00 PM James Gillard 
>> wrote:
>>
>>> Thanks for the feedback. I opened a ticket and it was indeed confirmed
>>> as a bug: https://code.djangoproject.com/ticket/34205
>>>
>>> On Thursday, 8 December 2022 at 15:04:40 UTC Ryan Nowakowski wrote:
>>>
 Might be a bug. Check the release notes for the post 4.0.8 versions to
 see if anything related changed. File a bug with the simplest example code
 that demonstrates the issue.


 On December 8, 2022 6:37:52 AM CST, James Gillard <
 ja...@journeetrips.com> wrote:
>
> I can't yet work out whether this is a Django bug or how I'm using
> model constraints... Upgraded from 4.0.8 to 4.1.4 and have hit this issue
> when saving this model in the admin. I'd read in the release notes that
> these constraints would be validated on model save, and that's the code
> that's leading to this exception. If it's not something I've done, it 
> seems
> ArrayField isn't working with this new validation of my condition. The 
> same
> happens for Q(phone_numbers__len__gte=0), and the error disappears if I
> comment out this condition. It seems the generated code might be wrong, as
> I see 12 "%s" and only 11 elements in params. All it's trying to do is
> ensure that an empty list isn't considered unique.
>
> Here's the failing model:
>
> phone_numbers = ArrayField(models.CharField(max_length=200),
> default=list, blank=True)
>
> class Meta:
> constraints = [
> models.UniqueConstraint(
>fields=['phone_numbers'],
>condition=~Q(phone_numbers__len=0),
>name='unique_email_phones',
> ),
> ]
> )
>
> [image: Screenshot 2022-12-08 at 12.30.35.png]
>
> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/4a8a0941-dd65-4c22-bf16-4e11181794a0n%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/29d9d224-3027-4346-9552-8fcadedd21dfn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGz3pXL8EHtARE_PLX0MM4jnGWBRq%2BAE-Bc9%2B7dsJtxKHYdnrA%40mail.gmail.com.


Re: Arrayfield constraint issue in 4.1

2022-12-12 Thread James Gillard
I agree it looks odd, but the docs I linked say that list is fine, and
here's example from a test inside Django itself:
https://github.com/django/django/blob/cb791a2540c289390b68a3ea9c6a79476890bab2/tests/postgres_tests/models.py#L51

[image: James from Journee] 
*James Gillard*
*Technical Co-Founder at Journee*
Trustpilot 4.9⭑ 
Instagram  | TikTok

Journee, London, United Kingdom
[image: Journee Logo] 


On Mon, 12 Dec 2022 at 14:45, Manjusha  wrote:

> I think default should be assigned like this
>
>  default=[ ] or
> default= list()
>
>
> But I'm junior so may I don't know well
>
> On Mon, 12 Dec 2022, 03:13 James Gillard,  wrote:
>
>> The callable list is indeed assigned as the default for the ArrayField,
>> as documented here:
>> https://docs.djangoproject.com/en/4.1/ref/contrib/postgres/fields/#django.contrib.postgres.fields.ArrayField
>>
>> The original issue has already had a patch merged, which will be released
>> in 4.1.5, see the fix here:
>> https://docs.djangoproject.com/en/dev/releases/4.1.5/
>>
>> On Sunday, 11 December 2022 at 18:02:24 UTC manjushak...@gmail.com wrote:
>>
>>> Hello Sir, I need to understand the form.py  file because , what  is the
>>> only list you have assigned as default in arrayfield, is it the method
>>> list() ?
>>>
>>>
>>> On Sat, Dec 10, 2022 at 10:00 PM James Gillard 
>>> wrote:
>>>
 Thanks for the feedback. I opened a ticket and it was indeed confirmed
 as a bug: https://code.djangoproject.com/ticket/34205

 On Thursday, 8 December 2022 at 15:04:40 UTC Ryan Nowakowski wrote:

> Might be a bug. Check the release notes for the post 4.0.8 versions to
> see if anything related changed. File a bug with the simplest example code
> that demonstrates the issue.
>
>
> On December 8, 2022 6:37:52 AM CST, James Gillard <
> ja...@journeetrips.com> wrote:
>>
>> I can't yet work out whether this is a Django bug or how I'm using
>> model constraints... Upgraded from 4.0.8 to 4.1.4 and have hit this issue
>> when saving this model in the admin. I'd read in the release notes that
>> these constraints would be validated on model save, and that's the code
>> that's leading to this exception. If it's not something I've done, it 
>> seems
>> ArrayField isn't working with this new validation of my condition. The 
>> same
>> happens for Q(phone_numbers__len__gte=0), and the error disappears if I
>> comment out this condition. It seems the generated code might be wrong, 
>> as
>> I see 12 "%s" and only 11 elements in params. All it's trying to do is
>> ensure that an empty list isn't considered unique.
>>
>> Here's the failing model:
>>
>> phone_numbers = ArrayField(models.CharField(max_length=200),
>> default=list, blank=True)
>>
>> class Meta:
>> constraints = [
>> models.UniqueConstraint(
>>fields=['phone_numbers'],
>>condition=~Q(phone_numbers__len=0),
>>name='unique_email_phones',
>> ),
>> ]
>> )
>>
>> [image: Screenshot 2022-12-08 at 12.30.35.png]
>>
>> --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/4a8a0941-dd65-4c22-bf16-4e11181794a0n%40googlegroups.com
 
 .

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/29d9d224-3027-4346-9552-8fcadedd21dfn%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/4VDnW7plykw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGz3pXL8EHtARE_PLX0MM4jnGWBRq%2BAE-Bc9%2B7dsJtxKHYdnrA%40mail.gmail.com
> 

Re: Permission for admin to add patient

2022-12-12 Thread Manjusha
Hi, need to register the model.py file in admin.py file and then make 
migrations as like mention in following documentation.
https://docs.djangoproject.com/en/4.1/intro/tutorial02/

On Monday, December 12, 2022 at 4:49:26 AM UTC+5:30 curtis...@gmail.com 
wrote:

> Hello to all. Please, I would like to know in Django, how to allow an 
> administrator to add a patient, but not a simple connected user? the 
> following pics are my models.py, view.py and my template.py.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/00c5b214-27be-432e-a862-d8c8394f8d5cn%40googlegroups.com.


Re: Permission for admin to add patient

2022-12-12 Thread Manjusha
I'm junior may it will work!!

On Tuesday, December 13, 2022 at 12:31:17 PM UTC+5:30 Manjusha wrote:

> Hi, need to register the model.py file in admin.py file and then make 
> migrations as like mention in following documentation.
> https://docs.djangoproject.com/en/4.1/intro/tutorial02/
>
> On Monday, December 12, 2022 at 4:49:26 AM UTC+5:30 curtis...@gmail.com 
> wrote:
>
>> Hello to all. Please, I would like to know in Django, how to allow an 
>> administrator to add a patient, but not a simple connected user? the 
>> following pics are my models.py, view.py and my template.py.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4ce231dd-8fb3-474a-b359-7a549837e07bn%40googlegroups.com.


Re: Permission for admin to add patient

2022-12-12 Thread rahul sharma
connect with me in zoom

On Tue, Dec 13, 2022 at 12:34 PM Manjusha 
wrote:

> I'm junior may it will work!!
>
> On Tuesday, December 13, 2022 at 12:31:17 PM UTC+5:30 Manjusha wrote:
>
>> Hi, need to register the model.py file in admin.py file and then make
>> migrations as like mention in following documentation.
>> https://docs.djangoproject.com/en/4.1/intro/tutorial02/
>>
>> On Monday, December 12, 2022 at 4:49:26 AM UTC+5:30 curtis...@gmail.com
>> wrote:
>>
>>> Hello to all. Please, I would like to know in Django, how to allow an
>>> administrator to add a patient, but not a simple connected user? the
>>> following pics are my models.py, view.py and my template.py.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4ce231dd-8fb3-474a-b359-7a549837e07bn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACvpWio%2BOwjmnHrU_si6Cq9RPopoafbJwBd-9itTqoyOKGX2Ww%40mail.gmail.com.


Re: Permission for admin to add patient

2022-12-12 Thread André Hangalo
from .models import ModelName

admin.site.register(ModelName)

On Tue, 13/12/2022 at 08:04 Manjusha  wrote:

> I'm junior may it will work!!
>
> On Tuesday, December 13, 2022 at 12:31:17 PM UTC+5:30 Manjusha wrote:
>
>> Hi, need to register the model.py file in admin.py file and then make
>> migrations as like mention in following documentation.
>> https://docs.djangoproject.com/en/4.1/intro/tutorial02/
>>
>> On Monday, December 12, 2022 at 4:49:26 AM UTC+5:30 curtis...@gmail.com
>> wrote:
>>
>>> Hello to all. Please, I would like to know in Django, how to allow an
>>> administrator to add a patient, but not a simple connected user? the
>>> following pics are my models.py, view.py and my template.py.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4ce231dd-8fb3-474a-b359-7a549837e07bn%40googlegroups.com
> 
> .
>
-- 
RICK DEU

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACQ9QcFKgKrkKWtGAEjPYJnS9ctutgN%3DL2hXtDModCwDUsGtrQ%40mail.gmail.com.