Re: GROUP BY

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 20:20 -0800, Glenn Maynard wrote: > On Jan 26, 10:20 pm, Russell Keith-Magee > wrote: > > I'm a little bit confused as to what you think is happening here - > > what do you mean by "other than a simple column"? The default > > aggregate grouping is effectively by object inst

Re: blob database field

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 20:47 -0700, reed crowe wrote: > I am trying to integrate a web front end to another > application that uses a mysql database. The applications > stores small png graphs as blobs in the database and I > would like to be able to display those in the web front > end. I have

Re: could not able to schedule a standalone python script which uses a django module

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 19:46 -0800, Rama Vadakattu wrote: > i configured the DJANGO_SETTINGS_MODULE in /etc/profile.this means > that it is a system wide environmental variable and can be used every > where. Cron jobs are run in a very limited environment by default, for security reasons. That inc

Re: Embed HTML snippets through django

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 19:27 -0800, DrKayBee wrote: > Hi, > I am creating a small website, where I would like to provide users > with a database field (through admin) where they can enter a link to > their public google calendar (This is an tag). > > Obviously, if I just write it to a django temp

Re: Extending User model

2009-01-26 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 00:11 +0100, Alex Rades wrote: > Hi, > I need to have two sets of users in my application: One is the Person > and the other is the Company. So, I have to decide between going with > the userprofile way or inheriting from User. > > The problem with userprofile is that i can

Re: trouble with yesno to generate images

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 14:52 -0800, Margie wrote: > Thanks very much, autoescape did the trick, here is the result for > anyone interested: > > {% autoescape off %} > {{ task.done|yesno:" \" alt=\"False\" />, \"False\" />" }} > {% endautoescape %} Hmmm ... then that's actu

Re: template: writing "\u20ac 20.000" fails

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 14:40 -0800, SanPy wrote: > For my website, I need to write this in one of my generated html's > (dynamically, of course): > > > var prices=[[0, '\u20ac 0'],[100, '\u20ac 100'],[150, '\u20ac 150'], > [200, '\u20ac 200'],[250, '\u20ac 250'],[300, '\u20ac 300']]; > > > BTW,

Re: Sorting by the human readable options in field provided with choices

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 14:20 -0800, Jeromie wrote: > I have a model with a status field that includes a choices argument to > provide human readable options. Because the options were changing > during development, the values stored in the database are rather > generic - S01, S02, etc. There is one

Re: Finding all Named URLs

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 13:31 -0800, rtelep wrote: > I'm looking for a way to get a list of all named URLs in a given > URLconf, including all "included" URLconfs. > > I have made one, but it's ridiculous. > > The fact that I imagine it makes me believe that it exists: No such method exists in Dj

Re: Django Forms in HTML 4.01 Strict

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 10:35 -0800, Ty wrote: > Thanks for the link. > I'm supprised there nothing "built-in" to allow this. Django's > essentally pushing you to use XHTML over HTML. > > Not really a big deal though, I suppose. Precisely. In XHTML, validity errors must be handled by not parsing

Re: Django unittest fails to check empty values

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 03:25 -0800, marco sedda wrote: > Hi, I've a problem with unittest in django: > > I've described a models.py: > > class Season(models.Model): > name = models.CharField(max_length=30, unique=True) > startDate = models.DateField("From") > endDate =

Re: How to extend queryset iterator?

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 07:59 -0800, Enrico wrote: > I would like to track which items are being loaded in a queryset, > without having to loop through the entire list. > > I think the best way would be to extend the Queryset object, probably > the "__iter__" or "iterator" methods... > > But I don

Re: Target anchor on div's id (/account/#divid ) + Redirection after a POST = ascii encode problem

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 07:13 -0500, Steve Holden wrote: [...] > Quick unrelated nit: you don't actually need to create a dict here, as > dict.update takes keyword arguments. So you can just say > > locals_dict.update(model=model, action=action) Providing you're using Python 2.4 or later. W

Re: Target anchor on div's id (/account/#divid ) + Redirection after a POST = ascii encode problem

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 00:10 -0800, Seth Kaïne wrote: > Here's my problem. I want to redirect my urls by the name of its > model, like this: > urls.py: > > > (r'^(?P\w+)/$', 'urlCatcher'), > (r'^(?P\w+)/(?P\w+)/$', 'urlCatcher'), > (r'^(?P\w+)/(?P\w+)/(?P\w+)/$', > 'ur

