Recursive Serialization for Django REST framework

Overview

djangorestframework-recursive

build-status-image pypi-version

Overview

Recursive Serialization for Django REST framework

This package provides a RecursiveField that enables you to serialize a tree, linked list, or even a directed acyclic graph. Also supports validation, deserialization, ModelSerializers, and multi-step recursive structures.

Example

from rest_framework import serializers
from rest_framework_recursive.fields import RecursiveField

class TreeSerializer(serializers.Serializer):
    name = serializers.CharField()
    children = serializers.ListField(child=RecursiveField())

see here for more usage examples

Requirements

  • Python (Tested on 2.7, 3.4, 3.6)
  • Django (Tested on 1.8, 1.9, 2.0)
  • Django REST Framework (Tested on 3.3, 3.7)

Installation

Install using pip...

$ pip install djangorestframework-recursive

Release notes

0.1.2

  • This is the first release to include release notes.
  • Use inspect.signature when available. This avoids emitting deprecation warnings on Python 3.
  • Updated CI versions. djangorestframework-recursive is now tested against DRF 3.3-3.6, Python 2.7 and 3.6 and Django 1.8-1.11.

Testing

Install testing requirements.

$ pip install -r requirements.txt

Run with runtests.

$ ./runtests.py

You can also use the excellent tox testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:

$ tox
Comments
  • AttributeError: 'RecursiveField' object has no attribute 'get_fields'

    AttributeError: 'RecursiveField' object has no attribute 'get_fields'

    Heyo! First of all: thanks for releasing and supporting this, really appreciate it!

    class CategorySerializer(serializers.ModelSerializer):
        # We need special recursive serialization here for Category (parent) -> Category (child) relationship
        children = serializers.ListSerializer(read_only=True, child=RecursiveField())
        alternate_namings = CategoryOfficeNamingSerializer(many=True, required=False)
    
        class Meta:
            model = Category
            fields = (
                'id',
                'children',
                'parent',
                'order',
                'name',
                'alternate_namings',
            )
    

    Using this Serializer with django-rest-swagger I get this error:

    AttributeError: 'RecursiveField' object has no attribute 'get_fields'

    Not sure if maybe I'm misusing RecursiveField? Thanks for any advice!

    opened by ckcollab 8
  • Support for depth limiting

    Support for depth limiting

    It would be nice if the field honoured the Meta.depth attribute. This would help avoid issues with circular relationships as well as keep payloads lighter.

    More documentation on depth can be found here http://www.django-rest-framework.org/api-guide/serializers/#specifying-nested-serialization

    By default, the ModelSerializer uses PrimaryKeyFields so maybe that can be the fallback when depth is reached. That, or perhaps specify what field type to fallback.

    enhancement 
    opened by Soviut 7
  • Specify a recursivity depth

    Specify a recursivity depth

    Hi ! Thanks for this great plugin for django rest framework. Is there any way to specify the depth of the recursion ? I tried using the class Meta depth attribute but I don't think the field uses it. What would be the best approach to this ? Best regards,

    opened by achedeuzot 6
  • Children List is always NULL

    Children List is always NULL

    Hi,

    I am using this package to get all children of any node. Here is my Model and Serializer :

    class VenueSerializer(serializers.HyperlinkedModelSerializer):
        children = RecursiveField(source='children.all', many=True, read_only=True)
    
        class Meta:
            model = Venue
            fields = ( 'name', 'description','children',)
    
    class Venue(MPTTModel):
        name = models.CharField(_('name'), max_length=100)
        description = models.TextField(_('description'), null=True, blank=True)
        parent = TreeForeignKey('self', null=True, blank=True, related_name='children',
            db_index=True, verbose_name=_('parent'))
    

    But I am getting children list NULL

    {
      "count": 1,
      "next": null,
      "previous": null,
      "results": [
        {
          "name": "first Venue",
          "description": "testing purpose",
          "children": [
            {},
            {}
          ]
        }
      ]
    }
    

    Any idea where I am getting things wrong

    opened by veris-neerajdhiman 5
  • How to use children?

    How to use children?

    Model:

    class Category(models.Model):
        title = models.CharField(max_length=50, verbose_name=_('Title'), db_index=True)
        parent = models.ForeignKey('self', related_name="children", null=True, blank=True)
    

    Seralizer:

    class CategorySerializer(serializers.ModelSerializer):
        children = serializers.ListField(child=RecursiveField())
    
        class Meta:
            model = Category
            fields = ('id', 'title', 'children')  
    

    It is does not work (it should?) with TypeError: 'RelatedManager' object is not iterable .

    Hm, seems it is DRF issue, because

    children = serializers.ListField() 
    

    does not work too.

    only this is work, returned ids only.

    class CategorySerializer(serializers.ModelSerializer):
    
        class Meta:
            model = Category
            fields = ('id', 'title', 'children')  
    

    Can you held with this, or close issue...

    opened by LennyLip 5
  • Non-normal Primary Key name

    Non-normal Primary Key name

    Thank you for your work on this plug-in.

    I hope this thread is still monitored.

    I am having an issue that I think is due to a non-defaulted primary key. I am creating a Django stack for an existing MSSQL database, and have successfully integrated my database models with DRF. However, due to the nature of the existing database, I am stuck using pre-determined field names, including primary key assignments.

    Model:

    from django.db import models, connection
    
    class ClientModel(models.Model):
        ClientID = models.IntegerField(primary_key=True)
        Name = models.CharField(max_length=100)
        BusinessUnitID = models.IntegerField(default=0)
        ParentID = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
        InvoicePreFix = models.CharField(max_length=50, default="")
        BillingTerms = models.IntegerField(default=0)
        BillingInterval = models.IntegerField(default=0)
        MaximumAllowedExposure = models.DecimalField(decimal_places=2, max_digits=10, default=0)
        InvoiceTypeID = models.IntegerField(default=0)
    
        @staticmethod
        def getClientList():
            cur = connection.cursor()
            cur.execute("{CALL getClientList}")
            results = cur.fetchall()
            cur.close()
            return [ClientModel(*row) for row in results]
    

    Serializer:

    class ClientModelSerializer(serializers.ModelSerializer):
        ParentID = RecursiveField(allow_null=True)
    
        class Meta:
            model = ClientModel
            fields = (
                'ClientID',
                'Name',
                'BusinessUnitID',
                'ParentID',
                'InvoicePreFix',
                'BillingTerms',
                'BillingInterval',
                'MaximumAllowedExposure',
                'InvoiceTypeID'
            )
    

    After installation and implementation of DRF-Recursive, I am receiving the following error:

    ('42S22', "[42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'Name'. (207) (SQLExecDirectW);_ [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'BusinessUnitID'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'ParentID_id'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'InvoicePreFix'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'BillingTerms'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'BillingInterval'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'MaximumAllowedExposure'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'InvoiceTypeID'. (207); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Statement(s) could not be prepared. (8180)")

    Of note, as shown in the error, my primary key field ("ClientID") is not included in the error report. I could not find an example on the Git page that did not use Django's "id" default primary key field.

    Also, my "ParentID" field is getting an "_id" appended to the end of the field name. How can I allow this field name to remain the same?
    [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'ParentID_id'. (207);

    Thank you for your time and effort.

    opened by ItsAcedia 3
  • maximum recursion depth exceeded

    maximum recursion depth exceeded

    models.py

    from django.db import models
    from mptt.models import MPTTModel, TreeForeignKey
    
    from poinkbackend.apps.menus.models import Menu
    
    
    class Category(MPTTModel):
        name = models.CharField(max_length=50)
        parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
        menu = models.ForeignKey(Menu, related_name='categories', related_query_name='categories',
                                 on_delete=models.SET_NULL, null=True, blank=True)
    
        class MPTTMeta:
            order_insertion_by = ['name']
    
        def __str__(self):
            return f'{self.name} {self.menu}'
    

    Serializers.py

    from rest_framework import serializers
    from rest_framework_recursive.fields import RecursiveField
    
    from poinkbackend.apps.categories.models import Category
    
    
    class CategorySerializer(serializers.ModelSerializer):
        parent = RecursiveField(allow_null=True)
    
        class Meta:
            model = Category
            fields = [
                'id',
                'name',
                'parent',
                'menu',
            ]
    

    viewsets.py

    from rest_framework import viewsets
    
    from poinkbackend.apps.categories.api.serializers import CategorySerializer
    from poinkbackend.apps.categories.models import Category
    
    
    class CategoryViewSet(viewsets.ModelViewSet):
        queryset = Category.objects.all()
        serializer_class = CategorySerializer
    

    I got the error maximum recursion depth exceeded

    Where am I wrong?

    django==1.11.9
    djangorestframework-jwt==1.11.0
    djangorestframework-recursive==0.1.2
    djangorestframework==3.7.7
    django-mptt==0.9.0
    
    opened by elcolie 3
  • Mutual Recursion: Maximum Depth

    Mutual Recursion: Maximum Depth

    So I've followed your example use cases but I'm experiencing some issues. Here is the code I'm using:

    class RequestSerial(ModelSerializer):
    
        bidpick = RecursiveField('BidSerial')
    
    
        class Meta:
    
            model = Request
    
            fields = '__all__'
    
    
    class BidSerial(ModelSerializer):
    
        request = RequestSerial()
    
    
        class Meta:
    
            model = Bid
    
            fields = '__all__'
    

    I definitely expected this to work but I'm getting a maximum recursion depth exceeded as a runtime error.

    opened by ghost 3
  • 'fields' attribute not being followed on ModelSerializers

    'fields' attribute not being followed on ModelSerializers

    I have a set of fields specified, yet am getting others.

    Serializer:

    class ServiceSerializer(recursive_serializers.ModelSerializer):
        parent = RecursiveField(required=False)
        class Meta:
            model = Service
            fieds = ('id', 'name', 'parent', 'active')
    

    Results:

        "results": [
            {
                "id": 18, 
                "parent": null, 
                "name": "Bankruptcy", 
                "active": true, 
                "lft": 1, 
                "rght": 2, 
                "tree_id": 2, 
                "level": 0
            }
        ]```
    
    opened by boulderdave 3
  • TypeError: 'QuestionnaireItem' object is not iterable

    TypeError: 'QuestionnaireItem' object is not iterable

    Hi all,

    I am experiencing an issue when using the RecursiveField. I am creating questionnaires. To create sections in the questionnaire, you can recursively add questionnaire items to existing questionnaire items. The questionnaire is well created into the DB but when it is returning the response, there is no item key for the nested questionnaire items. Do you have an idea? (Thanks for your help)

    django RF= 3.7.3 python=2.7.10

    Those are my models:

    class Questionnaire(models.Model):
    
    	rowId = models.BigAutoField(primary_key=True, editable=False, db_column="rowId")
    	
    	id = models.UUIDField(unique=True, default=uuid4, editable=False, db_column="id")
    
    	owner = models.ForeignKey('oauth.Application', related_name='Questionnaire', on_delete=models.CASCADE, db_column="ownerId")
    
    	url = models.CharField(max_length=250, null=True, db_column="url")
    
    	title = models.CharField(max_length=200, null=True, db_column="title")
    
    	status = models.CharField(max_length=3, choices=STATUS_CHOICES, default=UNKNOWN, db_column="status")
    
    	date = models.DateField(auto_now=True, null=False, db_column="date")
    
    	publisher = models.CharField(max_length=200, null=True, db_column="publisher")
    
    	description = models.CharField(max_length=400, null=True, db_column="description")
    
    	purpose = models.CharField(max_length=400, null=True, db_column="purpose")
    
    	# item
    	# Reverse foreign key ---> QuestionnaireItem
    
    	class Meta:
    		db_table = "questionnaire"
    
    class QuestionnaireItem(models.Model):
    
    	id = models.BigAutoField(primary_key=True, editable=False, db_column="id")
    
    	questionnaire = models.ForeignKey("api.Questionnaire",
    										db_index=True,
                                                                                    null=True,
    										on_delete=models.PROTECT,
    										to_field='id',
    										related_name='item',
    										db_column="questionnaireId")
    
    
    	text = models.CharField(max_length=400, null=True, db_column="text")
    
    	type = models.CharField(max_length=4, choices=TYPE_CHOICES, default=UNKNOWN, db_column="type")
    
    	required = models.NullBooleanField(null=True, db_column="required")
    
    	readOnly = models.NullBooleanField(null=True, db_column="readOnly")
    
    	maxLength = models.PositiveIntegerField(null=True, db_column="maxLength")
    
    	# option
    	# Reverse foreign key ---> QuestionnaireOption
    
    	initialBoolean = models.NullBooleanField(null=True, db_column="initialBoolean")
    
    	initialDecimal = models.DecimalField(null=True, db_column="initialDecimal", max_digits=10, decimal_places=2)
    
    	initialInteger = models.IntegerField(null=True, db_column="initialInteger")
    
    	initialDate = models.DateField(null=True, db_column="initialDate")
    
    	initialString = models.CharField(max_length=400, null=True, db_column="initialString")
    
    	initialUri = models.CharField(max_length=200, null=True, db_column="initialUri")
    
    	initialAttachment = models.OneToOneField("api.Attachment", null=True, on_delete=models.PROTECT, related_name="initialAttachment", db_column="initialAttachmentId")
    
    	initialQuantity = models.OneToOneField("api.Quantity", null=True, on_delete=models.PROTECT, related_name="initialQuantity", db_column="initialQuantityId")
    
    	# item
    	# Allow to create sections and sub-sections
    	# Reverse foreign key ---> QuestionnaireItem
    	item = models.ForeignKey('self',
    							 db_index=True,
    							 on_delete=models.PROTECT,
    							 null=True,
    						     related_name='sub_item',
    						     db_column="questionnaireItemId")
    
    	class Meta:
    		db_table = "questionnaire_item"
    
    class QuestionnaireOption(models.Model):
    
    	id = models.BigAutoField(primary_key=True, editable=False, db_column="id")
    
    	questionnaireItem = models.ForeignKey("api.QuestionnaireItem",
    										  db_index=True,
    										  on_delete=models.PROTECT,
    										  null=True,
    										  to_field='id',
    										  related_name='option',
    										  db_column="questionnaireItemId")
    
    	valueInteger = models.IntegerField(null=True, db_column="valueInteger")
    
    	valueDate = models.DateField(null=True, db_column="valueDate")
    
    	valueString = models.CharField(max_length=200, null=True, db_column="valueUri")
    
    	class Meta:
    		db_table = "questionnaire_option"
    

    Those are my serializers:

    class QuestionnaireOptionSerializer(serializers.ModelSerializer):
    
    	valueInteger = serializers.IntegerField(required=False)
    
    	valueDate = serializers.DateField(required=False)
    
    	valueString = serializers.CharField(required=False)
    
    	class Meta:
    		model = QuestionnaireItem
    		fields = ('valueInteger', 'valueDate', 'valueString')
    
    	def to_representation(self, instance):
    		result = super(QuestionnaireOptionSerializer, self).to_representation(instance)
    		return OrderedDict([(key, result[key]) for key in result if result[key] is not None])
    
    
    class QuestionnaireItemSerializer(serializers.ModelSerializer):
    
    	text = serializers.CharField(required=True)
    
    	type = CustomChoiceField(choices=TYPE_CHOICES, required=True)
    
    	required = serializers.CharField(required=False)
    
    	readOnly = serializers.CharField(required=False)
    
    	maxLength = serializers.IntegerField(required=False)
    
    	option = QuestionnaireOptionSerializer(many=True, required=False)
    
    	initialBoolean = serializers.BooleanField(required=False)
    
    	initialDecimal = serializers.DecimalField(required=False, max_digits=10, decimal_places=2)
    
    	initialInteger = serializers.IntegerField(required=False)
    
    	initialDate = serializers.DateField(required=False)
    
    	initialString = serializers.CharField(required=False)
    
    	initialUri = serializers.CharField(required=False)
    
    	initialAttachment = AttachmentSerializer(many=False, required=False)
    
    	initialQuantity = QuantitySerializer(many=False, required=False)
    
    	item = serializers.ListField(child=RecursiveField(), required=False)
    
    	class Meta:
    		model = QuestionnaireItem
    		managed = True
    		fields = ('text', 'type', 'required', 'readOnly', 'maxLength', 'option', 'initialBoolean', 'initialDecimal', 'initialInteger', 'initialDate', 'initialString', 'initialUri', 'initialAttachment', 'initialQuantity', 'item')
    
    	def to_representation(self, instance):
    		result = super(QuestionnaireItemSerializer, self).to_representation(instance)
    		return OrderedDict([(key, result[key]) for key in result if result[key] is not None])
    
    
    
    class QuestionnaireSerializer(serializers.ModelSerializer):
    
    	id = serializers.UUIDField(read_only=True)
    
    	url = serializers.CharField(required=False)
    
    	title = serializers.CharField(required=True)
    
    	status = CustomChoiceField(choices=STATUS_CHOICES, required=False)
    
    	date = serializers.DateField(required=False)
    
    	publisher = serializers.CharField(required=False)
    
    	description = serializers.CharField(required=False)
    
    	purpose = serializers.CharField(required=False)
    
    	item = QuestionnaireItemSerializer(many=True, required=True)
    
    	def create(self, validated_data):
    
    		print(validated_data)
    
    		# Get the linked application
    		application = get_app_by_access_token(self.context)
    
    		# Dealing with the nested structure
    		questionnaire_item_data = validated_data.pop('item')
    
    		# Saving the questionnaire
    		questionnaire = Questionnaire.objects.create(owner=application, **validated_data)
    
    		# Saving first level
    		for item in questionnaire_item_data:
    
    			should_add_option = False
    			should_add_item = False
    
    			if 'option' in item:
    				questionnaire_option_data = item.pop('option')
    				should_add_option = True
    
    			if 'item' in item:
    				sub_item_data = item.pop('item')
    				should_add_item = True
    
    			# Saving the questionnaire item
    			questionnaireItem = QuestionnaireItem.objects.create(questionnaire=questionnaire, **item)
    
    			if should_add_option:
    				# Saving second level
    				for option in questionnaire_option_data:
    					# Saving the questionnaire options
    					QuestionnaireOption.objects.create(questionnaireItem=questionnaireItem, **option)
    
    			if should_add_item:
    				# Saving second level
    				for sub_item in sub_item_data:
    					# Saving the questionnaire sub item
    					QuestionnaireItem.objects.create(questionnaire=questionnaire, item=questionnaireItem, **sub_item)
    
    		# Return
    		return questionnaire
    
    	class Meta:
    		model = Questionnaire
    		fields = ('id', 'url', 'title', 'status', 'date', 'publisher', 'description', 'purpose', 'item')
    
    	def to_representation(self, instance):
    		result = super(QuestionnaireSerializer, self).to_representation(instance)
    		return OrderedDict([(key, result[key]) for key in result if result[key] is not None])
    
    opened by ghost 2
  • RecursionError: maximum recursion depth exceeded

    RecursionError: maximum recursion depth exceeded

    I am trying to follow the docs https://github.com/heywbj/django-rest-framework-recursive/blob/master/tests/test_recursive.py

    Python 3.6.2 django==1.11.4 djangorestframework-recursive==0.1.2 djangorestframework==3.6.3

    models

    from django.db import models
    from mptt.fields import TreeForeignKey
    from mptt.models import MPTTModel
    
    
    class ProductCategory(MPTTModel):
        name = models.CharField(max_length=255, blank=False, unique=True)
        description = models.TextField(blank=True, null=True)
    
        parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
    
        class MPTTMeta:
            order_insertion_by = ['name']
    
        class Meta:
            verbose_name_plural = u"Categories"
    
        def __str__(self):
            return f"{self.name}"
    

    serializers

    from rest_framework import serializers
    from rest_framework_recursive.fields import RecursiveField
    
    from apps.categories.models import ProductCategory
    
    
    class CategoryTreeSerializer(serializers.Serializer):
        parent = RecursiveField(allow_null=True)
    
        class Meta:
            model = ProductCategory
            fields = ['name', 'description', 'parent']
    

    views

    from rest_framework import viewsets
    
    from apps.categories.api.serializers import CategoryTreeSerializer
    from apps.categories.models import ProductCategory
    
    
    class ProductCategoryViewSet(viewsets.ModelViewSet):
        queryset = ProductCategory.objects.all()
        serializer_class = CategoryTreeSerializer
    

    api_urls

    from rest_framework import routers
    
    from apps.categories.api.views import ProductCategoryViewSet
    
    router = routers.SimpleRouter()
    router.register(r'product-category', ProductCategoryViewSet, base_name='product-catagory')
    
    urlpatterns = [
        # url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
    ]
    
    urlpatterns += router.urls
    

    I got the error

      builtins.RecursionError
    RecursionError: maximum recursion depth exceeded
    

    Where am I wrong? In the traceback does not show my lines. It shows only library lines.

    opened by elcolie 2
  • Not working in django 4

    Not working in django 4

    DJango 4.1 djangorestframework==3.14.0

    models.py
    
    class Category(PreModel):
        name = models.CharField(max_length=255)
        slug = models.SlugField(blank=True)
        image = models.ImageField(null=True, blank=True)
        parent = models.ForeignKey('self', related_name='get_category_children', on_delete=models.CASCADE, null=True,
                                   blank=True)
    
        def __str__(self):
            return self.name
    
    serializers.py
    
    class CategoryGetSerializer(serializers.ModelSerializer):
        children = RecursiveField(many=True, read_only=True)
    
        class Meta:
            model = Category
            fields = "__all__"
    
    views.py
    
    class CategoryView(ModelViewSet):
        pass
    
        def get_serializer_class(self):
            # return CategorySerializer
    
            if self.action == 'list':
                return CategoryGetSerializer
            else:
                return CategorySerializer
    
        queryset = Category.objects.filter(parent__isnull=True)
    
    Response json
    
    [
      {
        "id": 0,
        "children": [
          "string"
        ],
        "date_created": "2022-12-27T11:12:28.099Z",
        "date_updated": "2022-12-27T11:12:28.099Z",
        "active": true,
        "deleted_at": "2022-12-27T11:12:28.099Z",
        "name": "string",
        "slug": "4p7XC77HuaJPRhUyaUNGMMpcbLFmeWe0rwyr",
        "image": "string",
        "parent": 0
      }
    ]
    

    No data is response here in children. but here parent has many ids. I want to all children serializers in children. How can i solve this problem???

    opened by shahriar350 0
  • Bump wheel from 0.24.0 to 0.38.1

    Bump wheel from 0.24.0 to 0.38.1

    Bumps wheel from 0.24.0 to 0.38.1.

    Changelog

    Sourced from wheel's changelog.

    Release Notes

    UNRELEASED

    • Updated vendored packaging to 22.0

    0.38.4 (2022-11-09)

    • Fixed PKG-INFO conversion in bdist_wheel mangling UTF-8 header values in METADATA (PR by Anderson Bravalheri)

    0.38.3 (2022-11-08)

    • Fixed install failure when used with --no-binary, reported on Ubuntu 20.04, by removing setup_requires from setup.cfg

    0.38.2 (2022-11-05)

    • Fixed regression introduced in v0.38.1 which broke parsing of wheel file names with multiple platform tags

    0.38.1 (2022-11-04)

    • Removed install dependency on setuptools
    • The future-proof fix in 0.36.0 for converting PyPy's SOABI into a abi tag was faulty. Fixed so that future changes in the SOABI will not change the tag.

    0.38.0 (2022-10-21)

    • Dropped support for Python < 3.7
    • Updated vendored packaging to 21.3
    • Replaced all uses of distutils with setuptools
    • The handling of license_files (including glob patterns and default values) is now delegated to setuptools>=57.0.0 (#466). The package dependencies were updated to reflect this change.
    • Fixed potential DoS attack via the WHEEL_INFO_RE regular expression
    • Fixed ValueError: ZIP does not support timestamps before 1980 when using SOURCE_DATE_EPOCH=0 or when on-disk timestamps are earlier than 1980-01-01. Such timestamps are now changed to the minimum value before packaging.

    0.37.1 (2021-12-22)

    • Fixed wheel pack duplicating the WHEEL contents when the build number has changed (#415)
    • Fixed parsing of file names containing commas in RECORD (PR by Hood Chatham)

    0.37.0 (2021-08-09)

    • Added official Python 3.10 support
    • Updated vendored packaging library to v20.9

    ... (truncated)

    Commits
    • 6f1608d Created a new release
    • cf8f5ef Moved news item from PR #484 to its proper place
    • 9ec2016 Removed install dependency on setuptools (#483)
    • 747e1f6 Fixed PyPy SOABI parsing (#484)
    • 7627548 [pre-commit.ci] pre-commit autoupdate (#480)
    • 7b9e8e1 Test on Python 3.11 final
    • a04dfef Updated the pypi-publish action
    • 94bb62c Fixed docs not building due to code style changes
    • d635664 Updated the codecov action to the latest version
    • fcb94cd Updated version to match the release
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bug with simple tree structure

    Bug with simple tree structure

    I implemented basically the exact recursive model and RecursiveModelSerializer and Django throws maximum recursion depth exceeded while calling a Python object which is interesting, because we only have one parent relation in the database with only 3 objects.

    class UnitSerializer(serializers.ModelSerializer):
        parent = RecursiveField(allow_null=False)
        address = AddressSerializer(read_only=True)
        type = serializers.StringRelatedField(read_only=True)
        properties = PropertySerializer(many=True, read_only=True)
    
        class Meta:
            fields = ('id', 'name', 'description', 'enabled', 'parent', 'type', 'address', 'properties')
            model = Unit
            depth = 3
    

    is our serializer class and it doesn't work. I am using the latest Django 3.0.7 and DRF 3.11.0.

    opened by creyD 9
  • How deserializer data and save it  in db?

    How deserializer data and save it in db?

    Store need

    {
      'name': 'category 1',
      'children':[
        {'name': 'category 2'},
        {'name': 'category 3'},
      ]
    }
    

    I use djangorestframework and trying to write serializer for

    class Category(MPTTModel):
        name = models.CharField(max_length=100)
    
        parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children')
    
        class MPTTMeta:
            order_insertion_by = ['name']
    

    I made it

    class CategorySerializer(serializers.ModelSerializer):
        class Meta:
            model = Category
            fields = ['id', 'name', 'children']
            read_only_fields = ['parents']
    
        # parent = serializers.ListField()
        children = RecursiveField('CategorySerializer', required=False, allow_null=True, many=True)
    

    And I got the error TypeError: unhashable type: 'collections.OrderedDict'. It seems that the internal fields are not serialized.

    opened by heckad 1
Owner
null
Country-specific Django helpers, to use in Django Rest Framework

django-rest-localflavor Country-specific serializers fields, to Django Rest Framework Documentation (soon) The full documentation is at https://django

Gilson Filho 19 Aug 30, 2022
Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

Tivix 2.4k Dec 29, 2022
Authentication for Django Rest Framework

Dj-Rest-Auth Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Ang

Michael 1.1k Dec 28, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Jazzband 3.3k Jan 4, 2023
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.

drf-yasg - Yet another Swagger generator Generate real Swagger/OpenAPI 2.0 specifications from a Django Rest Framework API. Compatible with Django Res

Cristi Vîjdea 3k Jan 6, 2023
Introduction to Django Rest Framework

Introduction to Django Rest Framework This is the repository of the video series Introduction to Django Rest Framework published on YouTube. It is a s

Simple is Better Than Complex 20 Jul 14, 2022
JSON:API support for Django REST framework

JSON:API and Django REST framework Overview JSON:API support for Django REST framework Documentation: https://django-rest-framework-json-api.readthedo

null 1k Dec 27, 2022
DRF-extensions is a collection of custom extensions for Django REST Framework

Django REST Framework extensions DRF-extensions is a collection of custom extensions for Django REST Framework Full documentation for project is avail

Gennady Chibisov 1.3k Dec 28, 2022
Generate Views, Serializers, and Urls for your Django Rest Framework application

DRF Generators Writing APIs can be boring and repetitive work. Don't write another CRUDdy view in Django Rest Framework. With DRF Generators, one simp

Tobin Brown 332 Dec 17, 2022
Swagger Documentation Generator for Django REST Framework: deprecated

Django REST Swagger: deprecated (2019-06-04) This project is no longer being maintained. Please consider drf-yasg as an alternative/successor. I haven

Marc Gibbons 2.6k Dec 23, 2022
Document Web APIs made with Django Rest Framework

DRF Docs Document Web APIs made with Django Rest Framework. View Demo Contributors Wanted: Do you like this project? Using it? Let's make it better! S

Manos Konstantinidis 626 Nov 20, 2022
Dropdown population implementation for Django REST Framework

drf-dropdown Dropdown population implementation for Django REST Framework Usage Add DropdownView to API URL # urls.py import dropdown urlpatterns = [

Preeti Yuankrathok 4 Dec 6, 2022
simple api build with django rest framework

Django Rest API django-rest-framework Employees management simple API in this project wrote test suites for endpoints wrote simple doc string for clas

OMAR.A 1 Mar 31, 2022
Simple Crud Api With Django Rest Framework

SIMPLE CRUD API WITH DJANGO REST FRAMEWORK Django REST framework is a powerful and flexible toolkit for building Web APIs. Requirements Python 3.6 Dja

kibet hillary 1 May 3, 2022
BloodDonors: Built using Django REST Framework for the API backend and React for the frontend

BloodDonors By Daniel Yuan, Alex Tian, Aaron Pan, Jennifer Yuan As the pandemic raged, one of the side effects was an urgent shortage of blood donatio

Daniel Yuan 1 Oct 24, 2021
Built on Django Rest Framework, to provide with command execution on linux terminal

Built on Django Rest Framework, to provide with command execution on linux terminal

null 1 Oct 31, 2021
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

Microsoft 1.8k Jan 4, 2023
Mlflow-rest-client - Python client for MLflow REST API

Python Client for MLflow Python client for MLflow REST API. Features: Minimal de

MTS 35 Dec 23, 2022
Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

?? Fast, Async-ready, Openapi, type hints based framework for building APIs

Vitaliy Kucheryaviy 3.8k Jan 4, 2023