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
from django.views.generic import UpdateView | |
from forms import MyModelForm | |
from models import MyModel | |
class MyUpdateView(UpdateView): | |
# specify a custom ModelForm | |
form_class = MyModelForm | |
# or simply specify the Model | |
# model = MyModel | |
def get_object(self, queryset=None): | |
# get the existing object or created a new one | |
obj, created = MyModel.objects.get_or_create(col_1=self.kwargs['value_1'], col_2=self.kwargs['value_2']) | |
return obj | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to write
url.py
for both create and update