JSON Objects

2017-09-16 Thread yingi keme
Say you have a simple class class Cart(object): def _init_(self, name, age): self.name = name self.age = age And then you have an instance of the class T = Cart('john', 23) How will you serialize the object instance T using json? I know json serializes limited data

Re: JSON Objects

2017-09-16 Thread Jani Tiainen
Hi One of the simplest ways is to use special serializer. At least django-nap and django-rest-framework do have excellent serializers you can leverage. Django itself also has serializer you can use. https://docs.djangoproject.com/en/1.11/topics/serialization/ 16.9.2017 13.26 "yingi keme"

Re: JSON Objects

2017-09-16 Thread yingi keme
I will check it out, i have just used the third party package jsonpickle. And it was easy to use Thanks a lot Yingi Kem > On 16 Sep 2017, at 11:31 AM, Jani Tiainen wrote: > > Hi > > One of the simplest ways is to use special serializer. At least django-nap > and

Re: Validate and get the user using the jwt token inside a view

2017-09-16 Thread Robin Lery
I was about to that by this from rest_framework_jwt.serializers import VerifyJSONWebTokenSerializer data = {'token': token} valid_data = VerifyJSONWebTokenSerializer().validate(data) user = valid_data['user'] Hope this helps any body like me. On Sat, Sep 16, 2017 at 9:34 AM, Robin Lery

django autocomplete light

2017-09-16 Thread Ahmet Muazim Tunç
I want to make two or three dropdown menus which are dependent on each other. It's Country, City dropdown menus and when Country is selected City dropdown menu has to be filled with proper cities. How can I make this? I have the data, installed the django-cities-light app and filled my db with

Re: How to authenticate a user in websocket connection in django channels when using token authentication

2017-09-16 Thread Robin Lery
Ok, thanks. So, I was confused about two things on authenticating a user. 1. What to do with the token? - You can pass the token as a query string and get that query params. Read more about how to get the query params here

Re: django autocomplete light

2017-09-16 Thread Ryan Nowakowski
If all dropdowns are on the same page, you probably need to create some views that return json, then hit those views with ajax. On September 15, 2017 9:25:42 PM CDT, "Ahmet Muazim Tunç" wrote: >I want to make two or three dropdown menus which are dependent on each

Re: Getting my head around ForeignKey, One-To-Many and Many-To-Many.

2017-09-16 Thread Ryan Nowakowski
Instead of using ManyToMany in stencil, add a ForeignKey(EditorStencil) in vocab. On September 13, 2017 6:25:32 PM CDT, Jack Razors wrote: >I am creating a mindmap visio-like editor website using d3js and a >bunch of >custom javascript. Rather than the schema/stencils

Autocomplete in Django

2017-09-16 Thread Mreno sert
I have a small app in which I have form for taking 5 inputs as City1, City2,City3,City4 and City5 as the fields. I have written a code for auto completing it but A user can not enter the new fields. Only existing values can be used. How can I make it to accept a new field if not present in the