FormSets with different, single, ModelChoice's selected

2009-10-24 Thread ty
Hi All, I have a simple model Node defined as such: class Node(models.Model): name = models.CharField(max_length=255, unique=True) description = models.CharField(max_length=255) active = models.BooleanField(default=True) Now I want to create a formset of this form: class NodeSelect

Open uploaded file while still in memory; In the Form Clean method?

2009-03-11 Thread Ty
I need to validate an uploaded XML file in my Form clean method, but I'm unable to open the file for validation. It seams, in the clean method, the file hasn't yet been moved from memory (or the temporary directory) to the destination directory. For example the following code would fail because t

Re: file validation in admin form

2009-03-04 Thread Ty
Perhaps instead of rejecting specific file types, you should only allow specific file types? Most of the time a file upload is taking place the programmer has some sort of idea what the user will upload. This is probably the most secure method, even though it won't work for everyone. On Feb 20, 6

Model and Validation Confusion - Looking for advice.

2009-02-25 Thread Ty
I'm new to Python and Django, and I'd like some advice on how to layout the code I'd like to write. I have the model written that allows a file to be uploaded. In the models save method I'm checking if the file has a specific extension. If it has an XML extension I'm opening the file and grabbing

Re: "SuspiciousOperation" Error While Deleting an Uploaded File

2009-02-20 Thread Ty
Turns out the problem was the FileField value. It can't start with a forward slash, it has to be relative. On Feb 20, 2:28 pm, Ty wrote: > That's the thing... (and I probably should have mentioned this) I'm > developing on Windows XP using the "manage.py runserver&quo

Re: "SuspiciousOperation" Error While Deleting an Uploaded File

2009-02-20 Thread Ty
gt; issue before I set the directory group to be Apache and gave it RWX > privileges > > On Feb 20, 2:21 pm, Ty wrote: > > > When I login to the administration and try to delete a file I get a > > "SuspiciousOperation" error. Here's the traceback:http://dpaste.com

"SuspiciousOperation" Error While Deleting an Uploaded File

2009-02-20 Thread Ty
When I login to the administration and try to delete a file I get a "SuspiciousOperation" error. Here's the traceback: http://dpaste.com/123112/ Here's my full model: http://dpaste.com/hold/123110/ Any help would be appreciated. --~--~-~--~~~---~--~~ You received

Re: Session Variables as Default Form Values

2009-02-02 Thread Ty
Ah, DURR. I just had to put "initial=" before the dictionary. Now it all makes sense! On Feb 2, 9:48 pm, Ty wrote: > Yes, but that would bound the data to the form and the data would try > to be validated on page load. I'm looking to pass default values to an > unbound f

Re: Session Variables as Default Form Values

2009-02-02 Thread Ty
ictionary of the values in your session under some name that you'll > know to use. > > On Fri, Jan 30, 2009 at 5:04 PM, Tyler Brownell > wrote: > >http://groups.google.com/group/django-users/browse_thread/thread/ed74... > > > On Fri, Jan 30, 2009 at 5:03 PM,

Session Variables as Default Form Values

2009-01-30 Thread Ty
I've went through the documentation for "modelforms" and "forms" but I couldn't figure our how someone would set the default value for a form field to a session variable. I have a checkbox in my comment form that says "remember my information". After a comment is submitted and if the checkbox is

Re: Django Forms in HTML 4.01 Strict

2009-01-26 Thread Ty
#x27;ll probably just go that route. On Jan 26, 1:28 pm, "Eduardo O. Padoan" wrote: > On Mon, Jan 26, 2009 at 4:23 PM, Ty wrote: > > > I write HTML 4.01 strict documents and I'm using the django.forms form- > > handling library. > > > Currently when pr

Django Forms in HTML 4.01 Strict

2009-01-26 Thread Ty
I write HTML 4.01 strict documents and I'm using the django.forms form- handling library. Currently when printing input fields on the template, the output includes the ending slash: "". Is there any way, other then manually writing the input field to the template, to get these variables to outpu

Re: Issue with save(commit=False). Can't append primary key.

2009-01-26 Thread Ty
mit=False) > comment.entry = entry <http://entry.id/> > comment.save() > > On Mon, Jan 26, 2009 at 7:28 PM, Ty wrote: > > > Here's a snip of my model: > > > class Comment(models.Model): > >        entry = models.ForeignKey('Entry') &

Issue with save(commit=False). Can't append primary key.

2009-01-26 Thread Ty
Here's a snip of my model: class Comment(models.Model): entry = models.ForeignKey('Entry') name = models.CharField(max_length=100) email = models.EmailField(max_length=200, blank=True) website = models.URLField(verify_exists=True, blank=True) body = models.

Re: Confused with annotate() and filter().

2009-01-20 Thread Ty
@Alex: Nope, that's only pulling back entry's that have approved comments. On Jan 20, 12:43 pm, "alex.gay...@gmail.com" wrote: > On Jan 20, 11:53 am, tlow wrote: > > > > > I think you can not do that with only one query using annotate. > > > You could do it manually in python using the code ab

Re: Confused with annotate() and filter().

2009-01-20 Thread Ty
I'm currently using the extra method (subquery) and it's working perfectly. Thanks for clearing that up for me Thomas. On Jan 20, 11:53 am, tlow wrote: > I think you can not do that with only one query using annotate. > > You could do it manually in python using the code above including the > a

Confused with annotate() and filter().

2009-01-20 Thread Ty
Here are my models: class Entry(models.Model): name = models.CharField(max_length=200, unique=True) date_published = models.DateTimeField() is_published = models.BooleanField(default=False) class Comment(models.Model): entry = models.ForeignKey('Entry') na

Re: Installing the development version of Django on Windows XP - Environment Variable?

2009-01-16 Thread Ty
Thanks for the clarification. On Jan 16, 2:18 pm, Daniel Roseman wrote: > On Jan 16, 7:03 pm, Ty wrote: > > > Follow-up question: > > I have a project that was created using the 1.0.2 version. Is it a > > good idea to basically recreate the project and apps using the n

Re: Installing the development version of Django on Windows XP - Environment Variable?

2009-01-16 Thread Ty
It seams we have posted at almost the same time. Thanks for the reply. On Jan 16, 1:59 pm, Ramiro Morales wrote: > On Fri, Jan 16, 2009 at 4:47 PM, Ty wrote: > > >http://docs.djangoproject.com/en/dev/topics/install/#installing-the-d... > > > I'm currently on a Window

Re: Installing the development version of Django on Windows XP - Environment Variable?

2009-01-16 Thread Ty
method. Follow-up question: I have a project that was created using the 1.0.2 version. Is it a good idea to basically recreate the project and apps using the newest version of the django-admin.py file, and then migrate the code over? I'm assuming so. On Jan 16, 1:47 pm, Ty wrote: > http://d

Installing the development version of Django on Windows XP - Environment Variable?

2009-01-16 Thread Ty
http://docs.djangoproject.com/en/dev/topics/install/#installing-the-development-version I'm currently on a Windows system and stuck on step #3. I have no idea how to continue because I don't know what an "environment variable" actually is and what they do. I've looked into how to create "environ

Re: Extending Admin Interface - Image Manipulation After Upload

2009-01-13 Thread Ty
Thanks for the help, much appreciated. On Jan 13, 1:28 pm, Brian Neal wrote: > On Jan 13, 12:06 pm, Ty wrote: > > > > > I've started creating a photo blog project to get familiar with Python > > and Django. I'm using Python 2.6.1 and Django 1.0.2. I&#

Extending Admin Interface - Image Manipulation After Upload

2009-01-13 Thread Ty
I've started creating a photo blog project to get familiar with Python and Django. I'm using Python 2.6.1 and Django 1.0.2. I'm working on the models and the administration first, before I tackle the front end side of the site. I have everything working fine, for the exception of an image upload f

Get External IP Address

2008-10-17 Thread Ty
I'd like to grab the users external IP address. I'm using it for a spam catching class that I'm porting over to Django/Python. Is this possible? This person outlines how to 'hack' it, but I'd rather not depend on an external site. http://dmiessler.com/blog/how-to-use-python-to-get-your-external-i

Re: Add foreign key name to admin's list_display?

2008-10-17 Thread Ty
Great! Changing the list_display to 'post' and changing the return value of Post's __unicode__ worked perfectly. Thanks for your help! On Oct 17, 4:16 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 17, 2008 at 3:21 PM, Ty <[EMAIL PROTECTE

Add foreign key name to admin's list_display?

2008-10-17 Thread Ty
# admin.py: from django.contrib import admin from clydefrog.blog.models import Post, Comment class PostAdmin(admin.ModelAdmin): list_display = ('name', 'slug', 'date', 'is_published',) list_filter = ('is_published',) ordering = ('is_published', '-date', 'name',) se