Last active
December 22, 2015 08:08
-
-
Save earthling-shruti/6442618 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model1(models.Model): | |
pass | |
class Model2(models.Model): | |
model1 = OneToOneField('Model1') | |
==================================== | |
class myView(UpdateView): | |
... | |
def get_context_data(self, **kwargs): | |
model1 = Model1.objects.get(pk=self.pk_url_kwargs) | |
model2, created = Model2.objects.get_or_create(model1=model1) | |
return model2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment