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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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 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 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: 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: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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Best way to unique upload file name

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 20:39 -0800, chatchai wrote: > Hi, > > I want to unique upload file and there is not unique parameter > available for file field model. I think I can do this at the form > level but I just want to make sure if it is the best way to go. The simplest way is to let Django do i

Re: Best way to unique upload file name

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 20:52 -0800, chatchai wrote: [...] > I know that Django will append the underscore after the file name > until the file can be saved but what i mean is, > do not allow the file with the same name to be able to upload. That's kind of an odd requirement. The filename says noth

Re: Best way to unique upload file name

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 21:06 -0800, chatchai wrote: > Thanks for your quick reply, > > I need to unique file upload name because the client say the file is > unique by name (date based) so that they won't upload the same file. > > I know that the file name cannot determine file uniqueness. > >

Re: admin list display icons for callable?

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 21:51 -0800, Paddy Joy wrote: > The admin interface shows nice green/red icons for BooleanFields. If I > have a callable that returns only true or false, is there a way I can > make these show in the admin with icons rather than the text > 'True'/'False' > > For example I wo

Re: Finding all Named URLs

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 21:33 -0800, rtelep wrote: > > > > sufficiently useful to add to the maintenance load of core. Sadly, > > people asking about this type of thing frequently omit the use-case. > > > My bad. I was thinking of testing. Run through all the URLs with the > test client, look

Re: GROUP BY

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 23:46 -0800, Glenn Maynard wrote: [...] > I don't care if it takes more than one line, though there is, in > fact :), a big difference between taking more than one line and having > to bypass the public API. Only semantically, when you're trying to access something like "gr

Re: urlresolvers.reverse() breaks when given exactly one arg of more than one character

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 18:07 -0800, Fluoborate wrote: > Hello All, > > I have a question. When I use the function > django.core.urlresolvers.reverse(), it works fine with args=(), and it > works fine with args=(string1, string2 [, ...more strings]), and it > even works fine with args=(anyOneCharac

Re: template: writing "\u20ac 20.000" fails

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 00:37 -0800, SanPy wrote: > Thanks a lot, Malcolm, > > You got me on the right track, I just needed to escape the string, > like this: > > var prices=[{% for price in prices %}[{{ price.0 }}, '{{ price.1| > escape }}']{% if not forloop.last %},{% endif %}{% endfor %}]; > >

Re: reverse foreignkey "add" method using multiple INSERTs

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 02:17 -0800, Andrew Ingram wrote: > Hi All, > > I'm using something along the following lines to bulk add a bunch of > objects to a model's reverse foreignkey relationship: > > foo.bar_set.add(*bars) > > where bars is a list of Bar objects. > > I've noticed that Django is

Re: Splitting a NullBooleanField in a template

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 06:53 -0800, chewynougat wrote: > After having a closer look in django, it seems that the > RadioFieldRenderer that renders the radio buttons, renders the entire > set as a single string, therefore it is not possible to split these > fields in the template (using django) - if

Re: passing self?

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 08:32 -0800, ajlozier wrote: > I have made a little progress on the problem I posted about earlier > (http://groups.google.com/group/django-users/browse_thread/ > thread/100679d9c298dc52/ffa1564be0c4b276?hl=en&lnk=gst&q=tree > +admin#ffa1564be0c4b276">creating tree inputs in

Re: Problem with encoding and using ifequal in Django templates

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 09:25 -0800, Ben Gerdemann wrote: > Hello, > > I'm having problems using {% ifequal s1 "some text" %} to compare > strings with extended characters in Django templates. When string s1 > contains ascii characters >127, I get exceptions in the template > rendering. I know you

Re: Adjusting these models for other functionality

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 09:57 -0800, Almost George wrote: > -- MODELS -- ( Other, unimportant fields/models have been removed ) > > class Band(models.Model): > name= models.CharField(max_length = 50, unique = True) > > class Venue(models.Model): > name

Re: error when using Create, Update generic views

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 19:36 -0800, vierda wrote: > Dear all, > > Today I'm learning to use generic views for create and update objects. > It required form_class or model for the argument. My model is User > from django.contrib.auth.models.User and my form as per below : > > from django.contrib.a

Re: Changing comments preview form

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 20:11 +0100, Florian Lindner wrote: > Hello, > > I'm playing around with the contrib.comments framework. I want to > change the preview form. For that I've copied preview.html to xgm/Blog/ > templates/comments (xgm is my project, Blog is app). My template > loaders are:

Re: Common fields in an abstract class, with customized db_column values for concrete models

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 11:19 -0800, psj wrote: > Hi community -- > > All my models have some common fields, say "created_date" and > "last_modified_date". However, for various reasons not important here, > we have some naming conventions on column names: we like them to have > a prefix that pertai

Re: Extending User model

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 21:44 +0100, Alex Rades wrote: [...] > my situation is: It's a site for students and companies, where > students can post their data and search for internships, and companies > post their data, internship opportunities, and search for students. > > So, students have to fill

Re: Setup_environ before or after forking?

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 12:56 -0800, Andrew Fong wrote: [...] > Question: Does it make more sense to call setup_environ before or > after forking? I'd do it after forking. > > In particular, I don't know how Django sets up its database > connection. A connection is created the first time you acc

Re: DateField comparison with date.today()

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 22:03 +, Tim Sawyer wrote: > Hi, > > I have a model that includes: > > from datetime import date as pydate, datetime > > date = models.DateField() > > I've overridden delete to do: > > def delete(self): > ... > if self.date < pydate.today(): >

Re: how to: munge words and numbers into a URL, then reverse it ?

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 16:48 +0100, felix wrote: > > there is some hashing function or combination of URL encoding that can > do this : > > > given some parameters : > > 'music' 'artist' 32L 2L 100 100 > ( artist id 32, 2nd picture, dimensions 100 x 100 ) > > I wish to generate a fake filenam

Re: Bound Inline Formset doesn't render FileField's current value, needs to be reentered.

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 14:48 -0800, Rodrigo C. wrote: > > This isn't a Django issue. It's a standard property of browsers: you > > can't set an initial value for file input fields. This is a security > > measure, to stop malicious pages uploading files from your hard drive > > without your explicit

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