Re: Premature end of script headers

2009-12-23 Thread Peter Rowell
> I'm getting a 'Premature end of script headers' issue when I'm > submitting post data, and I'm not sure why. There's a good chance there are errors in the code that executes when there is POST data. Try running this under the development server and look for error messages on the console.

Re: django hosting

2009-12-23 Thread Peter Rowell
And your question is ...? This looks like fairly vanilla FastCGI setup instructions. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email

Re: debugging cache

2009-12-23 Thread Peter Rowell
> CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True I know this is a silly question, but have your tried this *as an anonymous user*? I ask because it's easy to forget you are logged in. When in doubt use something like Firefox's Web Developer Toolbar and clear all the cookies for your test site. -- You

Re: Table Names and Foreign Keys

2009-12-23 Thread Peter Rowell
What rev are you running? I just tried this on Ubuntu 9.04 with Django 1.1.1 and got the following SQL generated. It looks right to me. ./manage.py sql test BEGIN; CREATE TABLE `Register` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(48) NOT NULL UNIQUE, `title`

Re: Trying to delete uploaded images (SuspiciousOperation)

2009-12-22 Thread Peter Rowell
Did you see my response to this question on SO? http://stackoverflow.com/questions/1950069/suspicious-operation-django/1950178#1950178 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Peter Rowell
OK, let's do a little Networking 101. 127.0.0.1 is an unroutable address (that means you'll never see it on the Internet) that *always* means the local host; in fact it's called 'localhost' in your 'hosts' file. For Linux this is /etc/hosts, for Windows it's in

Re: Keeping fields out of the Admin

2008-11-22 Thread Peter Rowell
On Nov 21, 10:58 am, maeck <[EMAIL PROTECTED]> wrote: > Please note that the result of this is that if you use > 'editable=False' this field is not visible in the admin at all. > As far as I know there is no good way (see below) of putting read only > data in an admin page. The world is strange.

Re: Newbie question: HTML formatting not applied to pages

2008-11-06 Thread Peter Rowell
You're being tripped up by auto-escaping of variable contents. This is a security feature that was first introduced in November of last year. (http://code.djangoproject.com/changeset/6671) See http://docs.djangoproject.com/en/dev/ref/templates/builtins/#autoescape

Re: Accessing User Object From Template

2008-07-12 Thread Peter Rowell
> The only weird thing I imagine I could be doing is using > render_to_response in my view. Would that be blocking the context from > being populated correctly? Nothing weird about that. Try reading the following section:

Re: Creating a Scheduled Task

2008-07-12 Thread Peter Rowell
> I can do > this "outside" Django with Cron and a script that uses the standalone > ORM, but is there any way to incorporate this into admin so I can see > what tasks are run and when? Well, you are probably still going to have cron (or equivalent) in there somewhere because you need something

Re: Querying a User profile

2008-06-29 Thread Peter Rowell
> Any advice on how to query User for a particular team name? Since the relationship is between Team and UserProfile, I believe that's where you need to start. Something like this would work: team = Team.objects.get(team=team_name) ups = UserProfile.objects.filter(team=team) users = [up.user

Computed m2m relationships not being saved when in Admin

2008-06-29 Thread Peter Rowell
Short version: during a Save from the Admin interface, m2m associations computed and applied as a side effect of calling save() do not seem to be recorded (permanently?) in the database. The same call from a view or a standalone script works. Longer version: I have the following class:

Re: Django setup with apache

2008-06-26 Thread Peter Rowell
You didn't share with us the specific error you are getting. I strongly recommend a) DEBUG=True in settings.py, and b) checking your Apache error_log. If you are getting a generic Apache 404, then the problem will be in the Apache httpd.conf or .htaccess files. If you are getting a Django 404,

Re: Data truncated for column change_message

2008-06-24 Thread Peter Rowell
I don't know if this is the problem, but I've noticed that inspectdb can generate wrong max_length for CharFields. Check the lengths in the database vs. the lengths in your models. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Mako templates with flatpages

2008-06-20 Thread Peter Rowell
> Is this possible? Short answer: No. (At least I can't see anyway to accomplish it.) On the other hand, the flatpages code is really quite straightforward. views.py is 46 lines and models.py is only 36 lines. Why not grab a copy, possibly rename it to avoid confusion, and hack away?

Re: Session lost between two requests from the test client

2008-06-12 Thread Peter Rowell
> Would appreciate any help in this regards Try using Firefox and the Live HTTP Headers plugin. Start at the beginning and see what is being exchanged between browser and server. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Handling unknown data

2008-06-12 Thread Peter Rowell
> I'd like to store the results for the event, but can't > figure out how. The event object is generic, but the results > structures are specific to that event. What first occurs to me is to give the Event class a TextField called 'results' which contains a pickled python object/dict/list

Re: Caching question

2008-06-06 Thread Peter Rowell
@James: I'm a little confused. The docs (http://www.djangoproject.com/ documentation/middleware/#django-middleware-cache-cachemiddleware) say, and the code appears to support it, that if django.middleware.cache.CacheMiddleware in the MIDDLEWARE_CLASSES list, then caching is turned on for the

Re: Caching question

2008-06-05 Thread Peter Rowell
> does per-view or template fragment caching override that? >From looking at django/middleware/cache.py, I would say that the view (and therefore the template) never get a chance to override. This check is done early in the request processing cycle, even before URL routing is performed. Peter

Re: forms - WTF

2008-06-05 Thread Peter Rowell
On Jun 5, 8:50 am, "Emily Rodgers" <[EMAIL PROTECTED]> wrote: > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to

Re: sessions, Internet Explorer cookies and domain forwarding

2008-06-05 Thread Peter Rowell
Sigh, brain fart. impeded => embedded --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send

Re: sessions, Internet Explorer cookies and domain forwarding

2008-06-05 Thread Peter Rowell
It doesn't work in Firefox either. I get a "Please enable cookies and try again" message. I suspect your problem is that the cookie has 85.214.104.194 as its domain, but the browser thinks it is on www.jouwadresboek.nl, so it never returns the cookie. I was wondering how you were doing

Re: Setting a ManyToMany default

2008-06-04 Thread Peter Rowell
> perhaps having an __init__ function in your Vineyard class could allow > you to set pinot noir as the default, unless it is passed another type > of wine. Conceptually, what you said is correct, but TDIITD (The Devil Is In The Details). I believe that the "correct" way to do this is to set

Re: Setting a ManyToMany default

2008-06-04 Thread Peter Rowell
> How about writing your own constructor that takes an argument of type > and has a default value assigned there? I guess I don't understand where this constructor lives in the food chain. It can't exist prior to the first save() of the object because we don't have the id before that. I tried

Re: Dynamic choice on Model

2008-06-04 Thread Peter Rowell
> How can I cast this 2 values dictionary into a 2 values tuple? Why are you creating a dict here? Try something like this: choices = [] for i in range(100): choices.append( (i, i+1) ) SONGNO_CHOICES = choices Or more concisely: SONGNO_CHOICES= [ (i,i+1) for i in range(100) ] This gives

Re: Navigation components

2008-06-03 Thread Peter Rowell
> The bit I don't see is how you get the info about section navigation > into the context - is it hard-coded into the view? This is what I'd > like to avoid. Ah. The short answer is: sort of. The breadcrumbs are a straight computation. The nav bar was done by CSS class manipulation, where the

Setting a ManyToMany default

2008-06-03 Thread Peter Rowell
My current project is loaded with ManyToMany relationships. Most of them are not required and default to nothing. One of them, however, is required and there is a very clear default value I could use ... if I could only figure out how. Consider: class Varietal(models.Model): name =

Re: Navigation components

2008-06-02 Thread Peter Rowell
A site I finished a few months ago had a 4 level hierarchy. I created a Section model and all content classes had an FK to Section (including Section itself). E.g., Home Section A Section A.1 Article Video Audio Books (etc., etc.) Section A.2 (etc.)

Re: may be BUG. SyntaxError: non-keyword arg after keyword arg

2008-05-28 Thread Peter Rowell
> SyntaxError: non-keyword arg after keyword arg > > "operator__office=self.operator.office" WAS truncated to the > "operator__" in traceback... The ORM filter() method uses double underscore "__" in a magic way. See http://www.djangoproject.com/documentation/db-api/#filtering-objects

Re: ForeignKey, but not...

2008-05-25 Thread Peter Rowell
Thoughts, in no particular order: 1. What about your app is dependent on the uid/User? I.e., At what points in the app's use does the uid come into play? 2. Since there is a uid, where is it coming from? UNIX uid? Some other forum id? 3. Are there events in the life of a uid/User (creation,

Re: dynamic filtering (with jQuery)

2008-05-23 Thread Peter Rowell
> Firebug is where you will get django's errors, if you are using an async > call to django (AJAX, XHR, etc..) You are absolutely correct. That's the second post I've misread this morning. I got rear-ended pretty hard yesterday and I think my neurons aren't working too well today. Sigh.

Re: How do I pass a value to a javascript function? (ie. lat and lng values to Google Maps)

2008-05-23 Thread Peter Rowell
> I think you just want something like: > {% for p in precinct_list %} > point = new GLatLng({{p.precinct_lat}}, p.precinct_lng{}); > map.addOverlay(createMarker(point, "{{p}}")); > {% endfor %} Oops, brain fade on my part -- I didn't read your question carefully enough. Baxter is

Re: dynamic filtering (with jQuery)

2008-05-23 Thread Peter Rowell
> The debug information is available from firebug. You will see the reuest, > right click on it and select 'Open in New Tab' Richard: I love Firebug, but I was talking about debugging Django, not Javascript. Joseph: You also need to have you IP in the INTERNAL_IP list in settings.py. If you

Re: How do I pass a value to a javascript function? (ie. lat and lng values to Google Maps)

2008-05-23 Thread Peter Rowell
>What > do I need to do to pass the values that are stored in my table to the > javascript? I see this as app-logic so I would create the URL in the view and then use simple variable substitution in the template. Look at urllib and urllib2 (standard Python modules) for functions that do nice

Re: storing a list of arbitrary generic objects in a db field

2008-05-23 Thread Peter Rowell
> Thoughts on this approach? I do this all the time. I call them objrefs (Object References). My syntax is ..id. If the model_name is unique across the project (which is normally true), then .id is also accepted. I also allow for .id.. I have three apps I am getting ready to post that make

Re: dynamic filtering (with jQuery)

2008-05-23 Thread Peter Rowell
> However when I get the query from > request.POST, it throws up server error (500). Well, I kind of doubt that jQuery in the browser is causing a 500 error on the server. I strongly recommend setting DEBUG=True in your settings.py file. Django gives you a perfectly lovely, formatted stack

Re: Any examples of django order-processing systems out there?

2008-05-17 Thread Peter Rowell
You might want to look at Satchmo. I think it's at 0.7 right now. http://groups.google.com/group/satchmo-users --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: Sorting a dict by value for template rendering

2008-05-16 Thread Peter Rowell
Variations on this come up all the time. Note that arrays can be sorted. So, create an array of tuples containing the key and the value. Then you can sort the array anyway you please. In the view: # create the array of tuples ordered_dict = [(key, val) for key,val in my_original_dict.items()]

Re: Why are my parameters gettings mangled?

2008-05-08 Thread Peter Rowell
Well, I'm not quite sure exactly what is being done to it, but it appears to happen at: = django/http/__init__.py: ... class QueryDict(MultiValueDict): ... def appendlist(self, key, value): self._assert_mutable() key =

Re: Pass variable with HttpResponseRedirect

2008-05-03 Thread Peter Rowell
> How can I pass a variable with HttpResponseRedirect? I've tried: I suggest using the session. This allows you to have arbitraily complex error structures. E.g., session['errors'] = HttpResponseRedirect('to somewhere') then in your other view(s) do something like:

Re: Templating patterns

2008-05-03 Thread Peter Rowell
> Is it posible to send the {{tag}} variable as a parameter from > another template (where i use the include tag) ? Unfortunately, no. There is another templating system, Jinja (http:// jinja.pocoo.org/), which looks a *lot* like Django templates. Jinja gives you full python expressions and

Re: Django and Services

2008-05-02 Thread Peter Rowell
> The one catch that I see is that you still > have to go through all your views and make sure that you're now > passing in a request object, and if you miss any then you won't > necessarily know until you notice that your page is rendered funny. No problems, mate. :-) All Django views a) take a

Re: how do designers create content

2008-04-22 Thread Peter Rowell
To expand on what Kenneth just said: It really depends on the individuals involved. I love the work my primary designer does in Photoshop, but her HTML/CSS makes me cringe. I got her to stop using GoLive to create these Tables From Hell (multi- row/multi-col spans all over the place), but she is

Re: guidance on sub-classing models

2008-04-22 Thread Peter Rowell
> I need some guidance on sub-classing a model ... Actually, you can't subclass a model ... anymore / yet. Something like this existed prior to an momentous event called the Magic Removal Branch, which was before my time but appears to have been the Django equivalent of the Spanish Inquisition

Re: Question about sessions in the DB

2008-04-21 Thread Peter Rowell
> It seems like I need to reference the session_key variable before I > can use it. Can anybody explain why? Well, I'll try. I spent sometime looking at django.contrib.session.backends.* The session is created in a 'lazy' fashion. In particular, db.py's load() method creates the record (and

Re: define a function in a model that calls itself from the db?

2008-04-21 Thread Peter Rowell
> I have the main page > that will display multiple sections that are each individuals apps. My first question is: do they update anything after the initial data fetch? If not, why not just build the page on the first GET (using template includes, etc.) and be done with it. > One obvious

Re: Multiple views, multiple apps?

2008-04-21 Thread Peter Rowell
> This works but looks really ugly... Agreed. Is there some reason you can't use class Admin in your models? More than one person has observed that Django's auto-generated admin interface is its Killer App. It's integrated with the django.contrib.auth authentication app, and it's even

Re: awareness of current view in template/site navigation

2008-04-21 Thread Peter Rowell
There are any number of Cheap Hacks you can do to make this simpler. In the view (or possibly using the {% expr %} tag (See http://www.djangosnippets.org/snippets/9/)), set a variable called in_news_archive to "-active" if you are in that section, and '' or None if you aren't. If this is a

Re: Formwizard Initial Data

2008-04-21 Thread Peter Rowell
> forms.ModelMultipleChoiceField(queryset=Submission.objects.all()) > > how can I make the queryset use Submission.objects.filter rather than > objects.all ? I have not used formtools, but just from looking at the above line I wonder if you tried:

Re: filters should throw exceptions

2008-04-21 Thread Peter Rowell
From http://www.djangoproject.com/documentation/templates/#variables If you use a variable that doesn’t exist, the template system will insert the value of the TEMPLATE_STRING_IF_INVALID setting, which is set to '' (the empty string) by default. So you could at least define this to be something

Re: define a function in a model that calls itself from the db?

2008-04-21 Thread Peter Rowell
> if I include the template tags within the html, will > that still be parsed? Or would it be wiser to call a .py script that > will return html after all the object calling is done? I think you might need to work on your model of how things work. Template tags are only meaningful to the

Re: Authenticate

2008-04-21 Thread Peter Rowell
> Authentication works perfectly on the latter method. Why would one > work but not the other? Because they are two different models that are unrelated except for Userprofile having a ForeignKey to User. Just as with Userprofile, if you modify the User record you have to explicitly save() it.

Re: define a function in a model that calls itself from the db?

2008-04-21 Thread Peter Rowell
Uhm, you could use . However, you eat the overhead of a second breowser<=>server chat, so I would investigate ways to directly include your news item in a larger template. The higher the volume of your site, the more that second chat will hurt you. AJAX is appropriate if you are going to be

Re: Some weird. In production, imagen is redirected to images

2008-04-21 Thread Peter Rowell
> This not happend in dev mode with the webserver of django. That's an important observation to make because it limits the places where this might be happening. Firefox has an excellent plugin, Live HTTP headers, that can give a little more insight into what is happening. The following was

Re: How to call a secure url?

2008-04-20 Thread Peter Rowell
We ran into a problem where users would either a) not be in SSL mode when they should be, or b) be *in* SSL mode when they shouldn't be. We solved it with middleware to make sure that we were always in the correct mode. Note: the page you are on when filling out a form does not, technically, have

Re: best practice for creating featured field

2008-04-20 Thread Peter Rowell
> featured_place = models.ForeignKey(Place, null=true, blank=true) 1. By any chance are you getting an error like "NameError: name 'true' is not defined"? The python keyword is "True", not "true". 2. If you reference a mode before it is defined, you need to supply a string for the

Re: Is there a better way to strip CharFields?

2008-04-19 Thread Peter Rowell
On Apr 18, 9:52 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > You could just write a clean_mycharfield() and just return > self.cleaned_data['mycharfield'].strip(). True. I guess what bothers me about that technique is that if the data is *not* passing through a Form you have subclassed,

Re: Javascript GUI Editor that works with Django templates

2008-04-19 Thread Peter Rowell
> > gets butchered to > Just did a quick check with TinyMCE: Blank textarea, into HTML mode, entered your text, update, save-and- continue-editing, HTML mode. The only thing it did was wrap everything in , but I think that's a configurable behavior. I.e., ==>> HTH, Peter

Re: Best practices sending out http requests from within django code

2008-04-18 Thread Peter Rowell
> I've been using urllib2 very effectively - do be careful with it though I second this (both halves). Very easy to use. The only gotcha I encountered was making sure I correctly handled various failure modes for the connection. This was the backend credit card handshake for a membership site

Re: Does the ORM support eager fetches?

2008-04-18 Thread Peter Rowell
Take a look at select_related(), it may be of some help, depending on how you define "parent" and "child". http://www.djangoproject.com/documentation/db-api/#select-related "Returns a QuerySet that will automatically “follow” foreign-key relationships, selecting that additional related-object

Is there a better way to strip CharFields?

2008-04-18 Thread Peter Rowell
I have an author who doesn't understand that a space is not nothing. He persists in *sometimes* putting a leading space at the beginning of a 'name' field. This name shows up in a ForeignKey drop down in the admin interface. As a result, we often end up with two records. He creates one named "

Re: Selecting Python version for mod_python

2008-04-09 Thread Peter Rowell
> This means that a python version has to be selected before the PythonPath > directive is processed. "Selected" is not quite the right way to think of it. mod_python has the Python interpreter linked in at build time, not run time. To change which version you have, you need to rebuild

Re: Whats wrong

2008-04-08 Thread Peter Rowell
And now for those famous words ... works for me. I'm using WinXP / FF 2.0.0.13 / Flash 9 Either you fixed the problem since you first posted, or there is something messed up on your desktop/laptop. By the way, I don't speak Hungarian, but I really like the look and feel of your site. Nicely

Re: Intial Data from Script

2008-04-08 Thread Peter Rowell
Are you asking how to run a standalone Django script? If so, the following gives you a fully initialized Django environment. standalone_script.py #!/usr/bin/env python from django.core.management import setup_environ import settings setup_environ(settings) # Your python/Django

Re: middleware that works with Ajax

2008-04-08 Thread Peter Rowell
Claudio, Your question made me look at RJS (which I had never heard of before) and at some stuff I did for a recently completed site. I think a rev 0.1 of something like RJS could be done in a weekend. I'll email you in the next day or so with some thoughts. Cheers, Peter

Re: Way to show recently updated items from multiple apps?

2008-04-07 Thread Peter Rowell
> I am wondering if there is an easy way to implement this so I can have > a list that is contains the most recently updated items from multiple > apps. Here are two ways to do this: 1. Add a field to models that you care about. E.g. date_modified = models.DateTimeField('date modified',

Re: Use django auth db for phpbb?

2008-04-06 Thread Peter Rowell
> - Make PhpBB Use the django auth This is probably the way to go. >I have not the slightest clue on where to start There is no "magic" in the django database. It is just a vanilla MySQL/ PostgreSQL database with vanilla tables. The table you are interested in is auth_users. The only required

Re: sql & cache problem? Am I crazy?

2008-04-03 Thread Peter Rowell
> Any light to understand/solve it? With any sort of suspected caching problem (and this certainly smells like one), Step 1 is always to disable caching, restart the server, and see if the problem magically goes away. If it does, you can put away the Xanax and start looking at where and how

Re: Is Django thread safe?

2008-03-29 Thread Peter Rowell
> The best I have ever been able to get out of anyone associated with > Django development about thread safety is the comments by Jacob Kaplan- > Moss in the following thread: Sigh. Reading through that thread was singularly unsatisfying. I guess that, for the moment, I'll have to stick with

Re: Do I need two classes that are identical because I want to use two database tables?

2008-03-28 Thread Peter Rowell
> So should I just create two classes that are identical but name one > CurrentElectionResults and the other PastElectionResults? That would be one way of doing it. There are promises of subclassable (?) Models in the works, but it hasn't been released yet. If there are a fair number of methods

Re: Tutorial: Admin Template Customization

2008-03-28 Thread Peter Rowell
On Mar 28, 2:48 pm, Evert Rol <[EMAIL PROTECTED]> wrote: > locate uses a database which doesn't always get promptly updated. > Waiting a few hours (or perhaps days) will show the correct > base_site.html as well. So locate not finding this is not an issue here. If you are root on the machine,

Is Django thread safe?

2008-03-28 Thread Peter Rowell
Graham -- Thanks very much for your replies. My concerns were from having two authorities saying different things -- it makes the unwashed masses nervous. :-) Of course, *now* I need to do a code review, since I hadn't been thinking "thread safe" when I wrote it. Is anyone (Django core

Re: how to convert {{candidate.vote_set.filter(vote='TU').count()}} in template syntax

2008-03-27 Thread Peter Rowell
Specifically, you might look at http://www.djangosnippets.org/snippets/9/. This allows you to do something like: {% expr candidate.vote_set.filter(vote='TU').count() as count %} and now {{count}} can be used in the current context. If you find yourself yearning for Total Python Power in

Configuring Apache and mod_python for Django

2008-03-27 Thread Peter Rowell
In another thread (http://groups.google.com/group/django-users/ browse_thread/thread/962cfdf7609839eb/), On Mar 23, 11:48 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > For example, using prefork MPM because PHP is not thread safe in > conjunction with Python web applications in embedded mode

Re: Installing mod_python and Django on webserver

2008-03-24 Thread Peter Rowell
> He's running a site on vBulletin, so his PHP needs to stay, is there > any issues I should be careful of not upset the PHP, while still > getting Django and mod_python correctly installed on the server? The one thing I am aware of is that under certain circumstances there can be a problem

Re: Head swimming - JavaScript libraries

2008-02-17 Thread Peter Rowell
Yet another vote for jQuery. It completely changed the way I look at using JS on pages. BTW, ext works with jQuery. See http://docs.jquery.com/Tutorials:Using_Ext_With_jQuery --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Tool recommendations

2008-02-04 Thread Peter Rowell
> I have some ideas for AJAXy web sites, and I'm thinking of > implementing them in my spare time, but I don't know what tools > to learn and use. One tool I strongly recommend is Firebug, a Firefox plugin. Amongst its many good features is that it makes debugging AJAX transactions almost

Re: Flash and Django

2008-02-01 Thread Peter Rowell
>I just want to know if it's > possible to have a flash script showing elements that was retrieve from > a data base by django? I'm not entirely sure what you are asking, but I think the answer is: Yes. Are you asking about the flash script calling a URL, getting data back and then displaying

Re: Complex relationship for user profile

2008-02-01 Thread Peter Rowell
> Failing a response to that one must mean I'm asking for something that > is undoable. Uh, this isn't McDonald's. Slow/no response does not immediately equate to undoable. It more likely means that people who might have answered the question were doing something else (watching the debate,

Managing the order of subordinate objects

2008-01-28 Thread Peter Rowell
I have run into the same problem on several different websites: a couple of PHP sites and, most recently, two Django sites. This is where you have a 'container object' that has a particular desired order of subordinate objects. Consider: class Newletter(models.Model): title =

Tracing Django execution

2008-01-11 Thread Peter Rowell
> I think I got it! Wrong ordering of middleware - I had the i18n-urls > middleware before some other stuff, which screwed up a lot. I'm beginning to think of caching and middleware as being to Django problems as firewalls are to networking problems: powerful, unseen, 'out of band' manipulators.

Re: i18n problem: Some template variables "get stuck" in one language

2008-01-10 Thread Peter Rowell
Emil: > Except that on a couple of pages, > the language seems to get stuck on the translated language after the > first time I change languages. This smells very much like a caching issue. Do you have any form of caching enabled? If so, turn it off and see if the problem is magically fixed.

Re: SESSION_SAVE_EVERY_REQUEST creates new session?

2008-01-10 Thread Peter Rowell
Eoin: Do you have SESSION_SAVE_EVERY_REQUEST = True in your settings.py file? I found that with that set to False, the problem went away. From something Malcolm said, it may also go away if you explicitly set SESSION_COOKIE_DOMAIN. --~--~-~--~~~---~--~~ You

Re: how to create new variable in html file in template

2008-01-09 Thread Peter Rowell
On Jan 9, 12:20 am, Gaojiawang <[EMAIL PROTECTED]> wrote: > I want to use the local variable in template's html file. > like 'count = 0' and how to use it > How to do it? The snippet José links to uses the resolve function of Django's templating system, which is good because it stays within the

Re: Many Django checkouts, setting which one to use (PYTHONPATH perference)

2008-01-07 Thread Peter Rowell
On Jan 7, 4:42 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Putting that in settings.py is too late, since by the thing that reads > settings.py is Django itself, so it's already been imported. You have to > modify your Python import path *before* anything Django-related is > imported.

Re: how to restrict username length must more than 5 words

2008-01-07 Thread Peter Rowell
> i user django-register in my project,it is fatastic, but how to: > 1. restrict username length must more than 5 words > 2. make sure email is unique. Good question. I don't recommend our short-term solution--modify the contrib/auth code--but it was the only way I could figure out how to do it

Re: Calling a method from the base template

2008-01-06 Thread Peter Rowell
> There is a mechanism available > for that -- context processors -- but people don't want to use it > because they want *something else* that happens for every template. Malcolm's absolutely correct: context processors (I mis-typed when I said content processors) is exactly what you want here.

Re: SESSION_SAVE_EVERY_REQUEST creates new session?

2008-01-06 Thread Peter Rowell
Malcolm, please accept my apologies for 1/2 of the problem described in the original article. I, of all people (I wrote debuggers back in the 80's), should know that you have to vet your diagnostic tools before you depend on them. Short version: The high cookie creation frequency was real (I'm

Re: Calling a method from the base template

2008-01-06 Thread Peter Rowell
> Attempting to do a method call {% views.get_stuff %} just results in a 'bad > tag' error. Right, because there is no tag with the name 'views.get_stuff'. > Doing it like a variable {{ views.get_stuff }} just seems to be ignored. Not ignored, but it probably fails which the template engine

Re: Context Processors: {{ MEDIA_URL }} not available in templates

2008-01-04 Thread Peter Rowell
> Well, if I can't get this working I suppose I can just stuff the > settings.MEDIA_URL variable into each template render by placing it > into the render dictionary myself each time. Nah, don't do that. I think your problem is that you are running 0.96 instead of trunk. I am on trunk/6688 and

Re: Context Processors: {{ MEDIA_URL }} not available in templates

2008-01-04 Thread Peter Rowell
> (3) Imported the RequestContext object in my views.py file: > > from django.template import Template, Context, RequestContext I know this is a silly question, but did you *use* RequestContext, or just import it? E.g. return render_to_response('base.html',

SESSION_SAVE_EVERY_REQUEST creates new session?

2008-01-04 Thread Peter Rowell
It appears that setting SESSION_SAVE_EVERY_REQUEST = True is causing a new session to be created on each page access. Background: I was doing some fiddling with a 'session browser' so that we can get an idea of how people are dealing with our new site. I set this config value because I wanted

Re: passing data to view using httpresponseredirect

2008-01-03 Thread Peter Rowell
I didn't like my own explanation and did a little more searching. I just found a better description of this at http://requires-thinking.blogspot.com/2007/10/note-to-self-default-parameter-values.html. He points out that the 'def' is an executable statement and it's only executed once.

Re: passing data to view using httpresponseredirect

2008-01-03 Thread Peter Rowell
> def new(request, errors = [], messages = []): > ... > [ snip] > unfortunatly, django somehow remembers this and the arrays don't get cleaned > up. It's not django that's tripping you up. > So, normal python rules say these should get default values [] and > thus be cleared. Actually, normal

Re: How do I connect to development server with my browser?

2008-01-02 Thread Peter Rowell
> If I run the dev server briefly, that won't cause any problems, will it? It all depends on your hosting company. When in doubt, ask. It's not that you are port-scanning their accounting machine, but you are creating a "long running process" (i.e. it doesn't just generate a page and exit) that

Re: Templates with multiple repeating blocks

2008-01-02 Thread Peter Rowell
> Use the user defined inclusion template tag or {% include %} standard > taghttp://www.djangoproject.com/documentation/templates_python/#inclusio... @Alex: That's not what he was asking for. He wants to be able to have multiple blocks with the same name in a parent template and have them get

Re: sitemaps for subdomains

2008-01-02 Thread Peter Rowell
> How can I add URLs with sub-domains to my sitemap files? If you are talking about XML sitemaps, you can't. >From http://www.sitemaps.org/protocol.php: Note that this means that all URLs listed in the Sitemap must use the same protocol (http, in this example) and reside on the same host as

Re: Can I use a underscore in my url to separate variables?

2008-01-02 Thread Peter Rowell
(This is hedronist in his disguise as himself, whatever that means.) > www.mysite.com/sprint_cellular_M1000/ Ah, something specific. Of course, it doesn't look like what you first posted, but I kind of suspected that. I'll say it one more time, if you have a specific problem, then you need to

Re: How do I connect to development server with my browser?

2008-01-02 Thread Peter Rowell
> My son gave me some space to play in on an Apache server he rents. Is this a dedicated server or a shared hosting account? Dedicated? Carry on. Shared? Watch out! Many shared hosting providers frown on (or outright forbid) "long running processes." Without thinking about what I was doing, I