Re: Queryset unexpectedly turning into list

2009-01-26 Thread Malcolm Tredinnick
On Sat, 2009-01-24 at 19:57 -0800, mb0...@googlemail.com wrote: > Ah, ok thanks for the explanation :) Alex's explanation is correct (as his explanations tend to be). I just wanted to add some extra thoughts to that... "Normally" (which might well mean "hopefully") it shouldn't matter whether yo

Re: Use _meta.fields to return the datatype

2009-01-26 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 21:48 -0800, dj wrote: > It would appear there is method called get_internal_type() that maybe > what I am looking for. > The method is in django.db.models.Field. But I am unable to find > anything that would tell > me how to use the function to return the data type for a fie

Re: InternalError and transactions

2009-01-26 Thread Malcolm Tredinnick
On Sat, 2009-01-24 at 11:56 -0800, Rob Hudson wrote: [...] > Based on what you describe above, it sounds preferable to let Django > handle the unique_together on is_valid(), but I don't think I can do > that since I need to attach the user to the form later since I don't > know it until the reque

Re: Formset for user-specific data

2009-01-26 Thread Malcolm Tredinnick
On Sat, 2009-01-24 at 21:08 +0200, Roman Odaisky wrote: > Greetings, > > In a Web app, users can create categories for their data. Categories are > stored in a model as (PK, user, name, description). I want users to be able > to edit categories that belong to them using a formset. To display a

Re: Multiple static media roots?

2009-01-26 Thread Malcolm Tredinnick
On Sat, 2009-01-24 at 10:09 -0800, John Baker wrote: > OK thanks and yes it does but that's half the story. I haven't made > myself very clear. The ImageField still tries to append /media/ to the > image upload_to path rather than /uploads/ which would retrieve them > from the dynamic media root r

Re: Last-Modified headers and render_to_response

2009-01-26 Thread Malcolm Tredinnick
On Sat, 2009-01-24 at 18:24 +0100, Viktor Nagy wrote: > Hi, > > I would like to provide proper Last-Modified headers, but in general > my code uses the render_to_response shortcut. As far as I understand > the code, even though I can add a **kwargs argument to > render_to_response, it won't get

Re: Getting Logged in User with Test Client

2009-01-26 Thread Malcolm Tredinnick
On Sat, 2009-01-24 at 12:14 -0500, Vitaly Babiy wrote: > Yes either way would work I was just wondering if there was a more > cleaner way of doing so. Then you're going to have to define what "cleaner" means from your persepctive. What could be cleaner that simply get()-ing the right model based

Re: Related Field has invalid lookup error

2009-01-26 Thread Malcolm Tredinnick
Hey Derek, On Sat, 2009-01-24 at 04:58 -0800, dwil...@gmail.com wrote: > Ramiro, > > Thanks very much - I knew I must have been overlooking something. > Adding __exact did the trick nicely. If you want to open a ticket about that, it might be worth us taking another look at the error reporting.

Re: Style Question: Template tag or include?

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 16:26 -0800, Brian Neal wrote: > I have an object that I display on multiple pages. Initially I created > a little template .html file for it, and I simply > > {% include 'my_object.hml' %} > > every where I need it. > > I have since discovered inclusion tags. Would it be

Re: ImageField image upload problems

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 15:47 -0800, Foxpl wrote: > Hi, i have errors while i am trying to upload image by an admin panel. > > Here is my image model: > > class Photo(models.Model): > Title = models.CharField(max_length=256) > Description = models.TextField(max_length=1024, blank=True) >

Re: API mismatch bug with CursorDebugWrapper?

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 14:39 -0800, Nathaniel Whiteinge wrote: > Requesting a sanity check before I file a ticket. > > The API for directly accessing a database cursor() changes depending > on if DEBUG is True or False. (Excepting execute() and executemany().) > > This shell session spells it out

Re: ImageField, width_field, height_field not working

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 15:19 -0800, Andrew Ingram wrote: > I reverted Django to revision 9756 (just after aggregation was merged > in) and everyone works fine, so evidently a commit made in the last > few days has caused this issue. So the next thing is to narrow down which commit. You know a good

Re: Reverse match Exception on password_reset_confirm

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 22:44 +0200, Oleg Oltar wrote: > Hi! > > > I am trying to add password reset function to my application. > But when I am trying to process the email with confirmation link: > > > code: > # Password resend group > >

