2009/11/29 Kai Timmer <em...@kait.de>:
> Hello,
> I'm new to django, so this question may look a bit stupid, but I
> couldn't find the information in the documentation.
>
> I have a pretty simple model which looks like this:
> class article(models.Model):
>  headline = models.CharField(max_length=140)
>  newsentry = models.TextField()
>  pub_date = models.DateTimeField('date published', null=True,
> blank=True)
>  write_date = models.DateTimeField('started writing')
>  published = models.BooleanField()
>  author = models.CharField(max_length=20)
>
> What i want to do now, is that some of these fields are preset when a
> new article is written. Lets say a user named Peter is going to write
> a new article, then the author field should be preset to "Peter" and
> shouldn't be editable. Same thing for write_date, which should be set
> to the time Peter started to write this article. How do I do this?
>
> Greets,
> Kai
>
> --

Have you tried using fieldsets [1] in you ModelAdmin. Also you can
override save_model method on the ModelAdmin to set values for some
object attributes when the object is being saved [2].

[1] 
http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-form
[2] 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

Davor

--

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