Hi

1. When in django.admin I want to pick a source from dropdown list it always 
lists every item as "source object".
How I can modify it so it will show source_name from Source model?

from django.contrib import admin
from news.models import News, Comment, Source

class NewsAdmin(admin.ModelAdmin):
    date_hierarchy = 'date_added'
    list_display = ('date_added',  'title', 'created_by')
    list_display_links = ('date_added', 'title', 'created_by', )
    fields = ['title', 'text', "source",  'created_by']

class SourceAdmin(admin.ModelAdmin):
    list_display = ('source_name', 'source_url')

Models:
class News(models.Model):
    source = models.ForeignKey("Source", related_name="source_name_set", 
blank=True, null=True)

class Source(models.Model):
    source_name = models.CharField(max_length=50)
    source_url = models.URLField("Link")


2. I am having a problem with fieldsets in django admin, second parameter 
"advanced options does not work for any subclass of models.

It always returns me an error: 'NewsAdmin.fieldsets[1][1]['fields']' refers 
to field 't' that is missing from the form.
where field "x" is always the first letter of particural model subclass for 
exmaple "s" - source, "t" title.

fieldsets = (
        (None, {
            'fields': ('text')
        }),
        ('Advanced options', {
            'classes': ('collapse',),
            'fields': ('title')
        }),
    )

3. In list display in admin.model I'd like to view connected data (foreign 
key) from another model.

For example I have a CommentAdmin class and I want to see the title from 
NewsAdmin class and link it to particural news.

I have completely no idea how to do it - I couldn't find any examples in 
django docs

class CommentAdmin(admin.ModelAdmin):
    date_hierarchy = 'date_added'
    list_display = ('id', 'date_added', 'title', )

class NewsAdmin(admin.ModelAdmin):
    date_hierarchy = 'date_added'
    list_display = ('date_added',  'title', 'created_by')
    list_display_links = ('date_added', 'title', 'created_by', )
    fields = ['title', 'text', "source",  'created_by']



Please provide me some hints and help with these 3 issues and I will try to 
resolve the problems :)
I will appreciate it

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/xUCspWwaOmIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to