RE: Multiple form objects, only getting contents from last one

2008-01-22 Thread Chris Brand
I'd start by looking at the HTML that results, particularly the "input name" parts. From your symptoms, it sounds like you may have two (or more) with the same name. Chris > -Original Message- > From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of Tim > Sent:

Re: get choice value in Form

2007-12-07 Thread Chris Brand
> class CustomForm( forms.Form): > age = forms.ChoiceField(label='Age', choices=AGE_CHOICES) > > How can I get the value (not the key) of the age attribute after > validation? > > if f.is_valid(): > cd = f.cleaned_data > > cd['age'] # returns the "key", not the value Once you've saved

Re: newforms ModelChoiceField queryset

2007-11-06 Thread Chris Brand
Gonzalo Delgado wrote: > > The question is: why doesn't something like this work: > > ticketform.fields['server'].queryset = > Server.objects.filter(users=request.user) > ? > It doesn't end up on any error, but the rendered form doesn't filter out the > server choices.. any clue? > >

Re: questions about form_for_model

2007-10-12 Thread Chris Brand
msoulier wrote: > I am using Django stable (0.96). > > When I use form_for_model on a model that includes CharFields that > have choices attributes, the resulting form field is not a ChoiceField > as specified in the documentation. Is this simply a bug in 0.96? > > I think it's this one :

Re: NewForms Choice Field Working ?

2007-10-04 Thread Chris Brand
staff-gmail wrote: > I'm using vers .96 > I converted a char field to have choices > > old: prefix = models.CharField(maxlength=100, default = 'Mr.') > > I then changed my model: > SALUTATION=( > ('Mr.','Mr.'), > ('Ms.','Ms.'), > ) > ... > prefix = models.CharField(maxlength=100,

Re: confused over using ORM in view/template

2007-10-03 Thread Chris Brand
staff-gmail wrote: > Where is "choice_set" coming from ?? That one's easy - http://www.djangoproject.com/documentation/db-api/#backward Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Problem with MultipleChoiceField

2007-10-01 Thread Chris Brand
This behaviour seems odd. Am I doing something wrong, or have I hit a bug ? I'm expecting that changing the choices of f shouldn't affect f2. I'm using 0.96. class MyForm(forms.Form): x = forms.MultipleChoiceField() > f = MyForm() > f2 = MyForm() > f2.as_p() u'X: \n > f.choices =

Re: Multiple Django Projects Under One Directory

2007-09-26 Thread Chris Brand
kidormb wrote: > When I restart Apache2 and invoke an application in mysite, the > response is correct. If I then > invoke an application in testsite, there are errors with the url since > it is apparently still using the > mysite settings. > > I have to restart Apache2 to correctly invoke an

Re: reassessing our Operating System

2007-09-18 Thread Chris Brand
Justin Lilly wrote: > Actually there is a reason why debian based OS's are preferred (in my > opinion). Having installed Django on CentOS, I found that you have to > run two concurrent versions of python. One for the OS and its tools > and one to run django on. (I believe I had to run 2.3 and

Re: Multi-table lookup ... Pt.2

2007-09-11 Thread Chris Brand
dbee wrote: >When the reminders_list in the 'if' statement below gets assigned, >there doesn't seem to be a problem. But when I reference it at the >bottom of the code segment. I end up with the programming error at the >bottom of the page. > > Do you know which line triggers the error ? It's

Re: Multi-table lookup ... ?

2007-09-10 Thread Chris Brand
dbee wrote: >Hmm, I'm not entirely sure where you got the campaign.groups_set >construction there James. There is no campaign.groups_set afaik ... > > > Probably from here : http://djangoproject.com/documentation/db-api/#related-objects Did you try it or just assume that James made a mistake

RE: value for choices arguments for newforms.MultipleSelectField

2007-08-08 Thread Chris Brand
Hi Peter, > What should I pass as a dummy queryset parameter: this is positional > mandatory argument and I cannot pass None. If you're going to replace it before you render the form, it really doesn't matter - any queryset will do. I used .objects.all(), but that has the disadvantage of

RE: value for choices arguments for newforms.MultipleSelectField

