Syntax for Updating Arbitrary Model Object Fields

2008-04-02 Thread Szaijan
I am having difficulty updating a model object in a view when the field to be updated is determined by the data submitted in the request. For instance, if the model has some arbitrary fields, and the request submitted includes POST data indicating that one of those fields should be updated, what

Re: Syntax for Updating Arbitrary Model Object Fields

2008-04-02 Thread Szaijan
Wow, fast response. Thank you. Unfortunately, the following doesn't work either: setattr(object, fieldName, value) >> doesn't work... I get TypeError: "modelName object is unsubscriptable." Is my syntax incorrect? It seems to be in line with the base Python setattr fn docs. > What you're lo

Re: Syntax for Updating Arbitrary Model Object Fields

2008-04-02 Thread Szaijan
Thank you for the swift reply, Malcolm. setattr(object, fieldName, value) >> doesn't work. I get TypeError: "modelName object is unsubscriptable". Is my syntax incorrect? Does Django overload the Python object setattr fn? > What you're looking for is the setattr() function (it's a built-in).

Re: Syntax for Updating Arbitrary Model Object Fields

2008-04-02 Thread Szaijan
My mistake. setattr(object, fieldName, value) works perfectly. I had a piece of verification code where I had repeated the non-functional object[fieldName] notation and it was giving an identical error. My apologies, and thanks again! This is what comes from working with a Python based framewo

Re: Syntax for Updating Arbitrary Model Object Fields

2008-04-02 Thread Szaijan
A follow on question. In a similar vein, I need to be able to call the object manager on models specified at run time. I figured out how to get this to work for cases where the arguments are empty, thanks to Malcolm's assstance: mgr = getattr(eval(modelName), 'objects'); objs = getattr(mgr, 'a

Re: Syntax for Updating Arbitrary Model Object Fields

2008-04-02 Thread Szaijan
Thanks Alex. I'm not sure why this works for you, but not in my code. The only difference I see is the '**' you have preceding your use of the filter argument. What is the significance of that? The following: ln[1]: filter = {'id__exact':'100'} ln[2]: mgr = getattr(eval(mn), 'objects') ln[3]:

Response JSON Quoting

2008-04-16 Thread Szaijan
I had my first Django app running on the dev server, but in gettting mod-python installed and running I seem to have broken something... or fixed something that was broken before. Previously, when I'd send a response dictionary object from a view, I would include a field called queryJson which he

Re: Response JSON Quoting

2008-04-16 Thread Szaijan
Thanks Justin. Yes, I'm certain. And my previous install was also some variety of 0.96, though I downloaded that one manually. In any case, the " escape outputs to screen just fine, but I get a parse error any time I try to use it in my javascript. It would be nice if there was a built in 'une

Django Registration Error (Does not return from SMTP call)

2008-04-24 Thread Szaijan
I am building my first Django app and trying to incorporate django- registration. Whenever a link gets clicked that calls for sending mail to a user, the page loads continually with no timeout. No errors are generated and no URL info appears in STDOUT or STDERR when running on the dev server. T

Django Registration Error (Does not return from SMTP call)

2008-04-24 Thread Szaijan
I am building my first Django app and trying to incorporate django- registration. Whenever a link gets clicked that calls for sending mail to a user, the page loads continually with no timeout. No errors are generated and no URL info appears in STDOUT or STDERR when running on the dev server. T

Re: Django Registration Error (Does not return from SMTP call)

2008-04-25 Thread Szaijan
Thanks stranger, this is what I tried originally (libgmail and the suggested alteration to django-registration), but got the same behavior. No help there. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django user

Re: Django Registration Error (Does not return from SMTP call)

2008-04-25 Thread Szaijan
Previously, when I'd used libgmail, I got an error, rather than the failure to return behavior I am getting using sendmail. When I comment out the EMAIL settings in settings.py, and using the libgmail fix, I get the following error: error at /visionary/accounts/register/ (49, "Can't assign reque

Template Tags Inside 'ifequals'

2008-04-26 Thread Szaijan
I'm trying to create an ifequals tag in a template to check if request.path equals the URL for a particular view. Either this is not possible, or I just can't find the right syntax. As I haven't been able to find an example via Google, does anyone know hoe to do this correctly? {% ifequals requ

Django Registration URLs

2008-04-28 Thread Szaijan
I am using django_registration as part of my Django web app, visionary. The 'registration' directory is in the same base django directory as 'visionary'. I've imported 'registration/urls.py' into my 'visionary/urls.py' via the line: (r'^visionary/accounts/', include('registration.urls')),

Re: Django Registration Error (Does not return from SMTP call)

2008-04-28 Thread Szaijan
Just as an update, I was told that due to a security change at GMail, libgmail is not currently functional, which certainly matches with my complete inability to get it functioning as an SMTP sever for my django-registration install. Returning to local SMTP, I finally got it functioning on Debian

Re: Template Tags Inside 'ifequals'

2008-04-28 Thread Szaijan
Thanks Malcolm. Is there a way to access the URL values assigned to the view names within a view? Perhaps something less inelegant than importing urls.py and searching for the view name in the tuple? Otherwise I've traded hardcoding URLs into one template for hard coding them into 5+ views. --~

Re: Template Tags Inside 'ifequals'

2008-04-28 Thread Szaijan
Perfect. Thanks guys. While I don't really agree with the philosophy behind purposely limiting the template language, as a rule I prefer to keep as much in the view as possible, so this solution appeals to me. Bottom line, if I weren't using mostly Javascript based, Ajax style updates, I would

Re: Django Registration URLs

2008-04-29 Thread Szaijan
Thanks Nathaniel. Adding the line to my urls.py just before the include works. MJ On Apr 29, 5:00 am, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > On Apr 28, 6:30 pm, Szaijan <[EMAIL PROTECTED]> wrote: > > > The base urls function properly, i.e. /visionary/accounts

SITE_ID Set Incorrectly and Ignored by get_current()

2008-04-29 Thread Szaijan
I'm not quite sure what I'm doing wrong here. Using the Sites framework, I have a site defined in my database with ID = 2. In the manage.py shell, I can get the correct site by setting SITE_ID to '2' or 2, and calling Site.objects.get(id=SITE_ID), but Site.objects.get_current() always returns th

Re: Suggestions on UI (client side web) framework to complement Django

2008-04-29 Thread Szaijan
In searching for a JS toolkit for my first JS app, I found YUI and Dojo to be of equal power and utility, but YUI is MUCH better documented. If you like writing the widgets but need a cross- functional framework to put underneath them, try http://mochikit.com/. Very functional and well documente

Login Redirect Ignored

2008-04-29 Thread Szaijan
I'm using the latest django-registration (svn). When I use the login URL directly, so 'next' is not set, the result of a successful login drops the user to my document root directory. I've checked in shall and LOGIN_REDIRECT_URL is set correctly and being imported correctly, but it is not being

Re: Django, Komodo and Mac OS X

2008-04-29 Thread Szaijan
Hi Rui, I'm using Komodo Edit 4 on Mac OSX 10.5 and code completion works for me in .py files out of the box (just tested it for django.utils.simplejson.) I did nothing to the setup to get this to work. Is it possible your django installation isn't on the python path for the user you're logged

Re: Login Redirect Ignored

2008-04-29 Thread Szaijan
Dead on Karen, thanks. I am transferring the site from my OS X box to a hosting site and was reviewing the wrong template. All is well now. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To po

XHR Request Headers

2008-05-11 Thread Szaijan
I'm rewriting my scratch built Javascript AJAX layer for my Django site using MochiKit, primarily due to cross-browser incompatibility issues. Previously, I would construct a default XHR request, set the headers to "Content-Type":"application/x-www-form-urlencoded" and send it. This worked fine w

Re: XHR Request Headers

2008-05-12 Thread Szaijan
I resolved this by using MochiKit's evalJSONRequest instead of using JS eval on request.response_text. Here's sample code for a MochiKit JS to Django AJAX function: selectEntity : function (entity) { try { var url = '/' + ['visionary', this.model.url ? this.mo

MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Szaijan
Hi, I developed my first Django app on my mapbook using PostgreSQL and have recently moved it to a production site which uses MySQL. PostgreSQL stores boolean values and True and False, just like Python and JS, while MySQL uses 1 and 0. Is there some automated way to get the models to understand

Boolean Values: PostgreSQL vs. MySQL

2008-05-15 Thread Szaijan
Hi, I developed my first Django app on my Macbook Pro using PostgreSQL and have recently moved it to a production site which uses MySQL. PostgreSQL stores boolean values as True and False, just like Python and JS, while MySQL uses 1 and 0. Is there some automated way to get the models to understa

Re: MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Szaijan
I see it in my views. When I return the set and saved values for a model, I get True or False from my app on the MacBook (Postgres) and 1 or 0 from the exact same code on my Slicehost site (MySQL.) So, if I add something like: m = Model.objects.get(id=id) print m.boolean_field_name I get True/

Re: MySQL Boolean vs. PostgresQL Boolean

2008-05-16 Thread Szaijan
Thanks Karen. Actually, the behavior here is worst case, from my perspective, in that Ture/False values will update an instance, but will not be saved and no exception is thrown. When I try to update the model with a True/False value, it simply fails to update without giving any indication of an