Tuesday, November 1, 2016

Re: [Ask for help]How to convert django models schema to json?

Hi,

you can try django-rest-frameworks model serializer, modelviewsets and django-json-api package for this job.

thanks

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 django-users+unsubscribe@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/00fc2393-20a7-4196-a8b5-a2c368913f59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment