hi
I have an Entry class that has no title but is to be represented
uniquely by a combination of its category and a datetime value.The
Category  has a name field.I have modelled these like

class MyCategory(models.Model):
        name=models.CharField(max_length=10)
        description=models.TextField(help_text='a description about the
category')
        slug=models.SlugField(unique=True,help_text='will be auto generated
from name')

        class Meta:
                verbose_name_plural="MyCategories"

        def __unicode__(self):
                return self.name

class MyEntry(models.Model):
        posted_time=models.DateTimeField(default=datetime.now)
        category=models.ForeignKey(MyCategory)
        description=models.TextField()
        slug=models.SlugField(unique=True,help_text='will be auto generated
from category and date')

        class Meta:
                verbose_name_plural="MyEntries"

        def __unicode__(self):
                return self.slug

In admin module ,I have created 2 admins

class MyEntryAdmin(admin.ModelAdmin):
        prepopulated_fields= {'slug':['category','posted_time']}
class MyCategoryAdmin(admin.ModelAdmin):
        prepopulated_fields= {'slug':['name']}
        ordering=['name']

admin.site.register(MyEntry,MyEntryAdmin)
admin.site.register(MyCategory,MyCategoryAdmin)


I think there is something wrong with the way I am creating the slug
for MyEntry..It doesn't get created at all..I couldn't figure out how
to do this.I would like to have a slug like
'programming-1010jan21-01-30-56' or similar .Can someone tell me how I
can do this. Without a unique slug to represent an entry ,the admin
interface lists all entries using the same string (MyEntry Object or
something like that)..

thanks
harry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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