Hi,

I don't know if this is a bug or expected behavior, but when I'm trying to
create a new generic relation object from a GenericInlineModelAdmin form,
the object's validation methods (eg. clean or validate_unique) don't have
object_id and content_type fields set.

When the generic relation object, already exists object_id and content_type
are properly set.

Here is the sample code:

models.py:
class Article(models.Model):
    title = models.CharField(max_length=32)
    body = models.TextField()

class TaggedItem(models.Model):
    tag = models.SlugField()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

    def clean(self, exclude=None):
        pass

admin.py:
class InlineTags(generic.GenericTabularInline):
    model = TaggedItem

class ArticleAdmin(admin.ModelAdmin):
    inlines = [InlineTags]

admin.site.register(Article, ArticleAdmin)

Now if you go to Articles admin and add a tag, in the clean method of
TaggedItem self.object_id and self.content_type are set to None. If the tag
is being edited they are set accordingly.

I tried on both django 1.4.x and 1.5.x.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to