SuperForm(ProjectForm, TodoForm): pass #stuff peace,
Ryan McIntosh Software Architect PeaceWorks Computer Consulting ph: (204) 480-0314 cell: (204) 770-3682 r...@peaceworks.ca ----- Original Message ----- From: "Harry" <glazed...@gmail.com> To: "Django developers" <django-developers@googlegroups.com> Sent: Friday, 24 September, 2010 10:17:02 GMT -06:00 US/Canada Central Subject: How To Create A Form With Generic Relations In Django Hi, How can I create a Form with normal form elements and generic elements together as ModelForm For using frontend CRUD. For example; Generic Model: class Todo(models.Model): user = models.ForeignKey(User, related_name="todo") title = models.CharField(max_length=100, unique=False) slug = models.SlugField(max_length=50) completed = models.BooleanField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now_add=True) content_type = models.ForeignKey(ContentType, related_name="todos") object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey() And other model: class Project(models.Model): user = models.ForeignKey(User, related_name="project") title = models.CharField(max_length=255, unique=True) slug = models.SlugField(max_length=50) description = models.TextField() active = models.BooleanField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now_add=True) # Generic relation with Todo model todo = generic.GenericRelation(Todo) Forms: Created a formset for making Todo inline for Project and passed formset to form template. But its not merged with ProjectForm when render form. from django.contrib.contenttypes.generic import generic_inlineformset_factory TodoFormSet = generic_inlineformset_factory(Todo, extra=1) formset = TodoFormSet(instance=Project()) Now if I create a ModelForm, for project: (project/create urlpattern, with this i can get ProjectForm to produce form) for todo: (project/todo/create urlpattern, with this i can get TodoForm to produce todo) How to i do ProjectForm inline TodoForm form? and produce new ProjectForm? Thanks. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.