In the Service Provided field, I want to add more text box dynamically,when the user wants to add more than one service name. How to achieve that?
models.py
from django.db import models
from django.contrib.auth.models import User
class CustomerProfile(models.Model):
customer_username = models.ForeignKey('auth.User')
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
organisation_name = models.CharField(max_length=20)
website = models.URLField()
office_address = models.CharField(max_length=200)
service_provided = models.CharField(max_length=100)
contact = models.IntegerField()
city = models.CharField(max_length=20)
state = models.CharField(max_length=20)
zip_code = models.IntegerField()
number_of_employee = models.IntegerField()
establishment_year = models.IntegerField()
number_of_project_done = models.IntegerField()
def __str__(self):
return self.organisation_name
forms.py
from django import forms
from .models import CustomerProfile
class CustomerProfileForm(forms.ModelForm):
class Meta:
model = CustomerProfile
fields = '__all__'
exclude = ('customer_username',)
CustomerProfileto have a single service. If you want to allow multiple services for each profile, you'll need to rethink your models (e.g. have aServicemodel with a foreign key toCustomerProfile.