Newbie problem with view/model interaction

2007-03-24 Thread Ross Burton
Hi, (I'm a bit of a newbie to Django so excuse any foolish mistakes) I'm writing a basic paper review system for a conference (Paper is the primary object, with Note and Vote objects having a foreign key to the paper), and currently have it somewhat working. Now my task is to make the list of p

Re: Newbie problem with view/model interaction

2007-03-25 Thread Ross Burton
(re-sending, apologies if this hits the list twice) On Mar 24, 5:27 pm, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote: > What is it you want to do with the ones they've voted on vs. haven't? If > you're going to hide the ones they've already voted on, just write a > query in the view method that only

Re: Newbie problem with view/model interaction

2007-03-26 Thread Ross Burton
On Mar 25, 3:28 pm, "Ross Burton" <[EMAIL PROTECTED]> wrote: > > What is it you want to do with the ones they've voted on vs. haven't? If > > you're going to hide the ones they've already voted on, just write a > > query in the view method th

get_FOO_display and grouped data

2006-12-04 Thread Ross Burton
Hi, I have a model with an integer field that uses choices for display names: class Task(models.Model): PRIORITY_CHOICES = ( ('0', 'Low'), ('1', 'Normal'), ('2', 'High') ) priority = models.IntegerField(choices=PRIORITY_CHOICES) In my view, I'm grouping the d

Re: get_FOO_display and grouped data

2006-12-04 Thread Ross Burton
Jacob Kaplan-Moss wrote: > Try:: > > {% regroup feature.task_set.all|dictsortreversed:"priority" by > get_priority_display as grouped %} > > That is, the "by" argument to {% regroup %} doesn't just have to be a field > name; it can be anything that a variable could resolve. Excellent, thanks. Ro

Read only fields once created

2006-12-05 Thread Ross Burton
Hi, Is it possible to have fields in the model that can be set at object creation, but are immutable after that? I have an "original estimate" field that should only be set when creating the object, and never edited after that. Thanks, Ross --~--~-~--~~~---~--~

Programatic defaults

2006-12-05 Thread Ross Burton
Hi, Is it possible to have programmatic defaults in a model? If I have a many to one relationship between A and B, I'd like A.flob to default to B.flob. Also A.foo should default to B.foo if it isn't specified. Would the best way of doing this be in a custom save() method in the model? Thanks

Re: Read only fields once created

2006-12-07 Thread Ross Burton
MerMer wrote: > You can add "editable=False" to you database model. This prevents it > from showing up in Admin, though of course it can still be edited > directly in the DB. This stops it being set in the admin when creating a new object, which isn't what I want. I think I'll have to hack the