Hello list members!

Since yesterday I am testing around with Django, and this GREAT tool  
impresses me a lot!

So, I still play with the poll tutorial. I trying to make some  
improvements to it's code, to learn techniques I will use in future  
work.
I.e. I added image-upload. Adding works perfectly, but I wonder how  
to delete an added image. The same question appears for choices.

Here is my polls.py how it looks now:

#polls.py

from django.core import meta

# Create your models here.
from django.core import meta

class Poll(meta.Model):
     question = meta.CharField(maxlength=200)
     pub_date = meta.DateTimeField('date published', auto_now_add=True)
     image = meta.ImageField(
                   'Attach Image',
                   upload_to='.',
                   blank=True
           )

     def was_published_today(self):
         return self.pub_date.date() == datetime.date.today()
     was_published_today.short_description = 'Published today?'

     def __repr__(self):
         return self.question

     class META:
        admin = meta.Admin(
                list_filter = ['pub_date'],
                date_hierarchy = 'pub_date',
                list_display = ('question', 'pub_date', 'was_published_today'),
                fields = (
                        (None, {'fields': ('question',)}),
                        ('Date information', {'fields': ('pub_date',), 
'classes':  
'collapse'}),   
                         ('Images',{'fields':('image',)}),
                ),
                
        )

class Choice(meta.Model):
     poll = meta.ForeignKey(Poll, edit_inline=meta. TABULAR,  
num_in_admin=3)
     choice = meta.CharField(maxlength=200, core=True,blank=True)
     votes = meta.IntegerField(default=10, core=True)

     def __repr__(self):
         return self.choice

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to