New custom field and widget for admin

2008-11-19 Thread Andy McKay

I'm stuck on creating a custom widget for the admin interface and  
wondering if anyone can help on where to look.

I've got a field which is essential a ForeignKey pointing to a State  
model. In the admin interface I would like to show the current state  
(done) and a list of the possible transitions (where I'm stuck). The  
list of the possible transitions is the issue since this is based on  
the attributes of the current State AND the current values of the  
model instance.

On the state I've got a method:

def get_transitions(self, obj):
...

Which given the model instance, will combine and figure out the  
possible transitions. But I'm not sure how to get the required object.

I've been rummaging around in  
django.db.models.fields.related.ForeignKey > formfield, there's an  
option to set the queryset. For example for a foreign key, it uses the  
default object manage of the class the reference is pointing to. But  
at that point I don't have the model instance to pass to  
get_transitions.

If I go up to the widget I don't have access to the model instance at  
all.

I've wandered around object managers and I'm a bit stumped. Any ideas  
appreciated, I have a feeling I'm going about it all wrong (wouldn't  
be the first or last time :).

Thanks
--
   Andy McKay
   Site: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy






--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: referencing style sheets in templates

2008-11-19 Thread Andy McKay


On 19 Nov 2008, at 23:46, ayayalar wrote:
> I am running into an issue with style sheets are not being found (404)

I'm assuming you are using runserver in which case you need to set up  
static file serving as per:

http://docs.djangoproject.com/en/dev/howto/static-files/

If you've already done this, or are not using runserver, we would  
likely need some more information.

Cheers
--
   Andy McKay
   Clearwind Consulting

   Site: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy






--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Andy McKay

Yes but you never pass two forms to the template at the same time. In  
add_product you pass form1, in add_product_details you pass form2.

>>> (r'^product/$', views.add_product),
>>> (r'^product/$', views.add_product_details),

You have the same URL twice, only one of them will ever be active.

Remove one of those of URL's, then merge the two views together and  
pass both form1 and form2 to the template.
--
   Andy McKay
   Clearwind Consulting

   Site: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy






--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: del session variables

2008-11-20 Thread Andy McKay

On 20 Nov 2008, at 22:06, Bobby Roberts wrote:
> is there a way to kill a session rather than running a del statement
> on each session variable?  I know in .asp you can simply say
> session.abandon.  Is there an equivalent with django?


In the session documentation there are mentions of: clear() and flush()

http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions

Sounds like one of those might be helpful.
--
   Andy McKay
   Clearwind Consulting

   Site: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy






--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django And os.path Behavior

2008-12-05 Thread Andy McKay

> os.path.exists behaves differently if called from a django app.  Why?


I don't think it does, for example:

~/sandboxes/arecibo $ ls -al ~/Desktop/
[...snip..]
drwxr-xr-x   2 andy  andy 68  5 Dec 21:57 El Camarón de la Isla

~/sandboxes/arecibo $ cat test.py
# -*- coding: utf-8 -*-
import os
print os.path.exists("/Users/andy/Desktop/El Camarón de la Isla")

~/sandboxes/arecibo $ python test.py
True

~/sandboxes/arecibo $ python manage.py shell
imPython 2.4.4 (#1, Feb 18 2007, 22:11:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
 >>> import django
 >>> import test
True

Seems to work just fine, there's nothing I've seen that fiddles with  
os.path. What is more likely: in one situation you've got a string  
encoded one way, in another its another. Check those strings encodings  
are what you expect prior to calling them.
--
   Andy McKay
   www.clearwind.ca | www.agmweb.ca/blog/andy







--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: specify widget in "Admin"

2009-01-13 Thread Andy McKay

On 13 Jan 2009, at 12:05, BabySnakes wrote:
> I just want to use same kind of widget like the one used while I edit
> User permissions in /admin/auth/user for my own model.

Add filter_horizontal to the admin class for that model, specifying  
your field name.

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#filter-horizontal
--
   Andy McKay
   www.clearwind.ca | www.agmweb.ca/blog/andy







--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Andy Mckay

I don't think you are defining the ModelForm correctly, the whole  
point is that Django creates the fields for you. If you look at:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms

This is the key difference between a ModelForm and a normal form:

http://docs.djangoproject.com/en/dev/topics/forms/#form-objects

You'll see there are no field definitions and there is instead a  
pointer through class Meta: to the model. The form is trying to create  
the model and failing. A better form for you would be:

class SurveyForm(forms.ModelForm):
 class Meta:
 model = Survey

(add in your import statement so it knows what Survey is).

Cheers
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Suspicious Operation/ filestorage problem

2009-01-19 Thread Andy Mckay

> SuspiciousOperation: Attempted access to '/img/avatars/default.gif'
> denied.

If i remember, it's because there's a / at the beginning, you probably  
want a relative path.
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is safe unsafe?

2009-02-23 Thread Andy Mckay


On 23-Feb-09, at 1:45 PM, Michael Repucci wrote:
> Of course, now I'm a bit scared (thanks to my inexperience), and
> tempted to not use the safe filter at all, letting everything get
> escaped. But there are thousands of sites (e.g., message boards, blog
> sites, etc.) where users can post messages that contain HTML - as I'd
> like to do with my application - so I suspect that there must be
> relatively simple solution. Am I wrong? I would think Django would
> have something specifically tailored to deal with this. If not, would
> it be enough to simply remove text between  tags, or
> are XSS attacks possible through other HTML tags as well (that's still
> a bit unclear to me)? Thanks for your help!

You want to use a script to only allow certain HTML tags and enforce a  
whitelist. Don't be naive and just use string or regular expression to  
strip only a few, there's lots of hacks that can be done. I use the  
SGMLParser in Plone, here's an old one: 
http://code.activestate.com/recipes/52281/ 
  some googling will probably find you more.
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Static file serve with prior authentication?

2009-02-23 Thread Andy Mckay


On 23-Feb-09, at 1:44 PM, Katja Loeffler wrote:
> I have been looking for a solution to make a file download with prior
> authentication ...

>
> But this is not really "protected" since they can make the link public
> once they have it and everyone can download without prior login.
>
> I have used:
> (r'^site_media/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/path/to/media'})

You don't really want use django.views.static.serve in the real world  
anyway, you want to use Apache. And for Apache there is an  
Authentication handler for mod_python that allows you to authenticate  
a request for a static file.

http://docs.djangoproject.com/en/dev/howto/apache-auth/

Other webservers and tools may vary.
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is safe unsafe?

2009-02-23 Thread Andy Mckay


On 23-Feb-09, at 2:04 PM, Michael Repucci wrote:
> Obviously the latter would
> be safer, but there's worth in having the added flexibility, provided
> I haven't left a huge hole open.

What hole is there to leave open? So they upload a .exe, you aren't  
executing it are you?
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is safe unsafe?

2009-02-23 Thread Andy Mckay

On 23-Feb-09, at 2:27 PM, Michael Repucci wrote:
> No, but it will be served, so a PHP file would constitute a hole
> (without my regexp filter), and I'm just not confident that I thought
> of all the extensions that the server will execute automatically when
> such a file is served.

Then you should really be very sure that your web server is not going  
to be executing files and will just be serving them. Once you are  
confident of that, problem removed.
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can i access UserProfile from User in the views?

2009-03-17 Thread Andy Mckay


On 17-Mar-09, at 9:46 AM, Paolo Corti wrote:
> from django.contrib.auth.models import User
> u = User.objects.get(pk=1) # Get the first user in the system
> user_address = u.get_profile().home_address
>
> but is there a way to access to UserProfile in the view?

Do you mean in the template?

The view is python and you can access the profile just as you do so

> supposing the UserProfile model is called myprofile, this will not do
> the trick:
>
> {{ user.myprofile.home_address }}

I don't use Django templating but have you tried:

user.get_profile.home_address

Not sure why you'd be using myprofile there where in python you used  
get_profile.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can i access UserProfile from User in the views?

2009-03-17 Thread Andy Mckay


On 17-Mar-09, at 10:36 AM, Paolo Corti wrote:

> if i use this in the template i get this error: Caught an exception
> while rendering: Cannot resolve keyword 'user' into field

So it has no variable user, that has nothing to do with the rest of  
your problem.

If you use request context then you will get the user available:

http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#django-core-context-processors-auth
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: including text files with django tags?

2009-03-17 Thread Andy Mckay


On 17-Mar-09, at 7:48 PM, codingJoe wrote:
> 
>   
> 
>
> I have a text file that I want the user to see in a scrolling text
> area?

I would recommend reading through the django tutorial on the website,  
since it shows that this is done in python in views and not in a  
template.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need two response statements on same def

2009-03-18 Thread Andy Mckay

On 18-Mar-09, at 11:24 AM, Jesse wrote:
> In the view.py I have  (def Bypub) that sends data to a template and
> paginates it.  I have a second (def TextFile) that uses the same data
> to send to a CSV file.  I would like to combine the two (def Bypub and
> def TextFile) together into def Bypub, but I'm not sure how to write
> the statements to combine two responses.

You can only send one response to a request, so it can be either HTML  
or a CSV.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Signals, sites and instances

2009-03-19 Thread Andy Mckay


On 19-Mar-09, at 7:59 AM, bax...@gretschpages.com wrote:
> So what can I do? Is the POST info available to the signal maybe?

Well I would have lots of questions there, some real code might help,  
not sure we have enough info. But lets start with what signal are you  
trying to catch (theres a few different ones)?
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need two response statements on same def

2009-03-19 Thread Andy Mckay


On 19-Mar-09, at 8:35 AM, Jesse wrote:
> My concern is that each view has 87 lines of duplicate code from the
> "GET" data to get the appended list (shown here as: data retrieved to
> create a list .list.append(publications)).  Anytime I make a
> change in one view I have to remember to make the change in the other
> view.

A view is just a Python function, you can do whatever you'd normally  
do to refactor Python to refactor views. So move the 87 lines of  
duplicated code into another function and re-use.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Map events in space on a django app

2009-03-19 Thread Andy Mckay


On 19-Mar-09, at 5:29 PM, Alessandro wrote:

> I'm looking for some documentation, but it seems not too simple.
> it should be very easier if someone shared a sample simple app using
> django.contrib.gis

You need two fields on a model, longitude and latitude. The rest of it  
is pure Javascript to place the pin on a map. You can see javascript I  
used for my site on http://www.cleartrain.ca, if you really want to  
see the code behind the scenes, I can share some with you in private.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django versioning and backup best practice

2009-03-20 Thread Andy Mckay


On 20-Mar-09, at 3:15 AM, Fabio Natali wrote:
> However, on updating the website, I must be very *careful* and run a
> selective update/merge: I must not overwrite the data.db file which is
> on the web server and actually the most important piece of the story.

Best practice imho is not to use SQL lite for anything other than  
quickly playing around. I would strongly recommend postgres (other  
people my recommend others).

If i need to move data between database I do psql dumps and then  
import on the other server, but I think the idea of using SQL lite and  
keeping it SVN along with code is quite a fragile way to go.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TypeError: 'module' object is not callable

2009-06-19 Thread Andy McKay


On 19-Jun-09, at 3:38 PM, db_333 wrote:
>  File "/Library/Python/2.5/site-packages/django/core/handlers/
> wsgi.py", line 228, in __call__
>self.load_middleware()
>  File "/Library/Python/2.5/site-packages/django/core/handlers/
> base.py", line 47, in load_middleware
>mw_instance = mw_class()
> TypeError: 'module' object is not callable
> [19/Jun/2009 14:09:22] "GET / HTTP/1.1" 500 644

But what Middleware do you have installed - whats the settings.py  
value for middleware?

It looks like that might be problem, none of the above code.


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: active django battery projects

2009-06-19 Thread Andy McKay

There's also a list of plugins at http://djangozen.com/plugins/

--
   Andy McKay
   www.clearwind.ca

On 2009-06-19, at 1:14 PM, notcourage  wrote:

>
> I for one would be interested in replies showcasing django battery
> projects underway. As a new django user, I'm stumbling on some active,
> useful projects (django piston, south) and wondering if there are
> projects addressing my wish list (django model cache, django parsed
> template cache, multi DB, fuzzy dates, etc).
> >

--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: djangoplugables.com is down ?

2009-06-22 Thread Andy McKay

Fortunately there other sites that offer a list of plugins, for  
example: http://djangozen.com/plugins and http://djapp.org. The former  
has every plugin from djangoplugables on it.

On 22-Jun-09, at 8:25 AM, Dunsun wrote:

>
> Hi,
>
> I am not able to access djangoplugables.com.
> It has been down for 2 days.
>
>
> >


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to make email field unique in model User from contrib.auth in Django

2009-07-21 Thread Andy McKay

Use a pre-save signal, but also validate your forms correctly.

On 21-Jul-09, at 12:33 PM, ramu...@gmail.com wrote:
> Another idea may be to open a new ticket and upload a patch with new
> parameter inside settings.py:
>
> AUTH_USER_EMAIL_UNIQUE = True

You could do that, but if I had anything to do with it, it would be  
rejected, so don't bother :)
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Success at using "reusable apps"?

2009-08-16 Thread Andy McKay


On 16-Aug-09, at 8:50 PM, Margie Roginski wrote:
> * modify the threadedcomments views.py code to take a callback
> function as an argument - that callback function could do my Task
> specific stuff as described above, but this would keep it more
> encapsulated within my Task app (but of course I would still have to
> modify threadecomments to take the callback arg)

Or sounds like you could write a signal in your own code.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: From a relative noob

2009-08-22 Thread Andy McKay

On 22-Aug-09, at 9:20 AM, Matthias Kestenholz wrote:
>>  Some.object.filter(id = var1).filter(value =
>> var2).extra(where=['Cost>%s'], params=['var4'])

Follow Matthias advice, below.

But for the record you've put 'var4', instead of var4, so you are  
passing a string which MS SQL doesn't know how to convert.

> Is there a reason why you cannot simply do the following?
>
> Some.object.filter(id = var1).filter(value =  
> var2).filter(Cost__gt=var4)

--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Test server and Https

2009-08-22 Thread Andy McKay


On 22-Aug-09, at 7:50 AM, Vitaly Babiy wrote:

> Hey,
> I am working on a site that part of it must be behind HTTPS, is  
> there any I can run this using the test server?

The built in django server does not do HTTPS. Use Apache or some other  
server to serve HTTPS
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Duplicating objects, avoid signals

2009-08-25 Thread Andy McKay

On 25-Aug-09, at 1:45 PM, Michel Thadeu Sabchuk wrote:
> This way I can disable signals for an specific operation, this is what
> I want but I prefer not modify django source. Is there another way to
> disable signals for an specific operation?

Here's an example:

http://djangozen.com/blog/turning-off-django-signals
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to define variables used in every page?

2009-09-02 Thread Andy McKay

Look up template context processors.

--
   Andy McKay
   www.clearwind.ca

On 2009-09-02, at 7:03 PM, "richardcur...@googlemail.com" 
 wrote:

>
> Hi,
>
> I want to use two 'global' variables in all pages. Obviously I don't
> want to put the same variable in all template dictionaries.
>
> Is there a simpler way to have something like 'global' variables in
> Django?
>
> Thanks.
> >

--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: extending objects.get()

2009-09-03 Thread Andy McKay


On 2009-09-03, at 4:40 PM, dwh wrote:
>>>> j = Junk.objects.get(cheese='12345')
>
> The field cheese isn't part of Junk obviously.

You can do anything you want in a custom manager. What cheese is and  
how possible that is, is up to you.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What happened to djangoplugables.com?

2009-09-03 Thread Andy McKay


On 2009-09-03, at 3:47 PM, Anthony wrote:

> It's been down for a while.


It's been dead for a while. Fortunately I did spider it many months  
ago and put it into http://djangozen.com/app.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serializing with not just the query data but also some additional columns

2009-09-03 Thread Andy McKay


On 2009-09-03, at 1:21 PM, Neeraj wrote:
> I am trying to serialize a queryset but for each row I want  
> supplementary data that is appropriate to the context I am doing the  
> serialization in. I might want to add a column to each row in one  
> situation which is some calculate value, etc, etc, etc.
>
> It seems that serialization only really lets you serialize a queryset.

It does indeed, you would have to extend the built-in ones with your  
own serializer.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Last object of a set?

2009-09-03 Thread Andy McKay

If you are in a for loop you can test whether you are at the end.  
Otherwise I think you'd have to do it in the view.

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

On 2009-09-03, at 9:01 PM, watusee wrote:

>
> I'm attempting to get the first and last items in a set inside a
> django template. The first is no problem:
>
> {{ course.coursepart_set.all.0.begin_date }}
>
> but I can't figure out how to get the last item without knowing the
> length of the set. Is there a way to do this?
>
> Something like (theoretically):
>
> {{ course.coursepart_set.all.LAST.end_date }}
>
> kind regards,
>
> -raymond
> >

--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'function' object has no attribute 'fields' errror on first access to development server

2009-09-03 Thread Andy McKay

Make sure you've added in autodiscover:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf

If you want help on a specific error, you are going to have give us a  
traceback, otherwise its unlikely we have enough information to go on.

On 2009-09-03, at 4:34 PM, hamdiakoguz wrote:

>
> After starting django dev server I get this error on the first access.
> After refreshing the page it goes away but somehow it seems that
> admin.py (in my application dir) seems not to be executed and none of
> the models i registered does not appear in admin.
>
> >

--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Twitter: @clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can I alter a JS file with Django

2009-03-27 Thread Andy Mckay


On 27-Mar-09, at 11:44 AM, Ross wrote:

>
> I'm a bit new to this, so don't be surprised if I'm way off base here.
>
> Is there any way for me to deliver a javascript that contains
> templated content through Django?  Or is Django somehow limited to
> only rendering html content based templates.
>
> So I'm thinking I'd have an html page which contains a:
>
> script type='application/x-javascript' src='deliverJS/'
>
> and my urls.py would trap the 'deliverJS/' and call something like
> views.makeJS
>
> and in views.py I'd gather some stuff and render a file  'jsFile.js'
> into which I've stuffed some things using template tags?
>
> Is that possible?

In short yes, that's pretty much how you'd do it. Just make sure to  
send the correct mime-type to the response as well:

http://docs.djangoproject.com/en/dev/ref/request-response/#httpresponse-objects
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: DjangoBook forms

2009-03-30 Thread Andy Mckay

On 23-Mar-09, at 5:53 PM, AKK wrote:
> I'm working through chapter 7 of the djangobook online. and i've got
> the following:
>
> def search(request):
>if 'criteria' in request.GET:
>
> however, if i leave it blank rather than it saying "You submitted an
> empty form" it says:
>
> Can someone tell me how to fix this or mention why it occurs?

Line two merely checks for the presence of the field, not its contents  
so you probably want (untested)

if request.GET.get('criteria'):
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Script the New App Process

2009-03-30 Thread Andy Mckay


On 30-Mar-09, at 10:21 AM, mjlissner wrote:

> - The startapp script doesn't complete about 80% of the actions
> necessary to make a basic app
> - There are eight files (!) that need to be completed/edited for an
> app to work (admin.py, forms.py, views.py, models.py, index.html,
> urls.py needs an include, appname/urls.py needs to be made,
> settings.py needs the app turned on)

Admin.py, forms.py, views.py, index.html are all optional. It all  
depends what *kind of app* you are building.

Some projects (eg Plone) use paster to create mulitple different  
starting points. Some like rails give you different commands to  
generate different parts. I think assuming that it has to be just one  
particular way is wrong.

This has been discussed quite a few times before I believe, so maybe  
do a bit of googling on that first.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Auto-populate fields in django?

2009-03-30 Thread Andy Mckay
Try this more recent one:

http://www.b-list.org/weblog/2008/dec/24/admin/

On 30-Mar-09, at 7:29 PM, Dr.Hamza Mousa wrote:

> Hello , am wondering , how to auto-populate fields as ( User field ,  
> and current datetime filed ) , i follow up those tips , and created  
> a custom manager / and manipulator   
> http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/ 
>  , though am wondering if there is another way around !!!
>
> -- 
> Hamza
>
>
> >

--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Search in multiple models

2009-04-03 Thread Andy Mckay


On 3-Apr-09, at 12:54 PM, Alex Rades wrote:
>
> Now, I need to create a search form which should search among both
> articles and static pages and return the list of matches. I'd like
> very much to return an object_list so that this search result would be
> automatically paginated.
[snip]
>
> I think this is a fairly common need so... what could I do?

Use the content types framework

http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/

eg:

http://www.agmweb.ca/blog/andy/2195/
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Reusing fields in forms

2009-06-10 Thread Andy McKay

I've got a bunch of fields in a bunch of forms. Some of those fields
repeat themselves. So rather than copy and paste them around, I
defined the fields in a module and then imported them. Then pulled
them into my forms. All well and good.

The problem is that the fields are coming out in the wrong order, (I
think) because of the creation_counter which tracks the order of the
fields. The field is created in the library and not in the form and
thats when it gets the counter value.

Before I dig deeper on this tomorrow, has anyone had a try at this?

--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: WebFaction + Django Fixture: Help?

2009-06-17 Thread Andy McKay


On 17-Jun-09, at 12:48 PM, Keyton Weissinger wrote:
> backends/util.py", line 19, in execute
>return self.cursor.execute(sql, params)
> DataError: value too long for type character varying(4)
>
>
> Any ideas?

The unhelpful answer is that the field is too long. One way to get  
this is to have a different database schema at home from on the  
webfaction server. Double check your schema in postgres the same as  
home, chances are something has changed.

--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread Andy McKay

> I've been seeing that for a few months now when trying to visit the site.

Before djangopluggables has been dead for many months. Before it went
offline, I spidered everything into http://djangozen.com/, its been growing
slowly since then.

--
Andy McKay

--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Making the case for Django (vs. Drupal)

2009-10-31 Thread Andy McKay

One key thing to remember is that Django and Drupal (and the other  
things you mentioned) are quite different things. You are comparing  
apples to oranges which makes the sell harder.

Drupal is a CMS and has a different target audience. It has the level  
of complexity that comes from solving the CMS problems.

Drupal like most CMS's will allow you to do things the Drupal way  
quite easily. As soon as you stray from that path, you'll be in trouble.

I recommend understanding your audience and the difference in tools  
and how this affects them.
--
   Andy McKay
   www.clearwind.ca

On 2009-10-31, at 9:44 AM, shacker  wrote:

>
> At the university where I work, there is a LOT of momentum behind
> Drupal. A large and active users group, and dozens of departmental
> sites running it. I've succeeded in building a few departmental sites
> with Django but still feel like it's an uphill battle convincing
> managers to agree to go with a relative unknown, both in terms of
> language (Python) and platform. Things like the announcement that
> whitehouse.gov switched to Drupal just cement the deal in many
> managers' minds.
>
> I'd like to put together a summary sheet and blog post summarizing all
> the reasons why I feel Django is the better choice for many sites, to
> try and help make the "sale" to managers. I have my own set of reasons
> but am not going to include them in this message. I'm especially
> interested in hearing from people who have done development in both
> Django and Drupal (or WordPress or Joomla, or other). Would be
> interested in hearing comments on things like:
>
> - Overall development time
> - Ease of making changes to templates
> - Ease of finding 3rd party functionality (modules vs. reusable apps)
> - Server performance
> - Ease of building data models that reflect the needs of the
> organization
> - Ease of finding other developers to take on a project when someone
> leaves
> - User friendliness (admin and editorial interface)
> - Ease of getting the system to do highly custom tasks
> - Ease of upgrades
> - Security
>
> etc. etc. - anything at all. Please indicate whether it's OK to quote
> you (I can paraphrase you if not)
>
> Thanks in advance,
> Scot
> >

--~--~-~--~~~---~--~~
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 email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to save a forms.ModelForm with extra fields?

2009-11-12 Thread Andy Mckay
On 09-11-12 2:33 PM, jul wrote:
> I've got the Rating model and the AddRestaurantForm shown below. In
> order to add a rating when submitting a new restaurant, I added an
> extra field to AddRestaurantForm. Can I do that? If I can, how can I
> save separately the Restaurant instance and the rating instance (I'll
> get the user from the context)?

Sure that works just fine.

When you save the form, you'll save the restaurant instance. You can 
then get the rating from the forms.cleaned_data and save that however 
you'd like.
--
   Andy McKay
   @clearwind
   Training: http://clearwind.ca/training/
   Zen: http://djangozen.com

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Help a Rails refugee - how to do site specific layouts?

2009-11-12 Thread Andy Mckay
On 09-11-12 10:35 AM, Todd Blanchard wrote:
> I like the rails mechanism for specifying page layouts (boilerplate
> template that surrounds the currently rendered view).
>
> Its simple and obvious.

Use the "extends" tag. If you want rails style boilerplate, there's 
always "include"

http://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance
-- 
   Andy McKay
   @clearwind
   Training: http://clearwind.ca/training/
   Zen: http://djangozen.com

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: ManyToOne to auth.models.User

2009-11-15 Thread Andy Mckay
On 09-11-15 7:00 AM, TiNo wrote:
> On Sun, Nov 15, 2009 at 09:31, Dennis Kaarsemaker
> mailto:den...@kaarsemaker.net>> wrote:
>
> On za, 2009-11-14 at 15:53 -0800, TiNo wrote:
>
>  > In my apps, Users of the app participate in a certain Year. I would
>  > like a Year to continue a ManyToOne relationship with a User. As
>  > creating a ForeignKey on a User is not possible, what would be the
>  > best way to do this? I don't need a full-blown profile for a user,
>  > just this connection with a year.
>
> Creating a ForeignKey to django.contrib.auth.models.User is definitely
> possible.
>
>
> Of course. But having each User have a ForeignKey to a Year is not..
> Which is what I want.

You could write your own user model. But if you don't want to do that, 
make a profile and put the year on that. Or use model inheritance. Or 
make a foreign key on another model to the User object (as Dennis noted) 
and then use reverse lookups.

Personally I would recommend making a profile, you'll likely be adding 
more to it.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Stucked in template language

2009-11-15 Thread Andy McKay
On 09-11-15 8:27 AM, Nagy Károly wrote:
> In the template i cannot decide if specific attribute is assigned to a
> car or not, because i cant pass parameter to method call.
>
> How can i override this?

You can't. You could use a different template language. But you'll be 
better off formatting all your data in the view, its easier to write and 
unit test in Python.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Redirect

2009-11-15 Thread Andy McKay
On 09-11-15 9:35 AM, Zeynel wrote:
> how do i redirect www.swimswith.com to www.swimswith.com/admin/

http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-redirect-to

First hit in Google.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: DB table hook/callback

2009-11-16 Thread Andy McKay
On 09-11-16 9:01 PM, Ishwor Gurung wrote:
> "Django includes a “signal dispatcher” which helps allow decoupled
> applications get notified when actions occur elsewhere in the
> framework." The word "framework" is I think the key here. Right?

Correct, signals won't help spot changes in the database that do not 
pass through Django.

> A way which I think this can work is having field within the db that
> gets polled every say 5 minutes OR using database triggers as a
> callback (this one is the one I want to implement but is it even
> possible?)

I've done something similar to this in the past so I can integrate Plone 
(which pushes straight to the db) with Django. I have a database trigger 
that writes to an audit log table. That table has a matching Django 
model. So then I have a cron job that runs every couple of minutes, 
looking for any changes on the table and then does some work (in this 
case updating navigation and search).

This lets me stay in the Django ORM as much as possible, with the 
addition of just one trigger.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Django and reportlab table question

2009-11-16 Thread Andy McKay
On 09-11-16 9:59 PM, adelaide_mike wrote:
> I am attempting to user ReportLab with Django to make a report
> displaying my data in a tabular format.
[..]
>  ['Conclusion','Run!']

Loop through your vehicles as your simple naive start, eg:

data = []
for vehicle in vehicles:
 data.append([vehicle.ve_name, vehicle.ve_type])

Then expand. Looping through your query set and your models is pretty 
much the same be it reportlab or not.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Apache/mod_wsgi woes

2009-11-19 Thread Andy McKay
On 09-11-19 6:40 AM, Brandon Taylor wrote:
> ImproperlyConfigured: ImportError filebrowser: No module named
> filebrowser
 >
> I can start python from the command line, and import filebrowser,
> django, or any of my other modules without errors.

You could be using a different python. If you installed mod_wsgi through 
a package manager, which Python does it use 2.5 or 2.6 (I don't know the 
answer to that, but the traceback might). Do you have multiple pythons 
on your machine?
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: FAQ?

2009-11-19 Thread Andy McKay
On 09-11-19 7:57 AM, Carl Zmola wrote:
> Does anyone want to take a stab at an FAQ?  There are a lot of repeated
> questions on the list.

