> No, that's they way it is documented as working.  The one-to-one  
> field acts as the primary key for the model, and primary keys can't  
> be edited.  From http://www.djangoproject.com/documentation/model- 
> api/#one-to-one-relationships:
>
> This OneToOneField will actually replace the primary key id field  
> (since one-to-one relations share the same primary key), and will  
> be displayed as a read-only field when you edit an object in the  
> admin interface:
Oh, I definitely missed that :)

But:

now I tried this:

item = models.ForeignKey(Article, edit_inline=models.TABULAR,  
num_in_admin=1, max_num_in_admin=1 )

in HeaderImage. Now each time some field of Article is changed, a  
assigned HeaderImage is deleted.
I doubt, that this is a feature too.
But what is wrong now?

Here my models:

class Article(models.Model):
     title = models.CharField(_("Full Name"), maxlength=255)
     slug = models.SlugField(_("Slug Name"), prepopulate_from= 
("title",), unique=True, help_text=_("This is a short, descriptive  
name of the shirt that will be used in the URL link to this item"))
     text = models.TextField(_("Text of article"),  blank=True,  
null=True)
     category = models.ManyToManyField(Category, filter_interface=True)
     date = models.DateTimeField(auto_now=True)
     from django.contrib.auth.models import User
     owner = models.ForeignKey(User, blank=True, null=True)

class HeaderImage(models.Model):
     """
     A HeaderImage of an Article.
     """
     picture = models.ImageField(null=True, upload_to='./ 
images/',core=True)
     item = models.ForeignKey(Article, edit_inline=models.TABULAR,  
num_in_admin=1, max_num_in_admin=1 )

     def __unicode__(self):
         return self.picture

     def delete(self):
         if not self.picture==None and not self.picture=='':
             basename, format = self.picture.rsplit('.', 1)
             miniature_folder  = os.path.join(s.MEDIA_ROOT, basename 
+'/')

             if os.path.exists(miniature_folder):
                 dir = os.getcwd()
                 os.chdir(miniature_folder)
                 listdir=os.listdir(miniature_folder)
                 for i in listdir:
                     os.remove(i)
                 os.chdir(dir)
                 os.removedirs(miniature_folder)
         super(HeaderImage,self).delete()

     def get_image_url(self):
         return '/'+s.MEDIA_URL+self.picture

     def get_image_path(self):
         return s.MEDIA_ROOT+'/'+self.picture

     class Admin:
         pass
  
        

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to