Re: How can I get this result?

2015-02-15 Thread Krishnasagar Subhedarpage
Hi,

consider two objects,
ls_dic=[{'key1':a , 'key2': b},{'key1':c , 'key2': d}]
num=sum([len(x.values()) for x in ls_dic])

print '%s' % ','.join(sorted(sum([x.values() for x in ls_dic],[])))[:-num]
print '%s' % ','.join(sorted(sum([x.values() for x in ls_dic],[])))[num:]

This is will help a lot.
ls_dic list object is considered for input. I used num object to store
number of values in each directory item of ls_dic list. This object is used
in further 2 print statements. These statements will print in expected
output fashion. Check it out.


Enjoy!



On Sun, Feb 15, 2015 at 7:59 PM, Shai Efrati  wrote:

> sorry.
> assuming:
> l = [{'key1':'a' , 'key2': 'b'},{'key1':'c' , 'key2': 'd'}]
>
> for e in l:
> for k, v in e.iteritems():
> print v,
> print
>
> On 2/15/15, Shai Efrati  wrote:
> > assuming:
> > l = [{'key1':a , 'key2': b},{'key1':c , 'key2': d}]
> >
> > for e in l:
> > for k, v in iteritems(e):
> > print v,
> > print
> >
> >
> >
> > On 2/15/15, aronivi...@gmail.com  wrote:
> >> [{'key1':a , 'key2': b},{'key1':c , 'key2': d}]
> >> a,b
> >> c,d
> >>
> >> --
> >> 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 post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/django-users.
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/django-users/90d2e6f3-ed06-40f3-a6cd-29e895504710%40googlegroups.com
> .
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALr%3D9OUwqwh5oX1974DPRGuiPUWBVvWu7WX1gFSzidHWwt4RKw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Krishnasagar S. Subhedarpage
India

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc-ReDbRhCidNw-XO7kufhwja-LkWhSSv9ExNSOEHQPwdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DRF JWT Token with Mobile

2017-12-28 Thread Krishnasagar Subhedarpage
Can you elaborate question? Please add some background for it.
---
Krishnasagar



On Thu, Dec 28, 2017 at 1:40 PM, Mukul Mantosh 
wrote:

> How to get JWT Token in DRF using only mobile number as the parameter
> instead of email and password..
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1b3ae8bb-2039-4aa9-8a9f-2c4ddb2ffc55%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc8zEVa8Ci%3D4sh1TC07kL9R9c2CM7u%3DQd9TVz9MsGxPkHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to edit model.py and serializer so I can recieve contact":{"name":"asdf","email":"m...@email.com","phone":"1111111111"}}

2018-10-31 Thread Krishnasagar Subhedarpage
Hi Tim,

IMHO, you can change angular's request body as per model defined in app so
that, serializer can validate and save into table.

Regards,
Krishna



On Wed, 31 Oct 2018 at 15:11, Tim Vogt  wrote:

> Hi group ;-)
>
> I have a little challenge.
>
> We have a frontend angular api. Wich sinds data to my django backend from
> an input form.
>
> And Contact in the frontend How to just my serializer / models file right
> so the contact data is in my database?
>
>
> contact?: {
> name: string;
> email: string;
> phone: string;
> }
>
> *What gets forwarded to my backend?*
>
> {"id":189267,"name":"asdf","address":"asdf","description":"asdf","totalSpots":"0","spotsTaken":"0","location":"0,0","contact":{"name":"asdf","email":"
> m...@email.com","phone":"11"}}
>
> *this part is sending the data and arrives in the database.√*
>
>
> {"id":189267,"name":"asdf","address":"asdf","description":"asdf","totalSpots":"0","spotsTaken":"0","location":"0,0",
>
>
> *This part is my challenge and I made this ajustment in my models.py file
> and serialisers.py*
>
>
> "contact":{"name":"asdf","email":"m...@email.com","phone":"11"}}
>
>
> What are the files?
>
> the angular file:
>
> export interface IWorkPlace {
> id: string;
> name: string;
> address: string;
> description: string;
> totalSpots: number;
> spotsTaken: number;
> location: [number, number];
> contact?: {
> name: string;
> email: string;
> phone: string;
> }
> }
>
> *my models.py*
>
>
> name = models.CharField(max_length=250)
> address = models.CharField(max_length=250)
> description = models.CharField(max_length=250)
> totalSpots = models.CharField(max_length=250)
> spotsTaken =models.CharField(max_length=250, blank=True)
>
> image = models.ImageField(upload_to='workplace_image', blank =True)
> location = models.CharField(max_length=250)
> name = models.CharField(max_length=150)
> email = models.EmailField(max_length=100, default='m...@example.com',blank
> =False)
> phone = models.CharField(max_length=14 ,default='11"', blank=False
> )
>
>
>
> my serializer
> class Workspace_bookingSerializer(serializers.ModelSerializer):
> class Meta:
> model = Workspace_booking
> fields = ( 'id','name','address','description','totalSpots','spotsTaken',
> 'location','name','email','phone')
>
>
>
>
> Sincere!
>
> Tim
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7ed5caaf-7140-4b1f-a490-916a7c67d45d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc_J64mnUd3QtFZeEEhwpxjmwkAS0yiHZBbGh8etOmCFXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to solve django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')?

2018-11-14 Thread Krishnasagar Subhedarpage
Hi Prateek,

Did you check disk info of server instance? What's disk consumption?

Regards,
Krishnasagar Subhedarpage




On Thu, 15 Nov 2018 at 12:09, prateek gupta  wrote:

> It is strange again, now I am getting the same error.
> Till morning it was working fine but now it is again showing same error.
>
> On Wednesday, November 14, 2018 at 7:07:46 PM UTC+5:30, Jason wrote:
>>
>> also, you might want to update your mysqlclient package.  1.3.12 was
>> released over a year ago, and 1.3.13 was pushed out late June of this year.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9bd1c72a-7c97-49b5-8a37-646e49dbc785%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9bd1c72a-7c97-49b5-8a37-646e49dbc785%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc-kazkgi0km1rfJRP4S%3D9v6Lfv0Wq4pBy12U6EhNu_Scw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to solve django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')?

2018-11-15 Thread Krishnasagar Subhedarpage
Okay. Please check error logs of mysql. Its default
path: /var/log/mysql/error.log
Please look into any error signals for the same table into it. This could
give clue for root cause of issue.

Regards,
Krishnasagar Subhedarpage




On Thu, 15 Nov 2018 at 14:42, prateek gupta  wrote:

> Hi,
>
> My all db have 20 gb of size.
>
> On Thursday, November 15, 2018 at 12:27:27 PM UTC+5:30, Krishnasagar
> Subhedarpage wrote:
>>
>> Hi Prateek,
>>
>> Did you check disk info of server instance? What's disk consumption?
>>
>> Regards,
>> Krishnasagar Subhedarpage
>>
>>
>>
>>
>> On Thu, 15 Nov 2018 at 12:09, prateek gupta  wrote:
>>
>>> It is strange again, now I am getting the same error.
>>> Till morning it was working fine but now it is again showing same error.
>>>
>>> On Wednesday, November 14, 2018 at 7:07:46 PM UTC+5:30, Jason wrote:
>>>>
>>>> also, you might want to update your mysqlclient package.  1.3.12 was
>>>> released over a year ago, and 1.3.13 was pushed out late June of this year.
>>>>
>>> --
>>> 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 post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/9bd1c72a-7c97-49b5-8a37-646e49dbc785%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/9bd1c72a-7c97-49b5-8a37-646e49dbc785%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cf5bdd99-6e58-430f-85bd-6df249378f2c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cf5bdd99-6e58-430f-85bd-6df249378f2c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc91DPRP8cqk9bHn6nrK6PA64oo0Zz3kmxuN_AzOMJmdAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ORM queryset substring on a column

2019-01-04 Thread Krishnasagar Subhedarpage
You can try with __contains queryset.


Regards,
Krishnasagar Subhedarpage



On Fri, 4 Jan 2019 at 15:34, BIJAL MANIAR  wrote:

>
> Hello,
>
> Can anyone please help with this.
>
> Thanks,
> Bijal
>
> On Thursday, January 3, 2019 at 6:47:43 PM UTC+5:30, BIJAL MANIAR wrote:
>>
>>
>> Hello,
>>
>> Consider below column in mysql table Employee. I need to write django orm
>> query for below mysql query.
>> emp_number
>> 4-DEF-A111
>> 3-MNO-333
>> 2-DEF-222
>> 1-ABC-111
>>
>>
>> Mysql query which splits by '-' and matches against last index.
>> SELECT * from Employee WHERE substring_index(emp_number, '-', -1) = '111';
>>
>> I cannot write endswith on a column like below:
>> Employee.objects.filter(emp_number__endswith='111').values('emp_number')
>> This will return below 2 records:
>> 4-DEF-A111
>> 1-ABC-111
>>
>>  Any help would be appreciated. Thanks.
>>
>> -Bijal
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a3535912-e7a6-46ed-8770-cb55d183a633%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a3535912-e7a6-46ed-8770-cb55d183a633%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc_o0_eH5CGEGmG0McUtiqQhq%3Ds7xrS6yu92y_3E4PYbzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Queryset for Multiple set

2019-03-13 Thread Krishnasagar Subhedarpage
You could do using django ORM query expressions. Refer below link:
https://docs.djangoproject.com/en/2.1/ref/models/expressions/


Regards,
Krishnasagar Subhedarpage



On Wed, 13 Mar 2019 at 17:14, Vaibhav Mishra  wrote:

> Hi All,
>
> I am trying to achieve below ,
>
> variable = object.filter(clientname =cname , clienttype='windows' and
> clienttype='unix', errorcode='20')
>
>
>
>  Notice that I want to filter by two or more values in second parameter..
> How can we do this ?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/54464687-7fd0-4103-b74f-5de566ae9e89%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/54464687-7fd0-4103-b74f-5de566ae9e89%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAChYJc8NwTG5LDBmjBbFav3b125dOsNCTwtHN%3DJrMbhrZ9T0rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.