How about http://docs.djangoproject.com/en/dev/faq/
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: querySet + select distinct

2009-11-19 Thread Andy McKay
On 09-11-19 3:36 PM, Benjamin Wolf wrote:
> I'm trying to create a select with the django query set which should
> give me the same result like this sql statement:
> SELECT distinct(YEAR(`mydate`)) FROM `table`
>
> I've tried it for a while but don't get it.

Try using values in the filter eg:

Disposal.objects.values("mydate").filter(mydate__year__gte=2008).distinct()

The problem is the default django query selects all the fields, messing 
up the distinct part.

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Write debug error to file

2009-11-26 Thread Andy McKay
You should take a look at Arecibo which has been used by a few  
Facebook apps for that very readson. It has full Django libraries and  
if you don't use it a full example of how to use middleware to process  
an error.

http://areciboapp.com

--
   Andy McKay
   www.clearwind.ca

On 2009-11-26, at 8:15 AM, Gabriel Rossetti  
 wrote:

> Hello everyone,
>
> I'd like to write the django error page (when debug == true) to a file
> and return a page with that link instead of the actual page. The  
> reason
> I'd like to do this is to be able to debug a facebook app because fb
> seams to filter/block the error page. Does anyone know how to do that?
>
> Thanks,
> Gabriel
>
> --
>
> 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 to 
> django-users+unsubscr...@googlegroups.com 
> .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en 
> .
>
>

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Error when generating PDF

2009-11-26 Thread Andy McKay
You are passing through None to reportlab, not a string. Follow the  
traceback and you will find the line in your code where the error  
occurs.

--
   Andy McKay
   www.clearwind.ca

On 2009-11-26, at 5:40 AM, adelaide_mike   
wrote:

> In my report generating view I have this (snip):
>
> if tablename == 'Area':
>areas = Area.objects.all()
>data.append(['Code','Name','Description'])
>for area in areas:
>data.append([
>Paragraph(area.area, normalstyle, bulletText=None),
>Paragraph(area.nick, normalstyle, bulletText=None),
>Paragraph(area.desc, normalstyle, bulletText=None)
>])
>table = Table(data, 1*[0.75*inch]+1*[2.0*inch]+1*[4.0*inch],
> style=ts)
>
> elif tablename == 'Rack':
>racks = Rack.objects.all()
>data.append(['Code','Name', 'Description'])
>for rack in racks:
>data.append([
>Paragraph(rack.rack, normalstyle, bulletText=None),
>Paragraph(rack.nick, normalstyle, bulletText=None),  #
> thats line 108
>Paragraph(rack.desc, normalstyle, bulletText=None)
>])
>table = Table(data, 1*[1.25*inch]+1*[2.0*inch]+1*[4.0*inch],
> style=ts)
>
> When tablename = "Area" the .pdf is generated without error.  Wnen it
> is "Rack" this error is raised:
>
> Traceback (most recent call last):
>
> File "/home/mrowan/django/django/core/handlers/base.py", line 86, in
> get_response
>   response = callback(request, *callback_args, **callback_kwargs)
>
> File "/home/mrowan/projects/cbm/djcbm/cbm/reports.py", line 108, in
> print_list
>   Paragraph(rack.nick, normalstyle, bulletText=None),
>
> File "/usr/lib/python2.5/site-packages/reportlab/platypus/
> paragraph.py", line 523, in __init__
>   self._setup(text, style, bulletText, frags, cleanBlockQuotedText)
>
> File "/usr/lib/python2.5/site-packages/reportlab/platypus/
> paragraph.py", line 543, in _setup
>   text = cleaner(text)
>
> File "/usr/lib/python2.5/site-packages/reportlab/platypus/
> paragraph.py", line 61, in cleanBlockQuotedText
>   L=filter(truth,map(_lineClean, split(text, '\n')))
>
> File "/usr/lib/python2.5/site-packages/reportlab/platypus/
> paragraph.py", line 23, in split
>   return [uword.encode('utf8') for uword in text.split(delim)]
>
> AttributeError: 'NoneType' object has no attribute 'split'
>
> What does the error message mean?  Can someone translate please? TIA
>
> Mike
>
> --
>
> 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 to 
> django-users+unsubscr...@googlegroups.com 
> .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en 
> .
>
>

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-26 Thread Andy McKay

> Can anyone tell me how I can load the content and execute/render the
> javascript, css styling, template tags/filters?

You really shouldn't be doing this. One string is everything on your  
page? You can use the Template library to re-render a template and  
that's discussed in the templating docs - but I wonder why you are  
doing that in the first place.

>
> Allen
>
> --
>
> 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 to 
> django-users+unsubscr...@googlegroups.com 
> .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en 
> .
>
>

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Newbie: is it possible to re-render a tag/filter after adding it to the web page as string

2009-11-27 Thread Andy McKay
On 09-11-27 4:41 AM, Allen wrote:
> Dear Bruno
>
> Great to hear that there are other ZOPE users among us.

More than you might think ;)

> When I work with ZOPE I code with dtml. I only found out about ZPT
> when I quiz ZOPE and never got familiar with it afterwords. The first
> thing they teach you when working with ZOPE is to combine segment of
> web pages with. With this I could type use
> some page with other tags or javascript/css and it will all render
> normally.

The include tag will include a chunk of another template and is a simple 
way include a HTML snippet for re-use:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#include

> I want to create a application that uses minimal html files. At the
> present stage of development, coded everything into one html and save
> all the static data into the database.
>
> I want to know about re-rendering a django tag/javascript/css is
> because I want to allow my users to use a web interface to type in
> their contents and custom tag that I created and save it back to the
> database.

So users should be typing in some HTML, that becomes part of a model and 
you then render the model back out.

As for the custom tag you can compile that back out like this:

http://docs.djangoproject.com/en/dev/ref/templates/api/#compiling-a-string

> If everything work accordingly, the custom tag will activate and put
> javascript/googleMap api onto the page and display a google map. But
> sadly it didn't gone according to plan and instead the page only
> displayed the tag as if it was just text.

To be honest this is one of the things I did in my first or second Zope 
project which seems about 4 bazillion years ago. Users could enter these 
custom tags into the HTML area and magic would happen. Sadly it didn't 
work out very well.

I would recommend a simple "add map to this page" button myself that 
twiddles a model attribute.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Registration open for DjangoSki Conference, March 2-4 2010

2009-12-03 Thread Andy McKay
Registration is now open for the first DjangoSki Conference in Whistler, 
March 2-4 2010.

http://djangoski.com

DjangoSki is a conference with a difference. It's set in the ski resort 
of Whistler and is half conference, half un-conference and, erm, half 
skiing.

Come to the conference and meet with our keynote speakers: Jacob 
Kaplan-Moss, Matt Berg and David Ascher [1], then go skiing on the hills 
with them in the afternoon.

Talk submission is now open. If you'd like to speak there, we'd love to 
hear you talk.  Ad-hoc talks, birds of a feather and so on are also a 
big part of the conference [2]

Afternoons, we break for skiing before reconvening in the evening [3]

There's lots more to talk about, but check out the website for more. 
Early birds are on a first come, first served basis, so register soon. [4]

We look forward to seeing you there.

[1] http://www.clearwind.ca/djangoski/keynotes.html
[2] http://www.clearwind.ca/djangoski/keynotes.html#pre
[3] http://www.clearwind.ca/djangoski/when.html
[4] http://www.clearwind.ca/djangoski/register.html
[5] ...and oh, it's snowing like crazy: http://bit.ly/8goJIc
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Performance monitoring

2009-12-09 Thread Andy McKay
On 09-12-09 6:43 PM, Kegan Gan wrote:
> Google App Engine provides a rather extensive set of tools to monitor
> the performance of your applications running in App Engine. Is there
> something similar for Django?

Not that I know of. There's django-debug-toolbar and a quick hack I 
wrote to track the time of each sql query. But I would classify both as 
debugging tools. Is there anything specific you are looking for?
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Performance monitoring

2009-12-09 Thread Andy McKay
On 09-12-09 8:43 PM, Kegan Gan wrote:
> Thanks for reply, Andy.
>
> I am aware of django-debug-toolbar. I am looking something to run with
> production.
>
> How do people monitor Django application performance in production
> environment today?

Hmm I guess if I knew what you were looking for I could help more. Like 
I say I've run a sql query recording tool, its v. simple. But most of 
the time I rely on system tools like munin or monit.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Howto output rows as HTML columns instead?

2009-12-13 Thread Andy McKay
On 09-12-13 7:35 PM, John Handelaar wrote:
> My problem, and question:  how on earth can I instead spit this data
> out with years as the column headers and the categories as rows,
> instead?  There are far more categories of data than there are years
> of data, and what I have now simply won't fit into the horizontal
> space of the average browser window.

If your template is getting too complex or you can't see how to figure 
it out, restructure your content in your view to make your template 
easier. Python's good at doing that, the templating language isn't.

So if your data was:

[ "year": "2009", "data": expenserow1 ],
[ "year": "2008", "data": expenserow2 ],

You would be able to do simply, for head:

{% for row in expenses %}{{ row.year }}{% endfor %}

For rows:

{% for row in expenses %}
{{ row.data.salary }}{{ row.data.travel }}
{% endfor %}

And so on.

> Tips (which don't involve creating a dozen new
> semantically-much-less-meaningful models) gratefully received...

You could get the models to work the way you want, but one tip is to 
considering getting the data just the way you want to work easily in 
your template and that's just (hopefully) simple Python data structure 
manipulation.

Good luck fitting all those 000's in for their expenses for the duck 
pond and the adult movies ;)
-- 
   Andy McKay, @clearwind
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Filter (AND excluding empty values)

2009-12-13 Thread Andy McKay
On 09-12-13 5:46 PM, Osiaq wrote:
>   properties = Property.objects.filter( Q(city=t) | Q(category=c ) | Q
> (status=s) )
> Goal:
> Find all the properties in 'city' no matter of category or status

Well you haven't told us what your models look like so we can't really 
be sure what you mean. If a Property has a ForeignKey of City, then: 
Property.objects.filter(city=t) might work.

 >  From the other side: find all the properties that belongs to
 > 'category' no matter of  'status' or 'city'  and so on

Assuming category is meaningful on property this would be: 
Property.objects.filter(category=c)...

All I can really say is: 
http://docs.djangoproject.com/en/dev/ref/models/querysets/

> OR doesn't work properly as well as AND

If you want help you will need to be more specific. "doesn't work 
properly" is not useful information.
-- 
   Andy McKay, @clearwind
   Whistler conference: http://clearwind.ca/djangoski/

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Filter (AND excluding empty values)

2009-12-14 Thread Andy McKay
A filter can take a python dictionary. So all you have to do is:

  Property.objects.filter(**some_dictionary)

All you have to do is populate that dictionary. You can do that by  
accessing request.get, but the best way is to pass that into a django  
form.

--
   Andy McKay, @clearwind
   Whistler conference: http://clearwind.ca/djangoski

--

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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Working for a startup.

2010-04-22 Thread Andy McKay

On 2010-04-21, at 10:40 PM, Joe Goldthwaite wrote:
>  The guy mentioned that they originally started with a
> different company using Ruby on Rails.  He said that after the other company
> got bogged down and wasn't making progress, he switched to the new company
> that we're considering.  He said that they got the project back on track and
> organized but ended up running into lots of problems with Rails.  They
> talked it over and decided to rewrite everything in .net.  Now he's happy
> with the progress and feels like .net is a superior platform and is allowing
> him to develop his program at a lower total cost.

So company X got into problems using rails, so they switched to .NET using 
company Y. And this is from a company referred to by company Y? 
That's not the most impartial conversation.

There's a lot of worrying about technology there - which can be relevant. But 
i've seen projects get bogged down in many different languages too, the skills 
of a company to produce are varied and include project management. 

There could be many, many reasons the Rails project didn't do too well and the 
.NET project is going better. And I bet few of them are to do with Rails.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: multiple django instances, one database?

2010-04-22 Thread Andy McKay

On 2010-04-22, at 9:52 AM, Tim Arnold wrote:

> hi,
> Until now I've been working on a single Freebsd server, hosting a
> couple of Django apps. Now we've bought another machine to provide
> load balancing and I'm wondering how to accomplish that.
> I guess the django code can be shared on the same drive, but the
> django instances running separately of course (apache/mod_python).
> 
> Is it possible to have two instances accessing the same database? How
> do you handle load-balancing?

Yes you can. There's lots of options, http://www.apsis.ch/pound/ is but one.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: multi-language capabilities of Django/Satchmo

2010-04-27 Thread Andy McKay
> I'm interested in finding out more about practical use of django's
> multi-language capabilities for international sites.  Do any of you
> have experience with this?  And can you point towards resources/apps
> etc. for utilizing these features?

This is for i18n of the interface: 
http://docs.djangoproject.com/en/dev/topics/i18n/

For content this is a great talk from djangoski: 
http://docs.google.com/fileview?id=0B29qXMz8reouYzJhMjhhZDMtOTQ5MC00NjY3LWIxM2EtY2U3ZmI2NzQzYjk3&hl=en
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Open source CMS (if based on Django better)

2010-05-07 Thread Andy McKay

On 2010-05-05, at 12:52 PM, Jonatan.mv wrote:

> What would be you recommended CMS?. Could you please give some reasons
> (pro and cons)?.


Just to confuse things, don't forget you can pretty much use any non-Django CMS 
as long as it can write to a relational database. All depends what you want to 
do.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multiple django version on developer machine

2010-05-11 Thread Andy McKay

On 2010-05-11, at 7:26 PM, james_027 wrote:
> While I have a number of django apps develop for Django 1.1 ... I also
> want to use Django 1.2 for my new project. How can I have multiple
> version of Django in my machine where my apps will be instructed
> either to use 1.1 or 1.2

You should look at using virtualenv to isolate your environment:

http://pypi.python.org/pypi/virtualenv
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking for a Django Developer

2010-05-21 Thread Andy McKay

On 2010-05-21, at 9:49 AM, Tom X. Tobin wrote:
> Job postings are perfectly relevant for django-users.  (Although
> follow-up replies to job postings should be handled via private email,
> and not on-list.)
> 
> By the way, djangogigs is not free; it costs $145 to post a job listing there.

http://djangozen.com/jobs is free
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Weekly rss feed

2010-06-21 Thread Andy McKay

On 2010-06-21, at 5:48 PM, TheIvIaxx wrote:
> I was wondering how to create a weekly feed for django.  Lets say i
> have a table of objects that gets added to all week long.  I'd like to
> allow people to subscribe to a feed that would give a single update
> with all items that were added that week.  Since the client doesn't
> send anything about when it last checked for updates, it's hard to
> determine if the requesting client needs to be given an update or not.

A few points:

- RSS readers keep track of all the things that have been read and don't 
display duplicates, so I don't really see a need for doing this anyway

- You maybe want a script that runs once a week and produces a summary post of 
all the things entered that week, but that just gives you one item.

- Or you just do a query that specifies the time range, eg: filter and only 
show posts in the last seven days.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django logging

2010-06-23 Thread Andy McKay

On 2010-06-23, at 8:48 AM, thusjanthan wrote:
> I am creating a new django framework and figured django would come
> with its own logging feature. I found this one that Fraser wrote but
> is no longer in development (http://code.google.com/p/django-logging/
> wiki/Overview) Can anyone suggest me a django logging project to log
> debug/error messages at server level and as a bonus feature perhaps an
> email to admin if a critical error happens.

Give Arecibo a look. 

http://www.areciboapp.com/
http://www.areciboapp.com/docs/client/django.html
http://www.agmweb.ca/blog/andy/2268/

etc...

Cheers
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Signal emitted after successful login?

2010-06-29 Thread Andy McKay
On 2010-06-29, at 10:48 AM, tiemonster wrote:

> Is a signal emitted after a successful login? I need to hook a
> particular piece of code into that point in the application.


Not specifically, if you are using django.contrib.auth last_login is set by 
some scripts, eg the login django.contrib.auth.login. So you can listen to the 
save signals on that model.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Parsing xml containing image - rawImage gif

2010-07-05 Thread Andy McKay
On 2010-07-05, at 8:09 AM, Bjørn Høj Jakobsen wrote:

> I have the following xml. how do I pass the image to a file.


This isn't really relevant to Django. 

There are libraries in Python for parsing XML, try using those: 
http://docs.python.org/modindex.html#cap-X

There are also SOAP libraries: http://www.google.ca/search?q=soap+python
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: News on every page

2010-07-08 Thread Andy McKay
On 2010-07-08, at 9:07 AM, Martin Tiršel wrote:
> 1.) Where is the right place to place news loader? 
> TEMPLATE_CONTEXT_PROCESSORS seems to be a good place and easy to implement. 
> Another possibility is a middleware, I feel, that it should go there instead 
> of TEMPLATE_CONTEXT_PROCESSORS.


Middleware is not the appropriate place, a context processor is the appropriate 
place.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Get pk before commit

2010-07-09 Thread Andy McKay
> I'd like to save the image file into a folder based on the ID of the
> new instance.

I wouldn't actually recommend saving your file with the filename being the 
primary key of your model anyway. It makes it a pain if you do database dumps 
or loads and need to keep the primary key in sync with your files. I would 
recommend making a UID field on your model (which also doesn't require a 
transaction) and using that for your filename.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: python logging and multiple process issue?

2010-07-12 Thread Andy McKay
Are you wanting to log errors that occur in your django site? If that's the 
case I'd recommend starting with simple tools like django's email logging and 
working up to more sophisticated tools like django-db-log or arecibo.

If you want to debug development code or you will find python's built in 
logging will be just fine for all but the most complicated of use cases. 

If you want to do access logging, your web server does that for you.
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Anyone want to take over maintaining Instant Django?

2010-07-13 Thread Andy McKay

On 2010-07-13, at 7:37 AM, cjl wrote:

> I no longer have the time or interest to maintain my little project:
> 
> http://www.instantdjango.com

> I'll also give you my 'build' script, but it no longer works correctly
> because the Python core devs broke the Windows installer, and mocked
> me when I reported the bug.

Is the source for building it in some sort of source control eg: github?
--
  Andy McKay, @andymckay
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Historical Records from "Pro Django" - not working with multiple foreign keys?

2010-01-05 Thread Andy McKay

On 10-01-05 11:54 AM, Stodge wrote:

I'm trying to use the Historical Records feature from Marty Alchin's
"Pro Django" book, but it's not working for me when my model has two
foreign keys to users. I'm getting

  Accessor for field 'owner' clashes with related field Add a
related_name argument to the definition for 'owner'. etc

It doesn't work if I add a related name to the field in my object. So
either I'm doing something silly or Historical Records don't work with
multiple foreign keys. Anyone used this successfully in this manner?


I hit the same problems with that feature. In the end number of 
relationships and tables it created got so complicated, that we gave up 
on it. We used http://code.google.com/p/django-reversion/ instead, but 
there are other choices.

--
  Andy McKay, @clearwind
  Whistler conference: http://clearwind.ca/djangoski/
-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Historical Records from "Pro Django" - not working with multiple foreign keys?

2010-01-05 Thread Andy McKay

On 10-01-05 12:00 PM, Stodge wrote:

Does a Revision instance represent a snapshot of the database or the
state of a single object?


As far as I remember: the state of a single object, however you'd likely 
be best starting a new thread on the specific Django reversion thread 
and issues rather than changing the thread mid stream.

--
  Andy McKay, @clearwind
  Whistler conference: http://clearwind.ca/djangoski/
-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: 500 internal error when posting

2010-01-07 Thread Andy McKay
You really need to find a way to get the traceback, without that its 
really hard to say what the problem is. Tools like http://areciboapp.com 
are useful for this, but just setting DEBUG=True and restarting your 
Apache/whatever should be enough.

--
  Andy McKay, @clearwind
  Whistler conference: http://clearwind.ca/djangoski/
-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Seeking Django developer for contract work

2010-01-08 Thread Andy McKay

On 10-01-08 2:47 PM, Nick Lo wrote:

We have an RFP for 3 web-based prototype applications. We have posted
to various freelance sites and I was wondering if anyone here could
advise where to post to ensure we get a Django solution proposed.


There is no where to post to "ensure to get a Django solution proposed". 
There is no company behind Django, just lots of companies and developers.


Pay sites like djangogigs or even free ones like djangozen.com/jobs can 
work. If you think you need a Django solution proposed from a company, I 
would recommend contacting Django consulting companies directly.

--
  Andy McKay, @clearwind
  Whistler conference: http://clearwind.ca/djangoski/
-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Register signal on all objects

2010-01-09 Thread Andy McKay

On 10-01-08 7:02 AM, Matias wrote:

Is there any recommended way to attach a post_save signal to ALL models?


When you create a signal you can optionally assign a model to listen 
too. Not doing that means it is called for all models.


http://docs.djangoproject.com/en/dev/topics/signals/#connecting-to-signals-sent-by-specific-senders
--
  Andy McKay, @clearwind
  Whistler conference: http://clearwind.ca/djangoski/
-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Djangoski Early Bird - time running out

2010-01-13 Thread Andy McKay

Time is running out for the DjangoSki Early Bird, sign up soon:

http://www.clearwind.ca/djangoski/register.html
--
  Andy McKay, @clearwind
  Whistler conference: http://clearwind.ca/djangoski/
-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: permalinks from cron job

2010-01-18 Thread Andy McKay

You can set a prefix here:

http://code.djangoproject.com/browser/django/trunk/django/core/urlresolvers.py#L364
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Gathering performance statistics

2010-02-02 Thread Andy McKay
I was going to build something like this for Django since neither 
django-tracking or analytics quite tick all the boxes. I was going to use 
carrot and celery using this great example here:

http://ask.github.com/celery/tutorials/clickcounter.html

If you do build something, that's probably the way you want to go.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: FieldError with get_object_or_404

2010-02-04 Thread Andy McKay

On 2010-02-04, at 7:36 AM, harryos wrote:
> In the shell I tried this
> from django.shortcuts import  get_object_or_404 as gtobj
> e1=gtobj(MyEntry,posted_time__year=2010,posted_time__month=2,posted_time__day=1)
> This is successful ,it gives this message
> MultipleObjectsReturned: get() returned more than one MyEntry -- it
> returned 4!

get(..) assumes there's one and only one object, hence the error.

> However when I tried ,
> e1=gtobj(MyEntry,posted_time__year=2010,posted_time__month=2,posted_time__day=1,posted_time__hour=10)
> 
> I get this error,
> FieldError: Join on field 'posted_time' not permitted. Did you
> misspell 'hour' for the lookup type?

There are lookups for year, month and day as documented here:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#year

But *not* hour or minute.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Slow admin performance with specific inline

2010-02-08 Thread Andy McKay
Try using the django-debug-toolbar and see if that tells you anything useful.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Callback method on session timeout

2010-02-08 Thread Andy McKay

On 2010-02-06, at 4:08 PM, adamjamesdrew wrote:

> Does django have the ability to do a callback when a session time out
> occurs?

No, there is no session time out. Its just that a session isn't valid anymore.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dictionary Model Merge

2010-02-15 Thread Andy McKay

On 2010-02-15, at 2:31 PM, cootetom wrote:

> Thanks Javier but I'm having problems with that. I do want to create a
> dictionary from the model first then override with the POST values.
> But when I try to make a dictionary from the model I get an 'object is
> not iterable' error.

Without the code that generates that error or the traceback, we can't provide 
much help.

One thing that is useful is model_to_dict, eg:

http://www.djangozen.com/blog/useful-django-apis
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: python manage.py test --omit=bad_app_one,bad_app_two

2010-02-17 Thread Andy McKay

On 2010-02-17, at 12:43 PM, Phlip wrote:

> Djangoids:
> 
> As Django apps get bigger, the odds that some contributed test cases
> fail go up.
> 
> (They fail for environmental reasons, and if nobody is changing their
> code at your site, then their test failures are less relevant!)
> 
> How can I knock out a list of apps from the test command line?

In the past for this I've defined a custom test runner:

http://docs.djangoproject.com/en/dev/ref/settings/#test-runner

But I haven't seen anything else that does that.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is the user member of a certain group

2010-02-22 Thread Andy McKay

On 2010-02-22, at 2:56 PM, Joakim Hove wrote:
> Any tip on how to write the "user_is_member_of_admin_group()"
> function?

You can access the groups via the ManyRelatedManager, which exposes a queryset: 
user.groups.filter(...)

eg: if user.groups.filter(name="Admin")
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Deciding how to start building a search form

2010-02-23 Thread Andy McKay

On 2010-02-23, at 12:50 PM, Nick wrote:
> Anyways, what I'm wondering is, should I build this up by hand or
> should I use something like haystack?  I am only querying against a DB
> and not en entire site.

Doing a search on one model is pretty straightforward. If however you need to 
do full text searches or searches on more than one model at a time, then you 
will need something like haystack.
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Optimizing template rendering and database queries

2010-02-23 Thread Andy McKay
> I would like to include the following values on my admin pages, as
> part of the base_site:
> time_to_query_database
> time_to_render_page

django-debug-toolbar has all that and more
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django in the enterprise?

2010-02-24 Thread Andy McKay

On 2010-02-24, at 6:40 AM, Steven Elliott Jr wrote:
> Right now we have Java and ASP.NET doing most of the work for us but the 
> systems are old and need updating. Not to mention budgetary constraints are 
> big thing now. I used Django to write an intranet application and it was very 
> nice and I think I can probably handle the other stuff, just wanted to draw 
> on other's experience.

Yes there are many large scale (in terms of data and complexity) running on 
Django. We've just completed a large "enterprise" project converting classic 
ASP to Django and its gone extremely well. It's not on djangosites because the 
NDA denies it.

What you might need to consider if you are pitching to management is making 
sure that training, consulting and support is available from companies (which 
it is).
--
  Andy McKay, @clearwind
  http://clearwind.ca/djangoski

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django marketplace?

2010-03-11 Thread Andy McKay

On 2010-03-11, at 8:50 AM, Tom Evans wrote:
> djangogigs.com

djangozen.com/jobs as well (and it's free)
--
  Andy McKay, @clearwind

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: getting request.user from a signal

2010-03-11 Thread Andy McKay
> Yes, this is essentially the same topic that was discussed here: 
> http://groups.google.com/group/django-users/browse_thread/thread/44ced967d9da3500
> However, there has not yet been an answer, and I think this particular (and 
> probably common) use-case renders the "write a function that accepts a user 
> argument" untenable.

No, but there's lots of other solutions. Marty Alchin solves this nicely with 
CurrentUserMiddleware:

http://bit.ly/9lIxsM

I've been wanting to make this into a reusable app for a long time, but the 
license on that code snippet is unclear.
--
  Andy McKay, @clearwind

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Strange difference between runserver and shell

2010-03-11 Thread Andy McKay
> Does anybody have any clue what the problem might be? Thanks for your help!

There should be no difference really between the two. What might help us if you 
show us the code that the runs from the shell and the code in the view.
--
  Andy McKay, @clearwind

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Strange difference between runserver and shell

2010-03-11 Thread Andy McKay
> def writer_stories(request, writer):
># Look up the writer (and raise a 404 if it can't be found).
>written=get_object_or_404(Writer, slug__iexact=writer)
>return list_detail.object_list(
>request,
>queryset=Entry.live.filter(writer=written),
>template_name='newssite/writer_archive.html',
>template_object_name='stories',


Presumably you've used pdb or simple print statements in your code to verify 
the results that the queryset is empty?
After that, look at your templates (this looks like you are using generic 
views).
--
  Andy McKay, @clearwind

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How execute erlang code ?

2010-03-11 Thread Andy McKay
On 2010-03-11, at 7:02 PM, nameless wrote:
> How can I execute erlang code through django views ?


A django view is just python, so ask yourself how you would execute erlang from 
python and the answer is you probably won't but you could be doing something 
like (first hit in Google for erland and python): 

http://code.activestate.com/recipes/534162-an-erlang-port-in-python/

or using the builtin popen functions:

http://docs.python.org/library/os.html#os.popen

--
  Andy McKay, @clearwind

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: DB Adapter for HTML5 Client Database Storage?

2010-04-07 Thread Andy McKay
Porting the Django ORM to Javascript would be great, but quite a lot of work. 
Go for it!

In the meantime I'm playing around (as noted in Daniels post) using the wrapper 
around lawnchair, which in turn stores stuff in the client side database if 
present, and to be honest that's enough for me ;)
--
  Andy McKay, @clearwind
  Django Consulting, Training and Support

-- 
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 to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



  1   2   >