Re: Testing uploads and content types

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 12:15 -0800, Julien Phalip wrote: > On Jan 24, 2:45 am, varikin wrote: > > The UploadedFile[1] object has a field called content_type. So if you > > have this in a form: > > > > myfile = request.FILES['some_file'] > > if myfile.content_type != 'application/zip': > > #ra

Re: TypeError: 'tuple' object is not callable

2009-01-23 Thread Malcolm Tredinnick
On Fri, 2009-01-23 at 23:37 +1300, joti chand wrote: > Hi Guys, I was doing to the tutorials from the book: Teach yourself > django in 24 hours and Part1 hour 3 ...to view the admin site it is > giving the following error. That book was published before Django 1.0 was released and, in particular,

Re: Disabling middleware for tests

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 15:17 -0800, davenaff wrote: > What is the best way to disable a specific middleware when running > django tests? > > This ticket was designated wontfix, so I get test failures on the auth > tests every time I run our test suite: > http://code.djangoproject.com/ticket/9172#c

Re: mod python child server won't start

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 12:01 -0800, May wrote: > Hello, > > I set up a windows XP(python 2.5, apache 2.2) startproject called > myprograms and used this code in http.conf (this works and server > starts): > > SetHandler python-program > PythonPath "['C:/django'] + sys.pat" If this is a cut and p

Re: Convert iso-8859-1 queryset to utf-8

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 06:16 -0800, Polat Tuzla wrote: > You may also want to make sure that you know whether your Flash/ > ActionScript components require UTF-8 with BOM (Byte-order Mark) or > not. > > Let me try to explain more clearly: > In my case, I had i18n problems when a flash component re

Re: why not load the index first?

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 19:46 +0530, Kenneth Gonsalves wrote: > On Thursday 22 Jan 2009 7:31:07 pm Malcolm Tredinnick wrote: > > But please do understand that this isn't a > > change that is necessarily universally better for everybody. It does > > harm the content

Re: run function on session.flush()

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 11:55 -0800, Abe wrote: > I would like to run a function (in my case, send an email summarizing > recent activity) when a user logs out *or* when their session > expires. Is there an easy way to do it without making a new version > of the Session class? No. Regards, Malcol

Re: why not load the index first?

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 19:17 +0530, Kenneth Gonsalves wrote: > On Thursday 22 Jan 2009 6:48:11 pm Malcolm Tredinnick wrote: > > I think you have not described whatever problem it is that you're trying > > to solve particularly well. "Index" has at least three

Re: How to send custom value to the SelectMultiple Widget

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 04:58 -0800, Lee wrote: > Thanks a lot. > > I'd like to pass the dynamic value to the choices, like what you said > in the last situation. > > Could you please give me some more instructions, I'm new in python and > django. I've given you a code fragment already to show ho

Re: why not load the index first?

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 18:31 +0530, Kenneth Gonsalves wrote: > hi, > > wrt django documentation, why not load the index first - on the left? Do you mean the thing labelled as "general index"? It would use up valuable horizontal screen real-estate without adding a lot of value. On every single pag

Re: How to send custom value to the SelectMultiple Widget

2009-01-22 Thread Malcolm Tredinnick
On Thu, 2009-01-22 at 03:54 -0800, Lee wrote: > Hi, Malcolm > > Thanks for you reply. However, I'm still not clear. > > My code is : > > from django import forms > > class TestForm(forms.Form): > title = forms.CharField( max_length=10 ) > selection = forms.CharField( widget=forms.Select )

Re: Port large webapp from PHP to Django: tips, experiences, links needed

2009-01-22 Thread Malcolm Tredinnick
This is a pretty good response. There are a couple of points where a different point of view might be interesting, however. I've added some extra things, below. On Thu, 2009-01-22 at 01:06 -0800, Webchemist wrote: > This is exactly my situation, when I started to work under drugme.ru - > this is

Re: How to send custom value to the SelectMultiple Widget

2009-01-22 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 21:41 -0800, Lee wrote: > Hi, everyone. > > I have some trouble in SelectMultiple Widget. The detailed information > is that: > > In the form.py, I have defined a TestForm which contain a > SelectMultiple Widget called selection > > #form.py > class TestForm(forms.Form): >

Re: Need help changing the ordering of a queryset stored in session

2009-01-22 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 21:40 -0800, Brandon Taylor wrote: > Hi everyone, > > I need to do some table sorting and paging. To reduce trips to the DB, > I'm storing my initial queryset in a session using the file system > backend for local development. > > I was thinking I might be able to use the d

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-22 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 19:38 -0800, Keyton Weissinger wrote: > OK. I figured it out and it was VERY STRANGE. Maybe some one reading > this can tell me WWWHHHYYY my solution works. For now, it's voodoo to > me... You're going to kick yourself after this. The reason for the failure turns out to be r

Re: RESTful PUT request

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 16:47 -0800, junker37 wrote: > Thanks, I see the request.raw_post_data now in my middleware class, > however, that request never gets to my view, but instead is sent back > as a 301 redirect and then the request_post_data is gone. A 301 redirect is effected as a GET request.

Re: Model.save() vs. ManyToMany

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 14:01 -0800, David Gordon wrote: > Hi Folks, > > I'm aware that foreign key fields such as manytomany don't update > during the save() method of Model, and that there are some issues > surrounding relations to 'self'. I have a model which has a couple of > utility functions

Re: MultiValueDictKeyError when accessing POST items

2009-01-21 Thread Malcolm Tredinnick
On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote: > I've created my own form: > > > Login: > Username: > > Password: > > > > > I am mappying /accounts/login/ to a view of mine, which is then > calling: > > if request.method == 'POST': > username = request.POST['lo

Re: ManyToManyField in both models

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 07:05 -0800, Evgeniy Ivanov (powerfox) wrote: > Hi, > > I've returned to the problem and noticed, that recipe described in the > docs is a kind of wrong: intermediary model is just a kind of M2M (I > mean multiselection) since you have select widgets for inline model > and t

Re: RESTful PUT request

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 07:01 -0800, junker37 wrote: > I can't seem to get django to handle a PUT request. > > I've googled quited a bit and there seems to be some RESTful > interfaces available for django, however, I can't seem to get any of > them to work because the PUT request gets a 301 direct

Re: Sessions being written twice?

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 05:23 -0800, Iqbal Abdullah wrote: > Hi Malcolm, > > Thank you for the tip! > I see now that in my particular code example above, the idea of using > session id and manually setting it through the request can only work > if the session id itself doesn't change after i've set

Re: Sessions being written twice?

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 04:11 -0800, Iqbal Abdullah wrote: > Hi guys, > > I need to support some browsers which doesn't handle cookies, so I > have followed the snippet here to manually get session ids from the > request: > http://www.djangosnippets.org/snippets/460/ > > and positioned the new mid

Re: Normal views and JSON API

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 01:32 -0800, Guyon Morée wrote: > Hi, > > I've built a bunch of 'normal' views rendering templates and > processing POST's. > > Now, I'd like to build a API for my site, based on JSON. When building > this API I noticed most of the views are 99% the same, Excellent. :-) T

