Re: Strange behavior with ModelForm and saving

2009-06-29 Thread Huuuze
StackOverflow to the rescue: http://stackoverflow.com/questions/1059831/strange-behavior-with-modelform-and-saving On Jun 29, 2:43 pm, Huuuze wrote: > This problem is very strange and I'm hoping someone can help me.  For > the sake of argument, I have a Author model with

Strange behavior with ModelForm and saving

2009-06-29 Thread Huuuze
This problem is very strange and I'm hoping someone can help me. For the sake of argument, I have a Author model with ForeignKey relationship to the Book model. When I display an author, I would like to have a ChoiceField that ONLY displays the books associated with that author. As such, I over

Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Huuuze
Malcolm, I believe you and appreciate your advice, but you need to ease up. You're getting hung up on semantics. In this instance, I'm simply differentiating between a user clicking a link that says "Logout" (a.k.a, a manual logout) versus Django detecting the lack of a session cookie and redire

Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Huuuze
Yes, it does generate new session_id. The user has essentially told Django to expire the session, which in turn results in a new session key. I'm starting to agree with Malcolm. Outside of an elaborate solution, this one may not be possible. As soon as the session expires, Django updates the r

Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-17 Thread Huuuze
on" table. >> However, the records in this table cannot be associated with that user >> because the sessionid value in the cookie is reset when the redirect occurs. >> I'm guessing I'm not the first to encounter this dilemma. Does anyone have >> insight int

Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Huuuze
omething > > terrible with JavaScript.  If not, or you can at least wait a little > > while--run a cron job (every minute, if you'd like) that finds all of > > the sessions that are past their expiration date.  You can log them as > > you'd like, and then clear t

Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Huuuze
Jeff (and Jacob)... I appreciate your responses and I stand corrected. With that being said, are either of you (or anyone reading this) aware of a method that would allow me to track idle session timeouts? I'd like to audit when a user has been logged out due to a timeout. Huuuze On M

Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Huuuze
I opened the following ticket which was unceremoniously closed by a committer: http://code.djangoproject.com/ticket/10518 Here is the text from the ticket: >> I have set the SESSION_COOKIE_AGE value in my settings.py file to expire >> sessions after 1 hour. Django successfully logs the user out

How do I determine when a user has an idle timeout in Django?

2009-03-16 Thread Huuuze
I would like to audit when a user has experienced an idle timeout in my Django application. In other words, if the user's session cookie's expiration date exceeds the SESSION_COOKIE_AGE found in settings.py, the user is redirected to the login page. When that occurs, an audit should also occur. C

SESSION_SAVE_EVERY_REQUEST behavior is overkill

2008-10-03 Thread Huuuze
I recently added "SESSION_SAVE_EVERY_REQUEST". As the name implies, the session ID is changed for every request made to the server. IMO, this is overkill. If your page has 10 images on it, the session ID will be changed 11 times (once for the initial page request and then 10 more times for each

Re: Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Huuuze
There are no tracebacks in this instance. I can see the non-descript 500 errors appearing in my terminal window. On Sep 23, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote: > > > I'm

Why does Django generate HTTP 500 errors for static media when Debug is set to False?

2008-09-23 Thread Huuuze
I'm preparing to deploy my Django app and I noticed that when I change the "DEBUG" setting to False, all references to static files (i.e., JavaScript, CSS, etc..) result in HTTP 500 errors. Any idea what's causing that issue (and how to fix it)? --~--~-~--~~~---~--~--

Re: Odd error when executing "runserver"

2008-09-17 Thread Huuuze
I got it working by using Psycopg 2 Beta 7, rather than Beta 8. You can DL it here: http://www.initd.org/svn/psycopg/psycopg2/tags/2_0_BETA_7/ On Sep 17, 1:02 am, "Whyneedsgoogle2know?" <[EMAIL PROTECTED]> wrote: > Graham Dumpleton wrote: > > On Aug 29, 6:43 am,

Odd error when executing "runserver"

2008-08-28 Thread Huuuze
I recently installed PostgreSQL 8.3.3 and psycopg 2 (latest from SVN). When I attempt to start Django, I receive this error: File "/Library/Python/2.5/site-packages/django/db/backends/ postgresql_psycopg2/base.py", line 20, in raise ImproperlyConfigured("Error loading psycopg2 module: %s" %

Django has "save_model", but what about "delete_model"?

2008-08-19 Thread Huuuze
The latest Django beta added this method to the admin models: >> save_model(self, request, obj, form, change) I have a business case where a "delete_model" method would come in very handy. Does anyone know if this will be included in an upcoming release? If not, here is my dilemma. When an it

Re: Overriding save_add/save_change fails when using NFA?

2008-07-22 Thread Huuuze
I'd appreciate it if someone else chimed in, but it appears as though the HOWTO contains a typo. I've looked at the older versions of Django and the NFA branch and none of them include the "model" parameter in the "save_add" method. Anyone else agree? On J

Overriding save_add/save_change fails when using NFA?

2008-07-22 Thread Huuuze
I am using Django 1.0alpha and I'm attempting to modify the add/change behavior of my ModelAdmin. As such, I'm following this example found on the Django wiki: http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowcanIchangewhereIgetsentaftersavinganewentrytothedatabase Unfortunately, the metho

Re: Strange error in admin interface when adding a new record (core.js and RelatedObjectLookups.js?)

2008-07-15 Thread Huuuze
Disregard. Odd issue with my ADMIN_MEDIA_PREFIX. On Jul 15, 2:13 pm, Huuuze <[EMAIL PROTECTED]> wrote: > When I click the button to add a new Person object (one of my objects, > not the User object) in the admin interface, I receive the following > error in my console wi

Strange error in admin interface when adding a new record (core.js and RelatedObjectLookups.js?)

2008-07-15 Thread Huuuze
When I click the button to add a new Person object (one of my objects, not the User object) in the admin interface, I receive the following error in my console window: ERROR: invalid input syntax for integer: "static_media/admin/js/ core.js" STATEMENT: SELECT "person_person"."id", "person_perso

Re: customizing or extending ModelForm

2008-07-06 Thread Huuuze
n or at > > least the svn trunk. I'm not adding the extra field to the model > > because it doesn't really belong there, though it's related to the > > model. > > > On Jul 3, 6:10 pm, Huuuze <[EMAIL PROTECTED]> wrote: > > > > Yes, you can do

Re: customizing or extending ModelForm

2008-07-03 Thread Huuuze
Yes, you can do that, but you'd need to add it to the ModelForm's fields: >> self.fields['short_name'] = forms.CharField(label='Short Name', max_length=9) This code would need to be added to an overridden __init__ in your ModelForm. One question, however: why don't you add this field to your mo

Re: How do I get the value of a disabled Select widget?

2008-07-02 Thread Huuuze
I figured out the puzzle: self.fields['state'] = forms.CharField(required=False, widget=forms.HiddenInput(), initial=self.instance.state) Still open to feedback since I'm new to Django. On Jul 2, 11:19 am, Huuuze <[EMAIL PROTECTED]> wrote: > I use the following cod

How do I get the value of a disabled Select widget?

2008-07-02 Thread Huuuze
I use the following code to disable a ModelForm field in a custom __init__: self.fields['state'] = USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'', 'tabindex':'-1',}, choices=STATE_CHOICES), required=False) Unfortunately, this presents a problem. When I post the form with

Re: how to get form fields to show

2008-06-26 Thread Huuuze
> urlpatterns = patterns('', >     (r'/step-1.html', 'billpay.views.DoPayDetailForm'), > ) > > Wouldn't this call the dopaydetailform view if you went to  the page / > step-1.html ? It's close. Re-write it as such: > urlpatterns = patterns('', > (r'^step-1.html/$', billpay.views.DoPayDetail

Re: Blank choice for USStateField?

2008-06-26 Thread Huuuze
You da man. That worked perfectly. Just out of curiosity, are the Django devs working on a patch? I wasn't able to find a ticket for this issue. On Jun 26, 12:46 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > On Jun 26, 8:29 am, Huuuze <[EMAIL PROTECTED]> wrote: &g

Blank choice for USStateField?

2008-06-26 Thread Huuuze
I'm using a ModelForm to render a model that contains a USStateField. >> state = models.USStateField(blank=True, null=True) Unfortunately, when it renders, the first selection is always "Alabama" rather than "--" or some other defined blank value (i.e., "Please select a state"). How can I a

Re: How do I save records when using two forms joined by a foreign key?

2008-06-25 Thread Huuuze
data > from the form, but doesn't save it to the db, then you can handle it > like a regular model. > > On Jun 25, 5:04 pm, Huuuze <[EMAIL PROTECTED]> wrote: > > > For the sake of argument, I have two models:  Book and Author.  Book > > has many fields and has a f

Re: How do I save records when using two forms joined by a foreign key?

2008-06-25 Thread Huuuze
ave it to the db, then you can handle it > like a regular model. > > On Jun 25, 5:04 pm, Huuuze <[EMAIL PROTECTED]> wrote: > > > For the sake of argument, I have two models:  Book and Author.  Book > > has many fields and has a foreign key relationship with Author. >

How do I save records when using two forms joined by a foreign key?

2008-06-25 Thread Huuuze
For the sake of argument, I have two models: Book and Author. Book has many fields and has a foreign key relationship with Author. Author has two fields and no additional relationships. To stay DRY, I have BookForm and AuthorForm classes that I use to generate the HTML for each class. When I s

Re: Django inserts an empty string into IntegerField?

2008-06-25 Thread Huuuze
alues. This seems odd. Is that by design with Django? Here is the code from my model for that ultimately gets rendered by my ModelForm: >> middle_name = models.CharField(max_length=30, blank=True, null=True) On Jun 25, 5:02 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote: >

Re: Django inserts an empty string into IntegerField?

2008-06-25 Thread Huuuze
quot; here doesn't seem to work. Any thoughts? On Jun 25, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Wed, Jun 25, 2008 at 4:39 PM, Huuuze <[EMAIL PROTECTED]> wrote: > > > Thanks for getting back to me.  You're correct -- that article is not >

Re: Django inserts an empty string into IntegerField?

2008-06-25 Thread Huuuze
can I go about creating a NullIntegerField? This is new territory for me. On Jun 25, 4:28 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote: > Huuuze wrote: > > I have defined a zip code field as follows in my Address model: > > > zip = models.IntegerField(blank=True, nu

Django inserts an empty string into IntegerField?

2008-06-25 Thread Huuuze
I have defined a zip code field as follows in my Address model: zip = models.IntegerField(blank=True, null=True) Being a good Djangonaut, I'm using a ModelForm to convert my address model into HTML. Now this where things get dicey. As you can see in the model, zip code can except empty values.

Re: How do I add the user ID to a template?

2008-06-24 Thread Huuuze
d to address you by your proper name, but > unfortunately some developer forgot to pass a variable to the template used > to render me!  You should call and complain. > {% endif %} > > :) > -richard > > On 6/24/08, Huuuze <[EMAIL PROTECTED]> wrote: > > > > &g

Re: How do I add the user ID to a template?

2008-06-24 Thread Huuuze
ologize in advance if using RequestContext does resolve this issue -- still learning! On Jun 24, 10:02 am, "Johan Liseborn" <[EMAIL PROTECTED]> wrote: > On Tue, Jun 24, 2008 at 15:47, Huuuze <[EMAIL PROTECTED]> wrote: > > > A n00b question for everyone: My base templ

How do I add the user ID to a template?

2008-06-24 Thread Huuuze
A n00b question for everyone: My base template has a "Welcome " section in it. Currently, I'm adding the username (which is coming from Django's auth/auth framework) to the template with the following bit of code: {{ request.session.user.username }} This works, however, it requires me to add th

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-20 Thread Huuuze
You da man. This worked perfectly out of the box. Thank you! On Jun 19, 5:54 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > On Jun 19, 3:45 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > > >                 if self.instance.state == 'processing': > >                     queryset = q

Re: eclipse + pydev + auto complete

2008-06-19 Thread Huuuze
You're off by one. The value added to the PYTHONPATH (note, not system path) should be: /Library/Python/2.5/site-packages/ That will trigger the auto-complete for django classes. One warning: auto-completion for Model.objects is broken. PyDev will flag that as an error -- the author of PyDev

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Huuuze
In this example, what if you wanted to selectively remove a value from the choice list. For example, let's say the list contained New, In Process, and Closed. When an item is "In Process", it cannot revert back to "New". As such, "New" should not be displayed amongst the choices if "In Process"

Re: Select field not generating with form_for_instance?

2008-06-19 Thread Huuuze
Got it worked out using ModelForms. Version 0.96.2 didn't include any of these slick features. For what its worth, I don't believe it would've ever worked using v0.96.2. On Jun 19, 11:01 am, Huuuze <[EMAIL PROTECTED]> wrote: > On Jun 18, 7:32 pm, "Karen Trac

Re: Select field not generating with form_for_instance?

2008-06-19 Thread Huuuze
One additional note: Can you post the code you used to get it working? On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote: > > > I have the following model: > > >

Re: Select field not generating with form_for_instance?

2008-06-19 Thread Huuuze
On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote: > > > I have the following model: > > > class Publishers(models.Model): > >  books = models.CharField(maxlength=1,

Select field not generating with form_for_instance?

2008-06-18 Thread Huuuze
I have the following model: class Publishers(models.Model): books = models.CharField(maxlength=1, choices=BOOKS) BOOKS is a tuple: BOOKS = ( ('1', 'Book A'), ('2', 'Book B') ) When I use form_for_instance(Publishers) to generate my template's HTML based upon the Publisher model, the books fie

Re: HELP: Foreign keys, models, and querysets

2008-06-09 Thread Huuuze
Its a typo. It should've been... >> pid = models.ForeignKey(Person) On Jun 9, 5:06 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > What is this `pid = models.ForiegnKey()` ? > > On 9 июн, 23:44, Huuuze <[EMAIL PROTECTED]> wrote: > > > I have

HELP: Foreign keys, models, and querysets

2008-06-09 Thread Huuuze
I have the following models in my models.py file: >> class Person(models.Model): >> pid = models.AutoField(primary_key=True) >> fname = models.CharField(max_length=50) >> lname = models.CharField(max_length=50) >> class Books(models.Model) >> bid = models.AutoField(primary_key=True) >>

How do I build a database call using data in HttpRequest?

2008-06-06 Thread Huuuze
I have a method that evaluates the incoming "HttpRequest" from a webpage. As such, I'll use the following call to retrieve the data: >> person_id = request.GET.get('person_id', '') At this point, assuming I have a valid value for "some_id", I'd like to use it in this statement: >> results = Pe

"Includes" directory?

2008-06-02 Thread Huuuze
I'm new to Django, so please be gentle. Basic question: when developing a web app, I've typically created an "includes" directory which stores commonly used functions or methods. From a best practice standpoint, is it recommended that I create an "includes" directory (not application) within my