On Thu, Jul 9, 2009 at 1:50 PM, jai_python <jayapa...@gmail.com> wrote:

>
> Hie.... I am using formset for edit details belonging to a particular
> ticket. But when I used the below function , I am getting error as
> follows.
>
> Models
> -------------------
> class Ticket(models.Model):
>    ticket_id = models.AutoField("ID", primary_key=True)
>    title = models.CharField("Ticket title", max_length=50)
>
> class Comment(models.Model):
>    ticket_id = models.ForeignKey(Ticket)
>    comment = models.TextField(max_length=500)
>
> class Attachment(models.Model):
>    ticket_id = models.ForeignKey(Ticket)
>    attach_title = models.CharField("Title", max_length=30,
> blank=True, null=True)
>
> Views
> ----------
> def edit(request, ticket_id):
>       ticket = get_object_or_404(Ticket, pk=ticket_id)
>        TickFomset=inlineformset_factory(Ticket,Comment,Attachment)# error
> arise in this line.
>        formset=TickFomset(instance=ticket)
>
> Error:
> ------------
>
> TypeError: metaclass conflict: the metaclass of a derived class must
> be a (non-strict) subclass of the metaclasses of all its bases
>

I don't believe inlineformset_factory supports what you are trying to do
here.  It lets you have a set of (all the same type) of related-instance
model forms appear "inline" with a parent model instance.  You've got two
different types of things you seem to be wanting to display inline with a
Ticket -- both a Comment and an Attachment, and seem to be assuming that
passing Attachment as the 3rd argument to inlineformset_facotry will do what
you want.  But the 3rd argument to inlineformset_factory is expected to be a
ModelForm, not another Model, so things get confused and you get an error.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to