(no subject)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Paras Jain
Hy, i am not getting my all fields on the my page which is written inside the forms.py of 'PersonForm'


models.py:
from django.db import models

# Create your models here.
TITLE_CHOICES = (
    ('Normal', 'Manager'),
)

class Company(models.Model):
    email = models.EmailField()

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)


    class Meta:
        verbose_name_plural = 'Company'



class Person(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField()
    type = models.CharField(max_length=6, choices=TITLE_CHOICES)

    class Meta:
        verbose_name_plural = 'Person'


forms.py:
from django import forms
from .models import Company,Person

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('email',)

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ('type', 'name','email',)

views.py:
from django.shortcuts import render
from .forms import CompanyForm, PersonForm
from django.views.generic  import CreateView

# Create your views here.
def home(request):

    form = CompanyForm()

    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)

        else:
            print('Error form invalid')

    return render(request, 'home.html', {'form':form})

def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMtmBS-LUNiBy-ey%2BrpvB1%3DRPo6n9x3GwuSnOswObBRt2OZK1g%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re:

Nijo Joseph
def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})
What is this form for? Adding into Company table. Then make this one to      form= CompanyForm() not PersonForm().

On Fri, 8 Nov 2019, 4:26 pm Paras Jain, <[hidden email]> wrote:
Hy, i am not getting my all fields on the my page which is written inside the forms.py of 'PersonForm'


models.py:
from django.db import models

# Create your models here.
TITLE_CHOICES = (
    ('Normal', 'Manager'),
)

class Company(models.Model):
    email = models.EmailField()

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)


    class Meta:
        verbose_name_plural = 'Company'



class Person(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField()
    type = models.CharField(max_length=6, choices=TITLE_CHOICES)

    class Meta:
        verbose_name_plural = 'Person'


forms.py:
from django import forms
from .models import Company,Person

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('email',)

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ('type', 'name','email',)

views.py:
from django.shortcuts import render
from .forms import CompanyForm, PersonForm
from django.views.generic  import CreateView

# Create your views here.
def home(request):

    form = CompanyForm()

    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)

        else:
            print('Error form invalid')

    return render(request, 'home.html', {'form':form})

def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMtmBS-LUNiBy-ey%2BrpvB1%3DRPo6n9x3GwuSnOswObBRt2OZK1g%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFFcXKKOB83-%2BLf1wh%2BpcFyhCfptOC62Refy5qAny_PPyQ%2B7eQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re:

Nijo Joseph
In reply to this post by Paras Jain
Or the either way round      instead of form = CompanyForm(request.POST), make it PersonForm(request.POST).

On Fri, 8 Nov 2019, 4:26 pm Paras Jain, <[hidden email]> wrote:
Hy, i am not getting my all fields on the my page which is written inside the forms.py of 'PersonForm'


models.py:
from django.db import models

# Create your models here.
TITLE_CHOICES = (
    ('Normal', 'Manager'),
)

class Company(models.Model):
    email = models.EmailField()

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)


    class Meta:
        verbose_name_plural = 'Company'



class Person(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField()
    type = models.CharField(max_length=6, choices=TITLE_CHOICES)

    class Meta:
        verbose_name_plural = 'Person'


forms.py:
from django import forms
from .models import Company,Person

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('email',)

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ('type', 'name','email',)

views.py:
from django.shortcuts import render
from .forms import CompanyForm, PersonForm
from django.views.generic  import CreateView

# Create your views here.
def home(request):

    form = CompanyForm()

    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)

        else:
            print('Error form invalid')

    return render(request, 'home.html', {'form':form})

def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMtmBS-LUNiBy-ey%2BrpvB1%3DRPo6n9x3GwuSnOswObBRt2OZK1g%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFFcXKLqN1ZUS3ognDyOwRB0drZ6QG667GBYUzCq_W2Xb_Q9xA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re:

Nijo Joseph
In the add function. Sorry for the breaking emails sending from phone.

On Fri, 8 Nov 2019, 8:11 pm Nijo Joseph, <[hidden email]> wrote:
Or the either way round      instead of form = CompanyForm(request.POST), make it PersonForm(request.POST).

On Fri, 8 Nov 2019, 4:26 pm Paras Jain, <[hidden email]> wrote:
Hy, i am not getting my all fields on the my page which is written inside the forms.py of 'PersonForm'


models.py:
from django.db import models

# Create your models here.
TITLE_CHOICES = (
    ('Normal', 'Manager'),
)

class Company(models.Model):
    email = models.EmailField()

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)


    class Meta:
        verbose_name_plural = 'Company'



class Person(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField()
    type = models.CharField(max_length=6, choices=TITLE_CHOICES)

    class Meta:
        verbose_name_plural = 'Person'


forms.py:
from django import forms
from .models import Company,Person

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('email',)

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ('type', 'name','email',)

views.py:
from django.shortcuts import render
from .forms import CompanyForm, PersonForm
from django.views.generic  import CreateView

# Create your views here.
def home(request):

    form = CompanyForm()

    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)

        else:
            print('Error form invalid')

    return render(request, 'home.html', {'form':form})

def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMtmBS-LUNiBy-ey%2BrpvB1%3DRPo6n9x3GwuSnOswObBRt2OZK1g%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFFcXKJvzLA632%2BKp2VvF5TVKJRp1j8iRXoTyjwiWSb8CaeDHw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re:

Paras Jain
no worries but thanks for the solution bro really appreciate it

On Fri, Nov 8, 2019 at 8:14 PM Nijo Joseph <[hidden email]> wrote:
In the add function. Sorry for the breaking emails sending from phone.

On Fri, 8 Nov 2019, 8:11 pm Nijo Joseph, <[hidden email]> wrote:
Or the either way round      instead of form = CompanyForm(request.POST), make it PersonForm(request.POST).

On Fri, 8 Nov 2019, 4:26 pm Paras Jain, <[hidden email]> wrote:
Hy, i am not getting my all fields on the my page which is written inside the forms.py of 'PersonForm'


models.py:
from django.db import models

# Create your models here.
TITLE_CHOICES = (
    ('Normal', 'Manager'),
)

class Company(models.Model):
    email = models.EmailField()

    def __str__(self):                                #will return search add by the user
        return '{}'.format(self.email)


    class Meta:
        verbose_name_plural = 'Company'



class Person(models.Model):
    name = models.CharField(max_length=255)
    email = models.EmailField()
    type = models.CharField(max_length=6, choices=TITLE_CHOICES)

    class Meta:
        verbose_name_plural = 'Person'


forms.py:
from django import forms
from .models import Company,Person

class CompanyForm(forms.ModelForm):
    class Meta:
        model = Company
        fields = ('email',)

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ('type', 'name','email',)

views.py:
from django.shortcuts import render
from .forms import CompanyForm, PersonForm
from django.views.generic  import CreateView

# Create your views here.
def home(request):

    form = CompanyForm()

    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)

        else:
            print('Error form invalid')

    return render(request, 'home.html', {'form':form})

def add(request):

    form= PersonForm()
    if request.method  == "POST":
        form = CompanyForm(request.POST)

        if form.is_valid():
            form.save(commit=True)



    return render(request, 'add.html', {'form':form})

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMtmBS-LUNiBy-ey%2BrpvB1%3DRPo6n9x3GwuSnOswObBRt2OZK1g%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFFcXKJvzLA632%2BKp2VvF5TVKJRp1j8iRXoTyjwiWSb8CaeDHw%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMtmBS8tRF7rsL6O-Bfz7tof9RZXkPzaVje-H-1er1kxBO6exA%40mail.gmail.com.