Django-Rest nested serialization OneToOne
<p>I've been looking and following the Django-Rest Official docs <a href="http://www.django-rest-framework.org/api-guide/relations/" rel="nofollow">here</a> and tried to base my approach on that, except I was using a OneToOne relationship.</p>

<p>However, when I go to add in the browsable interface, it doesn't pick up the value in the nested text fields, and tells me that it can't be null. I've tried Googling and searching on here, but can't really find anything that works for getting a OneToOne relationship to work like what I want. I'm new to the REST-framework, and am just really confused. Thanks!</p>

<p>Basically, each verb needs to have one past tense object, which has those three fields (for testing, more, or even another layer of nesting, will be added later). I just can't get them to add with the browsable API. </p>

<p>Models.py:</p>

<pre><code>from django.db import models

class Verb(models.Model):
    verb = models.TextField()
    verbal_noun = models.TextField()
    verbal_adjective = models.TextField()
    present = models.TextField()
    future = models.TextField()
    habitual_present = models.TextField()
    conditional = models.TextField()
    past_habitual = models.TextField()
    past_subjunctive = models.TextField()
    present_subjunctive = models.TextField()
    imperative = models.TextField()

class Past(models.Model):
    verb = models.OneToOneField(Verb)
    first_singular = models.TextField()
    second_singular = models.TextField()
    third_singular = models.TextField()
</code></pre>

<p>Serializers.py:</p>

<pre><code>from rest_framework import serializers
from conjugations.models import Verb, Past

class PastSerializer(serializers.ModelSerializer):
    class Meta:
        model = Past
        fields = ('first_singular','second_singular','third_singular')

class VerbSerializer(serializers.ModelSerializer):
    past = PastSerializer()

    class Meta:
        model = Verb
        fields = ('verb','verbal_noun','verbal_adjective','past','present',
                'future','habitual_present','conditional','past_habitual',
                'past_subjunctive','present_subjunctive','imperative' )

    def create(self, validated_data):
        past_data = validated_data.pop('past')
        verb = Verb.objects.create(**validated_data)
        for past in past_data:
            Past.objects.create(verb=verb, **past)
        return verb
</code></pre>

<p>Raw data input: </p>

<pre><code>{
    "verb": "test",
    "verbal_noun": "test",
    "verbal_adjective": "test",
    "past": {
        "first_singular": "test1",
        "second_singular": "test2",
        "third_singular": "test3"
    },
    "present": "test",
    "future": "test",
    "habitual_present": "test",
    "conditional": "test",
    "past_habitual": "test",
    "past_subjunctive": "test",
    "present_subjunctive": "test",
    "imperative": "test"
}
</code></pre>

<p>Views.py</p>

<pre><code>from conjugations.models import Verb
from conjugations.serializers import VerbSerializer
from rest_framework import generics, permissions

class VerbList(generics.ListCreateAPIView):
    queryset = Verb.objects.all()
    serializer_class = VerbSerializer
    permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

class VerbDetail(generics.RetrieveUpdateDestroyAPIView):
    queryset = Verb.objects.all()
    serializer_class = VerbSerializer
    permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
</code></pre>

<p>Urls.py</p>

<pre><code>from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from conjugations import views

urlpatterns = [
    url(r'^verbs/$', views.VerbList.as_view()),
    url(r'^verbs/(?P&lt;pk&gt;[0-9]+)/$', views.VerbDetail.as_view()),
]

urlpatterns = format_suffix_patterns(urlpatterns)
</code></pre>

<p>Error:</p>

<pre><code>File "/home/Projects/Python/virtualenvs/remnigh/lib/python3.5/site-packages/rest_framework/mixins.py", line 26, in perform_create
    serializer.save()
  File "/home/Projects/Python/virtualenvs/remnigh/lib/python3.5/site-packages/rest_framework/serializers.py", line 191, in save
    self.instance = self.create(validated_data)
  File "/home/Projects/Python/reimnigh-test/reimnigh/conjugations/serializers.py", line 19, in create
    past_data = validated_data.pop('past')
KeyError: 'past'
</code></pre>