Customizing form fields display

2009-01-07 Thread sagi s
Can anyone suggest a way to customize model field display? For example if I have a model called Course with fields n_girls and n_students, if for a particular record n_girls = 4 and n_students = 10, I want to display for n_girls: "40% (4)" instead of just "4". Obviously I can do this in the

Re: Your IDE of choice

2009-01-06 Thread sagi s
Pydev works pretty well, including visual debugging of the test server + test suite On Jan 6, 1:48 pm, HB wrote: > Hey, > What is your favorite IDE for coding Django projects? > Any ideas about PyDev and ActiveState Komodo IDE? > Thanks.

Re: Extra attributes in model fields

2009-01-06 Thread sagi s
Any suggestion on how to decorate a model with extra attributes? On Jan 1, 9:39 am, sagi s <sag...@yahoo.com> wrote: > I'd like to store extra attributes in the model fields so I can > control the subsequent field-specific behavior from there. > > Let's say I have a model tha

Extra attributes in model fields

2008-12-31 Thread sagi s
I'd like to store extra attributes in the model fields so I can control the subsequent field-specific behavior from there. Let's say I have a model that stores metrics I then need to chart. In the view, I prefer not to have some logic that says: metrics = Metric.object.all()

Customizing ModelForm fields appearance

2008-12-23 Thread sagi s
I really like the concept of generating a form from a model using ModelForm but would like to customize the apprearance slightly (e.g. size of the TextInput etc.). Any suggestion as to how to do this? I looked at the forms module code but got lost in the maze of the meta programming... Thanks

Using the test client to verify form fields content

2008-12-17 Thread sagi s
I'd like to use the test client to verify that when there's an error in a form field, the input field in the response is populated with the original input. So I'd like to do something like: iteration = 'bad data' response = self.client.post('/metrics/add/', { 'iteration' :

Re: ModelForms customization conundrum

2008-12-17 Thread sagi s
, Sagi On Dec 17, 3:40 pm, sagi s <sag...@yahoo.com> wrote: > On Dec 16, 4:49 pm, "James Bennett" <ubernost...@gmail.com> wrote: > > > On Tue, Dec 16, 2008 at 7:19 AM, sagi s <sag...@yahoo.com> wrote: > > > So I'm looking at the data available i

Re: ModelForms customization conundrum

2008-12-17 Thread sagi s
On Dec 16, 4:49 pm, "James Bennett" <ubernost...@gmail.com> wrote: > On Tue, Dec 16, 2008 at 7:19 AM, sagi s <sag...@yahoo.com> wrote: > > So I'm looking at the data available in the template to try to get my > > hands dirty and restore all this manually

ModelForms customization conundrum

2008-12-16 Thread sagi s
Maybe I'm missing something here but I've been struggling with some basic forms customization issues. I'm using ver. 1.0 I have created a simple model (Metric) and a form to go with it, deriving from django.forms.ModelForm with the model set it the Meta as per the examples. Out-of-the-box the

ifequal template tag quirks

2007-09-09 Thread sagi s
I tried to compare user ids in a template almost exactly like the example in the docs: {% ifequal user_id copy.checkout.user.id %} however, it seems like user_id (a context variable I'm passing) is a string and the other id that comes from the model is a long so the comparison always fails.

newforms.form_for_model() does not map CharField with choices into SELECT

2007-08-27 Thread sagi s
I am generating a form for a model that contains a CharField with choices. According to the documentation I expect to see this translated into a SELECT form field but all I get is a simple TEXT form field: models.py: class Publication(models.Model): PUBLICATION_TYPES = ( ('B',

Django database API - What is it good for?

2007-08-13 Thread sagi s
I've been playing around with Django for a couple of weeks. I'm finding myself spending most of my type tinkering with the Database API to try to wrestle the information I need out of my database. At this point it looks to me like I have replaced one set of incantations (SQL) for another

newforms - form for multiple models

2007-08-10 Thread sagi s
I am trying to create a form for a couple of models: PubForm = forms.form_for_model(Publication) CopyForm = forms.form_for_model(Copy) class PubCopyForm(PubForm, CopyForm): pass I would expect to see a combination of the Copy and Publication fields in the form but I only see

Rails-like Flash in Django

2007-08-10 Thread sagi s
In Rails, flash is a way to display a message in the next page. It is extremely useful to provide lightweight feedback to user operations. For examples when the user, say, submits a new article and after clicking on the "Submit" button, then is redirected to the front page, you want to let him

Re: Including view in a template

2007-08-01 Thread sagi s
k the existing views would just work fine. Regarding custom template tags, I guess I expect many users to want to use django this way, so I think that having a "load_view" template element would be useful. Don't you agree? Cheers, Sagi On Aug 1, 10:29 pm, "James Bennett" <

Re: Including view in a template

2007-08-01 Thread sagi s
se('frontpage_template.html', > {'list_users':list_users,'latest_articles':latest_articles}) > > On Aug 1, 2:34 pm, sagi s <[EMAIL PROTECTED]> wrote: > > > I am trying to find a way to include a view in a template. The view > > generates an html snippet based on a

Including view in a template

2007-08-01 Thread sagi s
I am trying to find a way to include a view in a template. The view generates an html snippet based on a DB query + another template. In pseudocode what I am trying to achieve is: frontpage_template.html: {{% include header.html %}} {{% load /views/list_users %}} {{% load /views/latest_articles

Null=True not respected by admin?

2007-07-22 Thread sagi s
I created a table where some of the fields have null=True since it's okay for them to be empty. Looking at the schema in mysql this option was correctly translated into the DB's schema, however when I try to add an entry via the admin interface I get errors on those fields saying that 'This field