Getting value of field from form.

2008-12-26 Thread evenrik
So I need to display the data for a form field from the post or from the instance if no post. This works but I am hoping there is a better way: {% if form.is_bound %} {{ form.data.foo }} {% else %} {{ form.instance.foo }} {% endif %} Any suggestions? --~--~-~--~~

Re: Preventing saving of objects in admin: how to send message back to the user?

2007-04-23 Thread evenrik
I have a project where I add a message that shows up in the admin interface: user.message_set.create(message="Your message") First you need to get the user using http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser. Hope this helps. Might be better in your case to use the custom validat

Re: can I mimic authenticated user from shell?

2007-03-06 Thread evenrik
I added a method to threadlocals.py that allows me to set the user so I can run code in the shell that depends on get_current_user() returning a user: def set_current_user(user): _thread_locals.user = user This should work for you. On Mar 6, 3:35 am, "Aidas Bendoraitis" <[EMAIL PROTECTED]

Get domain name

2007-02-02 Thread evenrik
I have 2 domain names pointing to the same ip. I need to customize some of the content depending on which domain is used. How do I know in a view which one the user connected with? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the G

Meta.unique_together containing a boolean field.

2006-06-14 Thread evenrik
Has anyone used unique_together with a BooleanField? Does unique_together only work for CharFields? Seems like the add manipulator does not enforce the constraint and the change manipulator raises a ProgrammingError exception: ERROR: operator does not exist: boolean ~~* "unknown" due to the sq

Re: Error creating SQL with string field containing a single quote.

2006-05-06 Thread evenrik
I thought this was created by Django, but on closer inspection it turns out that you are right and it is custom SQL. Thanks for the help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: Error creating SQL with string field containing a single quote.

2006-05-06 Thread evenrik
Here is the snippet of code where the exception is generated by get_object(). This is in a module level function of a model. sql = { 'manufacturer__iexact':post_data.get('manufacturer', None), 'model__iexact':post_data.get('model', None), 'wattage__exac

Error creating SQL with string field containing a single quote.

2006-05-05 Thread evenrik
Using pre magic removal I got this error: Exception Type: ProgrammingError Exception Value:ERROR: unterminated quoted string at or near "'F28T8/841 T8 4'' " at character 419 select count(a.id) from uv2_applications as a inner join uv2_rebatableobjects as r on a.ro_id=r.id inner jo