2007-08-07 Thread Chris Brand
> def my_view(request): > > class MyForm(forms.Form) > emails = forms.ModelMultipleChoiceField(queryset= > MyDBModel.objects.filter(user=request.user.id) > > > But I'd like to have form declaration out of this view na pass user's > ID as an argument - is there any

RE: Form_for multiple models

2007-07-24 Thread Chris Brand
> You can specify it upon form creation. Here is an example of how you > could use prefixes for multiple model forms: Thanks, Nathan. That's very useful. Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

RE: select_related() bug

2007-07-24 Thread Chris Brand
> Maybe the problem is with the depth parameter, but since I have a self > reference in the offer model, I have to use depth parameter. I have > increased the depth prameter, but I get the same error. Sounds like it could be bug 4789, which I recently tripped over myself. Can you increase the

RE: Form_for multiple models

2007-07-24 Thread Chris Brand
> - When you instantiate your form, pass in prefix='form1' as an > argument - all the fields on the form will get that prefix, which will > keep the two forms distinct in the POST dictionary. This will only be > an issue if there is an overlap in the field names on the two forms, > but it's

RE: is there any host servers that supports Django based sites?

2007-07-16 Thread Chris Brand
> can I run Django-based site on host provider that supports Python but > has NO django installed?? You might find some useful information in this thread : http://groups.google.com/group/django-users/browse_thread/thread/1c67d892907 d1abb/8fd08f175a11ac82?lnk=gst=httpd.conf=1#8fd08f175a11ac82

RE: Template variable when None displays None

2007-07-11 Thread Chris Brand
When a template variable value is None, is it expected to render the word 'None'? I would expect this to fail silently instead of displaying the word. Is there a configuration setting or some way to change the default rendering? Do I have to wrap variables with an {% if ... %} in order to not

RE: Admin module, user account editing and group assignment info

2007-07-04 Thread Chris Brand
> If I open page to edit user's account, at the bottom is multiselect > box containing all existing groups. > > If I select one(s) and save user profile, in DB table > auth_user_grooups I see a correct links between auth_user and > auth_group table. > > But I cannot find the same information in

RE: test client login problems

2007-06-28 Thread Chris Brand
> > Ahhh. So after I've used login() once in a test, get() will pass the > > existing session cookie, in which case my test to retrieve two pages > while > > logged in would look like : > > client.login(...) > > client.get(...) > > Does that sound right ? I'll try that later today. > > Sounds

RE: Method to find the admin url for an object

2007-06-27 Thread Chris Brand
> If you're wanting it for actual inclusion, there's also the edge case > of whether the model's been saved. If not PK is None, and the URL > will be mal-formed. > > I dunno what to do for that corner case. I guess it might make sense to return the "add" url instead, although that makes it

RE: Method to find the admin url for an object

2007-06-27 Thread Chris Brand
> Small tweak to support models which don't use AutoField for primary_key. > > def get_admin_url(self): >pk = getattr(self, self._meta.pk.attname) >return "/admin/%s/%s/%s/" % ( > self._meta.app_label, > self._meta.module_name, > pk) Hmmm. Nice, except that it

Method to find the admin url for an object

2007-06-27 Thread Chris Brand
? Thanks, Chris Brand --~--~-~--~~~---~--~~ 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

RE: test client login problems

2007-06-27 Thread Chris Brand
> > I'm running into problems with the test client's login method. > > Specifically, within a single test method, the first login succeeds but > the > > second one fails. > > Is this something that should work ? Am I doing something wrong ? > > The 'bool object has no attribute status_code'

RE: Beginner: (db) help with assigning unique names to multiple ForeignKeys

2007-06-26 Thread Chris Brand
> I have a "Category" and "Theme" table. Each category can have a number > of themes, and while a theme with the same name can belong to > different categories, more than one theme with the same name shouldn't > belong to the same category. I'm having a hard time figuring out how > to set this up

RE: 'retrieve': the missing permission?

2007-06-22 Thread Chris Brand
> > I just wonder why this permission is not part of the default > > permissions (like add, change and delete)? > > > > David > > > No more thoughts about that? I'm really surprised that it only happens > to me, maybe I will be luckier on the users' mailing-list? Chapter 18 of the Django book

RE: get_absolute_url(), sites and HTTPS

2007-06-21 Thread Chris Brand
> > Is there a way to tell Admin to use HTTPS rather than HTTP for these > links ? > > I guess if you admin site was accessed over https it would work. > Otherwise, no, since it is a relative URL (and then redirected via an > HTTP redirect), so it has to use the same schema (and hostname) as the

RE: get_absolute_url(), sites and HTTPS

2007-06-21 Thread Chris Brand
> But my admin site *is* accessed through https. > The "View on site" button links to a URL like https://[...]/admin/r/11/1/, > but when I click on it, it redirects to http://[...]/[get_absolute_url() > output] I'd guess that it ends up at

get_absolute_url(), sites and HTTPS

2007-06-21 Thread Chris Brand
hich would actually show something. Apart from that one "s", the resulting URL is fine, but it's a pretty important "s". Is there a way to tell Admin to use HTTPS rather than HTTP for these links ? Failing that, is there a way to turn them off (as they don't

test client login problems

2007-06-19 Thread Chris Brand
(r.status_code, 403) AttributeError: 'bool' object has no attribute 'status_code' I can't even see how to work out why it's failing (if I swap the two login calls, it's still the second that fails, BTW). Chris Brand --~--~-~--~~~---~--~~ You received this message because

RE: Providing defaults to models

2007-06-18 Thread Chris Brand
> > class Link(models.Model): > > link = models.URLField() > > user = models.ForeignKey(User, unique=False) > > text = models.TextField(maxlength = 20) > > votes = models.IntegerField() > > > > I want some of the fields to have defaults, like I want votes to have > > a default

RE: Including [django-users] in subject line?

2007-06-11 Thread Chris Brand
Mike Schinkel wrote: > Malcolm Tredinnick wrote: > > Outlook has had rule-based sorting into other mailboxes for a > > while, so I would have thought it was possible to use that. > > It does have that. And I tried that for a while, but found it to be > "out-of-sight, out-of-mind." It's worse

On the subject of error messages...

2007-05-24 Thread Chris Brand
ikely to be available, but I don't know for sure). (For the curious, I'd missed a comma between two parameters where I called render_to_response()). Chris Brand --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

RE: {{ perms }} seems to be empty

2007-05-24 Thread Chris Brand
> I guess you're looking for any permissions that are for the 'lab' app? > > Consider moving this into the view or writing a template tag-- There's > not an easy way to do str.startswith in a template, which is what > you'd need here. I thought you could do {% if perms.lab %} for "any

RE: Displaying my table data

2007-05-23 Thread Chris Brand
> >>> from mysite.rugs.models import Choice, Size, Price > >>> c = Choice.objects.filter(choice=1) > >>> c > [, , ] You can see here that your queryset maps to three objects. > >>> c.size.name > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'QuerySet' object has

RE: Using newforms for multiple db rows

2007-05-14 Thread Chris Brand
> I think if it were me I'd build a form builder function, metaclass, or > do it in __init__. Probably the easiest is passing in an argument to > __init__ , that gives enough information to build the form. That sounds like the kind of thing I'm looking for. Thanks very much once again, Chris

RE: Using newforms for multiple db rows

2007-05-11 Thread Chris Brand
After a few false starts, I managed to get this going. Now my problem is that this approach only really works for Booleans. What if I wanted a form to enter test scores for a class, one score per student ? All my approaches so far have ended up with multiple fields with the same name, which then

RE: Using newforms for multiple db rows

2007-05-04 Thread Chris Brand
> For the attendance form, you might use a MultipleChoiceField > checkboxSelectMultiple widget, where the value of each choice is set > to the pk of the student model. You should get a list of id's that > were checked when the form gets submitted. Thank you very much. Sounds like that approach

Using newforms for multiple db rows

2007-05-03 Thread Chris Brand
having a hard time visualizing it. Thanks in advance for any advice, Chris Brand --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dj

RE: Why are my FloatFields strings ?

2007-05-01 Thread Chris Brand
> What version of Python are you using? I *think* FloatFields are > returned as Python Decimal objects, which don't exist before > Python-2.4, which means you would then get a string from MySQLdb. We > might need a fix for Django on Python-2.3 to work around this. "python -V" reports "Python

Why are my FloatFields strings ?

2007-05-01 Thread Chris Brand
FloatField("Minimum age", max_digits=3, decimal_places=1, default=0, validator_list=[age_validator]) Why is this ? I'm using 0.96 with a MySQL backend. Chris Brand --~--~-~--~~~---~--~~ You received this message because you are subscribed to th

Per-app permissions ?

2007-04-03 Thread Chris Brand
What's the best way to restrict access on a per-app basis ? I want to have two apps, with some users allowed access to one, others allowed access to the other, and some allowed access to both. Any advice would be very much appreciated. Thanks, Chris

Per-app permissions ?

2007-03-14 Thread Chris Brand
What's the best way to restrict access on a per-app basis ? I want to have two apps, with some users allowed access to one, others allowed access to the other, and some allowed access to both. Any advice would be very much appreciated. Thanks, Chris

filter on related fields in admin ?

2007-02-28 Thread Chris Brand
In the Admin subclass of my class, is it possible to follow relations for list_display() and/or list_filter() ? When I'm dealing with applications, it would be nice to be able to filter/sort them by the squadron name of the related cadet, for example. Chris

RE: un-broken order_by (was "Upcoming Django release, and the future")

2007-02-28 Thread Chris Brand
> On 2/27/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > > Please apply & test the patch attached to ticket # 2076 > > But it could be of great help in you situation and it would be great > if you help us by testing it. I will do so, but it's going to be a week or so before I have the time to

RE: un-broken order_by (was "Upcoming Django release, and the future")

2007-02-26 Thread Chris Brand
Having gone on a dot-removal frenzy, I still have this one that fails : >>> from camps import models >>> app_list = models.Application.objects.select_related().order_by('camps_board_time_block .start_time') >>> app_list Traceback (most recent call last): File "", line 1, in ? File

RE: un-broken order_by (was "Upcoming Django release, and the future")

2007-02-26 Thread Chris Brand
> You have an addiction to dots...if you were doing unit tests, > this would be A Good Thing(tm) :) However, in an ORDER BY > clause, not so much. I wouldn't cause it an addiction as such. I may occasionally use them a little more than is good for me...:-) > > IIUC, you need to do a

