Tuesday, January 27, 2015

Re: Django: How to customize the admin form for specific model

Hi,

You could have the images be inline:

class CommentImageInline(models.TabularInline):
    model
= CommentImage
    extra
= 0

class CommentAdmin(models.ModelAdmin):
    inlines
= [CommentImageInline]

Though, you may need to use a custom widget to get the actual images to show up.

Collin

On Saturday, January 24, 2015 at 2:31:02 PM UTC-5, Shoaib Ijaz wrote:

First of all I apologize the question title can be unrelated to my query. I am also confused what I want to do because I am less familiar with django.

I want to create simple comment system. The requirement is clear that user can post comment with multiple images.Every comment should have reply. so I created following models.

#comment table   class Comments(models.Model):      parent = models.ForeignKey('self',null=True) // for comment reply      description = models.TextField(max_length=1000, blank=False, null=False)        class Meta:          db_table = u'comments'      #images table  class CommentImages(models.Model):      comment = models.ForeignKey(Comments)      image = models.CharField(max_length=250, blank=False, null=False)        class Meta:          db_table = u'comments_images'

I have query about admin side how can i manage these things?

I want to show images list when admin view the specific comment.

Admin can view replies of specific comment.

Here i draw the example. enter image description here

So I dont want to ask about coding. I want to know what techniques will be used to change the admin view. I am using admin panel for others models too so I want to change the specific model view.

How can I get these things? Thank you

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c399d663-c514-439d-b7e4-bab765fc6ea4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment