Hi Tim, IMHO, you can change angular's request body as per model defined in app so that, serializer can validate and save into table.
Regards, Krishna On Wed, 31 Oct 2018 at 15:11, Tim Vogt <[email protected]> wrote: > Hi group ;-) > > I have a little challenge. > > We have a frontend angular api. Wich sinds data to my django backend from > an input form. > > And Contact in the frontend How to just my serializer / models file right > so the contact data is in my database? > > > contact?: { > name: string; > email: string; > phone: string; > } > > *What gets forwarded to my backend?* > > {"id":189267,"name":"asdf","address":"asdf","description":"asdf","totalSpots":"0","spotsTaken":"0","location":"0,0","contact":{"name":"asdf","email":" > [email protected]","phone":"1111111111"}} > > *this part is sending the data and arrives in the database.√* > > > {"id":189267,"name":"asdf","address":"asdf","description":"asdf","totalSpots":"0","spotsTaken":"0","location":"0,0", > > > *This part is my challenge and I made this ajustment in my models.py file > and serialisers.py* > > > "contact":{"name":"asdf","email":"[email protected]","phone":"1111111111"}} > > > What are the files? > > the angular file: > > export interface IWorkPlace { > id: string; > name: string; > address: string; > description: string; > totalSpots: number; > spotsTaken: number; > location: [number, number]; > contact?: { > name: string; > email: string; > phone: string; > } > } > > *my models.py* > > > name = models.CharField(max_length=250) > address = models.CharField(max_length=250) > description = models.CharField(max_length=250) > totalSpots = models.CharField(max_length=250) > spotsTaken =models.CharField(max_length=250, blank=True) > > image = models.ImageField(upload_to='workplace_image', blank =True) > location = models.CharField(max_length=250) > name = models.CharField(max_length=150) > email = models.EmailField(max_length=100, default='[email protected]',blank > =False) > phone = models.CharField(max_length=14 ,default='1111111111"', blank=False > ) > > > > my serializer > class Workspace_bookingSerializer(serializers.ModelSerializer): > class Meta: > model = Workspace_booking > fields = ( 'id','name','address','description','totalSpots','spotsTaken', > 'location','name','email','phone') > > > > > Sincere! > > Tim > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/7ed5caaf-7140-4b1f-a490-916a7c67d45d%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/7ed5caaf-7140-4b1f-a490-916a7c67d45d%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAChYJc_J64mnUd3QtFZeEEhwpxjmwkAS0yiHZBbGh8etOmCFXQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

