Wednesday, October 31, 2018

How to edit and serializer so I can recieve contact":{"name":"asdf","email":"","phone":"1111111111"}}

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?

this part is sending the data and arrives in the database.√


This part is my challenge and I made this ajustment in my file and


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;


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='',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')



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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment