Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:55:00+00:00 2026-06-02T23:55:00+00:00

Sorry i’m a beginner in django and python..i create a project and i’ve a

  • 0

Sorry i’m a beginner in django and python..i create a project and i’ve a models.py like this:

from django.db import models

class Shoes(models.Model):
    type = models.CharField(max_length=30)
    start_date = models.DateTimeField() 
    number = models.IntegerField()
    def __unicode__(self):
        return str(self.id)
    class Meta:
        verbose_name_plural = "Shoes"

class Bottom(models.Model):
    type = models.CharField(max_length=30)
    finish = models.BooleanField()
    size = models.IntegerField()
    def __unicode__(self):
        return str(self.id)
    class Meta:
        verbose_name_plural = "Bottoms"

class Relation(models.Model):
    shoes = models.OneToOneField(Shoes)
    bottom = models.ForeignKey(Bottom)
    class Meta:
        verbose_name_plural = "Relations"

I want to serialize theese classes in json..sorry i need to understand where and how write the specific code to do it..
I wrote already a file views.py and a file.html to view a web page with table of theese objects, but now because i need to write a jquery function that allow to update the web page automatically when i add a new object, I think that we need to serialize the data in json before doing so.
Thanks and bear with me if I said something idiotic because i’m a really beginner in this field..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:55:01+00:00Added an answer on June 2, 2026 at 11:55 pm

    You want to serialize classes? You want to serialize objects! 🙂 In order to serialize Django objects you can use built-in mechanisms. Read this:

    https://docs.djangoproject.com/en/dev/topics/serialization/

    For example you can do this like this:

    from django.core import serializers
    from django.http import HttpResponse
    
    def someView(request):
        shoes_from_db = Shoes.objects.all()
        json = serializers.serialize(
                 'json', shoes_from_db, fields=('type','start_date', 'number')
               )
        return HttpResponse(json, content_type="application/json")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this has been asked before. Is it possible to create class in
Sorry this is basic, but I'm new to Python and Django. I have a
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Sorry if this sounds like a really stupid question, but I need to make
sorry if this is an obvious question, but I am relatively new to python
Sorry for this long post....But i have a headache from this task. I have
Sorry, I'm sure this is a stupid question. I have successfully installed python 2.6
Sorry if this is a dup; I haven't found any questions that pose quite
Sorry, I'm sure this is simple but I'm tired and can't figure it out.
Sorry. I'm just bitten (or bit. Go figure with this left-to-right language :-) I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.