Re: Admin Ordering

2009-01-15 Thread Scott Moonen
Sanrio, this is a known problem. See open ticket http://code.djangoproject.com/ticket/4926 -- Scott On Thu, Jan 15, 2009 at 11:21 AM, wrote: > > Hi, > > I just found out that you can only use one ordering key in the > ordering. Is this true? If so, what can I do to have

Re: Logout- Back Button

2008-11-06 Thread Scott Moonen
Hi, This is why many secure web application (e.g., your bank or credit card company) ask that you close your browser after you logout -- so that no one else can get to any of your data that may be stored in the browser cache. If your users are using your application from https:, then this is all

Re: DeprecationWarning: Non-ASCII character in models.py

2008-09-30 Thread Scott Moonen
An alternative solution is to replace the pound character with the HTML entity . -- Scott On Tue, Sep 30, 2008 at 8:01 AM, Jens <[EMAIL PROTECTED]> wrote: > > I got the same message the other day and the solution was to put > following line at the top (first line, befor everything else) of my

Re: Recursively rendering in template

2008-09-24 Thread Scott Moonen
Haven't tried it, but off the top of my head it seems like you could accomplish this by combining 'with' (to temporarily rename the child) and 'include': *app/node.html:* {{ node.name }} . . . {% for child in node.children %} {% with child as node %}{% include 'app/node.html' %}{% endwith

Re: Multiple instances using mod_python

2008-09-24 Thread Scott Moonen
FYI because there was some wildcarding going on, I think my ServerNames were actually duplicate in the two VirtualHost definitions (unqualified main domain name) and I was accomplishing any differentiation using ServerAlias. According to the mod_python docs <

Multiple instances using mod_python

2008-09-24 Thread Scott Moonen
I'm running a single instance of Apache to serve two IP addresses. One IP address has specific hostnames assigned in several VirtualHosts, and a Location statement for certain hostnames to be handled by a mod_python instance running a Django application. The other IP address has a wildcarded

Re: New Comments: Bad Magic Number Error

2008-09-10 Thread Scott Moonen
Hi Dave. I'm not sure how the .pyc file got corrupted, but from the error it sounds like it did. Perhaps you're running with a mix of Python versions? But I'd remove the .pyc file referenced by the error and try again. -- Scott On Wed, Sep 10, 2008 at 1:46 PM, [EMAIL PROTECTED] < [EMAIL

Re: Forms problem?

2008-08-28 Thread Scott Moonen
Greg, it looks to me like you are storing a date value into a datetime field. Consider the error: File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line 662, > in decompress > return [value.date(), value.time().replace(microsecond=0)] > > AttributeError: 'datetime.date' object

Re: fcgi - Problem using daemonize=true

2008-08-21 Thread Scott Moonen
Paddy, I can't remember all the details of my fcgi testing, but I think I saw the same mysterious behavior when I specified a relative path for the pid file. Once I specified an absolute path things seemed to work ok. I may be misremembering, or this may not be your problem. But it's worth a

Re: does it means we have to user Admin tool?

2008-07-21 Thread Scott Moonen
Hi Eric. Take a look at Django's generic views ( http://www.djangoproject.com/documentation/generic_views/), especially the List/Detail generic views and the Create/Update/Delete generic views on that page. If these generic views suit your needs then you may be able to get away with writing only

Re: Nested for loops in template

2008-07-18 Thread Scott Moonen
Brian, without knowing exactly how your models are configured, you can do something like this: {{ p.comment_set.count }} If you use it in more than one place (e.g., as {% if p.comment_set.count %} ... {{ p.comment_set.count }} ...), you will want to optimize things so that the SQL "COUNT()"

Re: Nested for loops in template

2008-07-18 Thread Scott Moonen
trouble. > I using django-threadedcomments > http://code.google.com/p/django-threadedcomments/ > so its a little confusing. > > Here are my models > http://dpaste.com/65848/ > > -Brian > > On Jul 18, 12:01 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > &

Re: Heavy database query (max 32 tables problem)

2008-07-18 Thread Scott Moonen
Norman, unfortunately I think he's asking for the mutual intersection of the users' courses, not the union. -- Scott On Fri, Jul 18, 2008 at 11:49 AM, Norman Harman <[EMAIL PROTECTED]> wrote: > > Deniz Dogan wrote: > > Hey. > > > > I have a model Course and then I have

Re: Modulo of 4 not working right

2008-07-16 Thread Scott Moonen
Joshua, For the simple fix, I think you should remove the word "not" from your while condition. The better fix is to do the math all in one step: amountofblanks += (4 - (len(templist) + amountofblanks) % 4) % 4 -- Scott On Wed, Jul 16, 2008 at 10:30 AM, joshuajonah <[EMAIL PROTECTED]>

Re: templates: additional forloop variable?

2008-07-14 Thread Scott Moonen
t actually display more attractively -- it could be rather ugly to have tags and bundles interspersed. Thank you for serving as my CardboardProgrammer<http://c2.com/cgi/wiki?CardboardProgrammer>for the day. :) -- Scott On Mon, Jul 14, 2008 at 7:53 AM, Russell Keith-Magee <[EMAIL PROT

templates: additional forloop variable?

2008-07-13 Thread Scott Moonen
Within a Django template, sometimes I find myself wishing that I had access to the loop item from the previous iteration of a loop. Usually the ifchanged tag is good enough for my purposes, but occasionally if some attribute of the loop item has changed I need to do further examination of the

Re: postgres schema support

2008-07-11 Thread Scott Moonen
mas I create > myself? > > Thanks! > > Jon Brisibn > http://jbrisbin.com > > On Jul 11, 2008, at 9:01 AM, Scott Moonen wrote: > > Hi Jon. I believe you can use the Django model meta property db_table to > specify the schema. According to ticket > #6064<http:/

Re: postgres schema support

2008-07-11 Thread Scott Moonen
Hi Jon. I believe you can use the Django model meta property db_table to specify the schema. According to ticket #6064you need to use somewhat hackneyed syntax at the moment (notice the outer single quotes and the explicit inner double quotes): class

Re: Alpha Chars in dynamic url?

2008-07-10 Thread Scott Moonen
Luke, this should work. Here's an example I use: *urls.py:* url('^user/(?P\w+)/$', user.view) *views/user.py: *def view(request, user_id) : user = get_object_or_404(User, username = user_id) Hope that helps, -- Scott On Thu, Jul 10, 2008 at 1:42 PM, lukeqsee <[EMAIL PROTECTED]> wrote: >

Re: A little help with an idea

2008-07-03 Thread Scott Moonen
Bryan, here's one way that you might approach it: 1. From a model perspective, you probably want to have a model like Account or Person or Blog that corresponds to the first component of the URL path. Then you can have a model like BlogPost or somesuch (maybe other models like

Re: Accessing URL Parameters in Django Templates

2008-07-02 Thread Scott Moonen
Sameer, if you are using the RequestContext object to produce the template context, then you should be able to access the URL parameters in your template as request.GET.*parametername*. In this case, request.GET is a QueryDict object (see

Re: Greater than Less than

2008-07-02 Thread Scott Moonen
00)^.{7,}') > > does that look right? > > > On Jul 2, 11:04 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > > Mike, you might try this: > > > > call.filter(number__regex = r'^.{7,}') > > > > That uses a regular expression that matches strings

Re: Greater than Less than

2008-07-02 Thread Scott Moonen
Mike, you might try this: call.filter(number__regex = r'^.{7,}') That uses a regular expression that matches strings of length 7 characters or more. -- Scott On Wed, Jul 2, 2008 at 11:59 AM, mike171562 <[EMAIL PROTECTED]> wrote: > > hello, >I am working on a web app that pulls call

Re: initializing a model with a dicitonary

2008-07-01 Thread Scott Moonen
Hi, try doing this: c = Customer(**customerdict).save() -- Scott On Tue, Jul 1, 2008 at 12:56 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I have an object called customer that I trying to initialize from a > large XML parse. I parse the XML into a dictionary into something > like

Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-07-01 Thread Scott Moonen
. -- Scott On Mon, Jun 30, 2008 at 9:18 PM, Malcolm Tredinnick < [EMAIL PROTECTED]> wrote: > > > On Mon, 2008-06-30 at 16:53 -0700, Milan Andric wrote: > > > > > > On Jun 30, 3:32 pm, Milan Andric <[EMAIL PROTECTED]> wrote: > > > On Jun 30, 3

Re: Programming error 1064 - possibly bad string length?

2008-06-30 Thread Scott Moonen
Actually, I might be misreading the error string. It looks like the address field has extra quotes around it too. Maybe that's just how strings get formatted in this case and is not the problem... -- Scott On Mon, Jun 30, 2008 at 4:02 PM, Scott Moonen <[EMAIL PROTECTED]> wrote: >

Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-06-30 Thread Scott Moonen
Hi Milan, would you mind posting the source for the object_list function as well? -- Scott On Mon, Jun 30, 2008 at 4:01 PM, Milan Andric <[EMAIL PROTECTED]> wrote: > > I've been wresting with this one for a couple hours now trying to > track it down, but no luck. I'm recently updated to

Re: Programming error 1064 - possibly bad string length?

2008-06-30 Thread Scott Moonen
Simon, my guess is that the error doesn't have to do with the truncation you see, but that something that is passing the error along is trying to be helpful by truncating the string -- one hopes in such a way that the error is still evident. :) Looking at the snippet you've posted, I wonder how

Re: Group by week

2008-06-26 Thread Scott Moonen
Chris, I have a utility function that does this for me. You can call it from your view, or if you set things up right from your template: from datetime import date def most_recent_Sunday(dt = None) : if dt is None : dt = date.today() return date.fromordinal(date.toordinal(dt) - (dt.weekday()

Re: views.py: Always a simple return?

2008-06-26 Thread Scott Moonen
., they contain a valid Content-Length header), then I think you may satisfy your goal. -- Scott On Thu, Jun 26, 2008 at 10:33 AM, Scott Moonen <[EMAIL PROTECTED]> wrote: > Ross, it seems to me that there are a number of potential hurdles to > holding a connection open for a long period: &g

Re: views.py: Always a simple return?

2008-06-26 Thread Scott Moonen
Ross, it seems to me that there are a number of potential hurdles to holding a connection open for a long period: 1. Some server configurations may require that requests be satisfied within a certain time period or else the connection will be reset. Of course, since the server is under

Re: very heavy problem with edit_inline

2008-06-21 Thread Scott Moonen
, Alessandro Ronchi < [EMAIL PROTECTED]> wrote: > 2008/6/21, Scott Moonen <[EMAIL PROTECTED]>: > > Alessandro, see the documentation for the "core" model field option: > > http://www.djangoproject.com/documentation/model-api/#core > > > > You shoul

Re: very heavy problem with edit_inline

2008-06-21 Thread Scott Moonen
Alessandro, see the documentation for the "core" model field option: http://www.djangoproject.com/documentation/model-api/#core You should set core=True on some field that must otherwise be present in an address. Looks like "indirizzo" is such a field. -- Scott On Sat, Jun 21, 2008 at 7:37

Re: Many To Many view in admin

2008-06-20 Thread Scott Moonen
Alessandro, It shows all the addresses inline of only the first? > It will show all of them inline. See http://www.djangoproject.com/documentation/model-api/#many-to-one-relationshipsand scroll down to the description of "edit_inline". -- Scott Moonen On Fri, Jun 20, 20

Re: Many To Many view in admin

2008-06-20 Thread Scott Moonen
Alessandro, if an address is for only one company, then I suggest that you remove the ManyToManyField, and instead put a ForeignKey within the Address model that references Company. If you set the edit_inline parameter on this ForeignKey you should be able to edit the address right on the company

Re: Template engine

2008-06-13 Thread Scott Moonen
Would it be possible to borrow from the embedded ruby syntax and define something like this: {{ variable.name -}} {% tag param1,param2 -%} If the '-' was present as part of the tag closure token, the template processor would eat the next 1-2 characters only if they were a CR or CR/LF. Although

Re: Filtering a query based on potential arguments

2008-06-12 Thread Scott Moonen
You can take advantage of the fact that query sets are not executed until they are inspected: cards = Card.objects.all() if request.POST.get('brand') : cards = cards.filter(brand = request.POST.get('brand')) if request.POST.get('year') : cards = cards.filter(year = request.POST.get('year')) .

Re: Text Formatting

2008-06-09 Thread Scott Moonen
You'll need to use some sort of rich text editor. I've used TinyMCEin the past; there are others as well. -- Scott On Mon, Jun 9, 2008 at 9:51 AM, yanksluvr7 <[EMAIL PROTECTED]> wrote: > > Is there a way to make a django page so you can copy and paste text >

Re: why my django site doesn't create .pyc file?

2008-06-09 Thread Scott Moonen
> > I think this way, apache could be a little more faster. Am I right? > I don't think it will be faster. Django normally runs as a long-standing process (either inside Apache or as a standalone process, depending on the deployment model you've chosen). So, unlike ordinary CGI scripts, your

Re: Missing calender button in Django Administration

2008-05-30 Thread Scott Moonen
>From an earlier email to this list, it sounds like the calendar doesn't work on 0.96.2 if USE_I18N is set to True in your settings.py file. This seems resonable to me; at one point I tried to use the calendar from my own templates but tripped over needing to define or stub out some gettext

Re: Session logout behaviour

2008-05-29 Thread Scott Moonen
Louis, there is some value in retaining the session past logout. The decision of what session data to keep/destroy is best left to the application. For any application that allows both anonymous and authenticated access, any site settings that you are able to set as an anonymous user (e.g., font

Re: How to change admin interface text boxes to text areas?

2008-05-28 Thread Scott Moonen
Emily, I suspect you have defined these particular fields as a CharField. Have you tried defining them as a TextField instead? -- Scott Moonen On Wed, May 28, 2008 at 7:59 AM, emy_66 <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm new at Django and is wondering if anyone k

Re: IntegerField with choices raising an TypeError

2008-05-22 Thread Scott Moonen
I suspect your problem may be due to the fact that your display value for 3 is a number rather than a string. Try changing: CHOICES = [(1, '1'), (2, '2'), (3, 3), (4, '4'), (5, '5')] to CHOICES = [(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5')] -- Scott On Wed, May 21, 2008 at

Re: postgresql 8.3 and ILIKE

2008-05-20 Thread Scott Moonen
Gacha, see my bug report and a possible fix (it is currently working for me) at: http://code.djangoproject.com/ticket/7197 -- Scott On Tue, May 20, 2008 at 4:14 AM, Gacha <[EMAIL PROTECTED]> wrote: > > I upgraded Postgresql to 8.3 version and got an error in admin: > >ProgrammingError:

Re: Error in new project creation

2008-05-19 Thread Scott Moonen
Swapna, did you install Django from SVN? If you extract Django from SVN, it creates the following directory tree: django-trunk/ (it looks like you may have renamed this to django/) django/ docs/ examples/ . . . Notice that there's a "django" *sub*-directory there. I'm not sure if you're

Re: Dynamic lookup

2008-05-17 Thread Scott Moonen
Toni, you can do this, for example: fieldname1 = "field" fieldname2 = "field2__ge" model.objects.filter(**{ fieldname : variable, fieldname2 : variable2}) -- Scott On Sat, May 17, 2008 at 7:11 AM, mwebs <[EMAIL PROTECTED]> wrote: > > Hello, > > I am using something like this: > >

Re: Reference to the url of the current page in a template

2008-05-16 Thread Scott Moonen
Ganesh, First ensure that your TEMPLATE_CONTEXT_PROCESSORS contains: TEMPLATE_CONTEXT_PROCESSORS = ( . . . 'django.core.context_processors.request', . . . ) Then you can use the variable {{ request.path }} in your templates, assuming that the URLs are all on the same host. If not,

Re: This field is required. NO!

2008-05-16 Thread Scott Moonen
Andre, in addition to saying null=True, try adding blank=True. -- Scott On Fri, May 16, 2008 at 8:06 AM, Andre Meyer <[EMAIL PROTECTED]> wrote: > hi all > > now, this is driving me crazy. this problem persists even after switching > from 0.96.1 to the newforms-admin branch. > > after

Re: MySQL Boolean vs. PostgresQL Boolean

2008-05-15 Thread Scott Moonen
You should find that Django's BooleanField understands the difference between the databases and does the right thing. -- Scott On Thu, May 15, 2008 at 1:57 PM, Szaijan <[EMAIL PROTECTED]> wrote: > > Hi, I developed my first Django app on my mapbook using PostgreSQL and > have recently moved

Re: capturing keyword and non-keyword arguments from urls

2008-05-14 Thread Scott Moonen
Berco, named and unnamed arguments shouldn't be mixed. See: http://www.djangoproject.com/documentation/url_dispatch/#the-matching-grouping-algorithm What the second paragraph means is that the URL handler is trying to call new(request, name = 'default') and (understandably) it is not working.

Re: symmetrical associations

2008-05-14 Thread Scott Moonen
James, one thing you might consider is creating an M2M relation between edges and nodes. That won't allow you to enforce at a database level the rule that edges relate to exactly one or two nodes, but it will work pretty naturally at the model level -- each node has a set of related edges, and

Re: Having a Many-to-One relationship with multiple other models

2008-05-13 Thread Scott Moonen
relational mappers require you to define relationships > on both sides. The Django developers believe this is a violation of > the DRY (Don't Repeat Yourself) principle, so Django only requires you > to define the relationship on one end." > > > On May 13, 12:03 pm, &

Re: Having a Many-to-One relationship with multiple other models

2008-05-13 Thread Scott Moonen
't think most other web frameworks go > this route for that very reason... > > Mike > > [1] > http://www.djangoproject.com/documentation/db-api/#how-are-the-backward-relationships-possible > > > > > On May 13, 11:32 am, "Scott Moonen" <[EMAIL PROTEC

Re: Having a Many-to-One relationship with multiple other models

2008-05-13 Thread Scott Moonen
Michael, you have two alternatives: 1. Create ManyToManyField fields in the UserProfile and Place models, pointing to Photo. "ManyToManyField" may seem a bit odd since you really have a many-to-one relation, but it will work as you expect, creating a join table connecting each pair

Re: response.write and memory, newbie question!

2008-05-12 Thread Scott Moonen
Andrew, it will build up its contents in memory. Consider how an exception thrown in your view will cause the response never to even be sent. Your best bet if you want to do streaming is to pass an iterator to the HttpResponse constructor. Your iterator should yield strings to its caller. --

Re: one-to-many design question

2008-05-09 Thread Scott Moonen
s book as chapter.book, and you can locate a book's chapters using book.chapter_set.all(). -- Scott Moonen On Fri, May 9, 2008 at 12:08 PM, Mike Chambers <[EMAIL PROTECTED]> wrote: > > I am working on an app to host some books online. I cant figure out the > best way to represent a one

Re: django_sessions table getting out of hand

2008-05-09 Thread Scott Moonen
See http://www.djangoproject.com/documentation/sessions/#clearing-the-session-table -- Scott On Fri, May 9, 2008 at 10:24 AM, Matt Davies <[EMAIL PROTECTED]> wrote: > I got you Scott > > cron job it is > > I seem to remember Adrian putting a nippet up somewhere with the code > in(laxz I

Re: How to modify contrib.auth models etc

2008-05-09 Thread Scott Moonen
Ok. Sounds like you can probably get by with creating your own ancillary GroupData model (for example) and associating it one-to-one with the Group model. I've done this in the past with User, creating my own UserData model to hold some additional attributes, and it worked well for me. --

Re: How to modify contrib.auth models etc

2008-05-09 Thread Scott Moonen
some of the behavior of the existing models; e.g., stretching permissions to do something new, then you might be better off creating your own models. -- Scott Moonen On May 9, 9:48 am, Marcin Gorczyński <[EMAIL PROTECTED]> wrote: > Hello > > I have a problem to tackle - in my site I want

Re: django_sessions table getting out of hand

2008-05-09 Thread Scott Moonen
. -- Scott Moonen On May 9, 8:54 am, "Matt Davies" <[EMAIL PROTECTED]> wrote: > Thanks for getting back to me Arien > > If that's what people are doing to sort it out then that's fine by me, I can > write a cron job to run a script and everyone is happy. > > If