Re: SQL query to django

2021-10-09 Thread carlos
ok, try this but is only idea (i don't is working)

from django.db.models import Count

result = (YY.objects
.values('time_frame','status')
.annotate(timecount=Count('time_frame'))
.order_by('status')
)

read this for understand
https://docs.djangoproject.com/en/3.2/topics/db/aggregation/

if this no help you maybe this way

results = YY.objects.raw('SELECT status FROM YY GROUP BY time_frame')

and read this too for understand
https://docs.djangoproject.com/en/3.2/topics/db/sql/#topics-db-sql

Cheers

On Sat, Oct 9, 2021 at 2:52 AM Eugene TUYIZERE 
wrote:

> Dear all,
>
> I have a table let call it *YY*. Some fields in this table are status,
> time_frame, etc.
> time frame is in terms of years and status are Not started, In progress
> and Completed. I want to display all services Not started, in progress and
> completed in each year.
> And at the end to display this on bar chart. but What I most want is the
> query.
>
> I want to transform this SQL query in Django:
>
> SELECT status from YY group by time_frame;
>
> please assist
>
> --
> *TUYIZERE Eugene*
>
>
> --
> 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/CABxpZHsysRxgE9bn9c9naLY%2BtWmKRfwpr%2BUsMYiAV_ZcPC_3Hw%40mail.gmail.com
> 
> .
>


-- 
att.
Carlos Rocha

-- 
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/CAM-7rO1KKmhjhCbFfO756tqwgOaKsAN-qiL-MhH%3D8KiGfbd9XQ%40mail.gmail.com.


Re: When you app depends on a custom user model

2021-10-09 Thread Harouna Diallo
I agree

Le sam. 9 oct. 2021 à 16:02, bnmng  a écrit :

> Django "strongly recommends" you create custom user, and in your apps you
> can refer to the custom user with "settings.AUTH_USER_MODEL" or with
> get_user_model().
>
> Here's the problem.  If you develop an app which refers to the custom
> user, the migrations won't be portable because even if you use the
> above references, the migration will use the app name and model name of the
> custom user.
>
> Here's what a migration might look like:
>
> dependencies = [
> ('my_custom_auth_app', '0001_initial'),
> ]
>
> operations = [
> migrations.AddField(
> model_name='mymodel',
> name='created_by',
> field=models.ForeignKey(
>   on_delete=django.db.models.deletion.CASCADE,
>   to='my_custom_auth_app.my_custom_user',
> ),
> ),
>  ]
>
> Even though I never put "my_custom_auth_app" or "my_custom_user" in the
> app, it translated settings.AUTH_USER_MODEL to the app name and model for
> the migration.
>
> Is there any way to get around this and make your app with its migrations
> portable?
>
> --
> 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/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%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/CAO73PDrtFnx67Ks1TpTe12sf8f0mT4NYQLNa4wyGqZeqamHvQQ%40mail.gmail.com.


When you app depends on a custom user model

2021-10-09 Thread bnmng
Django "strongly recommends" you create custom user, and in your apps you 
can refer to the custom user with "settings.AUTH_USER_MODEL" or with 
get_user_model().  

Here's the problem.  If you develop an app which refers to the custom user, 
the migrations won't be portable because even if you use the 
above references, the migration will use the app name and model name of the 
custom user.  

Here's what a migration might look like: 
 
dependencies = [
('my_custom_auth_app', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='mymodel',
name='created_by',
field=models.ForeignKey(
  on_delete=django.db.models.deletion.CASCADE,
  to='my_custom_auth_app.my_custom_user',
),
),
 ]

Even though I never put "my_custom_auth_app" or "my_custom_user" in the 
app, it translated settings.AUTH_USER_MODEL to the app name and model for 
the migration.

Is there any way to get around this and make your app with its migrations 
portable?

-- 
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/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com.


Re: Re:

2021-10-09 Thread Sebastian Jung
Have you truncate table auth_users?

ola neat  schrieb am Sa., 9. Okt. 2021, 16:00:

> But it working perfectly offline
>
> On Sat, Oct 9, 2021, 14:26 Ahmad Abdulnasir Shuaib <
> ahmadabdulnas...@gmail.com> wrote:
>
>> Check your models, you may have unique_together option enabled.
>>
>> On Sat, Oct 9, 2021, 12:09 PM Sebastian Jung 
>> wrote:
>>
>>> Hello,
>>>
>>> No only friends get social media or WhatsApp.
>>>
>>> I think yoz need a experience developer. Try to get one developer on
>>> upwork. I have no expeeience with serializer...
>>>
>>> Regards
>>>
>>>
>>>
>>> Hubert Kanyamahanga  schrieb am
>>> Sa., 9. Okt. 2021, 09:31:
>>>
 Can you write to me on whatsapp so that I can  provide more help or
 even skype or telegram

 Get Outlook for Android 

 --
 *From:* django-users@googlegroups.com 
 on behalf of Sebastian Jung 
 *Sent:* Saturday, October 9, 2021 7:26:44 AM
 *To:* django-users@googlegroups.com 
 *Subject:* Re:

 I mean same database and not same database system...

 ola neat  schrieb am Sa., 9. Okt. 2021, 09:25:

 Yes postgres

 On Sat, Oct 9, 2021, 08:15 Sebastian Jung 
 wrote:

 On exactly same database?

 ola neat  schrieb am Sa., 9. Okt. 2021, 09:14:

 But it working on localhost without issues

 On Sat, Oct 9, 2021, 08:07 Hubert Kanyamahanga <
 kanyamahanga.hub...@aims-senegal.org> wrote:

 Hi Ola, I see where the issue is, the line
 *self.perform_create(serializer)* on the *def create() *method creates
 as well as the line *serializer.save()* on the method *def post()*. So
 in other words, you are trying to create the same user twice,* please
 comment one of them if you want you can empty your table and start again it
 will work.*

 Again there is no reason to use these two methods as they do the same
 thing. Remove completely either the post or the create.

 You can text me on whatsApp if you need more support: +221777922780

 Best,

 H


 On Sat, 9 Oct 2021 at 06:51, ola neat  wrote:

 this is my function
 [image: image.png]


 On Fri, Oct 8, 2021 at 6:52 PM Sebastian Jung <
 sebastian.ju...@gmail.com> wrote:

 Hello,

 Your app tries to insert a new entry in table auth.users. in this table
 a User exists with id=2 and you get this constraint error. Please truncate
 auth.users table and try it again.

 Regards

 ola neat  schrieb am Fr., 8. Okt. 2021, 18:12:

 Hello guys
 I've got this issue i don't understand, before i deployed my  APIS to
 heroku everything was working perfectly, but now that i deployed I'm
 getting this error, pls can anyone help me?

 --
 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/CAHLKn727okM8xWxX2o7ZgSLT6pDFXQf_oS6NC-83K7zkv9NhXw%40mail.gmail.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/CAKGT9mz-hLnzKVtPSh5WsGhG1CO-afPLJtqwSBz2mHTibgpPZw%40mail.gmail.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/CAHLKn71yxd2sTLNvXf4srU9t2pfahc29NdOOa5j0zZmPn%3DACgw%40mail.gmail.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
 

Re: Re:

2021-10-09 Thread ola neat
But it working perfectly offline

On Sat, Oct 9, 2021, 14:26 Ahmad Abdulnasir Shuaib <
ahmadabdulnas...@gmail.com> wrote:

> Check your models, you may have unique_together option enabled.
>
> On Sat, Oct 9, 2021, 12:09 PM Sebastian Jung 
> wrote:
>
>> Hello,
>>
>> No only friends get social media or WhatsApp.
>>
>> I think yoz need a experience developer. Try to get one developer on
>> upwork. I have no expeeience with serializer...
>>
>> Regards
>>
>>
>>
>> Hubert Kanyamahanga  schrieb am
>> Sa., 9. Okt. 2021, 09:31:
>>
>>> Can you write to me on whatsapp so that I can  provide more help or even
>>> skype or telegram
>>>
>>> Get Outlook for Android 
>>>
>>> --
>>> *From:* django-users@googlegroups.com 
>>> on behalf of Sebastian Jung 
>>> *Sent:* Saturday, October 9, 2021 7:26:44 AM
>>> *To:* django-users@googlegroups.com 
>>> *Subject:* Re:
>>>
>>> I mean same database and not same database system...
>>>
>>> ola neat  schrieb am Sa., 9. Okt. 2021, 09:25:
>>>
>>> Yes postgres
>>>
>>> On Sat, Oct 9, 2021, 08:15 Sebastian Jung 
>>> wrote:
>>>
>>> On exactly same database?
>>>
>>> ola neat  schrieb am Sa., 9. Okt. 2021, 09:14:
>>>
>>> But it working on localhost without issues
>>>
>>> On Sat, Oct 9, 2021, 08:07 Hubert Kanyamahanga <
>>> kanyamahanga.hub...@aims-senegal.org> wrote:
>>>
>>> Hi Ola, I see where the issue is, the line
>>> *self.perform_create(serializer)* on the *def create() *method creates
>>> as well as the line *serializer.save()* on the method *def post()*. So
>>> in other words, you are trying to create the same user twice,* please
>>> comment one of them if you want you can empty your table and start again it
>>> will work.*
>>>
>>> Again there is no reason to use these two methods as they do the same
>>> thing. Remove completely either the post or the create.
>>>
>>> You can text me on whatsApp if you need more support: +221777922780
>>>
>>> Best,
>>>
>>> H
>>>
>>>
>>> On Sat, 9 Oct 2021 at 06:51, ola neat  wrote:
>>>
>>> this is my function
>>> [image: image.png]
>>>
>>>
>>> On Fri, Oct 8, 2021 at 6:52 PM Sebastian Jung 
>>> wrote:
>>>
>>> Hello,
>>>
>>> Your app tries to insert a new entry in table auth.users. in this table
>>> a User exists with id=2 and you get this constraint error. Please truncate
>>> auth.users table and try it again.
>>>
>>> Regards
>>>
>>> ola neat  schrieb am Fr., 8. Okt. 2021, 18:12:
>>>
>>> Hello guys
>>> I've got this issue i don't understand, before i deployed my  APIS to
>>> heroku everything was working perfectly, but now that i deployed I'm
>>> getting this error, pls can anyone help me?
>>>
>>> --
>>> 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/CAHLKn727okM8xWxX2o7ZgSLT6pDFXQf_oS6NC-83K7zkv9NhXw%40mail.gmail.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/CAKGT9mz-hLnzKVtPSh5WsGhG1CO-afPLJtqwSBz2mHTibgpPZw%40mail.gmail.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/CAHLKn71yxd2sTLNvXf4srU9t2pfahc29NdOOa5j0zZmPn%3DACgw%40mail.gmail.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/CAE4dFh0xyoU%3DH1N%3DvZTeTo3gGbAKNR5Z7qqT4JkwN9reb3kF2w%40mail.gmail.com
>>> 
>>> .
>>>
>>> --
>>> You received this message because you 

Re: Re:

2021-10-09 Thread Ahmad Abdulnasir Shuaib
Check your models, you may have unique_together option enabled.

On Sat, Oct 9, 2021, 12:09 PM Sebastian Jung 
wrote:

> Hello,
>
> No only friends get social media or WhatsApp.
>
> I think yoz need a experience developer. Try to get one developer on
> upwork. I have no expeeience with serializer...
>
> Regards
>
>
>
> Hubert Kanyamahanga  schrieb am
> Sa., 9. Okt. 2021, 09:31:
>
>> Can you write to me on whatsapp so that I can  provide more help or even
>> skype or telegram
>>
>> Get Outlook for Android 
>>
>> --
>> *From:* django-users@googlegroups.com  on
>> behalf of Sebastian Jung 
>> *Sent:* Saturday, October 9, 2021 7:26:44 AM
>> *To:* django-users@googlegroups.com 
>> *Subject:* Re:
>>
>> I mean same database and not same database system...
>>
>> ola neat  schrieb am Sa., 9. Okt. 2021, 09:25:
>>
>> Yes postgres
>>
>> On Sat, Oct 9, 2021, 08:15 Sebastian Jung 
>> wrote:
>>
>> On exactly same database?
>>
>> ola neat  schrieb am Sa., 9. Okt. 2021, 09:14:
>>
>> But it working on localhost without issues
>>
>> On Sat, Oct 9, 2021, 08:07 Hubert Kanyamahanga <
>> kanyamahanga.hub...@aims-senegal.org> wrote:
>>
>> Hi Ola, I see where the issue is, the line
>> *self.perform_create(serializer)* on the *def create() *method creates
>> as well as the line *serializer.save()* on the method *def post()*. So
>> in other words, you are trying to create the same user twice,* please
>> comment one of them if you want you can empty your table and start again it
>> will work.*
>>
>> Again there is no reason to use these two methods as they do the same
>> thing. Remove completely either the post or the create.
>>
>> You can text me on whatsApp if you need more support: +221777922780
>>
>> Best,
>>
>> H
>>
>>
>> On Sat, 9 Oct 2021 at 06:51, ola neat  wrote:
>>
>> this is my function
>> [image: image.png]
>>
>>
>> On Fri, Oct 8, 2021 at 6:52 PM Sebastian Jung 
>> wrote:
>>
>> Hello,
>>
>> Your app tries to insert a new entry in table auth.users. in this table a
>> User exists with id=2 and you get this constraint error. Please truncate
>> auth.users table and try it again.
>>
>> Regards
>>
>> ola neat  schrieb am Fr., 8. Okt. 2021, 18:12:
>>
>> Hello guys
>> I've got this issue i don't understand, before i deployed my  APIS to
>> heroku everything was working perfectly, but now that i deployed I'm
>> getting this error, pls can anyone help me?
>>
>> --
>> 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/CAHLKn727okM8xWxX2o7ZgSLT6pDFXQf_oS6NC-83K7zkv9NhXw%40mail.gmail.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/CAKGT9mz-hLnzKVtPSh5WsGhG1CO-afPLJtqwSBz2mHTibgpPZw%40mail.gmail.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/CAHLKn71yxd2sTLNvXf4srU9t2pfahc29NdOOa5j0zZmPn%3DACgw%40mail.gmail.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/CAE4dFh0xyoU%3DH1N%3DvZTeTo3gGbAKNR5Z7qqT4JkwN9reb3kF2w%40mail.gmail.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
>> 

SQL query to django

2021-10-09 Thread Eugene TUYIZERE
Dear all,

I have a table let call it *YY*. Some fields in this table are status,
time_frame, etc.
time frame is in terms of years and status are Not started, In progress and
Completed. I want to display all services Not started, in progress and
completed in each year.
And at the end to display this on bar chart. but What I most want is the
query.

I want to transform this SQL query in Django:

SELECT status from YY group by time_frame;

please assist

-- 
*TUYIZERE Eugene*

-- 
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/CABxpZHsysRxgE9bn9c9naLY%2BtWmKRfwpr%2BUsMYiAV_ZcPC_3Hw%40mail.gmail.com.