Re: how may i write Recursion for this

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 00:43 -0800, Praveen wrote: > class Listing_channels(models.Model): > list_parent_id = models.IntegerField(blank = True) > list_channel = models.CharField(max_length = 20) > visibility = models.BooleanField() > index = djangosearch.ModelIndex(text=['list_channel'], ad

Re: Shortcut for combining "with...as" and "include" template tags?

2009-01-21 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 00:40 -0800, Flo Ledermann wrote: > > > On Jan 21, 12:06 am, Malcolm Tredinnick > wrote: > > Huh? You have some change you want to make to the way a template tag > > behaves, but you don't want to write a custom template tag to do that? > &

Re: django comments preview posts instead

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 20:08 -0800, meppum wrote: > I'm not sure if it's a bug, but I had to change the following line: > > value="Preview" /> > > to instead be: > > value="Preview" /> It looks like you're using Django 1.0.0. Strongly recommended to upgrade to version 1.0.2. The above change

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 19:32 -0800, Keyton Weissinger wrote: > Hello, > > OK. I'm totally stuck. I am trying to create an object (of type > Student -- see below) with the following: > > new_student = Student.objects.create(**import_object_dict) > > I'm using the following dictionary as "import_o

Re: httpresponseredirect

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 17:51 -0800, saved...@gmail.com wrote: > Hello Malcolm, > > Thanks for you reply. Unfortunately, there is no 404 error message. > For some reason (beyond the scope of my django knowledge), the view > just won't redirect. The scope of my django knowledge. Here are my > simp

Re: django caching database object

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 11:00 -0800, Derek Payton wrote: > The issue is that CLIENT_CHOICES is only evaluated once, when the > server is started an all the code is loaded into memory. Try wrapping > it all in a function, thusly: > > def CLIENT_CHOICES() > choices = [ > ('', 'Select Clie

Re: httpresponseredirect

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 15:43 -0800, saved...@gmail.com wrote: > Hello Malcolm, > > Thanks for your reply. In response to your questions: > > > (a) what does "is_correct" contain when you think you should be entering > > the "correct" branch? Is it really something that will evaluate to >True in

Re: httpresponseredirect

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 13:08 -0800, saved...@gmail.com wrote: > i have a quiz app, 4 answers per question, one correct via boolean. > For some reason I can't get the view to redirect to next question if > answer is correct. Whenever I click on the correct answer the app > doesn't redirect to the n

Re: Raw SQL parameters

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 11:19 -0800, Ian wrote: > On Jan 19, 5:20 pm, Malcolm Tredinnick > wrote: > > Just to be accurate, PEP 249 says that a paramstyle of "pyformat" is one > > possible value, which would permit the above sort of query. It does not > > say that

Re: Shortcut for combining "with...as" and "include" template tags?

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 11:11 -0800, Flo Ledermann wrote: > Hi all, > > in my templates I often use combinations of "with...as" and "include" > for modularization of HTML building blocks, like so: > > {% with "save" as label %}{% include "components/button.html" %}{% > endwith %} > > however, thi

Re: Getting user outside of view

2009-01-20 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 07:46 -0800, Dan wrote: > Hello, > > I am trying to make an application that can log events (changes to the > database) from other django applications. To do this i am currently > using the post_save hook and post_delete hook to get any inserts, > updates or deletes however

Re: Deleting m2m relationship without deleting the data

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 22:38 -0800, I.A wrote: > Hi guys, > I apologize for the confusing title. > > I'm still confused on using the models in a m2m relationship. Suppose > I have the models below from the tutorials on the django site: > > class Author(models.Model): > name = models.CharField

Re: Built-in Template Reference in Admin

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 20:46 -0800, Kerr wrote: > Hi all, I'm reading through the Django book online and am currently on > chapter 10. http://djangobook.com/en/1.0/chapter10/ > > Near the end it mentions a built-in template reference available from > the admin interface, which contains info for a

Re: HttpResponseRedirect with https screws up Firefox?

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 19:47 -0800, csingley wrote: > > On Jan 19, 9:05 pm, Malcolm Tredinnick > wrote: [...] > > In that sort of situation, it is the responsibility of the external > > webserver to rewrite any outgoing URLs correctly for the external world. > > Thus

Re: model Admin inner class and admin.autodiscover()

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 18:14 -0800, Elyézer Mendes Rezende wrote: > Hi, I'm using django 1.0.2 final, and for a test I setted the admin > site configuration in the urls.py and used the Admin inner class like > this: > > class MyModel(...): > ... > class Admin(): > pass > > And the

Re: HttpResponseRedirect with https screws up Firefox?

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 18:42 -0800, csingley wrote: > I've got a Django project set up behind an Apache SSL listener on port > 443. Unfortunately, this seems to break HTTP redirects. > > For example, I have one view like this: > """ > @login_required > def home(request): > return HttpResponse

Re: Can I get the request object into the django.contrib.auth.views.password_change view template?

2009-01-19 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 02:07 +, Hans Fangohr wrote: [...] > However, in the template files, I extend my base.html which makes use > of the request object (basically checking whether the request has as > authenticated used and changing the html depending on this). > > It appears that the re

Re: Composite Indexing

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 16:55 -0800, Andrew Fong wrote: > I'm using contrib.contenttypes and have added the following to my > model: > > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField() > content_object = generic.GenericForeignKey() > > When examining the D

Re: Raw SQL parameters

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 17:49 +0100, Matias Surdi wrote: > Hi, > > > I'm trying to run a sql query with parameters taken from a dict, here is > the relevant part of the code: > query = "select * from table where name='%(name)s'" > parameters = {'name':'valueofname'} > cursor

Re: Filter model and retrieve associated model/objects at same time

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 12:27 -0800, sico wrote: [...] > I haven't checked but assuming this is going to execute 2 sql commands > for each row returned by the first query not good!! > Is there a way to tell django/python that I want to retrieve the > related data from the other 2 models before l

Re: Odd problem with date based generic views

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 04:38 -0800, phoebebright wrote: > Generic view - year_archive, is not working for me. There are no > errors displayed and no data either. On investigation, there seems to > be a mysql error that is causing the problem and it could be related > to the my using a view instea

Re: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Malcolm Tredinnick
On Mon, 2009-01-19 at 01:31 -0800, jazz wrote: > p.was_published_today() Traceback (most recent call last): > File "", line 1, in File "c:\projects\mysite..\mysite\polls > \models.py", line 11, in was_published_today return self.pub_date.date > () == datetime.date.today() NameError: global name 'd

Re: Possible to see sql for queryset before database gets it?

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 17:46 -0200, Ramiro Morales wrote: [] > > or if you are using a recent trunk version (more recent than two weeks or so) > you might want to try printing the output of: > > .as_sql() Please don't recommend that one, it's very likely to change in the near future (like, t

Re: Do Mysql Views and Django work together?

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 10:59 -0800, phoebebright wrote: > Got django reading the view ok. Potential problem where table uses two > fields as a primary key - don't think django likes this, but think I > can use a view to get around this one too. Yes, we don't support multi-column primary keys at th

Re: how to enforce uniqueness

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 09:58 -0700, Dj Gilcrease wrote: > On Sun, Jan 18, 2009 at 4:34 AM, Malcolm Tredinnick > wrote: > >> Right now, that is only enforced by the admin interface, > > > > I should have extended this to also say "and ModelForms", since if yo

Re: Best practise for using settings in templates

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 03:26 -0800, phoebebright wrote: > What is best practise if you want to use a variable defined in > settings.py in a template? > Pass it in via the view or call it directly in the template? Since you can't access it directly in a template, that leaves only the former option

Re: how to enforce uniqueness

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 22:32 +1100, Malcolm Tredinnick wrote: [...] > Have a look at unique_together: > http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together > > Right now, that is only enforced by the admin interface, I should have extended this to also say &qu

Re: how to enforce uniqueness

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 02:40 -0800, Konstantin wrote: > Hello! > > First of all I want to apologize for maybe very basic question, but I > newbie in django and web coming from c/c++ world. > > I have two models: > > class Box(models.Model): > description = models.CharField(max_length=250) >

Re: Comparing values from multiple tables; *show new posts* forum feature

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 02:48 -0800, Piotr Husiatyński wrote: > Hello, > I'm writing forum and I have a problem with *show new posts* feature. > Here's the code of my application: > > http://github.com/husio/arch-pl/tree/09234f6d780c76b45b5e1a6576d80080507873d4/forum > > I have two tables for *new

Re: Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 01:46 -0800, Adam Yee wrote: [...] > I'm still very puzzled by not being able to use '/mysite'. I agree > with you that somewhere '/mysite' is being stripped or just not being > accessed at all. My guess is somewhere in the generic views and/or > how they are set up in the

Re: Deploying Django tutorial part 4, redirecting problem, apache error

2009-01-17 Thread Malcolm Tredinnick
On Jan 18, 2:53 pm, Adam Yee wrote: > It was a slam dunk for completing the tutorial in the development > server, but I can't figure out this issue I'm having with the generic > views while using my apache server.  I'm unable to get the vote view > to redirect correctly. > > My apache error seen

Re: Any libraries to create an online help system in Django or Python?

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 19:28 -0700, Jeff Anderson wrote: > I'd suggest using sphinx. It's designed for documenting Python projects, > and it's the documentation build system that Python and Django both use. Realise that Jeff means Sphinx as in http://sphinx.pocoo.org/ rather than Sphinx the SQL s

Re: ELSE condition not working

2009-01-17 Thread Malcolm Tredinnick
er and you'll be able to work out why it's missing. Regards, Malcolm > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sun, J

Re: ELSE condition not working

2009-01-17 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 10:21 +0800, shreyas k wrote: > Hi , > > I have pasted the code here , when i try to edit it always enters the > else condition. delete works fine > Please assist. There's a lot of code here and much of it isn't indented correctly (for example, there's a "try:" statement t

Re: unable to import django.forms.formsets

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 18:16 -0800, Atishay wrote: > Hello All > > Due to some production environment related issues, I am not able to > upgrade to 1.02 to get formsets. > > I am able to create list of forms to emulate formset as suggested on > http://collingrady.wordpress.com/2008/02/18/editing-

Re: Regroup models in administration

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 10:00 -0500, didier rano wrote: > Hi all, > > In Django administration page, models are grouped by > application/folder. Is it possible to change behavior by code ? If you wanted something vastly different, you would need to override the AdminSite.index method (currently th

Re: Do Mysql Views and Django work together?

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 02:14 -0800, phoebebright wrote: > I say an earlier post that seemed to imply they did. > > I created a view in an existing db and wrote a model test to match it > so syncdb works fine. Hm ... it just occurred to me: whilst running syncdb probably works if you've specified

Re: Do Mysql Views and Django work together?

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 02:14 -0800, phoebebright wrote: > I say an earlier post that seemed to imply they did. Well, for reasonable values of "works", that's true. There's no special view handling code in Django, but, particularly for read-only code, they should work without any problem. You can c

Re: How do you get the time and date out of a datetimefield object?

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 14:47 +0530, Kenneth Gonsalves wrote: [...] > what you need to do is to use dir() to find out the method names and help on > the method you want to get more info Do I? Okay. Haven't had to do that before, though, since I apparently use a special version of Python where help

Re: How do you get the time and date out of a datetimefield object?

2009-01-17 Thread Malcolm Tredinnick
On Sat, 2009-01-17 at 00:43 -0800, DragonSlayre wrote: > Hi, > > As I'm relatively new to python and django, I'm unsure how to get the > date and time out of a DateTimeField. > > How I usually work with this sort of thing is to 'python manage.py > shell' and then import whatever class i'm intere

Re: MEDIA_ROOT, MEDIA_URL and upload_to confusion (~.~)

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 21:06 -0800, DragonSlayre wrote: > I'm using django-thumbs (http://code.google.com/p/django-thumbs/) to > create some thumbnails for my site: > > class Image(models.Model): > title = models.CharField(max_length=50, blank=True, null=True) > caption = models.CharField(

Re: How check custom permission?

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 21:14 -0800, frankabel wrote: > Hi all, > > I'm newbie in Django so probably this is just a stupid error. After > read a lot of doc can't figure out how access a specific permission to > check it. Custom permission stuff is fairly poorly documented at the moment. The inform

Re: ForeignKeys and select_related

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 20:26 -0800, cptnwinky wrote: > Thanks for replying. > > I don't mean to sound crass but I did mention what the problem was. > > Quote: > I've even tried specifying in select_related which exact tables and > fields I want returned however, only the results from Torrent tabl

Re: django caching database object

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 16:26 -0800, raji wrote: > Hey django-users, > > I've got a form in my django app that contains a select box that is > dynamically generated from a db object. In this case, it's a list of > clients. > > When a user adds to the client list (via another django app), the > 'c

Re: ForeignKeys and select_related

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 13:21 -0800, cptnwinky wrote: [...] > I'm trying to perform a icontains search on the name field of the > Torrent class. I need it to also return, with each result, it's > corresponding trackers, seeds, leeches and downloads. Here is the > relevant line in my view... > > res

Re: Instance Error when saving my form!!

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 03:59 -0800, Gath wrote: > Great Malcolm, it was supposed to be questionid_id! solved. But i > wonder why for userid am not doing userid_id???, userid works well !!! Because request.user is an instance of the User model. Once again, reading and understanding the error messag

Re: Instance Error when saving my form!!

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 03:19 -0800, Gath wrote: > Guys > Am getting the following error message when try to save on my form: > > Cannot assign "U'1'": "Answer.Questionid" must be "Question" instance The error message is telling you exactly what the problem is. You should believe the error message

Re: session.save() after failed request

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 11:19 +0100, Thomas Guettler wrote: > Hi, > > I think it is bad that request.session.save() is called, if > the DEBUG-View gets returned on an uncaught exception. > > I looked at the django source, but could not find a good patch for django > or my code. > > What is bad ab

Re: ManyToManyField in both models

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 01:33 -0800, Evgeniy Ivanov (powerfox) wrote: > > > On Jan 16, 5:16 am, Malcolm Tredinnick > wrote: [...] > > You need to go back and look at your original problem. You wanted forms > > with multiselect fields for both forms. So the real questi

Re: How do i combine a list and a form in the same page using django?

2009-01-16 Thread Malcolm Tredinnick
On Fri, 2009-01-16 at 01:10 -0800, Gath wrote: > Am building a Q&A page, sort of stackoverflow.com kinda page! Am > having a bit of a problem trying to render the form. Am pasing 3 > objects to the template that renders the page i.e. Question object, > Answers related to the question and Answer fo

<    4   5   6   7   8   9   10   11   12   13   >