Re: override render_to_response

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 20:05 -0400, Malinka Rellikwodahs wrote: [...] > Unless I'm mistaken it should be fairly simple in this case to create > your own set of templates for each of the django apps you're using and > then have them output the data you need as json text instead of as > html Ooh

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

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 12:36 -0700, Huuuze wrote: > 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

Re: override render_to_response

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 18:42 +0200, a b wrote: > Hi, > > I'm building a one page app with no page refresh. > All the content is loaded as JSON dynamically and the UI is built > using javascript. > > I'm using external django apps and I need them to send back the > context dict as JSON instead >

Re: Lookup across relations

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 17:29 +0100, Matías Costa wrote: [...] > > BTW, this is Django 1.0, I had to rename your maxlength field > parameter to max_length. Are you using 0.96? Oh, dear. If the original poster is using 0.96, then this has little chance of working. Complex queries involving

Re: Many to Many is empty when saving parent object

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 08:48 -0700, Brandon Taylor wrote: > Hi everyone, > > I'm running Python 2.6.1, Django Trunk. > > I have a model (Entry) with a ManyToMany (Categories). I need to be > able to iterate over these categories whenever my parent model is > saved. > > I've tried overriding

Re: multiple python versions

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 08:43 -0700, TheIvIaxx wrote: > Hello, on my dev machine I am running a django instance on its little > dev server with python 2.5.2 32bit. Works fine. But all of our tool > are written for python 2.5.x 64bit. These are irrelevant to django. > > Having both python

Re: Verbose Error Logging

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 07:27 -0700, PB wrote: > Hi, > > Is there any way to force tracebacks that are normally swallowed by > the templating engine to be logged to the server's error logs? > It's not possible to tell which errors are intended to be caught and which aren't. Many AttributeError

Re: PositiveIntegerField returning a string?

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 07:06 -0700, msoulier wrote: [...] > The code populating it looks like this > >metrics.user_licenses_ca = int( > details.get('Max_users', '0/0/0').split('/')[2]) > > The Max_users field contains a '/' delimited sting of three numbers, > which is why I'm

Re: ImproperlyConfigured: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1 But I HAVE 1.2.2!

2009-03-15 Thread Malcolm Tredinnick
On Sun, 2009-03-15 at 21:08 -0700, Theme Park Photo, LLC wrote: > I'm getting this message when trying to start Django (from mod_python) > > > (From my apache log) > > [Sun Mar 15 22:07:28 2009] [error] [client 67.188.95.50] PythonHandler > django.core.handlers.modpython: ImproperlyConfigured:

Re: Complex Form Issue with saving only 1 of 4 form items

2009-03-15 Thread Malcolm Tredinnick
On Sun, 2009-03-15 at 18:54 -0700, steven.head...@gmail.com wrote: > Hello, > I am trying to create a complex form similar to the poll example. [...] > This method displays my form correctly, but when I try to save filling > out only 1 of the 4 Choices, I get a required validation error. Is

Re: Overriding django admin functionality

2009-03-15 Thread Malcolm Tredinnick
On Sun, 2009-03-15 at 16:06 -0700, Joshua Partogi wrote: > Thanks Malcolm, > > I'm going to read through the source code and see how I can create a > new template with my custom authorization. So do you reckon that > django admin system is already sufficient not to be overridden? It depends

Re: Overriding django admin functionality

2009-03-15 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 09:40 +1100, Joshua Partogi wrote: > Dear all, > > I need a custom authorization needs for the admin system. I need to > define certain users that is allowed to access certain admin > functionality. I also need to check whether use has logged in or not. > In the end I might

Re: Creating KML files for use in Google Maps

2009-03-15 Thread Malcolm Tredinnick
On Fri, 2009-02-27 at 05:06 -0800, phoebebright wrote: > Took me a long long time to work out why the .kml file I created in > django would parse as valid in Feedburner but googlemaps said it was > an invalid kml file. Need to be sending as correct content-type of > course. [...] > view >

Re: FormSet max_num and extra

2009-03-15 Thread Malcolm Tredinnick
On Sun, 2009-03-15 at 04:25 -0700, Kegan wrote: > I am dealing with formset, and finding the lack of documentation in > understanding it. Hope anyone experienced with formset could help. At some point just opening up the relevant source file is always a good solution. It's only Python code and

Re: Can fields access other field's data before saving to database?

2009-03-14 Thread Malcolm Tredinnick
On Sat, 2009-03-14 at 22:17 -0700, Michael Strickland wrote: > I'm building an app to serve the main pages for each category of a > news site. For this, I need to have several different ways to display > article teasers. For example, in one part of a page I might want to > display the teasers for

Re: Model problem, default not progagating to SQL

2009-03-14 Thread Malcolm Tredinnick
On Sat, 2009-03-14 at 21:51 -0700, kpeters wrote: > default (see active field) does not seem to propagate - see below > (Postgres 8.3.6 - current Django as of yesterday) > > Any ideas? That's normal behaviour; Django has never set up the default value on the database column. There are at least

Re: Can't run django on Apache

2009-03-14 Thread Malcolm Tredinnick
On Sat, 2009-03-14 at 19:52 -0700, Rex wrote: [...] > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE mysite.settings > PythonOption django.root /home/rex/django/mturk *sigh* Will people please stop

Re: http 404 is replaced by http 500----------Django-1.0.2-final

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 21:27 -0700, Flank wrote: > in order to use django/conf/urls/defaults.py, handler404, i did 2 > things: > 1:change DEBUG = False in settings.py > 2:create a 404.html template in the root of the template directory > > > when i request a page that won't find ,such as >

