Hi:

Although I spent time with researching I have no starting point for
solving my problem. Perhaps someone of you could give me a tip..

I have a simple model.py, e.g.

class AdressData(models.Model):

    forename=models.CharField(max_length=20,null=True,blank=True)

   surname=models.CharField(max_length=10,null=True,blank=False)

  

and forms.py e.g.

class AdressForm(forms.ModelForm):

   forename=forms.CharField(required=False)

   surname=forms.CharField(required=True)

   class Meta():

      model=AdressData

     fields= ['forename',surname']


and views.py e.g.

def question(request):

   if request.method=='Post':

      form=AdressForm(request.POST)

      if form.is_valid():

         form.save()


I render one input field surname. And if the user writes one string in
the input field it should be saved to surname (so forename is None). If
the user writes two strings (separated through a white space) than the
first part should be saved to forename and the second one to surname
(and perhaps I want to make some string manipulation further). My
problem is not the string manipulation. In result I have the forename in
a variable and the surname in an other variable.

I tried my luck with def clean_surname in the form.py and I could do the
string manipulation which I want. But I did not find a way to say django
- please save e.g. 'Mike' in forename and 'Smith' in surname.

Could anyone show me the path for solving it?

Thanks in advance,

bengoshi



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eddf7370-0821-1fa2-d510-a3a0a4d19be8%40gmail.com.

Reply via email to