how to define a User?

2007-08-10 Thread tit4

Hi,

I want to store a User who modify or create the Object:

class Object(models.Model):
...
 user = models.ForeignKey(django.contrib.auth.models.User,
editable=False)
...

the question is: how can I define User who save/create particular
object
inside save() method?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



how to implement image catalog

2007-08-07 Thread tit4

Hi,

I would like to store some image files related to one object.
For example: object "City" can have several pictures
Now I do so:

class ImageCatalog(models.Model):
name = models.CharField(maxlength=255)

class Image(models.Model):
source = models.ImageField(upload_to="...")
catalog = models.ForeignKey(ImageCatalog,
edit_inline=models.TABULAR)

class City(modesl.Model):
...
name = models.CharField(maxlength=255)
images = models.ForeignKey(ImageCatalog)
def save(self):
if (self.id is None):
ic = ImageCatalog(name='[city]%s'%self.name)
ic.save()
self.images = ic
models.Model.save(self)

but a problem in, whether that to add a new file to "City" object I
have to use "ImageCatalog" object.
Is there any other solution, how to manage Images in the same "City"
object form ?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---