Created
September 22, 2020 10:14
-
-
Save godfather68/8f6939f46cabc99c3448f483b316ed64 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 import forms | |
from .models import Customer, Request | |
class CreateRequestForm(forms.ModelForm): | |
customer = forms.CharField() | |
def clean(self): # update | |
data = self.cleaned_data.pop('customer') | |
customer, created = Customer.objects.get_or_create(name=data) | |
self.cleaned_data.update({'customer': customer}) | |
class Meta: | |
model = Request | |
fields = '__all__' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment