Re: ModelForms

2008-06-16 Thread emont88
I've been looking through the ModelForms code and can't really find a way to fix this. I changed the view code to this: print form.category.queryset form.category.queryset = Category.objects.filter(blog__exact=request.user.author_set.all() [0].blog) print form.category.queryset And my console ou

Re: ModelForms

2008-06-16 Thread Jonas Oberschweiber
Hmm, yeah, I guess it should... I don't really know much about the inner workings of ModelForms, but you could try inserting print statements or something the like directly in the django code for testing purposes. Or just look at the django code. That almost always solves the problems I have. On

Re: ModelForms

2008-06-16 Thread emont88
Ok, that makes sense, but I'm still getting weird behavior. Right after I call limit_categories() in my view, I inserted the print statement: "print form.category.queryset" so that I can see the contents of the queryset printed to the console. The result is that the console shows the correct thin

Re: admin-like list views

2008-06-16 Thread Jonas Oberschweiber
Hi, pagination is done by the object_list generic view. You'd have too implement the filter links and search yourself, though. On Mon, Jun 16, 2008 at 11:16 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > hello, > i'd like to have a view with behaves pretty much the same as the list > views

unit testing and comparing dictionaries

2008-06-16 Thread Gene Campbell
Hello Djangonauts I'm a noob on both Django and Python, so this question might be easy for the experts out there. I am trying to do test first development during the development of my model code. (I have lots of experience with test first coding in the Java world, no practical experience in the

Re: ModelForms

2008-06-16 Thread Jonas Oberschweiber
AFAIK querysets are always cached. On Tue, Jun 17, 2008 at 7:06 AM, emont88 <[EMAIL PROTECTED]> wrote: > > I'm running into an interesting problem with ModelForms. > I have a blogging app that handles multiple blogs, which makes things > tricky with categories, because each category needs to belo

ModelForms

2008-06-16 Thread emont88
I'm running into an interesting problem with ModelForms. I have a blogging app that handles multiple blogs, which makes things tricky with categories, because each category needs to belong to a specific blog, so an author editing blog1 should not be allowed to post an Entry to a Category from blog

Re: CMS application: auto-setting the post author

2008-06-16 Thread Ronny Haryanto
On Tue, Jun 17, 2008 at 9:02 AM, saxon75 <[EMAIL PROTECTED]> wrote: > I'm working on a CMS application and had a question about > automatically setting certain model fields. > > Suppose I have the following model (this is simplified from the actual > application): > > class Item(models.Model): >

Re: CMS application: auto-setting the post author

2008-06-16 Thread Ronny Haryanto
On Tue, Jun 17, 2008 at 9:02 AM, saxon75 <[EMAIL PROTECTED]> wrote: > > I'm working on a CMS application and had a question about > automatically setting certain model fields. > > Suppose I have the following model (this is simplified from the actual > application): > > class Item(models.Model): >

Re: Model - Only allow One

2008-06-16 Thread Rishabh Manocha
Why not just override the save method for the model and delete any instances of it before calling super.save(). I'm not a 100% sure on this, but I do think the admin interface calls the model save method whenever you edit something from there. So, something like this: class About(models.Model):

Re: Django comments not showing

2008-06-16 Thread joshuajonah
{% extends "blog/index.html" %} {% load extra %} {% load comments %} {% block title %}{{ object.title|escape }}{% endblock %} {% block content %} {{ object.title }} {% if object.lead_image %}http://joshuajonah.com/ {{ object.lead_image }}" alt="{{ object.title }}" /> {% endif %}

CMS application: auto-setting the post author

2008-06-16 Thread saxon75
I'm working on a CMS application and had a question about automatically setting certain model fields. Suppose I have the following model (this is simplified from the actual application): class Item(models.Model): author = models.ForeignKey(User) created = models.DateTimeField() title

Re: Lighttpd Vs Apache

2008-06-16 Thread Graham Dumpleton
On Jun 16, 11:22 pm, Florian Apolloner <[EMAIL PROTECTED]> wrote: > I would stay with Apache, but I would drop mod_python in favor > ofmod_wsgi[1].Mod_wsgiis pretty cool and written by the same person > as mod_python and should be seen as it's successor. The mod_wsgi code is not written by sam

Django comments not showing

2008-06-16 Thread joshuajonah
I have gone through the steps in: http://code.djangoproject.com/wiki/UsingFreeComment The post form is working as the comments are being added to the database. I forwards to the free_preview.html, and the preview looks fine, however, the comment_list in my template doesn't display anything. Th

Re: newbie: Filter an inclusion tag

2008-06-16 Thread Ned Batchelder
I think this will work: {% filter truncatewords:10 %} {% i18n_attr auction 'description' LANGUAGE_CODE %} {% endfilter %} --Ned. http://nedbatchelder.com pihentagy wrote: > Hi all! > > I have an inclusion tag: > {% i18n_attr auction 'description' LANGUAGE_CODE %} > > I don't know ho

Re: Title: Once again, subclassing User, UserProfile, Multiple User types...

2008-06-16 Thread Etienne Robillard
On Mon, 16 Jun 2008 11:58:48 -0700 (PDT) radioflyer <[EMAIL PROTECTED]> wrote: > > I've spent quite a lot of time reading through information about > extending Django's User model. I've read the arguments about > inheritance vs. user profiles. I've seen some posts in this forum > where the examp

Re: Switched to Python2.5 now PIL has stopped working

2008-06-16 Thread Oscar Carlsson
I installed python + pil + django etc with MacPorts, and I have no problems with PIL, whatsoever. And you get all your custom installs in /opt/local, keeping your OS X installation clean... :) Oscar On Mon, Jun 16, 2008 at 6:50 PM, Jude <[EMAIL PROTECTED]> wrote: > > Thanks, you've been really h

Re: Start server

2008-06-16 Thread Oscar Carlsson
No, you don't have to load everything by hand - there is another way :) http://superjared.com/entry/django-and-crontab-best-friends/ Oscar On Mon, Jun 16, 2008 at 11:33 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > On Mon, Jun 16, 2008 at 3:50 PM, Molly <[EMAIL PROTECTED]> wrote: > >> >> Hey gu

Re: What am I doing that is sooo wrong with newforms??

2008-06-16 Thread [EMAIL PROTECTED]
Whoops, good call Fernando. On Jun 16, 6:04 pm, Fernando Gutierrez <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > You can't assign to the form so your code should look like: > > > if form.is_valid(): > >     c = form.save(commit=False) > >     c.user = request.user > > Since the field

Re: What am I doing that is sooo wrong with newforms??

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 6:49 PM, Richard Green <[EMAIL PROTECTED]> wrote: > > Hi there - has anybody got a simple example of a newform that has a > few fields that are not edited by the user - a simple example is a > "comment" field - > the table looks something like : > > class Comment(models.Mod

Re: What am I doing that is sooo wrong with newforms??

2008-06-16 Thread Fernando Gutierrez
[EMAIL PROTECTED] wrote: > You can't assign to the form so your code should look like: > > if form.is_valid(): > c = form.save(commit=False) > c.user = request.user > Since the field in the model is "commentUser" it should be: c.commentUser = request.user > c.save() > > call

Re: What am I doing that is sooo wrong with newforms??

2008-06-16 Thread [EMAIL PROTECTED]
You can't assign to the form so your code should look like: if form.is_valid(): c = form.save(commit=False) c.user = request.user c.save() calling save on the form with commit=False will create a model object, but won't save it to the db. On Jun 16, 5:55 pm, "Karen Tracey" <[EMAIL P

UnboundLocalError: local variable 'module' referenced before assignment

2008-06-16 Thread kfadratek
Hi. I use Apache2, django 0,96. and I have an errorl please help my to resolve this problem. MOD_PYTHON ERROR ProcessId: 2970 Interpreter:'localhost' ServerName: 'localhost' DocumentRoot: '/home/kfadrat/Katedra' URI:'/' Location: '/' Directory: None Filena

What am I doing that is sooo wrong with newforms??

2008-06-16 Thread Richard Green
Hi there - has anybody got a simple example of a newform that has a few fields that are not edited by the user - a simple example is a "comment" field - the table looks something like : class Comment(models.Model): commentText = models.CharField(max_length=100) commentUser = models.Foreig

Re: Start server

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 3:50 PM, Molly <[EMAIL PROTECTED]> wrote: > > Hey guys, > > I created an app and I am trying to launch the server through my > pyweb.py code since I will eventually, when this gets working be > putting it on a different drive for other computers with different > servers to

admin-like list views

2008-06-16 Thread [EMAIL PROTECTED]
hello, i'd like to have a view with behaves pretty much the same as the list views in the django admin interface. (paginated, with a search field and filter links) the only way i currently see is to (re)implement the whole thing and that does not seem very django-ish to me. i suspect there is some

Re: Model - Only allow One

2008-06-16 Thread Dan Lazewatsky
The way you described has the added advantage of effectively keeping a version history. However, if no one is ever going to use this history it's just a waste of space. There are two other options I can think of, one probably better than the other: 1. Django's cache framework (http://www.djang

Re: Model - Only allow One

2008-06-16 Thread ocgstyles
The client wants certain parts of the site to be editable, I don't particularly agree with the logic, simply because why take a DB hit (although small) just to grab text from a database for an "About" page when that text us USUALLY static. So thinking of this "About" page, maybe the client just t

Start server

2008-06-16 Thread Molly
Hey guys, I created an app and I am trying to launch the server through my pyweb.py code since I will eventually, when this gets working be putting it on a different drive for other computers with different servers to use. My code works, but when i create a py2exe and i run it, i get an error.

Re: variable number of fields in form

2008-06-16 Thread Jim
Thank you both. They both look like they will help me a lot. Jim --~--~-~--~~~---~--~~ 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 unsubscr

Title: Once again, subclassing User, UserProfile, Multiple User types...

2008-06-16 Thread radioflyer
I've spent quite a lot of time reading through information about extending Django's User model. I've read the arguments about inheritance vs. user profiles. I've seen some posts in this forum where the examples even used some of the same model scenarios that I'm working with. Yet still...I need so

Re: newbie: Filter an inclusion tag

2008-06-16 Thread Aaron Fay
Hello, Filter it in your inclusion template, for instance if your tag returns a result from your auction object: def il8n_attr(context, arg, arg2, lang_code): # do you processing return {'result': my_result} register.inclusion_tag('il8n-inclusion.html', takes_context=True)(il8n_attr) #

Re: HTML Escaping JSON data?

2008-06-16 Thread Knifa
I'll try explain a little better, then. I'm trying to make a Quote Database, and trying to make it so switching between pages uses AJAX, loading them without refreshing. I grab the Quote objects and serialize them to JSON so jQuery can read it. Everything works fine, but the the quote field which

Re: HTML Escaping JSON data?

2008-06-16 Thread joshuajonah
Exactly, it sounds like there is a smarter way to do what your attempting here. On Jun 16, 12:59 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote: > What exactly are you trying to do? Are you worried about people entering > html into the form fields and having that saved to the database? If so, > D

Re: HTML Escaping JSON data?

2008-06-16 Thread Richard Dahl
What exactly are you trying to do? Are you worried about people entering html into the form fields and having that saved to the database? If so, Django's ORM escapes this for you when saving to the DB. you can use jQuery's ajax functions to submit the form, and do normal form validation with new

Re: HTML Escaping JSON data?

2008-06-16 Thread joshuajonah
This should work: http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=5015 On Jun 16, 12:26 pm, Knifa <[EMAIL PROTECTED]> wrote: > Err, nevermind that actually. It didn't seem to work. > > By escaping I mean like turning < into > and > into < etc like > the "escape" filter do

Re: Switched to Python2.5 now PIL has stopped working

2008-06-16 Thread Jude
Thanks, you've been really helpful. I followed the instructions on the link provided and although it hasn't fixed it I think I'm a bit closer to solving the problem. As you suggested, it's a jpg issue - there are no problems uploading .gifs I am having trouble importing PIL's _imaging module and

newbie: Filter an inclusion tag

2008-06-16 Thread pihentagy
Hi all! I have an inclusion tag: {% i18n_attr auction 'description' LANGUAGE_CODE %} I don't know how can I filter it with truncatewords. {% i18n_attr auction 'description' LANGUAGE_CODE|truncatewords:10 %} doesn't work. Any ideas? thanks --~--~-~--~~~---~--~~

Re: HTML Escaping JSON data?

2008-06-16 Thread Knifa
Err, nevermind that actually. It didn't seem to work. By escaping I mean like turning < into > and > into < etc like the "escape" filter does. On Jun 16, 5:22 pm, Knifa <[EMAIL PROTECTED]> wrote: > Oh damn, I should have probably looked around a bit more, heh. I'm not > really used to JS yet. >

Re: HTML Escaping JSON data?

2008-06-16 Thread Knifa
Oh damn, I should have probably looked around a bit more, heh. I'm not really used to JS yet. Thanks very much! On Jun 16, 5:09 pm, joshuajonah <[EMAIL PROTECTED]> wrote: > I'm not really catching what you're doing here. You want to escape > html with javascript? Just use escape() > > On Jun 16,

Re: HTML Escaping JSON data?

2008-06-16 Thread joshuajonah
I'm not really catching what you're doing here. You want to escape html with javascript? Just use escape() On Jun 16, 11:31 am, Knifa <[EMAIL PROTECTED]> wrote: > Hello there. > > I'm using Serialization with JSON to pass data to jQuery. Everything > is working fine, except that the data for the

Re: variable number of fields in form

2008-06-16 Thread [EMAIL PROTECTED]
Perhaps this can help: http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/ On Jun 16, 9:42 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Mon, Jun 16, 2008 at 9:41 AM, Jim <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I'm new to Django and apologize

HTML Escaping JSON data?

2008-06-16 Thread Knifa
Hello there. I'm using Serialization with JSON to pass data to jQuery. Everything is working fine, except that the data for the fields of my model are not escaped, allowing people to use HTML on my app. There isn't a function as such in jQuery to do this (and I'm unsure if there is a built in Jav

Re: library import issue.

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 9:19 AM, James Matthews <[EMAIL PROTECTED]> wrote: > Karen > > The library path is in both LD_LIBRARY_PATH and the PYTHONPATH You mean you've specified it in the appropriate config file? Based on the results, though, it doesn't seem to be working. What, exactly, did you

Re: variable number of fields in form

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 9:41 AM, Jim <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm new to Django and apologize if this is a dopey question. I need > to include a field a number of times in a form. For that I see > 'prefix'. But I need the field to appear a variable number of times. > I'm afraid

Re: Switched to Python2.5 now PIL has stopped working

2008-06-16 Thread joshuajonah
Are you testing with jpgs? if so, see the top paragraph here: http://www.agapow.net/programming/python/installing-and-using-pil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

variable number of fields in form

2008-06-16 Thread Jim
Hello, I'm new to Django and apologize if this is a dopey question. I need to include a field a number of times in a form. For that I see 'prefix'. But I need the field to appear a variable number of times. I'm afraid it has me stumped because I'm not sure how to validate, etc. I'd be very gra

Re: Switched to Python2.5 now PIL has stopped working

2008-06-16 Thread Jude
On Jun 16, 2:16 pm, joshuajonah <[EMAIL PROTECTED]> wrote: > Is this a local development installation? Yes. >There were alot of people > having issues with PIL on Mac OSX a while ago. I'm running OS X 10.4. It's strange because there are no problems using Python2.4 on the same machine. I can

Re: Lighttpd Vs Apache

2008-06-16 Thread Florian Apolloner
I would stay with Apache, but I would drop mod_python in favor of mod_wsgi [1]. Mod_wsgi is pretty cool and written by the same person as mod_python and should be seen as it's successor. Btw WSGI is the future for python web dev; so why not use it? There is even a page about Django Integration [2]

Re: library import issue.

2008-06-16 Thread James Matthews
Karen The library path is in both LD_LIBRARY_PATH and the PYTHONPATH On Mon, Jun 16, 2008 at 3:09 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > On Mon, Jun 16, 2008 at 8:48 AM, James Matthews <[EMAIL PROTECTED]> > wrote: > >> Sorry, >> >> I am running Django in a shared hosting environment, Apac

Re: Switched to Python2.5 now PIL has stopped working

2008-06-16 Thread joshuajonah
Is this a local development installation? There were alot of people having issues with PIL on Mac OSX a while ago. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send ema

Switched to Python2.5 now PIL has stopped working

2008-06-16 Thread Jude
I've just upgraded from python 2.4 to 2.5 and reinstalled all the necessary libraries but now PIL seems to have stopped working. When I try to upload images via the admin I get: "Upload a valid image. The file you uploaded was either not an image or a corrupted image." Any ideas where I've gone

Re: library import issue.

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 8:48 AM, James Matthews <[EMAIL PROTECTED]> wrote: > Sorry, > > I am running Django in a shared hosting environment, Apache, Fcgi > Then you need to make sure that whatever modifications you had to make in your user shell environment to get the import to work are also in e

Re: modifying a queryset in a generic view wrapper

2008-06-16 Thread joshuajonah
I resolved this by making a custom filter template. --~--~-~--~~~---~--~~ 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 gro

Re: library import issue.

2008-06-16 Thread James Matthews
Sorry, I am running Django in a shared hosting environment, Apache, Fcgi James On Mon, Jun 16, 2008 at 2:43 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > On Mon, Jun 16, 2008 at 6:07 AM, James Matthews <[EMAIL PROTECTED]> > wrote: > >> Hi, >> >> I am trying to import a library that is in a non-

Re: library import issue.

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 6:07 AM, James Matthews <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to import a library that is in a non-standard location > ~/opt/lib (I am in a shared environment) and i added it to my > "LD_LIBRARY_PATH" however Django tells me it cannot find it and me a 500 > error

Re: library import issue.

2008-06-16 Thread James Matthews
Thank You very much Peter. However this is the output of what you told me to do. And i don't get an import error when i try to import Hdate under the django shell Python 2.5.2 (r252:60911, Mar 30 2008, 02:18:56) [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2 Type "help", "copyright", "credits" or "lice

Re: Django HTML Editor

2008-06-16 Thread Daniel Hepper
There is a Dreamweaver Extension for Django template editing. http://store1.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1557518 Never tried it though, it was mentioned here on the list yesterday. Am Sonntag, den 15.06.2008, 12:36 +0200 schrieb James Matthews: > Th

Re: Trapping template errors

2008-06-16 Thread Russell Keith-Magee
On Mon, Jun 16, 2008 at 5:59 PM, Peter Bengtsson <[EMAIL PROTECTED]> wrote: > > I have TEMPLATE_DEBUG on but if I write:: > > X{{ somethingthatdoesnotexits }}X > > The output is just XX and no error. How can I enable explicit > rendering and raise errors on typos in the templates? Django templat

Trapping template errors

2008-06-16 Thread Peter Bengtsson
I have TEMPLATE_DEBUG on but if I write:: X{{ somethingthatdoesnotexits }}X The output is just XX and no error. How can I enable explicit rendering and raise errors on typos in the templates? --~--~-~--~~~---~--~~ You received this message because you are subsc

Re: library import issue.

2008-06-16 Thread Peter Bengtsson
On Jun 16, 11:07 am, "James Matthews" <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to import a library that is in a non-standard location ~/opt/lib > (I am in a shared environment) and i added it to my "LD_LIBRARY_PATH" > however Django tells me it cannot find it and me a 500 error. > > In p

Tutorial clarification -- Admin look and feel

2008-06-16 Thread Joulupukki Alan
I'm a Django newbie going through the tutorial. I had some difficulty figuring out how to implement custom Admin templates. Having done so, and wishing that this information was in the tutorial, I submit the following. I want to have a copy of base_site.html at each level of the application jus

library import issue.

2008-06-16 Thread James Matthews
Hi, I am trying to import a library that is in a non-standard location ~/opt/lib (I am in a shared environment) and i added it to my "LD_LIBRARY_PATH" however Django tells me it cannot find it and me a 500 error. In python i can import the library but not in Django. I compiled this library using