Re: weird behaviour of forms in render_to_response

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 21:08 -0700, ihome wrote: > Hi, > > I am using the latest django development version and have some problem > with the render_to_response to render a template. Here is a short > snippet: > > return render_to_response('index.html', { > 'form': form, >

Re: about checking if CharField value is empty

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 19:29 -0700, Sergio wrote: > > > On Mar 14, 2:23 am, Malcolm Tredinnick <malc...@pointy-stick.com> > wrote: > > Character fields in Django can never be NULL. They will either be empty > > (and stored as '') or not empty, but never stor

Re: about checking if CharField value is empty

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 16:51 -0700, Sergio wrote: > Hello, > > reading from this page: > http://docs.djangoproject.com/en/dev/ref/models/fields/#null > > I understand that, at validation time, I could use (variable is not > None) to verify whether the user did enter characters or not. > >

Re: transaction exceptions

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 13:22 -0700, sieg...@gmail.com wrote: > Hello! > > If I'm using the transaction middleware in a management command and > there is a conflict (e.g. transaction A in process a writes something, > and transaction B in process b overwrites it) does django detect that > and if

Re: Conditional row coloring in django-admin changelist

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 15:39 -0400, Blake M. Sisco wrote: > Here's my problem. I have set up a django app for my company to make > it easier for our warranty manager to track warranties. It's working > great (it's the first thing I've done w/ django and I love it) with > one exception. I have a

Re: Getting multiple values from a QuerySet

2009-03-13 Thread Malcolm Tredinnick
On Fri, 2009-03-13 at 12:02 -0700, Adam Nelson wrote: > If I have a QuerySet like this: > > >>> o1 = Store.objects.all() > >>> for o2 in o1: > ...o2.employees.all() > ... > [, ...] > > > Is there any way to get all employees for all stores without having to > do the for (in other words

Re: efficient Pagination of large queryset

2009-03-13 Thread Malcolm Tredinnick
On Thu, 2009-03-12 at 18:57 -0700, adrian wrote: > > I have users with 30K rows in the database and have to support various > types of queries, some of which > require raw SQL. I used a two-step approach to get the query_set, > first do a raw SQL query to get a list of the ids of the rows I

Re: ManyToMany reverse query

2009-03-12 Thread Malcolm Tredinnick
On Thu, 2009-03-12 at 11:04 +, Andrew Turner wrote: > 2009/3/12 Malcolm Tredinnick <malc...@pointy-stick.com>: > > The second one is close. However, since "user" is a User object, you > > need to be a little more careful in the filter comparison and filter &

Re: ManyToMany reverse query

2009-03-12 Thread Malcolm Tredinnick
On Thu, 2009-03-12 at 10:31 +, Andrew Turner wrote: > Hi, > > I've got a UserProfile model:- > > class UserProfile(models.Model): > user = models.ForeignKey(User, unique=True) > ... > friends = models.ManyToManyField(User, related_name='friend', blank=True) > ... > > I'm

Re: Combine several Forms to one class

2009-03-12 Thread Malcolm Tredinnick
On Thu, 2009-03-12 at 10:57 +0100, Thomas Guettler wrote: > Hi, > > I often have several forms in on tag. Like FormSet, > it would be nice to have a class which combines several forms. > > But FormSet can only deal with several forms of one class. > > This MultiForm class should do this: > >

Re: How can I verify correction of the form with SelectMultiple widget field?

2009-03-12 Thread Malcolm Tredinnick
On Thu, 2009-03-12 at 02:55 -0700, K*K wrote: > I got a strange problem. > > I specify a ChoiceField as SelectMultiple widget but got problem in > validation. > > Can django ChoiceFIeld support valid with a List ? or how can I do > it ? > > The source code is following: > > # Source code of

Re: Basic django snafu from a noob

2009-03-12 Thread Malcolm Tredinnick
On Thu, 2009-03-12 at 01:05 -0700, Steve Chervitz Trutane wrote: [...] > My error goes away when using the official Django release (1.0.2) > rather than the current trunk (r10032). > > As for the backend, I have not altered the settings.py that django- > admin.py startproject created, so my

Re: Django critter helps us code at the speed of light.

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 11:10 -0700, Eric Walstad wrote: [...] > I don't think she realizes it, but Django also helps pay the bills and > puts a smile on her dad's face. > > Now you can have your pony AND a Django Critter: > http://starship.python.net/~ewalstad/django_critter.html Damn. That's

Re: Basic django snafu from a noob

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 14:50 -0700, Steve Chervitz Trutane wrote: > I believe I may have hosed my django installation while I was trying > to get up and running with Pinax. I'm working from the django trunk > (1.1alpha) on linux. Here's what happens now when I try to fire up a > new django

Re: Unknown column in field list

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 13:55 -0700, mike171562 wrote: > Hello, I tried to add a column to one of my models named Ticket. I ran > a syncdb with no errors, but when i load my app I get the following > error. If you change a model that already exists in the database, "syncdb" will not do anything.

Re: Strange behaviour with templates, dictionarys, key/value, tuple as key and nested for loop Bug?

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 02:25 -0700, johan.u...@student.hpi.uni-potsdam.de wrote: > Thanks a lot. I was just blind eyed yesterday I think. Corrected code > is: > > {% for key,value in dictionary.items %} > {{key|date:"Y-m-d"}} > {% for key,value in value.items %} >

Re: Advice on project structure

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 01:01 -0700, Matt Doran wrote: > Hi Malcolm, > > On Mar 8, 4:57 pm, Malcolm Tredinnick <malc...@pointy-stick.com> > wrote: [...] > It seems that by making into a package, it make the django novice feel > like there is more importance to the &qu

Re: Does django support RESTful webservice and JSON encoding/decoding?

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 18:40 +1100, Joshua Partogi wrote: > Dear all, > > Does django support RESTful webservice meaning that I can invoke the > Http method with RESTful URL? Yes, except the question doesn't really make sense as you've written it (you don't invoke an HTTP method). You have full

Re: garbage collection on models after use?

2009-03-11 Thread Malcolm Tredinnick
On Wed, 2009-03-11 at 08:13 +, Crispin Wellington wrote: > Hello, > > I have a surprisingly simple bit of code, injecting data into a database > via django's ORM. The "Hit" table has 1.5 million records. The problem > is, as the loop runs, more and more memory is consumed until my machine >

Re: view help

2009-03-10 Thread Malcolm Tredinnick
On Tue, 2009-03-10 at 21:10 -0700, nixon66 wrote: > I'm trying to filter information for a page by year and can't seem to > get the view to work correctly. The view below should get the list of > counties and years so that I can show detailed information for vendors > by year. The url seems to

Re: Filter ALL requests before dispatching via URLs.py?

2009-03-10 Thread Malcolm Tredinnick
On Tue, 2009-03-10 at 20:18 -0700, Joshua K wrote: > Hello, > > Is there a way to filter all requests before URLS.py dispatches the > request? > > I am developing a Pinax application. I have some custom menu tabs > across the top, and I limit the visibility of those tabs depending on > flags

Re: Different Database object behavior on Production and Development servers.

2009-03-10 Thread Malcolm Tredinnick
On Tue, 2009-03-10 at 04:07 -0700, NoviceSortOf wrote: > Thanks Malcom, > > I re-read the links you sent along on forms and formsets. > > I'm now working with a form but instead of > ___ > > > [ ] Stevenson Collected Works > > > [ ]

Re: re-usable applications

2009-03-10 Thread Malcolm Tredinnick
Hi Robin, On Tue, 2009-03-10 at 10:33 +, Robin Becker wrote: > We're trying to write some re-usable apps, but face some problems when it > comes > to configuring various bits of the application to run together. > > First off it seems reasonable to allow apps to locate their resources

Re: Different Database object behavior on Production and Development servers.

2009-03-10 Thread Malcolm Tredinnick
So this is the first time you've explained the real problem you're trying to solve. It certainly helps explain, a little bit, at least, which direction to point you for solutions. On Tue, 2009-03-10 at 02:28 -0700, NoviceSortOf wrote: > > It's clear now that __str__(self) or __unicode__ >

Re: Formatted currency output question

2009-03-10 Thread Malcolm Tredinnick
On Tue, 2009-03-10 at 02:11 -0700, Joshua Russo wrote: > I found this in my searches for formatting a decimal as a proper > currency output: http://www.djangosnippets.org/snippets/552/ Oh, that's a really bad idea. :-( Calling setlocale() in multi-threaded applications is simply not something

Re: Category / Subcategory / Product

2009-03-10 Thread Malcolm Tredinnick
On Tue, 2009-03-10 at 01:12 -0700, Muslu Yüksektepe wrote: > Hi guys; > I am preparing one project with Django. i need to make one > application. it must be categories. > Like: > > Category1 > ...Subcategory1 > ..Video1 > ..Video2 > ...Subcategory2 > ..Video3 > ..Video4 > >

Re: How to access an element in a list using forloop.counter in django templates?

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 21:47 -0700, Rama Vadakattu wrote: > understood. > > But Malcom, > > 1.i feel doing restructuring of data in views for this purpose is not > appropriate. Then you are free to write a template filter to do what you like. It's probably about three lines long. > 2.And also

Re: Dynamically Changing Cache Settings

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 21:28 -0700, Dave Fowler wrote: > Thanks. So to summarize, > > No one knows of a way to change memcached settings without having to > re-load the django settings They're not intended to be changed like that, which is why you haven't been flooded with answers. Not a matter

Re: How to access an element in a list using forloop.counter in django templates?

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 21:21 -0700, Rama Vadakattu wrote: > I have a list in template. > I need to access that list based on a forloop.counter. > > For example : > > if forloop.counter is 1 then i need to access list[1] > if forloop.counter is 5 then i need to access list[5] > . > so

Re: Saving Deserialized Objects -- Help Needed

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 21:13 -0700, Brian wrote: > I'm having trouble saving deserialied model objects. My setup is that > I have two django instances, let's call them A and B. The intial > request comes into server A which then serializes some objects and > sends them off to server B for the

Re: Does Django 1.1 support mulitple primary_key ?

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 20:45 -0700, K*K wrote: > Let me show you some data in database, you will understand it. No, because that wasn't the question I was asking. I wasn't having problems understanding the models. I was asking why you have to do one query per Plan instance, instead of all

Re: Trouble with accents when passing tranlsated string with newforms

2009-03-09 Thread Malcolm Tredinnick
On Tue, 2009-03-10 at 13:15 +1100, Malcolm Tredinnick wrote: > On Mon, 2009-03-09 at 07:55 -0700, Tipan wrote: > > > > > Do you mean they are inserted into the source as "oacute;" and so > > > the user sees, literally, ""? > > > > >

Re: Does Django 1.1 support mulitple primary_key ?

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 19:22 -0700, K*K wrote: > Are there some other solution of it ? I still don't understand the problem. > > The more than 2000 queries is from the get_latest_text() function, it > will be generate one query each plan. I have more than 2000 plans so > it will generate more

Re: import settings problem

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 07:40 -0700, knight wrote: > Hi, > > I am trying to install django application on CentOS 5 and I'm getting > this error, when I go to the admin page: > > ImportError: Could not import settings 'mx30.settings' (Is it on > sys.path? Does it have syntax errors?): No module

Re: Trouble with accents when passing tranlsated string with newforms

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 07:55 -0700, Tipan wrote: > > > Do you mean they are inserted into the source as "oacute;" and so > > the user sees, literally, ""? > > > > Yes. The string has the html code for the accent as you show above. I showed two possiblities. Which one is it? If the string is

Re: creating a join of 2 models in a view, and accessing such an object collection in a template

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 18:04 -0700, Mario Zorz wrote: > Hi all > > Thanks in advance to whomever reads this :) > > Is it possible in a django view, to take objects from 2 different > models, which are related one to the other through a ForeignKey > (primary key of one model is foreign key in the

Re: Problem with uploading a ImageField through ModelForm

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 13:34 +0100, Marek Wawrzyczek wrote: [..] > When I try to use FileField it works the same. How can I slove this > problem ? You need to add a bit extra to the HTML form when file uploads are involved. Essentially, telling the browser that the response should be encoded

Re: How to get the value of ForeignKey

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 03:54 -0700, guptha wrote: > hi gp, > In models.py > > class BankerCategory(models.Model): > name = models.CharField(max_length=125,unique=True) > > class Banker(models.Model): > bankercategory = models.ForeignKey(BankerCategory) >

Re: Django and SEO activities

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 01:57 -0700, adam.abbo...@gmail.com wrote: > Hi, > > I'm currently looking at developing a major project in Django. I'll be > working with a team (2) developers on the project, however I wanted to > get an idea for how search engine friendly Django is? I'm really not > too

Re: Does Django 1.1 support mulitple primary_key ?

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 02:47 -0700, K*K wrote: > I'm porting a old system to Django architecture. The database schema > can not be modified because the data was existed. The new system will > running with the old system at the beginning but will run standalone > in the future. > > The system have

Re: How to create new User with Profile in elegant way

2009-03-09 Thread Malcolm Tredinnick
On Mon, 2009-03-09 at 01:06 -0700, myst3rious wrote: > > > If you're setting all these things in the User object, then reverse the > > logic slightly: > > > > new_user = User.objects.create(username=username, > > email=email, > > is_active=True, > >

Re: How to create new User with Profile in elegant way

2009-03-09 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 23:30 -0700, myst3rious wrote: > Hi, > Working on a Django app, which requires profile for each subscribing > user, I created a Profile model: > class Profile(models.model): > user = models.ForeignKey(User, unique=True) > middlename = models.CharField(max_length=32,

Re: Creating a multi-column index

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 21:58 -0700, Matt Doran wrote: > Hi there, > > I'm porting another system across to Django, and I need to create a > multi-column unique index. I previously used SQLObject which has a > syntax for doing this. > > I came across this old post that said it wasn't possible

Re: TemplateSyntaxError on unicode strings

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 18:01 -0700, juanefren wrote: > Right I would mean 1.1 alpha. Looking with more details I found that > error only appears when I use my class __str__ method, for example in > my Address Class I have > > class MyClass(models.Model): > string1 =

Re: custom filter question

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 17:37 -0700, danbergan wrote: [...] > > I changed the directory to "ea_app", and changed my settings.configure > to: > settings.configure(DEBUG=True, TEMPLATE_DEBUG=True, TEMPLATE_DIRS=("d:/ > current/ea_app/tpl","c:/python/tpl"), INSTALLED_APPS=("ea",)) The application

Re: Submitting two tables at once

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 17:31 -0700, AlexK wrote: [...] > I've tried implementing your advice, but it gives an error. That nice. Would you like us to just guess what the error is? And maybe guess what the form contains at the same time, since it's no doubt involved in the error? > > Here is the

Re: Submitting two tables at once

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 17:15 -0700, AlexK wrote: [...] > > To make it a bit easier to view the code, i'll use dpaste: > Models > http://dpaste.com/hold/10157/ > Views > http://dpaste.com/hold/10159/ > Template > http://dpaste.com/hold/10160/ That template looks very scary. It would be very

Re: custom filter question

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 16:22 -0700, danbergan wrote: > On Mar 8, 5:13 pm, danbergan <danber...@gmail.com> wrote: > > On Mar 8, 4:53 pm, Malcolm Tredinnick <malc...@pointy-stick.com> > > wrote: > > > > > > > > > On Sun, 2009-03-08 at 14:11 -

Re: Submitting two tables at once

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 14:24 -0700, AlexK wrote: > Hello, > > I'm relatively new to django and i've been trying to figure out this > difficulty for a while now. I have a set of models that interact like > so: > > A has many B. > B has many C. > > I need to be able to submit a new A and a new B

Re: Foreign Key query question

2009-03-08 Thread Malcolm Tredinnick
Take it as given that I agree with the bulk of Daniel's reply. It's correct. I have one quibble, however... On Sun, 2009-03-08 at 10:54 -0700, Daniel Roseman wrote: [...] > What do you mean by 'student=1'? Do you mean 'the student whose pk is > 1'? If so, the correct filter syntax for this on

Re: Trouble with accents when passing tranlsated string with newforms

2009-03-08 Thread Malcolm Tredinnick
On Sun, 2009-03-08 at 04:55 -0700, Tipan wrote: > I'm trying to pass a translated string to a select box using a Forms > Select widget and it always presents the output string with all the > accent HTML entity codes. > > In my models file, I have a range of subjects: > > Models.py > from

Re: Advice on project structure

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 22:59 -0800, Matt Doran wrote: [...] > The whole > "startproject" thing and the default layout feels like it's forcing me > to make decisions that I'm not ready to (i.e. it's on page 1 of the > tutorial). Hmmm. "startproject" doesn't require you to make any decisions at

Re: variable attributes in templates

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 18:54 -0800, only wrote: > Is it possible to use variable attributes in templates, something like > the following (which does not work of course), where form is a > dictionary and attribs is a list of attribute strings? > > {% for attrib in attribs %} > {{attrib}}:

Re: Meta, order_with_respect_to for recursive relation

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 16:37 -0800, NicoEchániz wrote: > Hi, > > I have a model with a recursive relation: > > class Category(models.Model): > name = models.CharField(max_length=100, blank=False, > db_index=True) > parent_category = models.ForeignKey('self', >

Re: How are request.session assignments persisted?

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 13:42 -0800, Rex wrote: > I'm reading the documentation on sessions (http:// > docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs) and > saw the following example: > > def post_comment(request, new_comment): > if request.session.get('has_commented',

Re: Users suddenly becoming inactive?

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 10:12 -0800, jeff wrote: > I'm finding random instances in my application where a new user > registers or an existing user changes their password and then can't > log in the next time because their account is no longer active. It > doesn't happen consistently, which is

Re: Read Only Form Field

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 08:29 -0800, Chris wrote: [..] > Others have posted similar questions in this forum, but it doesn't > look like anyone's found a good solution to this problem. There have been plenty of reasonable solutions posted to the forum. It's close to trivial to write a class to

Re: Django an STI

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 06:50 -0600, Tim Chase wrote: [...] > A slightly less DRY solution than ideal (ideal=solving the VERY > complex STI problem in Django's ORM), Um .. no. That's the one thing that is almost certainly not going to happen. Single-table inheritance --- a.k.a shoving all your

Re: include file, filename itself is variable.

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 00:28 -0800, jago wrote: > Hi, > > I want to include a file using {% include "header.html" %} > > However I want to be able to dynamically use different files then > "header.html" > > Obviously {% include {{ include_filename }} %} does not work. > > Can I make this work

Re: Django an STI

2009-03-07 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 22:09 -0800, Vbabiy wrote: > I know django does not support STI, Based on what follows, I guess you mean "single table inheritance", meaning all columns for all models in the same table. > but I was wondering if there is > any way I can implement this behaviour. > > Here

Re: Django and Python Warnings

2009-03-07 Thread Malcolm Tredinnick
Hi Graham, On Fri, 2009-03-06 at 21:50 -0800, Graham Dumpleton wrote: [...] > I am still toying with whether I add a few things or not. The first of > these is optionally enabled support in daemon mode for X-Sendfile > header where sending of file is actually performed back in main Apache >

Re: Is a Complex filter with __in and __exact possible?

2009-03-06 Thread Malcolm Tredinnick
One day I'll stop posting in this thread. Really. On Sat, 2009-03-07 at 12:03 +1100, Malcolm Tredinnick wrote: > However, find things that are simultaneously in all those categories can > be done without all the annotation nonsense I posted. Simply > > > Publication

Re: translating app name ... again

2009-03-06 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 12:21 +1100, Malcolm Tredinnick wrote: [...] > All of those are bugs (the same bug: not marking app name for > translation). If you'd like to open a ticket and drop in a patch, it's > an more-or-less obviously correct set of changes to make.

Re: How do I model optional Parent/Child relationships, e.g. not all Tasks are related to a Project?

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 15:45 -0800, Doug wrote: > I have 2 related models, Project and Task. > > What's the best way to set up my models so a Task can either be part > of a Project or not? Do I set up a "dummy" Project for Tasks which > aren't related to a specific Project? Or is there a way to

Re: Django and Python Warnings

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 18:12 -0500, Jacob Kaplan-Moss wrote: > On Fri, Mar 6, 2009 at 5:56 PM, Graham Dumpleton > wrote: > > Anyway, the issue is that at the moment mod_wsgi doesn't have an > > equivalent for the command line -W option. Do people feel it would be > >

Re: forms.ModelForm

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 12:25 -0800, mike171562 wrote: > I am using Django's ModelForm in a template im working on. I am trying > to use it to display the Django User Object and an extension I added > of the user model, what would be the correct way to display my User > model extension in my

Re: template include and for loop speed

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 10:51 -0500, Jacob Kaplan-Moss wrote: > On Fri, Mar 6, 2009 at 4:25 AM, Thierry wrote: > > Why is an include tag so much heavier on the template system? > > Because it has to search for the given template on the file system. > Depending on

Re: translating app name ... again

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 07:01 -0800, patrickk wrote: > so, now here´s a little tutorial for translating app-names throughout > the admin-interface: Nice summary. :-) > 3. change app-names in index.html /// on line 18 replace {% blocktrans > with app.name as name %}{{ name }}{% endblocktrans %}

Re: Figuring out what has changed at save()

2009-03-06 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 22:02 -0800, hanks...@gmail.com wrote: > Sorry for the unwieldy title, but nothing else strikes me at the > moment. > > I have a blog app -- a version of basic.blog, actually. There's a > field in the model called "status" with two options: "draft" and > "public." > > What

Re: Cherrypy and view variables caching?

2009-03-06 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 22:42 -0800, John M wrote: > Well, given my example, i would think it does. I'm sorry you think that, but if it was clear to me, I wouldn't have asked the question. At no point in your earlier posts did you show any examples of or mention using generic views. > I put the

Re: Is a Complex filter with __in and __exact possible?

2009-03-06 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 00:11 -0800, Daniel Hepper wrote: > > > Book.objects.filter(Q(categories=1), Q(categories=2), Q(categories=3)) > > > > Not if you were trying to solve the original poster's question. Your > > query is exactly the same as what he tried to do originally. > > I played a bit

Re: manage.py test doesn't run tests

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 19:46 -0800, saeb wrote: > In App1 > import pdb > import unittest > from django.test.client import Client > > class ShortTest(unittest.TestCase): > def add_test(self): > a = 1 > b = 1 > self.assertEqual(a,b) > > > This is my

Re: Django Resource Usage

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 18:08 -0800, Paulo wrote: > Hi > > I want to install Django on my webserver, but i would like to know > from you if django has an intense resource usage (memory, cpu) or it's > not a concern? As always, it depends on what you're doing. There simply *cannot* be any general

Re: Django Pluggable application for invoicing / accounts?

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 16:23 -0800, John Boxall wrote: > Hey everyone, > > I'm building a Django app that charges users monthly and one time > fees. I need to generate invoices and keep track of orders and I most > definitely don't want to write this non-core code myself :) Someone > else must

Re: Optimizing my ORM query

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 18:48 -0500, Jeff Gentry wrote: > Suppose I have three models (in pseudocode): > > class Foo: >asdf = models.CharField() > > class Blah: >qwerty = models.CharField() > > class Bob: >foo = models.ForeignKey(Foo) >blah = models.ForeignKey(Blah) > > Given a

Re: relative url to media dir

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 15:04 -0800, neri...@gmail.com wrote: > Hello, > > How do I keep a relative url to my media directory? The problems with relative URLs is that they have to be relative to *something*. So you could use a relative URL from, say, /foo/bar to /media/ by writing it as

Re: Custom filter() operators

2009-03-05 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 08:00 +0900, Russell Keith-Magee wrote: [...] > However, I agree that this would be a useful feature to add (or > improve). This isn't something we want to be trivial to accomplish, > but it should be a lot easier for people who are adding fields that > have unusual operator

Re: Cherrypy and view variables caching?

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 14:54 -0800, John M wrote: > I'm having a strange problem with running django on a Cherrypy > server. > > in my views.py, I setup a variable called oneweekago, and set it to > today() - (days=7) (it's obviously a date type variable), then in my > query, I ask for all

Re: opposite of icontains

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 12:54 -0800, Jeff FW wrote: > Well, then, that is quite a strange use case :-) Nevermind my simple > methods. Malcom's suggestion of an extension for postgres seems like > a good idea--writing functions in various languages (like Python!) is > _really_ easy in postgres. >

Re: Why django checks whether settings.DATABASE_NAME db actually exists for running testcases?

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 12:54 -0800, madhav wrote: > I will be frequently running testcases for my django project. But one > fine day it occured to me that django actually checks the > settings.DATABASE_NAME db actual existence while running testcases. It happens that the normal startup procedure

Re: how reverse works

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 10:56 -0800, adrian wrote: > > I've had some problems with reverse and have some questions and > thoughts: > > 1. When I add a view and a corresponding entry in urls,py, sometimes I > get a reverse error until I stop the dev server and restart it, even > though nothing is

Re: manage.py test doesn't run tests

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 09:05 -0800, saeb wrote: > My project is divided into 3 apps, and all 3 apps have a "tests.py" > file. When I run manage.py test, none of the tests run. But if I run > manage.py test app1.TestCase1.test1 , it runs fine. For some reason > django is unable to find app tests. I

<    1   2   3   4   5   6   7   8   9   10   >