RE: Upcoming Django release, and the future

2007-02-26 Thread Chris Brand
> Can you create a ticket with this on it so I don't lose track of it? http://code.djangoproject.com/ticket/3587 Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

RE: Upcoming Django release, and the future

2007-02-26 Thread Chris Brand
> > Please do elaborate on this. AFAIK FKs in filter() work just fine, so > > if there's something broken we should know about it right away. > > I found ticket 2076, but that only concerns order_by(). > > I haven't got access to my code at the moment. Ok, I got hold of my code. Of course (I

RE: Upcoming Django release, and the future

2007-02-26 Thread Chris Brand
> I'm not sure how Chris is filtering/ordering, but there are > several ways of specifying fields, depending on the context. In > filtering, one needs to use the double-underscore scheme as in > > Foo.objects.filter(foreignfieldname__foreignfield = 42) > > whereas in ordering, IIRC, you

RE: Upcoming Django release, and the future

2007-02-26 Thread Chris Brand
> Please do elaborate on this. AFAIK FKs in filter() work just fine, so > if there's something broken we should know about it right away. I found ticket 2076, but that only concerns order_by(). I haven't got access to my code at the moment. Chris

RE: Upcoming Django release, and the future

2007-02-26 Thread Chris Brand
> If there's a bug that's been annoying the heck out of you and you want > it fixed before the release, this would be the time to speak up about > it. We have a fairly high concentration of Django developers all in > one place with nothing to do but code, so hopefully we'll be able to > hit a lot

RE: Admin without Auth

2007-02-19 Thread Chris Brand
> I then erase my apps database and run 'manage.py syncdb' Are you aware that you don't have to erase the database before running syncdb ? If you don't erase the db, you won't need to recreate the superuser... Chris --~--~-~--~~~---~--~~ You received this

RE: DATETIME_FORMAT ignored

2007-02-05 Thread Chris Brand
Try {{ object.pub_date|date }} Chris > -Original Message- > From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of Matias > Sent: 4 February 2007 1:50 PM > To: Django users > Subject: DATETIME_FORMAT ignored > > > Hi, > > Hi, > > I'm my settings.py I've added

RE: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread Chris Brand
> > The problem is that it resets when the visitor first comes to the page. > > In other words, when I go to the site first thing in the morning > > last_seen resets to NOW. But that's exactly what your code says : > > l = request.session['last_seen'] > > last = now -l >

Checking for float zero in templates

2007-01-25 Thread Chris Brand
I've got some float fields in my model that default to 0.0. In my templates, it would be nice to use something like the "if" tag to display something like "Not set". I do seem to be able to do this with integer fields that default to zero. Can I do this with a built-in tag ? Chris

Database API blind spot

2007-01-22 Thread Chris Brand
I have the feeling that this is something that should be straightforward, but I can't see how to do it. I have an app with Applications, each of which is for a single Camp. What I want to do is retrieve all the Camps for which there exists an Application. Thanks, Chris

RE: How can I display the user-friendly version of my field with choices ?

2007-01-09 Thread Chris Brand
> Each instance of your model will have a special method name > 'get_foo_display', where 'foo' is the name of the field with the > choices. For example: I should have found that. Thanks. > >>> b.get_kind_display() Presumably I can also use that in a template : {% object.get_kind_display %}

How can I display the user-friendly version of my field with choices ?

2007-01-09 Thread Chris Brand
I have model with field with choices set, similar to that in the documentation at http://www.djangoproject.com/documentation/model_api/#choices In the admin, it displays the current value nicely (the second column), but on my page, it displays the actual value from the database (the first column)

Re: Weird apache problem

2007-01-06 Thread Chris Brand
usually app disappears when some run-time error happends (or when thereare no class Admin: in models.py but I think you did not altered that, right?) It was indeed a run-time error. One of my import statements was missing the project name (i.e. I had "from app.models import..." rather than

Weird apache problem

2007-01-05 Thread Chris Brand
I got apache with mod_python up and running ok. Then I used manage.py reset on one of my apps. Since then, I can't see that app in the Admin page. It was showing up fine before. It also shows up fine if I use the development server. I've restarted apache, my browser and even mysqld, all to

RE: model referencing itself

2007-01-04 Thread Chris Brand
i'm trying to create a model which referencing itself The documentation says : To create a recursive relationship -- an object that has a many-to-one relationship with itself -- use models.ForeignKey('self'). Chris --~--~-~--~~~---~--~~ You received this