Thursday, October 10, 2019

Re: FK forms in a Single CreateView

What do you want to do... With it...
Use Create it for creating object..


def view() :
model.objects.create()
model2.objects.create()

On Fri, 11 Oct, 2019, 4:33 AM Shazia Nusrat, <shazianusra@gmail.com> wrote:
Again I need to use multiple models in one CreateView. I couldn't make it work by just importing and using it. 
@Suraj can you share an example.

Regards,

Shazia

On Thu, Oct 10, 2019 at 3:27 PM Suraj Thapa FC <surajthapafc@gmail.com> wrote:
Just import and use it.. 

On Thu, 10 Oct, 2019, 10:51 PM Shazia Nusrat, <shazianusra@gmail.com> wrote:
ForeignKey.

On Thu, Oct 10, 2019 at 9:18 AM Mohammad yunus <yunus626@gmail.com> wrote:
What is mean FK Shaziya

On Thu, 10 Oct 2019, 9:19 pm Shazia Nusrat, <shazianusra@gmail.com> wrote:
Hi I have a situation to manage multiple models with FK for a single CreateView. 

Can someone give me a solution for the below.

class Client(models.Model):
     name = models.CharField(max_length=100)
     email = models.EmailField()
     phone = models.CharField(max_length=100)
     business = models.ForeignKey(Business, on_delete=models.CASCADE, related_name = 'user_business')
    contact = models.ForeignKey(Contact, on_delete=models.CASCADE,related_name='client_contact')
class Business(models.Model):
      name= models.CharField(max_length=100)
      #some other fields
class Contact(models.Model):
      #some fields


class ClientCreateView(CreateView):
        # I need help to get related models in create view. Please advise.

Help is much appreciated.

Regards,
Shazia

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD83tOy3%3DfE2ZM18E6MNTLE%2BOdsKY4F_de1rR-TGVsSy3%3DNU6w%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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEQiGcNtQwWgeBLZaLb%3DsToD6QRxFtm3Prv3Q2Lq9XaHONJ_XQ%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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD83tOxDdv7VBGhCJr%2BJ1fs66upZQxmVL6GPPV%2B%2B88v8z5HUGQ%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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPjsHcHf%3Dc4R_ADVn9k%3DJaiLmL-ux2RqOwDMkRfb_9W%3DAqmtew%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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD83tOw64VkK2oFgevxSUuJxVKCN%3D7y4Ke4taGmkS5j63GkqCg%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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPjsHcGruah3b4maP-v1yF8V_TEF0nsrEhx6kAzk81LErA7wGA%40mail.gmail.com.

No comments:

Post a Comment