Giter Club home page Giter Club logo

django_generic_serializers's Introduction

Django Generic Serializer

Generic serializer for django model objects. It Serializes you model based on dict() that is passed as parameter to it.


Documents

Installation

Two ways to install using pip

	pip install django_generic_serializer

Build the repo manually

	git clone https://github.com/abhishek246/django_generic_serializers.git
	cd django_generic_serializers
	python setup.py 

Use Cases

	class Mymodel(models.Model):
		normal_field = models.CharField(max_length = 255)
		fk_field = models.ForeignKey(SomeModel, unique = True)
		m2m_field = models.ManyToManyField(OtherModel)

	class SomeModel(models.Model):
		some_field = models.CharField(max_length = 255)
	
	class OtherModel(models.Model):
		other_field = CharField(max_length = 255)
		other_field_two = models.DateTimeField(auto_now_add=True) 

You models should look similar to this Importing Django Generic Serializer

	from django_generic_serializer import serializers
	serializer = serializers.Serializers()
	mymodel_object = Mymodel.objects.get(pk=1)
	res_dict = {
		'NormalField': 'normal_field',
		'some_field': 'fk_field.some_field',
		'm2m_field_data': {
			'field_name': 'm2m_field'
			'fields': {
				'otherField': 'other_field',
				'otherFieldTwo': 'other_field_two'
			}
		}
	}
	serializer.serializers(mymodel_object, res_dict)

Date Formating

All you time zone are converted to UTC before converting it to local time zone specified. Setting timezone

	serializers.Serializers.set_timezone('America/Halifax')

You can see the current time set by using

	serializers.Serializers.get_timezone()

django_generic_serializers's People

Contributors

abhishek246 avatar

Stargazers

Farhan avatar

Watchers

 avatar

Forkers

pritampalai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.