Hi!

There's also an alternative to Django REST Framework - Tastypie 
(https://django-tastypie.readthedocs.io/en/latest/ 
<https://django-tastypie.readthedocs.io/en/latest/>). You could use 
[Namespaced]ModelResource with Django Models.

And if you're not interested in API and only want to use JSON internally, you 
could write your own serialization method in some abstract model class - Django 
allows you to iterate over model fields 
(https://docs.djangoproject.com/en/1.10/ref/models/meta/#django.db.models.options.Options.get_fields
 
<https://docs.djangoproject.com/en/1.10/ref/models/meta/#django.db.models.options.Options.get_fields>).

> On 2 Nov 2016, at 07:19, Asif Saifuddin <[email protected]> wrote:
> 
> But seems like you are using sqlalchemy models. for sqlalchemy models you 
> could try sqlalchemy-marshmellow
> 
> On Wednesday, November 2, 2016 at 2:27:47 AM UTC+6, 周华 wrote:
> This is an example models
> class UserModel(db.Model):
>     __tablename__ = "user"
>     id = db.Column(db.Integer, primary_key=True)
>     user_id = db.Column(db.String(255), unique=True)
>     name = db.Column(db.String(255))
> 
> 
> 
> This is a Json example which I want get.
> {
>   "user":
>   {
>     "id":{
>       "type": "Integer",
>       "primary_key": True,
>       "null": True,
>       "default value": "",
>       "foreign key": ""},
>       
>       "user_id":{
>       "type": "Integer",
>       "primary_key": True,
>       "null": True,
>       "default value": "",
>       "foreign key": ""},
>       
>       "name":{
>       "type": "Integer",
>       "primary_key": True,
>       "null": True,
>       "default value": "",
>       "foreign key": ""},
>   }
> }
> 
> Wait your response online
> 
> 
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/django-users 
> <https://groups.google.com/group/django-users>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/bd6f5f3b-2e8c-4eac-80f3-1f787ab969ef%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/bd6f5f3b-2e8c-4eac-80f3-1f787ab969ef%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <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 [email protected].
To post to this group, send email to [email protected].
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/906193B1-BA55-4670-ADDE-8770B68C23F8%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to