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
-~--~~~~--~~--~--~---



are model field choices enumerated in the db?

2009-08-16 Thread cerberos

when the choices attribure is used for a model field are the choices
enumerated in the database?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django-tinymce and filebrowser, error.

2009-08-16 Thread tdelam

Hey,

I built a web site locally, I am using django-tinyce and the django-
filebrowser, it works no problem on my local machine. As soon as I
deploy it to the server I have a problem. The TinyMCE is showing up
and working fine but when I click inside the image popup window to add
an image, I get an error:

f is undefined
[Break on this error] return f.apply(s || t, Array.prototype.slice.call
(arguments, 1));\r\n  - tiny_mce_src.js (line 9360)

This line of code looks like this:

return f.apply(s || t, Array.prototype.slice.call(arguments, 1));

i am not really sure why and how to even debug this. I am a stumped
because it works locally so I can't really tell where to go from here.
Any suggestions?

Trevor
--~--~-~--~~~---~--~~
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: Problem with getting setting up apache server for django

2009-08-16 Thread NiJoMi

Done a reinstall and checked each step.
---
Step 1: Installed WampServer2 and verified working
Location: C:\imfree
Components of WampServer 2.0i [11/07/09]
Apache 2.2.11
MySQL 5.1.36
PHP 5.3.0
---
Step 2: Set up test enviroment
Created following folders
E:\localhost
E:\Django\djangotest
E:\Django\testsite2
placed unique index.html in each folder
edited hosts:
added
127.0.0.1   djangotest.lc
127.0.0.1   testsite2.lc
---
Step 3: Set up Virtual Hosts
Edits to files:

httpd.conf:
# Uncommented following
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

http-vhosts.conf:
# Virtual Hosts
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#

ServerAdmin webmas...@djangotest.lc
DocumentRoot "E:/Django/djangotest"
ServerName djangotest.lc
ServerAlias www.djangotest.lc
ErrorLog "logs/djangotest.lc-error.log"
CustomLog "logs/djangotest.lc-access.log" common

Order allow,deny
Allow from all




ServerAdmin webmas...@testsite2.lc
DocumentRoot "E:/Django/testsite2"
ServerName testsite2.lc
ServerAlias www.testsite2.lc
ErrorLog "logs/testsite2.lc-error.log"
CustomLog "logs/testsite2.lc-access.log" common

Order allow,deny
Allow from all




ServerAdmin webmas...@dummy-host2.localhost
DocumentRoot "E:/localhost"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common

Order allow,deny
Allow from all


Started server [ :) Working]
Stopped server
---
Step 4: Installed Python 2.6.2
Location: C:\imfree\bin [keeping things tidy]
tested and verified working by the following methods
1. Start>All Programs>Python 2.6>python [ :) Working]
2. Start>Run>CMD
   >cd C:\imfree\bin\Python26
   C:\imfree\bin\Python26>python [ :) Working]
---
Step 5. Install Django SVN
Location: C:\imfree\bin\Python26\Lib\site-packages\django
copied django-admin.py to C:\imfree\bin\Python26\Tools\Scripts
Tested by first deleting folder E:\Django\djangotest
then:
1.  Start>All Progams>Python 2.6>python
entered import django into Python command line Result no errors.

2.  Start>Run>CMD
>E:
E:\>cd DJango
E:\Django>django-admin.py startproject djangotest
'django-admin.py' is not recocognised as an internal or external
command,
operable program or batch file. [ :( missing path?. use 
set_path.]
E:\Django>set path=%path%;C:\imfree\bin\Python26\Tools\Scripts 
[path
to django-admin.py]
E:\Django>django-admin startproject djangotest
E:\Django>cd djangotest
E:\Django\djangotest>python manage.py runserver
'python' is not recocognised as an internal or external command,
operable program or batch file. [ :( missing path?. use 
set_path.]
E:\Django\djangotest>set path=%path%;C:\imfree\bin\Python26 
[path to
python]
E:\Django\djangotest>python manage.py runserver
Validating models...
0 errors found

Django version 1.2 pre-alpha SVN-11464, using settings
'djangotest.settings'
Development server is running at http://127.0.0.1:800/
Quit the server with CTRL-BREAK. [ :) Working]

3.  Test with built in server
edited httpd-vhosts.conf:
 #changed to port 8000
ServerAdmin webmas...@djangotest.lc
DocumentRoot "E:/Django/djangotest"
ServerName djangotest.lc
ServerAlias www.djangotest.lc
ErrorLog "logs/djangotest.lc-error.log"
CustomLog "logs/djangotest.lc-access.log" common

Order allow,deny
Allow from all
  

Re: Possible to use Django & MySQL with Python 2.6?

2009-08-16 Thread Alex Gaynor

On Sun, Aug 16, 2009 at 11:32 PM, Continuation wrote:
>
> According to the site of the python MySQL driver it only supports
> Python 2.3 - 2.5:
> http://sourceforge.net/projects/mysql-python/
>
> So is it possible to use Django & MySQL with Python 2.6? Is there any
> workaround I can do to make it work?
> >
>

MySQL works fine for me under Python 2.6, you get a warning when you
import it, but that doesn't prevent normal execution, it's just
annoying ;)

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Possible to use Django & MySQL with Python 2.6?

2009-08-16 Thread Continuation

According to the site of the python MySQL driver it only supports
Python 2.3 - 2.5:
http://sourceforge.net/projects/mysql-python/

So is it possible to use Django & MySQL with Python 2.6? Is there any
workaround I can do to make it work?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Success at using "reusable apps"?

2009-08-16 Thread Margie Roginski

I have a general question about how people manage "reusable apps" in
the web app world.  Let me give an example of what I am encountering,
maybe those of you with experience can comment.

I'm developing an app that is a task management app.  IE, an
engineering manger creates tasks, spawns them off to engineers,
engineers generate results, record those results in the app and the
manager sits in a meeting and quickly runs through the tasks
(displayed by my webapp, updated by the engineers and managers), fand
igures out "what's next", creating new tasks on the fly.

I've recently integrated Eric Florenzano's threaded comments app into
my app (thanks much to Eric!).  So far I've kept the threaded
threadedcomments functionality fairly decoupled from my own
"taskmanager" app.  For example, when the user adds a comment the post
goes to a URL that is defined in threadedcomments/urls.py, and then
gets sent the views.py function in threadecomments/views.py code.
However, as I've continued developing my UI,  I'm finding that it is
hard to keep them so decoupled.  For example, one of the html pages
rendered to my users is similar to the django admin changelist.  It
shows a filtered set of tasks and for each task shows a very brief
horizontal summary of the most important aspects of the task (task
name, owner, deadline, etc.).  Now that I have this nice comment app I
find that I want the user to be able to easly view the most recent
comment associated with the task.  No problem there. In my
"changelist" view I now display a "date modified" column, and in that
column I render the date of the last comment.  When the user mouses
over that date, they get a jquery "cluetip" (tooltip) that contains
the most recent comment.  All good.  However, the next thing I realize
I now need is the ability to sort on that column . So therein lies the
problem.

All other columns can be easily sorted on using order_by() because
they are fields in my Task model.  But the date of the last comment is
not.  I can of course create a field in my Task object that records
the date of a comment whenever a comment is added, but since a comment
is added via a threadecomments/views.py function, that would mean
doing one of the following:

 * modify the threadedcomments views.py code that receives the POST
for a new comment, and make it just know about my Task model (and save
the comment date and perhaps a id for the last comment in my Task
model).

 * 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)

 * give up on using the threadedcomments views.py function that
creates a new comment, and just do the same stuff in my Task app (ie,
handle the POST of a new comment), using the models specified by
threadedcomment, but also saving the date and id of last comment in my
Task object.

  * Do my sort ordering with something more custom than the standard
order_by() - ie, something that looks at the date of the last
ThreadedComment object that is associated with the task.  I'm sure
there must be a way to do this, but I'm concerned it could be very
slow, not sure though, perhaps there is sql magic I could do.

I can see other times when I will have similar problems, as well.  For
example, when a task is added, I would like the user to be able to add
a comment along with the other data - this seems like it cause a
similar problem.  I already have a "task add" form - so it seems that
I need to integrate the comment into my own form, which means I'd have
to deal with creation of that comment within my own views.py code, and
not just rely on the views.py in the threadedcomments app.


My goal is to have clean and reusable code, follow DRY principles,
etc..  I'd like to be able to integrate a new version of
threadedcomments into my app, if it becomes available, but I'm
concerned that I'm proceeding down a path that will make that
difficult, so I'm curious if any of you with lots of web app
experience can lend any insights toward the best way to manage this
sort of issue.

Sorry for the long post here.  Hopefully this is an interesting topic
to some of you out there!

Margie
--~--~-~--~~~---~--~~
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: misunderstanding

2009-08-16 Thread Mike Dewhirst

Karen and Eric - thank you. Yet another door opened for me :)

Mike


Karen Tracey wrote:
> On Sun, Aug 16, 2009 at 9:33 PM, Mike Dewhirst  
> Based on what your template does, you don't seem to really want to 
> combine a dictionary with the key 'title' and the META dictionary. 
> Rather you want a dictionary with the key 'title' and the key 
> 'meta_dict', with the value for the 'meta_dict' key being the META 
> dictionary:
> 
> def display_meta(request):
> dct = {'title':'META items',}
> dct['meta_dict'] = request.META
> return render_to_response('polls/meta_dict.html', dct)
> 
> Karen
> 

Eric Abrahamsen wrote:
> 
> On Aug 17, 2009, at 9:33 AM, Mike Dewhirst wrote:
> Variables should be passed to the template as a dictionary, so this  
> response line should look like this:
> 
> return render_to_response('polls/meta_dict.html', {'meta_dict':  
> meta_dict}
> 
> Then it will be available in your template. My guess is that, since  
> meta_dict is itself a dictionary, you can currently access its  
> contents in your template by directly using its keys as variables.




> 
>  meta_dict.html 
> {% extends "base_polls.html" %}
> {% block content_title %}{{ title }}{% endblock %}
> {% block content %}
> {% if meta_dict %}
> 
> {% for key, value in meta_dict.items %}
>  {{ key }} {{ value }}
> {% endfor %}
> 
> {% else %}
> No meta dictionary passed
> {% endif %}
> {% endblock %}
> -
> 
> 
> > 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



aggregate(Sum('x')) returns None

2009-08-16 Thread kesmit

I've noticed that the Sum('x') function will return None if there are
no records in the queryset.  This doesn't seem correct to me.
Shouldn't Sum always return a Decimal?  It makes it difficult to
compute more complex expressions when you can't depend on a number
being returned.
--~--~-~--~~~---~--~~
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: Class Meta discovery

2009-08-16 Thread James Bennett

On Sun, Aug 16, 2009 at 10:14 PM, aa56280 wrote:
> Not sure how well known this is but I thought I'd share seeing as how
> it cost me a lot of time and I can't find any discussion of it:

This is a well-known aspect of Python which is usually covered by any
good introductory Python tutorial.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Class Meta discovery

2009-08-16 Thread aa56280

Not sure how well known this is but I thought I'd share seeing as how
it cost me a lot of time and I can't find any discussion of it:

I have a form for a model. The model has three fields, but I only want
one displayed in the form. So I do this:

class NoteForm(ModelForm):

class Meta:
model = Note
fields = ('text')

Looks good, but craps out with: 'Caught an exception while rendering:
'NoneType' object has no attribute 'label''.

I checked the ModelForms documentation and they have this example when
discussing field exclusion:

class PartialAuthorForm(ModelForm):
class Meta:
model = Author
exclude = ('birth_date',)

Notice the comma after 'birth_date'? That was it. Hope this helps
someone.
--~--~-~--~~~---~--~~
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: misunderstanding

2009-08-16 Thread Karen Tracey
On Sun, Aug 16, 2009 at 9:33 PM, Mike Dewhirst wrote:

>
> There's something here I'm not seeing. If anyone can point out the docco
> which refers I would be most grateful ... I'm using py2.6 and Django
> from svn head.
>
> The template below displays the title correctly but claims "No meta
> dictionary passed". Since the title is one of the meta_dict key:value
> pairs I feel this should not be. Also, when I uncomment the #print line
> below, the entire meta_dict, including 'title': 'META items' prints.
>
> Thanks for any pointers ...
>
> Mike
>
>  views.py (excerpt) ---
> def display_meta(request):
> dct = {'title':'META items',}
> meta_dict = dict(request.META.items())
> meta_dict.update(dct)
> #print(meta_dict)
> return render_to_response('polls/meta_dict.html', meta_dict)
> 
>

Based on what your template does, you don't seem to really want to combine a
dictionary with the key 'title' and the META dictionary. Rather you want a
dictionary with the key 'title' and the key 'meta_dict', with the value for
the 'meta_dict' key being the META dictionary:

def display_meta(request):
dct = {'title':'META items',}
dct['meta_dict'] = request.META
return render_to_response('polls/meta_dict.html', dct)

Karen

>
>  meta_dict.html 
> {% extends "base_polls.html" %}
> {% block content_title %}{{ title }}{% endblock %}
> {% block content %}
> {% if meta_dict %}
> 
> {% for key, value in meta_dict.items %}
>  {{ key }} {{ value }}
> {% endfor %}
> 
> {% else %}
> No meta dictionary passed
> {% endif %}
> {% endblock %}
> -
>
>

--~--~-~--~~~---~--~~
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: misunderstanding

2009-08-16 Thread Eric Abrahamsen


On Aug 17, 2009, at 9:33 AM, Mike Dewhirst wrote:

>
> There's something here I'm not seeing. If anyone can point out the  
> docco
> which refers I would be most grateful ... I'm using py2.6 and Django
> from svn head.
>
> The template below displays the title correctly but claims "No meta
> dictionary passed". Since the title is one of the meta_dict key:value
> pairs I feel this should not be. Also, when I uncomment the #print  
> line
> below, the entire meta_dict, including 'title': 'META items' prints.
>
> Thanks for any pointers ...
>
> Mike
>
>  views.py (excerpt) ---
> def display_meta(request):
> dct = {'title':'META items',}
> meta_dict = dict(request.META.items())
> meta_dict.update(dct)
> #print(meta_dict)
> return render_to_response('polls/meta_dict.html', meta_dict)

Variables should be passed to the template as a dictionary, so this  
response line should look like this:

return render_to_response('polls/meta_dict.html', {'meta_dict':  
meta_dict}

Then it will be available in your template. My guess is that, since  
meta_dict is itself a dictionary, you can currently access its  
contents in your template by directly using its keys as variables.

Hope that works,
Eric

> 
>
>  meta_dict.html 
> {% extends "base_polls.html" %}
> {% block content_title %}{{ title }}{% endblock %}
> {% block content %}
> {% if meta_dict %}
> 
> {% for key, value in meta_dict.items %}
>  {{ key }} {{ value }}
> {% endfor %}
> 
> {% else %}
> No meta dictionary passed
> {% endif %}
> {% endblock %}
> -
>
>
>
> >


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



misunderstanding

2009-08-16 Thread Mike Dewhirst

There's something here I'm not seeing. If anyone can point out the docco 
which refers I would be most grateful ... I'm using py2.6 and Django 
from svn head.

The template below displays the title correctly but claims "No meta 
dictionary passed". Since the title is one of the meta_dict key:value 
pairs I feel this should not be. Also, when I uncomment the #print line 
below, the entire meta_dict, including 'title': 'META items' prints.

Thanks for any pointers ...

Mike

 views.py (excerpt) ---
def display_meta(request):
 dct = {'title':'META items',}
 meta_dict = dict(request.META.items())
 meta_dict.update(dct)
 #print(meta_dict)
 return render_to_response('polls/meta_dict.html', meta_dict)


 meta_dict.html 
{% extends "base_polls.html" %}
{% block content_title %}{{ title }}{% endblock %}
{% block content %}
{% if meta_dict %}
 
 {% for key, value in meta_dict.items %}
  {{ key }} {{ value }}
 {% endfor %}
 
{% else %}
 No meta dictionary passed
{% endif %}
{% endblock %}
-



--~--~-~--~~~---~--~~
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: Setting tzinfo for DateTimeFields with Postgresql - workaround

2009-08-16 Thread Ramiro Morales

Hi George,

On Thu, May 21, 2009 at 7:56 PM, George Song wrote:
>
> Hi Glenn,
>
> When you get the chance can you review my proposal[1] for fixing
> DateTimeField in Django?
>
> I'm going to try to get this in for 1.2 release.
>
> [1] http://code.djangoproject.com/ticket/10587
>

I've took the liberty of adding this to the Version1.2Features wikipage that is
currently being used as a bag of potential 1.2 modifications:

  http://code.djangoproject.com/wiki/Version1.2Features?action=diff=55

Feel free to fix  the description if the one I used isn't correct.

Regards,

-- 
Ramiro Morales
http://rmorales.net

PyCon 2009 Argentina - Vie 4 y Sab 5 Setiembre
Buenos Aires, Argentina
http://ar.pycon.org/2009/about/

--~--~-~--~~~---~--~~
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: QuerySet's cache

2009-08-16 Thread David

Ah, ok that makes more sense now. Thank you!

On Aug 16, 5:52 pm, Alex Gaynor  wrote:
> On Sun, Aug 16, 2009 at 8:42 AM, David wrote:
>
> > Hi all,
>
> > I'm a bit puzzled by the caching behaviour of QuerySets, when used in
> > iteration and when called with repr(). According to the documentation,
> > when a QuerySet is evaluated for the first time, the results are
> > cached.
>
> > Trying this out in the shell, this works as expected for iteration.
> > However when used with repr(), the QuerySet does not seem to be using
> > the cache, and I was just wondering if this is the correct behaviour.
>
> > I'll just illustrate this with a quick example. The Tag model has a
> > single field, name.
>
> > # starting with no tags
>  Tag.objects.all()
> > []
>
> > # create a tag
>  Tag.objects.create(name='one')
> > 
>
> > # as expected
>  Tag.objects.all()
> > []
>
> > # assigning the QuerySet, as illustrated in documentation
>  queryset = Tag.objects.all()
>
> > # evaluate, by implicitly calling repr()
>  queryset
> > []
>
>  Tag.objects.create(name='two')
> > 
>
> > # expecting queryset to use cache, which does not contain new tag
>  queryset
> > [, ]
>
> > # hmm, maybe not??
>
> > Any help on clarifying this would be greatly appreciated!
>
> > David
>
> The issue here is how __repr__ works on QuerySets, specifically it
> does repr(list(self[:MAX_REPR_SIZE])) that slicing causes it to create
> a new queryset, and so the result cache isn't populated in your
> QuerySet.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~-~--~~~---~--~~
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: Anybody?? uber-newb question... installing django

2009-08-16 Thread jzacsh
Thanks a bunch! :)
__
Jonathan Zacsh
www.jzacsh.com
via mobile phone

-Original Message-
From: Wayne Koorts 

Date: Mon, 17 Aug 2009 11:06:50 
To: 
Subject: Re: Anybody?? uber-newb question... installing django



Hi Jon,

The "python setup.py install" command copies the Django library files
to your Python's lib\site-packages directory.  You can safely remove
the Django archive which you downloaded.

Regards,
Wayne

2009/8/17 Jonathan Zacsh :
>
> please, can anyone help me out??
> --
> Jon
>
>
> On Sun, Aug 16, 2009 at 10:20 AM, jzacsh wrote:
>> hello,
>>
>> i'm sorry - i just want to get started and I'm trying to figure out
>> something simple. I installed django last night and am wondering what
>> setup.py actually did.
>>
>> the reason i want to know is: what do i do with the folder of stuff
>> that I downloaded from the original tar.gz (I get the impression its
>> important, as when i tried to move it I had to use sudo)? so can I
>> delete it (when i ran setup.py, it looked like a lot of files were
>> copying... maybe it was copied elsewhere anyway so this one isn't
>> needed?)? I tried reading docs/intro/install.txt (didn't explain much
>> for this purpose) and i tried making sense of the code in setup.py
>> (turned out to be a bit over my head).
>>
>> I'm running Mac OS X 10.5.8
>> i'm also trying to teach myself python, so sorry if something here
>> might seem obvious.
>> and i know there is a useful docs folder in there, but i'm using
>> docs.djangoproject.com
>> (maybe someone wants to advise me: "django is gonna be WAY over your
>> head if you don't have a good grasp of python"?)
>>
>> thanks for any help! :)
>
> >
>



--~--~-~--~~~---~--~~
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: Anybody?? uber-newb question... installing django

2009-08-16 Thread Wayne Koorts

Hi Jon,

The "python setup.py install" command copies the Django library files
to your Python's lib\site-packages directory.  You can safely remove
the Django archive which you downloaded.

Regards,
Wayne

2009/8/17 Jonathan Zacsh :
>
> please, can anyone help me out??
> --
> Jon
>
>
> On Sun, Aug 16, 2009 at 10:20 AM, jzacsh wrote:
>> hello,
>>
>> i'm sorry - i just want to get started and I'm trying to figure out
>> something simple. I installed django last night and am wondering what
>> setup.py actually did.
>>
>> the reason i want to know is: what do i do with the folder of stuff
>> that I downloaded from the original tar.gz (I get the impression its
>> important, as when i tried to move it I had to use sudo)? so can I
>> delete it (when i ran setup.py, it looked like a lot of files were
>> copying... maybe it was copied elsewhere anyway so this one isn't
>> needed?)? I tried reading docs/intro/install.txt (didn't explain much
>> for this purpose) and i tried making sense of the code in setup.py
>> (turned out to be a bit over my head).
>>
>> I'm running Mac OS X 10.5.8
>> i'm also trying to teach myself python, so sorry if something here
>> might seem obvious.
>> and i know there is a useful docs folder in there, but i'm using
>> docs.djangoproject.com
>> (maybe someone wants to advise me: "django is gonna be WAY over your
>> head if you don't have a good grasp of python"?)
>>
>> thanks for any help! :)
>
> >
>

--~--~-~--~~~---~--~~
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: Anybody?? uber-newb question... installing django

2009-08-16 Thread Jonathan Zacsh

please, can anyone help me out??
--
Jon


On Sun, Aug 16, 2009 at 10:20 AM, jzacsh wrote:
> hello,
>
> i'm sorry - i just want to get started and I'm trying to figure out
> something simple. I installed django last night and am wondering what
> setup.py actually did.
>
> the reason i want to know is: what do i do with the folder of stuff
> that I downloaded from the original tar.gz (I get the impression its
> important, as when i tried to move it I had to use sudo)? so can I
> delete it (when i ran setup.py, it looked like a lot of files were
> copying... maybe it was copied elsewhere anyway so this one isn't
> needed?)? I tried reading docs/intro/install.txt (didn't explain much
> for this purpose) and i tried making sense of the code in setup.py
> (turned out to be a bit over my head).
>
> I'm running Mac OS X 10.5.8
> i'm also trying to teach myself python, so sorry if something here
> might seem obvious.
> and i know there is a useful docs folder in there, but i'm using
> docs.djangoproject.com
> (maybe someone wants to advise me: "django is gonna be WAY over your
> head if you don't have a good grasp of python"?)
>
> thanks for any help! :)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django and MySQL 5.4

2009-08-16 Thread Thiago511

Are they compatible?
Django official website tells me to get the MySQLdb from
djangoproject.com/r/python-mysql

I tried installing it but it says that I need Python 2.5.I have
2.6
what SQL servers would you guys recommend?
I need a secure one like Open SSL
--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread Graham Dumpleton



On Aug 16, 10:43 pm, zayatzz  wrote:
> apparently installing mod_wsgi was not the instant get out of trouble
> card.
>
> For a while i had problem with mod_wsgi settings. Now the trouble with
> modules continues. I think i must somehow finally fix all the paths.
>
> current error is :
> [Sun Aug 16 12:38:22 2009] [error] [client 127.0.0.1]     raise
> ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> [Sun Aug 16 12:38:22 2009] [error] [client 127.0.0.1]
> ImproperlyConfigured: Error loading MySQLdb module: No module named
> MySQLdb

Nothing to do with paths. You simply have to install the MySQLdb
module from source code for that specific Python installation. You
can't have it use copy from another Python installation.

Graham

> Alan
>
> On Aug 16, 2:56 pm, zayatzz  wrote:
>
>
>
> > z...@zayatzz:/var/log/apache2$ ls -las /usr/local/lib/python2.6/site-
> > packages
> > total 27
> >  0 drwxrwsr-x  3 root staff   144 2009-08-16 12:09 .
> > 19 drwxrwsr-x 26 root staff 19392 2009-08-16 10:54 ..
> >  1 drwxr-sr-x 17 root staff   496 2009-08-16 12:09 django
> >  4 -rw-r--r--  1 root staff   947 2009-08-16 12:09 Django-1.1-
> > py2.6.egg-info
> >  4 -rw-r--r--  1 root staff   119 2009-08-16 10:53 README
>
> > I reinstalled it with ubuntu's aptitude. So as i get it,. i should
> > recompile mod_python
>
> > I was thinking about using mod_wsgi myself...
>
> > I'll investigate mod_wsgi setup.
>
> > Should i keep something in mind now that i have stackless instead of
> > regular python?
>
> > Alan.
>
> > On Aug 16, 2:37 pm, Graham Dumpleton 
> > wrote:
>
> > > On Aug 16, 9:24 pm, zayatzz  wrote:
>
> > > > I did reinstall mod_python indeed.
>
> > > Then you can't have installed it for that version of Python. Did you
> > > use the --with-python option to 'configure' for mod_python to tell it
> > > to use your alternate Python installation? That or the installed
> > > mod_python is not readable to the user that Apache runs as. What do
> > > you get for:
>
> > >   ls -las /usr/local/lib/python2.6/site-packages
>
> > > You might want to also consider using mod_wsgi instead as simpler to
> > > get working than mod_python.
>
> > > Graham
>
> > > > when i do import mod_python then :
>
> > > > >>> import mod_python
>
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > > ImportError: No module named mod_python
>
> > > > so nope  :(
>
> > > > Alan
>
> > > > On Aug 16, 2:01 pm, Graham Dumpleton 
> > > > wrote:
>
> > > > > Did you actually bother to reinstall mod_python after you nuked your
> > > > > original Python installation. Likely when reinstalling it you lost
> > > > > everything that was in prior site-packages and so are missing the
> > > > > Python module component bits of mod_python, ie., no longer installed.
>
> > > > > If from command line stackless Python you go:
>
> > > > >   import mod_python
>
> > > > > does it actually find the module?
>
> > > > > Graham
>
> > > > > On Aug 16, 8:51 pm, zayatzz  wrote:
>
> > > > > > i begun to think about the same thing when i went through the log.
>
> > > > > > Couldnt find anything useful why mod_python is failing atm, so i
> > > > > > anyone can think of why this is not working - i still could use your
> > > > > > help. Otherwise since it has nothing to do with django, i'll try to
> > > > > > get help though stackoverflow and google :)
>
> > > > > > Alan
>
> > > > > > On Aug 16, 1:19 pm, Austin Gabel  wrote:
>
> > > > > > > It looks like the issue is occurring when Apache tries to load 
> > > > > > > mod_python.
> > > > > > > This doesn't have anything to do with Django at this point.  You 
> > > > > > > may need to
> > > > > > > do a bit more research on how Stackless Python works with Apache 
> > > > > > > and
> > > > > > > mod_python.
>
> > > > > > > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz 
> > > > > > >  wrote:
>
> > > > > > > > apache error log shows such stuff:
>
> > > > > > > >http://dpaste.com/81241/
>
> > > > > > > > Alan.
>
> > > > > > > > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > > > > > > > Hello
>
> > > > > > > > > I installed stackless pyton 2.6.2 after reading several sites 
> > > > > > > > > that
> > > > > > > > > said its fully compatible with vanilla python. After 
> > > > > > > > > installing i
> > > > > > > > > found that my django applications do not work any more.
>
> > > > > > > > > I did reinstall django (1.1) again and now im kind of lost. 
> > > > > > > > > The error
> > > > > > > > > that i get is 500:
>
> > > > > > > > > Internal Server Error
>
> > > > > > > > > The server encountered an internal error or misconfiguration 
> > > > > > > > > and was
> > > > > > > > > unable to complete your request.
>
> > > > > > > > > Please contact the server administrator, 

Display Tables

2009-08-16 Thread haftish21

I'm new to django, my first time 2 use it.

I read this in the Writing your first Django app, part 1 document

>>> If you're interested, run the command-line client for your database and 
>>> type \dt (PostgreSQL), SHOW TABLES; (MySQL), or .schema (SQLite) to display 
>>> the tables Django created.

>>>I'm using PostgreSQL, and I successfully run python manage.py syncdb and saw 
>>>the created ten tables using pgAdmin III client. What I'm not clear with is 
>>>about the \dt command. How do I run it?

--~--~-~--~~~---~--~~
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: Render template tags together

2009-08-16 Thread Doug B

I don't know if it's the best approach or not, but what I've done in
the past is to have the first call to the tag do any expensive stuff
and store it in a dict under a special name in the context (I usually
use __tagname).  Subsequent calls to the tag use the data from the
context variable rather than rebuilding it each time.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Render template tags together

2009-08-16 Thread Jonas Obrist

hi django-users

I try to improve the performance of my web app and one of the things I 
want to do is render all occurrences of a certain tag at once instead of 
each on its own. The reason is simple: Each template tag loops over a 
series of regex pattern out of a database which it has to compile. 
Imagine the following:


for occurrence in templatetag:
for pattern, substitution in database:
regex = re.compile(pattern)
regex.sub(substitution, occurrence.content)

Now what I'd prefer is doing:

for pattern, substitution in database:
regex = re.compile(pattern)
for occurence in templatetag:
regex.sub(substitution, occurrence.content)


Sort of collecting all tags in a template with that name and render them 
collectively. Any ideas how I can achieve that with a custom template tag?

Jonas

--~--~-~--~~~---~--~~
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: 3 questions about DecimalFields

2009-08-16 Thread bobhaugen

Karen,

Once again, thanks for the detailed and useful response.

On Aug 16, 1:17 pm, Karen Tracey  wrote:
> If the Python object was created on the fly and relied on the default value:
>
> dt1 = DThing()
> dt1.save()

> Then prior to the fix for that bug, dt1.remaining and dt2.remaining would be
> unicode strings instead of Decimal objects.  The fix for #5903 corrects
> things so that remaining is a Decimal value in this case.

That's how it was (if I understand what you wrote correctly).  The
object that experienced the error was created and saved, and then the
next object was created and saved, and while being saved, called back
to the first object. (And both objects were created and saved in the
same view).
--~--~-~--~~~---~--~~
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: Unicode Text for Dictionary Keys ok for Templates?

2009-08-16 Thread Karen Tracey
On Sun, Aug 16, 2009 at 1:28 PM, rmschne  wrote:

>
> I'm extracting data from a database and then cross-tabbing the data
> (with some Python) code to create a list of dictionary data.  Because
> the key names are derived from data in the database, and the database
> is composed of unicode text, the keys are unicode, e.g. here are three
> records in the list of dictionaries:
>
> 'Date': datetime.date(2009, 3, 31), (u'ORM',): 1L, (u'ORMR',): 23L},


You might want to revisit how you are creating these dictionaries, because
your 'unicode' keys are not unicode.  They are single-element tuples where
the single elements are unicode strings.  Note the parens and comma in
(u'ORM',): 1L, for example.  If the key was the unicode string u'ORM' this
would show up as simply u'ORM': 1L.


>
> [snip]
> The template is
> {% for li in member_stats %}
> {{ li.Date }} {{li.HON }} {{li.ORM }} {{li.ORMR }} {{li.CORP1 }}
> {{li.CORP2 }} {{li.CORP3 }}
> {% endfor %}
>
> The Date fields come out as expected.  The other fields do not.
>
> Is it because they are Unicode? If so, how to deal with this.  As
> mentioned, these aren't hard-coded, but are coming originally from the
> data to construct a cross tab table (sometimes called Pivot Table).
>

>From a template li.HON will translate to the dictionary lookup li[u'HON'] in
Python.  That will find a matching unicode key u'HON' but you don't have
that, your keys are tuples.  You can experiment in the shell to see what
happens:

>>> key1 = u'ORM'
>>> key2 = (u'ORMR',)
>>> d = {key1: 1L, key2: 23L}
>>> d
{u'ORM': 1L, (u'ORMR',): 23L}
>>> d['ORM']
1L
>>> d['ORMR']
Traceback (most recent call last):
  File "", line 1, in 
KeyError: 'ORMR'
>>> d[('ORMR',)]
23L
>>>

I think you want to fix your dictionary creation step to actually create
keys that are unicode, not single-element tuples.

Karen

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



send_mail function

2009-08-16 Thread ramanathan

HI

In the message field i tried to include a link using href.

send_mail("subject"," Click here ",
'a...@yahoo.co.in', ['a...@gmail.com'] )

But it is not working. How to include a link in the message field of
send_mail function?


Thanks & regards,
Ramanathan M
--~--~-~--~~~---~--~~
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: 3 questions about DecimalFields

2009-08-16 Thread Karen Tracey
On Sun, Aug 16, 2009 at 12:24 PM, bobhaugen  wrote:

>
> 1, I ran into this anomaly in updating a decimal field:
>
> The field:
>
>remaining = models.DecimalField(max_digits=8, decimal_places=2,
> default=Decimal("0"))
>
> The code that failed:
>
>  658   self.remaining -= qty
>  659   self.remaining = max([Decimal("0"), self.remaining])
>  660  self.save()
>
> The error message:
>
>  TypeError
> unsupported operand type(s) for -=: 'unicode' and 'Decimal'
> models.py in update_from_transaction, line 658
>
> The workaround:
>
>remaining = Decimal(self.remaining)
>remaining -= qty
>self.remaining = max([Decimal("0"), remaining])
>self.save()
>
> So, what gives?
>
> Is this an example of this bug?
> http://code.djangoproject.com/ticket/5903
>
> (P.S. the object being updated had been saved before the code in error
> ran.  In other words, the error happened in a re-update of a
> previously saved object.)
>

Might be, but hard to say for sure based on the information.  For that bug
it does not matter if the model instance has been saved (though the first
sentence of the description may mislead one to think that), it matters how
the Python object you are working with was created, and you didn't tell us
that.  If you retrieved it from the database (assuming DThing is the model
containing the field remaining):

dt = DThing.objects.get(pk=n)

then dt.remaining should be a DecimalField, with or without the fix for that
bug.

If the Python object was created on the fly and relied on the default value:

dt1 = DThing()
dt1.save()

or:

dt2 = DThing.objects.create()

Then prior to the fix for that bug, dt1.remaining and dt2.remaining would be
unicode strings instead of Decimal objects.  The fix for #5903 corrects
things so that remaining is a Decimal value in this case.

If the Python object was created on the fly and specified remaining as a
unicode string:

dt3 = DThing.objects.create(remaining=u'44')

then dt3.remaining will be a unicode string, since that is what was passed
in during creation.  (Same if you use the sequence of calls used for dt1
instead of using create.)  This is the point mentioned here:

http://code.djangoproject.com/ticket/5903#comment:10

This behavior is not affected by the fix for #5903.


>
> 2. This changeset says it has fixed ticket #5903:
> http://code.djangoproject.com/changeset/9823
>
> Also says it was fixed 6 months ago.  I did not find the ticket listed
> in any of the milestones in the last 6 months, and the page does not
> list a milestone.  Does that mean it has not been included in any
> release, and awaits 1.2?
>

No.  The milestone field is just a way of tagging work to be done, it has no
effect on what changesets go into a release.  All changesets applied to
trunk prior to the 1.1 release are part of 1.1, thus r9823, which was
applied to trunk in Feb., is included in 1.1.

Since this sounds like a bug fix, it should also have been applied to the
1.0.X branch as well, but the ticket doesn't note that.  Unfortunately the
post-commit hook that automatically adds those notes sometimes fails to
trigger (I have no idea why) so they are sometimes missing and you have to
manually check to see if a particular changeset was backported to a branch.
In this case just hitting "Next changeset" on that changeset's page shows
that this fix was also applied to the 1.0.X  branch:

http://code.djangoproject.com/changeset/9824

Thus the fix is also available in the first release of 1.0.X made after Feb.
09, which is 1.0.3.


>
> 3. Also, what is the best practice for specifying a DecimalField
> default?  I did some googling and found code using default="0",
> default=Decimal(0), default=Decimal("0"), and default=Decimal("0.0").
> I did some tests and they all seem to work.
>

Best practice is for it to be a Decimal object, not a string.  Beyond that I
don't care to differentiate though personally I'd attempt to be consistent
and not mix passing in integers and strings and strings with trailing
fractional zero parts willy-nilly.

Karen

--~--~-~--~~~---~--~~
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: carrying value from ForeignKey

2009-08-16 Thread kmike

I mean smth. like
lambda: self.content.text


On 16 авг, 20:41, Ali Rıza Keleş  wrote:
> Hello,
>
> I want to carry value as default from one model to another.
>
> For example:
>
> class Text(models.Model):
>     text = models.TextField(blank = True)
>     name = models.SlugField(db_index=True, unique=True)
>
> class News(models.Model):
>     content = models.ForeignKey(Text, blank = True, null = True,
> defaut=)
>     text = models.SlugField(db_index=True, unique=True)
>
> I want to set content's default value as Text's text value. What can I
> put here instead of **?
>
> Thank you..
>
> --
> Ali Rıza
--~--~-~--~~~---~--~~
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: carrying value from ForeignKey

2009-08-16 Thread kmike

You can override `save` method or maybe provide callable ***,
smth. like

default=lambda: self.text

but i haven't test it.

On 16 авг, 20:41, Ali Rıza Keleş  wrote:
> Hello,
>
> I want to carry value as default from one model to another.
>
> For example:
>
> class Text(models.Model):
>     text = models.TextField(blank = True)
>     name = models.SlugField(db_index=True, unique=True)
>
> class News(models.Model):
>     content = models.ForeignKey(Text, blank = True, null = True,
> defaut=)
>     text = models.SlugField(db_index=True, unique=True)
>
> I want to set content's default value as Text's text value. What can I
> put here instead of **?
>
> Thank you..
>
> --
> Ali Rıza
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Unicode Text for Dictionary Keys ok for Templates?

2009-08-16 Thread rmschne

I'm extracting data from a database and then cross-tabbing the data
(with some Python) code to create a list of dictionary data.  Because
the key names are derived from data in the database, and the database
is composed of unicode text, the keys are unicode, e.g. here are three
records in the list of dictionaries:

'Date': datetime.date(2009, 3, 31), (u'ORM',): 1L, (u'ORMR',): 23L},
{(u'EXEC',): 48L, (None,): 39L, (u'POT',): 10L, (u'HON',): 65L,
(u'CORP1',): 1L, (u'CORP2',): 4L, (u'CORP3',): 7L, 'Date':
datetime.date(2009, 4, 30), (u'ORM',): 1L, (u'ORMR',): 23L},
{(u'EXEC',): 48L, (None,): 39L, (u'POT',): 10L, (u'HON',): 65L,
(u'CORP1',): 1L, (u'CORP2',): 4L, (u'CORP3',): 7L, 'Date':
datetime.date(2009, 5, 31), (u'ORM',): 1L, (u'ORMR',): 23L},
{(u'EXEC',): 48L, (None,): 39L, (u'POT',): 10L, (u'HON',): 65L,
(u'CORP1',): 1L, (u'CORP2',): 4L, (u'CORP3',): 7L, 'Date':
datetime.date(2009, 6, 30), (u'ORM',): 1L, (u'ORMR',): 23L},

the call to get the template created (I'm writing to a file):

t=get_template('memberdir/member_statistics.html')
f.write(smart_str(t.render(Context({'member_stats': n}

where "n" is the list of dictionaries.

The template is
{% for li in member_stats %}
{{ li.Date }} {{li.HON }} {{li.ORM }} {{li.ORMR }} {{li.CORP1 }}
{{li.CORP2 }} {{li.CORP3 }}
{% endfor %}

The Date fields come out as expected.  The other fields do not.

Is it because they are Unicode? If so, how to deal with this.  As
mentioned, these aren't hard-coded, but are coming originally from the
data to construct a cross tab table (sometimes called Pivot Table).

--rms

--~--~-~--~~~---~--~~
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: 3 questions about DecimalFields

2009-08-16 Thread bobhaugen

On Aug 16, 11:24 am, bobhaugen  wrote:
> 2. This changeset says it has fixed ticket 
> #5903:http://code.djangoproject.com/changeset/9823
>
> Also says it was fixed 6 months ago.  I did not find the ticket listed
> in any of the milestones in the last 6 months, and the page does not
> list a milestone.  Does that mean it has not been included in any
> release, and awaits 1.2?

Oh, and forgive the omission, but I'm running on django 1.02.
--~--~-~--~~~---~--~~
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: QuerySet's cache

2009-08-16 Thread Alex Gaynor

On Sun, Aug 16, 2009 at 8:42 AM, David wrote:
>
> Hi all,
>
> I'm a bit puzzled by the caching behaviour of QuerySets, when used in
> iteration and when called with repr(). According to the documentation,
> when a QuerySet is evaluated for the first time, the results are
> cached.
>
> Trying this out in the shell, this works as expected for iteration.
> However when used with repr(), the QuerySet does not seem to be using
> the cache, and I was just wondering if this is the correct behaviour.
>
> I'll just illustrate this with a quick example. The Tag model has a
> single field, name.
>
> # starting with no tags
 Tag.objects.all()
> []
>
> # create a tag
 Tag.objects.create(name='one')
> 
>
> # as expected
 Tag.objects.all()
> []
>
> # assigning the QuerySet, as illustrated in documentation
 queryset = Tag.objects.all()
>
> # evaluate, by implicitly calling repr()
 queryset
> []
>
 Tag.objects.create(name='two')
> 
>
> # expecting queryset to use cache, which does not contain new tag
 queryset
> [, ]
>
> # hmm, maybe not??
>
> Any help on clarifying this would be greatly appreciated!
>
> David
>
> >
>

The issue here is how __repr__ works on QuerySets, specifically it
does repr(list(self[:MAX_REPR_SIZE])) that slicing causes it to create
a new queryset, and so the result cache isn't populated in your
QuerySet.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



3 questions about DecimalFields

2009-08-16 Thread bobhaugen

1, I ran into this anomaly in updating a decimal field:

The field:

remaining = models.DecimalField(max_digits=8, decimal_places=2,
default=Decimal("0"))

The code that failed:

 658   self.remaining -= qty
 659   self.remaining = max([Decimal("0"), self.remaining])
  660  self.save()

The error message:

 TypeError
unsupported operand type(s) for -=: 'unicode' and 'Decimal'
models.py in update_from_transaction, line 658

The workaround:

remaining = Decimal(self.remaining)
remaining -= qty
self.remaining = max([Decimal("0"), remaining])
self.save()

So, what gives?

Is this an example of this bug?
http://code.djangoproject.com/ticket/5903

(P.S. the object being updated had been saved before the code in error
ran.  In other words, the error happened in a re-update of a
previously saved object.)

2. This changeset says it has fixed ticket #5903:
http://code.djangoproject.com/changeset/9823

Also says it was fixed 6 months ago.  I did not find the ticket listed
in any of the milestones in the last 6 months, and the page does not
list a milestone.  Does that mean it has not been included in any
release, and awaits 1.2?

3. Also, what is the best practice for specifying a DecimalField
default?  I did some googling and found code using default="0",
default=Decimal(0), default=Decimal("0"), and default=Decimal("0.0").
I did some tests and they all seem to work.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



carrying value from ForeignKey

2009-08-16 Thread Ali Rıza Keleş

Hello,

I want to carry value as default from one model to another.

For example:

class Text(models.Model):
text = models.TextField(blank = True)
name = models.SlugField(db_index=True, unique=True)

class News(models.Model):
content = models.ForeignKey(Text, blank = True, null = True,
defaut=)
text = models.SlugField(db_index=True, unique=True)

I want to set content's default value as Text's text value. What can I
put here instead of **? 

Thank you..

--
Ali Rıza


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



uber-newb question... installing django

2009-08-16 Thread jzacsh

hello,

i'm sorry - i just want to get started and I'm trying to figure out
something simple. I installed django last night and am wondering what
setup.py actually did.

the reason i want to know is: what do i do with the folder of stuff
that I downloaded from the original tar.gz (I get the impression its
important, as when i tried to move it I had to use sudo)? so can I
delete it (when i ran setup.py, it looked like a lot of files were
copying... maybe it was copied elsewhere anyway so this one isn't
needed?)? I tried reading docs/intro/install.txt (didn't explain much
for this purpose) and i tried making sense of the code in setup.py
(turned out to be a bit over my head).

I'm running Mac OS X 10.5.8
i'm also trying to teach myself python, so sorry if something here
might seem obvious.
and i know there is a useful docs folder in there, but i'm using
docs.djangoproject.com
(maybe someone wants to advise me: "django is gonna be WAY over your
head if you don't have a good grasp of python"?)

thanks for any help! :)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



QuerySet's cache

2009-08-16 Thread David

Hi all,

I'm a bit puzzled by the caching behaviour of QuerySets, when used in
iteration and when called with repr(). According to the documentation,
when a QuerySet is evaluated for the first time, the results are
cached.

Trying this out in the shell, this works as expected for iteration.
However when used with repr(), the QuerySet does not seem to be using
the cache, and I was just wondering if this is the correct behaviour.

I'll just illustrate this with a quick example. The Tag model has a
single field, name.

# starting with no tags
>>> Tag.objects.all()
[]

# create a tag
>>> Tag.objects.create(name='one')


# as expected
>>> Tag.objects.all()
[]

# assigning the QuerySet, as illustrated in documentation
>>> queryset = Tag.objects.all()

# evaluate, by implicitly calling repr()
>>> queryset
[]

>>> Tag.objects.create(name='two')


# expecting queryset to use cache, which does not contain new tag
>>> queryset
[, ]

# hmm, maybe not??

Any help on clarifying this would be greatly appreciated!

David

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



how do you display custom permissions on admin site?

2009-08-16 Thread sam lee

Hi,

I have the following model;

class MyModel(models.Model):
class Meta:
permissions = (('test_perm', 'a test permission'),)

I run syncdb and runserver

Then I go to /admin/auth/user/1/

But I don't see the myapp | test_perm listed under Permissions field.
Do I need to do some extra step to make my custom permissions
available to admin site?
Or am I completely missing the point of custom permissions?

Thank you.
Sam.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



something wrong with extra_context

2009-08-16 Thread iXh

i do my site, there is something wrong with extra_context
i define the url processer in urls.py follow as:
url(r'^$', 'simple.direct_to_template',
kwargs={'template': 'index.html','extra_context':
{'item_list': lambda: Item.objects.all()}},name = 'index'),

and in my template , when render my template, 'item_list'  cann't  be
recongnized
it encounter exception follow as:
'Caught an exception while rendering: global name 'self_id' is not
defined'

i want to know how to solute the problem

--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread zayatzz

apparently installing mod_wsgi was not the instant get out of trouble
card.

For a while i had problem with mod_wsgi settings. Now the trouble with
modules continues. I think i must somehow finally fix all the paths.

current error is :
[Sun Aug 16 12:38:22 2009] [error] [client 127.0.0.1] raise
ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
[Sun Aug 16 12:38:22 2009] [error] [client 127.0.0.1]
ImproperlyConfigured: Error loading MySQLdb module: No module named
MySQLdb

Alan

On Aug 16, 2:56 pm, zayatzz  wrote:
> z...@zayatzz:/var/log/apache2$ ls -las /usr/local/lib/python2.6/site-
> packages
> total 27
>  0 drwxrwsr-x  3 root staff   144 2009-08-16 12:09 .
> 19 drwxrwsr-x 26 root staff 19392 2009-08-16 10:54 ..
>  1 drwxr-sr-x 17 root staff   496 2009-08-16 12:09 django
>  4 -rw-r--r--  1 root staff   947 2009-08-16 12:09 Django-1.1-
> py2.6.egg-info
>  4 -rw-r--r--  1 root staff   119 2009-08-16 10:53 README
>
> I reinstalled it with ubuntu's aptitude. So as i get it,. i should
> recompile mod_python
>
> I was thinking about using mod_wsgi myself...
>
> I'll investigate mod_wsgi setup.
>
> Should i keep something in mind now that i have stackless instead of
> regular python?
>
> Alan.
>
> On Aug 16, 2:37 pm, Graham Dumpleton 
> wrote:
>
> > On Aug 16, 9:24 pm, zayatzz  wrote:
>
> > > I did reinstall mod_python indeed.
>
> > Then you can't have installed it for that version of Python. Did you
> > use the --with-python option to 'configure' for mod_python to tell it
> > to use your alternate Python installation? That or the installed
> > mod_python is not readable to the user that Apache runs as. What do
> > you get for:
>
> >   ls -las /usr/local/lib/python2.6/site-packages
>
> > You might want to also consider using mod_wsgi instead as simpler to
> > get working than mod_python.
>
> > Graham
>
> > > when i do import mod_python then :
>
> > > >>> import mod_python
>
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > > ImportError: No module named mod_python
>
> > > so nope  :(
>
> > > Alan
>
> > > On Aug 16, 2:01 pm, Graham Dumpleton 
> > > wrote:
>
> > > > Did you actually bother to reinstall mod_python after you nuked your
> > > > original Python installation. Likely when reinstalling it you lost
> > > > everything that was in prior site-packages and so are missing the
> > > > Python module component bits of mod_python, ie., no longer installed.
>
> > > > If from command line stackless Python you go:
>
> > > >   import mod_python
>
> > > > does it actually find the module?
>
> > > > Graham
>
> > > > On Aug 16, 8:51 pm, zayatzz  wrote:
>
> > > > > i begun to think about the same thing when i went through the log.
>
> > > > > Couldnt find anything useful why mod_python is failing atm, so i
> > > > > anyone can think of why this is not working - i still could use your
> > > > > help. Otherwise since it has nothing to do with django, i'll try to
> > > > > get help though stackoverflow and google :)
>
> > > > > Alan
>
> > > > > On Aug 16, 1:19 pm, Austin Gabel  wrote:
>
> > > > > > It looks like the issue is occurring when Apache tries to load 
> > > > > > mod_python.
> > > > > > This doesn't have anything to do with Django at this point.  You 
> > > > > > may need to
> > > > > > do a bit more research on how Stackless Python works with Apache and
> > > > > > mod_python.
>
> > > > > > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz 
> > > > > >  wrote:
>
> > > > > > > apache error log shows such stuff:
>
> > > > > > >http://dpaste.com/81241/
>
> > > > > > > Alan.
>
> > > > > > > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > > > > > > Hello
>
> > > > > > > > I installed stackless pyton 2.6.2 after reading several sites 
> > > > > > > > that
> > > > > > > > said its fully compatible with vanilla python. After installing 
> > > > > > > > i
> > > > > > > > found that my django applications do not work any more.
>
> > > > > > > > I did reinstall django (1.1) again and now im kind of lost. The 
> > > > > > > > error
> > > > > > > > that i get is 500:
>
> > > > > > > > Internal Server Error
>
> > > > > > > > The server encountered an internal error or misconfiguration 
> > > > > > > > and was
> > > > > > > > unable to complete your request.
>
> > > > > > > > Please contact the server administrator, webmas...@localhost and
> > > > > > > > inform them of the time the error occurred, and anything you 
> > > > > > > > might
> > > > > > > > have done that may have caused the error.
>
> > > > > > > > More information about this error may be available in the 
> > > > > > > > server error
> > > > > > > > log.
> > > > > > > > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with 
> > > > > > > > Suhosin-Patch
> > > > > > > > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 
> > > > > > 

Re: with statements

2009-08-16 Thread GuyBowden

Alex,

It's a Tag, so will give the filter route a go - shouldn't take too
much to swap it over.. at the moment this is the only place I'm using
the tag/filter..

Guy

On Aug 16, 1:37 pm, Alexander Dutton  wrote:
> On 16/08/09 09:50, GuyBowden wrote:
>
>
>
> > Hi All,
>
> > Just wondering what the best way to do this sort of thing is:
>
> > {% with last_tweet_sent this_user as sent_at %}
> >    {{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}}
> > {% endwith %}
>
> > I've got a function "last_tweet_sent" in a templatetags module that
> > takes a user and spits back the last time they sent a tweet.
>
> > I'd like to keep the formatting of the date in the template rather
> > than in the templatetag module (best practice?)
>
> > But I can't use the with statement to put the result of my function
> > call in a variable - I guess because of the spacing there for calling
> > the function with an argument.
>
> > Any suggestions?
>
> > Cheers,
>
> > Guy
>
> Just to clarify, is your last_tweet_sent a template tag or a template
> filter? In the first instance you won't be able to do what you want, and
> it's probably overkill. In the second instance you should be able to do:
>
> > {% with this_user|last_tweet_sent as sent_at %}
> >    {{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}}
> > {% endwith %}
>
> The template fitler definition would look something like this:> 
> @register.filter(name='last_tweet_sent')
> > def last_tweet_sent(user):
> >     # work out when it was and call it dt
> >     return dt
>
> The alternative is to make it a method on the user object, but that requires 
> a bit more fu in replacing the User model with a custom one. From what I 
> remember, [1] is the place that tells you how to do it. Again, this method is 
> probably overkill ;-).
>
> Alex
>
> [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m...
--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread zayatzz

z...@zayatzz:/var/log/apache2$ ls -las /usr/local/lib/python2.6/site-
packages
total 27
 0 drwxrwsr-x  3 root staff   144 2009-08-16 12:09 .
19 drwxrwsr-x 26 root staff 19392 2009-08-16 10:54 ..
 1 drwxr-sr-x 17 root staff   496 2009-08-16 12:09 django
 4 -rw-r--r--  1 root staff   947 2009-08-16 12:09 Django-1.1-
py2.6.egg-info
 4 -rw-r--r--  1 root staff   119 2009-08-16 10:53 README

I reinstalled it with ubuntu's aptitude. So as i get it,. i should
recompile mod_python

I was thinking about using mod_wsgi myself...

I'll investigate mod_wsgi setup.

Should i keep something in mind now that i have stackless instead of
regular python?

Alan.


On Aug 16, 2:37 pm, Graham Dumpleton 
wrote:
> On Aug 16, 9:24 pm, zayatzz  wrote:
>
> > I did reinstall mod_python indeed.
>
> Then you can't have installed it for that version of Python. Did you
> use the --with-python option to 'configure' for mod_python to tell it
> to use your alternate Python installation? That or the installed
> mod_python is not readable to the user that Apache runs as. What do
> you get for:
>
>   ls -las /usr/local/lib/python2.6/site-packages
>
> You might want to also consider using mod_wsgi instead as simpler to
> get working than mod_python.
>
> Graham
>
> > when i do import mod_python then :
>
> > >>> import mod_python
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ImportError: No module named mod_python
>
> > so nope  :(
>
> > Alan
>
> > On Aug 16, 2:01 pm, Graham Dumpleton 
> > wrote:
>
> > > Did you actually bother to reinstall mod_python after you nuked your
> > > original Python installation. Likely when reinstalling it you lost
> > > everything that was in prior site-packages and so are missing the
> > > Python module component bits of mod_python, ie., no longer installed.
>
> > > If from command line stackless Python you go:
>
> > >   import mod_python
>
> > > does it actually find the module?
>
> > > Graham
>
> > > On Aug 16, 8:51 pm, zayatzz  wrote:
>
> > > > i begun to think about the same thing when i went through the log.
>
> > > > Couldnt find anything useful why mod_python is failing atm, so i
> > > > anyone can think of why this is not working - i still could use your
> > > > help. Otherwise since it has nothing to do with django, i'll try to
> > > > get help though stackoverflow and google :)
>
> > > > Alan
>
> > > > On Aug 16, 1:19 pm, Austin Gabel  wrote:
>
> > > > > It looks like the issue is occurring when Apache tries to load 
> > > > > mod_python.
> > > > > This doesn't have anything to do with Django at this point.  You may 
> > > > > need to
> > > > > do a bit more research on how Stackless Python works with Apache and
> > > > > mod_python.
>
> > > > > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz  
> > > > > wrote:
>
> > > > > > apache error log shows such stuff:
>
> > > > > >http://dpaste.com/81241/
>
> > > > > > Alan.
>
> > > > > > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > > > > > Hello
>
> > > > > > > I installed stackless pyton 2.6.2 after reading several sites that
> > > > > > > said its fully compatible with vanilla python. After installing i
> > > > > > > found that my django applications do not work any more.
>
> > > > > > > I did reinstall django (1.1) again and now im kind of lost. The 
> > > > > > > error
> > > > > > > that i get is 500:
>
> > > > > > > Internal Server Error
>
> > > > > > > The server encountered an internal error or misconfiguration and 
> > > > > > > was
> > > > > > > unable to complete your request.
>
> > > > > > > Please contact the server administrator, webmas...@localhost and
> > > > > > > inform them of the time the error occurred, and anything you might
> > > > > > > have done that may have caused the error.
>
> > > > > > > More information about this error may be available in the server 
> > > > > > > error
> > > > > > > log.
> > > > > > > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with 
> > > > > > > Suhosin-Patch
> > > > > > > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 
> > > > > > > Ruby/1.8.7(2008-08-11)
> > > > > > > mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> > > > > > > Alan
>
>
--~--~-~--~~~---~--~~
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: with statements

2009-08-16 Thread Alexander Dutton

On 16/08/09 09:50, GuyBowden wrote:
> Hi All,
>
> Just wondering what the best way to do this sort of thing is:
>
> {% with last_tweet_sent this_user as sent_at %}
>   {{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}}
> {% endwith %}
>
> I've got a function "last_tweet_sent" in a templatetags module that
> takes a user and spits back the last time they sent a tweet.
>
> I'd like to keep the formatting of the date in the template rather
> than in the templatetag module (best practice?)
>
> But I can't use the with statement to put the result of my function
> call in a variable - I guess because of the spacing there for calling
> the function with an argument.
>
> Any suggestions?
>
> Cheers,
>
> Guy
>   
Just to clarify, is your last_tweet_sent a template tag or a template
filter? In the first instance you won't be able to do what you want, and
it's probably overkill. In the second instance you should be able to do:

> {% with this_user|last_tweet_sent as sent_at %}
>   {{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}}
> {% endwith %}
The template fitler definition would look something like this:
> @register.filter(name='last_tweet_sent')
> def last_tweet_sent(user):
> # work out when it was and call it dt
> return dt
The alternative is to make it a method on the user object, but that requires a 
bit more fu in replacing the User model with a custom one. From what I 
remember, [1] is the place that tells you how to do it. Again, this method is 
probably overkill ;-).

Alex

[1] http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/




--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread Graham Dumpleton



On Aug 16, 9:24 pm, zayatzz  wrote:
> I did reinstall mod_python indeed.

Then you can't have installed it for that version of Python. Did you
use the --with-python option to 'configure' for mod_python to tell it
to use your alternate Python installation? That or the installed
mod_python is not readable to the user that Apache runs as. What do
you get for:

  ls -las /usr/local/lib/python2.6/site-packages

You might want to also consider using mod_wsgi instead as simpler to
get working than mod_python.

Graham

> when i do import mod_python then :
>
> >>> import mod_python
>
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: No module named mod_python
>
>
>
> so nope  :(
>
> Alan
>
> On Aug 16, 2:01 pm, Graham Dumpleton 
> wrote:
>
>
>
> > Did you actually bother to reinstall mod_python after you nuked your
> > original Python installation. Likely when reinstalling it you lost
> > everything that was in prior site-packages and so are missing the
> > Python module component bits of mod_python, ie., no longer installed.
>
> > If from command line stackless Python you go:
>
> >   import mod_python
>
> > does it actually find the module?
>
> > Graham
>
> > On Aug 16, 8:51 pm, zayatzz  wrote:
>
> > > i begun to think about the same thing when i went through the log.
>
> > > Couldnt find anything useful why mod_python is failing atm, so i
> > > anyone can think of why this is not working - i still could use your
> > > help. Otherwise since it has nothing to do with django, i'll try to
> > > get help though stackoverflow and google :)
>
> > > Alan
>
> > > On Aug 16, 1:19 pm, Austin Gabel  wrote:
>
> > > > It looks like the issue is occurring when Apache tries to load 
> > > > mod_python.
> > > > This doesn't have anything to do with Django at this point.  You may 
> > > > need to
> > > > do a bit more research on how Stackless Python works with Apache and
> > > > mod_python.
>
> > > > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz  
> > > > wrote:
>
> > > > > apache error log shows such stuff:
>
> > > > >http://dpaste.com/81241/
>
> > > > > Alan.
>
> > > > > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > > > > Hello
>
> > > > > > I installed stackless pyton 2.6.2 after reading several sites that
> > > > > > said its fully compatible with vanilla python. After installing i
> > > > > > found that my django applications do not work any more.
>
> > > > > > I did reinstall django (1.1) again and now im kind of lost. The 
> > > > > > error
> > > > > > that i get is 500:
>
> > > > > > Internal Server Error
>
> > > > > > The server encountered an internal error or misconfiguration and was
> > > > > > unable to complete your request.
>
> > > > > > Please contact the server administrator, webmas...@localhost and
> > > > > > inform them of the time the error occurred, and anything you might
> > > > > > have done that may have caused the error.
>
> > > > > > More information about this error may be available in the server 
> > > > > > error
> > > > > > log.
> > > > > > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> > > > > > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> > > > > > mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> > > > > > Alan
--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread zayatzz

I did reinstall mod_python indeed.

when i do import mod_python then :

>>> import mod_python
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named mod_python
>>>

so nope  :(

Alan

On Aug 16, 2:01 pm, Graham Dumpleton 
wrote:
> Did you actually bother to reinstall mod_python after you nuked your
> original Python installation. Likely when reinstalling it you lost
> everything that was in prior site-packages and so are missing the
> Python module component bits of mod_python, ie., no longer installed.
>
> If from command line stackless Python you go:
>
>   import mod_python
>
> does it actually find the module?
>
> Graham
>
> On Aug 16, 8:51 pm, zayatzz  wrote:
>
> > i begun to think about the same thing when i went through the log.
>
> > Couldnt find anything useful why mod_python is failing atm, so i
> > anyone can think of why this is not working - i still could use your
> > help. Otherwise since it has nothing to do with django, i'll try to
> > get help though stackoverflow and google :)
>
> > Alan
>
> > On Aug 16, 1:19 pm, Austin Gabel  wrote:
>
> > > It looks like the issue is occurring when Apache tries to load mod_python.
> > > This doesn't have anything to do with Django at this point.  You may need 
> > > to
> > > do a bit more research on how Stackless Python works with Apache and
> > > mod_python.
>
> > > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz  
> > > wrote:
>
> > > > apache error log shows such stuff:
>
> > > >http://dpaste.com/81241/
>
> > > > Alan.
>
> > > > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > > > Hello
>
> > > > > I installed stackless pyton 2.6.2 after reading several sites that
> > > > > said its fully compatible with vanilla python. After installing i
> > > > > found that my django applications do not work any more.
>
> > > > > I did reinstall django (1.1) again and now im kind of lost. The error
> > > > > that i get is 500:
>
> > > > > Internal Server Error
>
> > > > > The server encountered an internal error or misconfiguration and was
> > > > > unable to complete your request.
>
> > > > > Please contact the server administrator, webmas...@localhost and
> > > > > inform them of the time the error occurred, and anything you might
> > > > > have done that may have caused the error.
>
> > > > > More information about this error may be available in the server error
> > > > > log.
> > > > > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> > > > > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> > > > > mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> > > > > Alan
>
>
--~--~-~--~~~---~--~~
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 get DATABASE_NAME

2009-08-16 Thread Alexander Dutton

On 16/08/09 09:38, Maksymus007 wrote:
> On Sun, Aug 16, 2009 at 10:30 AM, adelaide_mike 
> wrote:
>> In my reporting function I need to have:
>>
>> If DATABASE_NAME = x:
>>#do this
>> Else:
>>#do the other
>>
>> How can I obtain that name, which is established in settings.py?
>>
>> Mike
> import myproject.settings;
>
> if settings.DATABASE_NAME = x:
>   
Slight clarification required here. Best practice is to use:
> from django.conf import settings
for your import as it will contain the defaults not defined in
myproject.settings, along with other good reasons. See
http://docs.djangoproject.com/en/dev/topics/settings/#using-settings-in-python-code
for more information.

Alex

--~--~-~--~~~---~--~~
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: passing parameters in every view...

2009-08-16 Thread Mike Ramirez
On Sunday 16 August 2009 03:34:16 am Mirat Bayrak wrote:
> Hi i am working on a website and i am passing *request.user* and a
> *region*object to every template by manually in my every view. Can i
> do it by using
> some other method? i mean i dont want to pass them in every view can django
> do it automatically?
>

Take a look at context processors more deeply:
http://docs.djangoproject.com/en/dev/ref/templates/api/#playing-with-context-objects

there is a user context processor available also.  It sounds like you're using 
them correctly, but if you use the shortcut render_to_response() you can pass 
a RequextContext(request) instance to it that will set them for you, making 
them available in the template you passed to render_to_response().

Mike

-- 
"We never make assertions, Miss Taggart," said Hugh Akston.  "That is
the moral crime peculiar to our enemies.  We do not tell -- we *show*.
We do not claim -- we *prove*."  
-- Ayn Rand, _Atlas Shrugged_


signature.asc
Description: This is a digitally signed message part.


Re: Django and stackless python

2009-08-16 Thread Graham Dumpleton

Did you actually bother to reinstall mod_python after you nuked your
original Python installation. Likely when reinstalling it you lost
everything that was in prior site-packages and so are missing the
Python module component bits of mod_python, ie., no longer installed.

If from command line stackless Python you go:

  import mod_python

does it actually find the module?

Graham

On Aug 16, 8:51 pm, zayatzz  wrote:
> i begun to think about the same thing when i went through the log.
>
> Couldnt find anything useful why mod_python is failing atm, so i
> anyone can think of why this is not working - i still could use your
> help. Otherwise since it has nothing to do with django, i'll try to
> get help though stackoverflow and google :)
>
> Alan
>
> On Aug 16, 1:19 pm, Austin Gabel  wrote:
>
>
>
> > It looks like the issue is occurring when Apache tries to load mod_python.
> > This doesn't have anything to do with Django at this point.  You may need to
> > do a bit more research on how Stackless Python works with Apache and
> > mod_python.
>
> > On Sun, Aug 16, 2009 at 5:04 AM, zayatzz  wrote:
>
> > > apache error log shows such stuff:
>
> > >http://dpaste.com/81241/
>
> > > Alan.
>
> > > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > > Hello
>
> > > > I installed stackless pyton 2.6.2 after reading several sites that
> > > > said its fully compatible with vanilla python. After installing i
> > > > found that my django applications do not work any more.
>
> > > > I did reinstall django (1.1) again and now im kind of lost. The error
> > > > that i get is 500:
>
> > > > Internal Server Error
>
> > > > The server encountered an internal error or misconfiguration and was
> > > > unable to complete your request.
>
> > > > Please contact the server administrator, webmas...@localhost and
> > > > inform them of the time the error occurred, and anything you might
> > > > have done that may have caused the error.
>
> > > > More information about this error may be available in the server error
> > > > log.
> > > > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> > > > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> > > > mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> > > > Alan
--~--~-~--~~~---~--~~
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: i need your ideas

2009-08-16 Thread Mike Ramirez
On Sunday 16 August 2009 03:44:07 am Mirat Bayrak wrote:
> Hi, i am working on a website, to explain it basically i can say that it's
> works like twitter but every entry should have confirmed by admins. at that
> point i am little confused, should i write that confirmation screens on
> admin page or should i write a complatelyn new page? becouse i dont know
> anything about adding views to admin page, its looks more easy to write it
> as a normal page...
>

you can add an boolean field in the entries model for approval and then in the 
admin panel, display the fields you want to approve in the admin list and add 
an action to batch approve disaprove enteries.  This would be the easiest IMO

Model Admin Options:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options  
(see list_display option)

Admin Actions:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#ref-contrib-admin-actions

Mike
-- 
The Martian landed his saucer in Manhattan, and immediately upon 
emerging was approached by a panhandler.  "Mister," said the man, "can I 
have a quarter?"
The Martian asked, "What's a quarter?"
The panhandler thought a minute, brightened, then said, "You're 
right!  Can I have a dollar?"


signature.asc
Description: This is a digitally signed message part.


Re: Django and stackless python

2009-08-16 Thread zayatzz

i begun to think about the same thing when i went through the log.

Couldnt find anything useful why mod_python is failing atm, so i
anyone can think of why this is not working - i still could use your
help. Otherwise since it has nothing to do with django, i'll try to
get help though stackoverflow and google :)

Alan

On Aug 16, 1:19 pm, Austin Gabel  wrote:
> It looks like the issue is occurring when Apache tries to load mod_python.
> This doesn't have anything to do with Django at this point.  You may need to
> do a bit more research on how Stackless Python works with Apache and
> mod_python.
>
> On Sun, Aug 16, 2009 at 5:04 AM, zayatzz  wrote:
>
> > apache error log shows such stuff:
>
> >http://dpaste.com/81241/
>
> > Alan.
>
> > On Aug 16, 12:12 pm, zayatzz  wrote:
> > > Hello
>
> > > I installed stackless pyton 2.6.2 after reading several sites that
> > > said its fully compatible with vanilla python. After installing i
> > > found that my django applications do not work any more.
>
> > > I did reinstall django (1.1) again and now im kind of lost. The error
> > > that i get is 500:
>
> > > Internal Server Error
>
> > > The server encountered an internal error or misconfiguration and was
> > > unable to complete your request.
>
> > > Please contact the server administrator, webmas...@localhost and
> > > inform them of the time the error occurred, and anything you might
> > > have done that may have caused the error.
>
> > > More information about this error may be available in the server error
> > > log.
> > > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> > > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> > > mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> > > Alan
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



i need your ideas

2009-08-16 Thread Mirat Bayrak
Hi, i am working on a website, to explain it basically i can say that it's
works like twitter but every entry should have confirmed by admins. at that
point i am little confused, should i write that confirmation screens on
admin page or should i write a complatelyn new page? becouse i dont know
anything about adding views to admin page, its looks more easy to write it
as a normal page...

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



passing parameters in every view...

2009-08-16 Thread Mirat Bayrak
Hi i am working on a website and i am passing *request.user* and a
*region*object to every template by manually in my every view. Can i
do it by using
some other method? i mean i dont want to pass them in every view can django
do it automatically?

--~--~-~--~~~---~--~~
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: Master / Slave Database Replication Scenario

2009-08-16 Thread Matthias Kestenholz

On Sun, Aug 16, 2009 at 11:44 AM, Haes wrote:
>
> Hi,
>
> we are using master / slave database replication, no partitioning,
> just replicating the complete database to several slaves for
> performance reasons. This is making some problems with a newly
> developed Django project, which makes use of an existing database.
>
> Is there an (easy) way to use a different database for the admin
> application (master db) than for the remaining apps (slave db)?
>
> If I'd need more fine grained control about what database connection
> I'd like to use in a view, would I need to write a custom db backend
> for that? Or is there a way to set up two database connections and
> switch them manually (django.db.connection = )?
>

Take a look at django-multidb on github[1]. Django's own Multi-DB-API,
which is being developed by Alex Gaynor as part of the Google Summer
of Code is not ready yet, but seems to come along nicely.


[1]: http://github.com/mmalone/django-multidb/tree/master




-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
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: Master / Slave Database Replication Scenario

2009-08-16 Thread Austin Gabel
Off the top of my head a couple of ideas come to mind.  A quick and dirty
way would be to have a separate Django project that only handles the admin
app.  Another way would be to make a custom model manager that would select
the database to use.  This way is a little more involved but not impossible.



On Sun, Aug 16, 2009 at 4:44 AM, Haes  wrote:

>
> Hi,
>
> we are using master / slave database replication, no partitioning,
> just replicating the complete database to several slaves for
> performance reasons. This is making some problems with a newly
> developed Django project, which makes use of an existing database.
>
> Is there an (easy) way to use a different database for the admin
> application (master db) than for the remaining apps (slave db)?
>
> If I'd need more fine grained control about what database connection
> I'd like to use in a view, would I need to write a custom db backend
> for that? Or is there a way to set up two database connections and
> switch them manually (django.db.connection = )?
>
> Thanks for any hints.
>
> Cheers.
>
> >
>

--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread Austin Gabel
It looks like the issue is occurring when Apache tries to load mod_python.
This doesn't have anything to do with Django at this point.  You may need to
do a bit more research on how Stackless Python works with Apache and
mod_python.


On Sun, Aug 16, 2009 at 5:04 AM, zayatzz  wrote:

>
> apache error log shows such stuff:
>
> http://dpaste.com/81241/
>
> Alan.
>
> On Aug 16, 12:12 pm, zayatzz  wrote:
> > Hello
> >
> > I installed stackless pyton 2.6.2 after reading several sites that
> > said its fully compatible with vanilla python. After installing i
> > found that my django applications do not work any more.
> >
> > I did reinstall django (1.1) again and now im kind of lost. The error
> > that i get is 500:
> >
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was
> > unable to complete your request.
> >
> > Please contact the server administrator, webmas...@localhost and
> > inform them of the time the error occurred, and anything you might
> > have done that may have caused the error.
> >
> > More information about this error may be available in the server error
> > log.
> > Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> > mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> > mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
> >
> > Alan
> >
>

--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread Austin Gabel
Can you post your error log?



On Sun, Aug 16, 2009 at 4:12 AM, zayatzz  wrote:

>
> Hello
>
> I installed stackless pyton 2.6.2 after reading several sites that
> said its fully compatible with vanilla python. After installing i
> found that my django applications do not work any more.
>
> I did reinstall django (1.1) again and now im kind of lost. The error
> that i get is 500:
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Please contact the server administrator, webmas...@localhost and
> inform them of the time the error occurred, and anything you might
> have done that may have caused the error.
>
> More information about this error may be available in the server error
> log.
> Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> Alan
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Master / Slave Database Replication Scenario

2009-08-16 Thread Haes

Hi,

we are using master / slave database replication, no partitioning,
just replicating the complete database to several slaves for
performance reasons. This is making some problems with a newly
developed Django project, which makes use of an existing database.

Is there an (easy) way to use a different database for the admin
application (master db) than for the remaining apps (slave db)?

If I'd need more fine grained control about what database connection
I'd like to use in a view, would I need to write a custom db backend
for that? Or is there a way to set up two database connections and
switch them manually (django.db.connection = )?

Thanks for any hints.

Cheers.

--~--~-~--~~~---~--~~
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 and stackless python

2009-08-16 Thread zayatzz

apache error log shows such stuff:

http://dpaste.com/81241/

Alan.

On Aug 16, 12:12 pm, zayatzz  wrote:
> Hello
>
> I installed stackless pyton 2.6.2 after reading several sites that
> said its fully compatible with vanilla python. After installing i
> found that my django applications do not work any more.
>
> I did reinstall django (1.1) again and now im kind of lost. The error
> that i get is 500:
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Please contact the server administrator, webmas...@localhost and
> inform them of the time the error occurred, and anything you might
> have done that may have caused the error.
>
> More information about this error may be available in the server error
> log.
> Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
> mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
> mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80
>
> Alan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django and stackless python

2009-08-16 Thread zayatzz

Hello

I installed stackless pyton 2.6.2 after reading several sites that
said its fully compatible with vanilla python. After installing i
found that my django applications do not work any more.

I did reinstall django (1.1) again and now im kind of lost. The error
that i get is 500:

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, webmas...@localhost and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.

More information about this error may be available in the server error
log.
Apache/2.2.11 (Ubuntu) DAV/2 PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch
mod_python/3.3.1 Python/2.6.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11)
mod_ssl/2.2.11 OpenSSL/0.9.8g Server at 127.0.0.1 Port 80

Alan
--~--~-~--~~~---~--~~
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 Is telling me table already exists on syncdb - can’t figure out why

2009-08-16 Thread Alvin

django-mptt was the culprit

renamed table for memorial_music to memorial_music_library and
everything went smooth

thank you django for manage.py sqlall memorial

On Aug 16, 4:43 am, Alvin  wrote:
> Posted the model athttp://pastebin.com/f609771cc
>
> getting error: (yes it's windows) File "C:\Python25\lib\site-packages
> \MySQLdb\connections.py", line 35, in defaulterrorhandler raise
> errorclass, errorvalue _mysql_exceptions.OperationalError: (1050,
> "Table 'memorial_music' already exists")
>
> scanned the whole project directory and memorial_music is only
> referenced twice
>
> once as a table name and once as table name 'memorial_music_category'
>
> this one has me scratching my head, any ideas?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



with statements

2009-08-16 Thread GuyBowden

Hi All,

Just wondering what the best way to do this sort of thing is:

{% with last_tweet_sent this_user as sent_at %}
{{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}}
{% endwith %}

I've got a function "last_tweet_sent" in a templatetags module that
takes a user and spits back the last time they sent a tweet.

I'd like to keep the formatting of the date in the template rather
than in the templatetag module (best practice?)

But I can't use the with statement to put the result of my function
call in a variable - I guess because of the spacing there for calling
the function with an argument.

Any suggestions?

Cheers,

Guy
--~--~-~--~~~---~--~~
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 Is telling me table already exists on syncdb - can’t figure out why

2009-08-16 Thread Alvin

forgot to mention: before running syncdb I delete all memorial_
tables... hoping someone can offer some advice on this one

On Aug 16, 4:43 am, Alvin  wrote:
> Posted the model athttp://pastebin.com/f609771cc
>
> getting error: (yes it's windows) File "C:\Python25\lib\site-packages
> \MySQLdb\connections.py", line 35, in defaulterrorhandler raise
> errorclass, errorvalue _mysql_exceptions.OperationalError: (1050,
> "Table 'memorial_music' already exists")
>
> scanned the whole project directory and memorial_music is only
> referenced twice
>
> once as a table name and once as table name 'memorial_music_category'
>
> this one has me scratching my head, any ideas?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django Is telling me table already exists on syncdb - can’t figure out why

2009-08-16 Thread Alvin

Posted the model at http://pastebin.com/f609771cc

getting error: (yes it's windows) File "C:\Python25\lib\site-packages
\MySQLdb\connections.py", line 35, in defaulterrorhandler raise
errorclass, errorvalue _mysql_exceptions.OperationalError: (1050,
"Table 'memorial_music' already exists")

scanned the whole project directory and memorial_music is only
referenced twice

once as a table name and once as table name 'memorial_music_category'

this one has me scratching my head, any ideas?
--~--~-~--~~~---~--~~
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 get DATABASE_NAME

2009-08-16 Thread Maksymus007

import myproject.settings;

if settings.DATABASE_NAME = x:


On Sun, Aug 16, 2009 at 10:30 AM,
adelaide_mike wrote:
>
> In my reporting function I need to have:
>
> If DATABASE_NAME = x:
>    #do this
> Else:
>    #do the other
>
> How can I obtain that name, which is established in settings.py?
>
> 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-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
-~--~~~~--~~--~--~---



How to get DATABASE_NAME

2009-08-16 Thread adelaide_mike

In my reporting function I need to have:

If DATABASE_NAME = x:
#do this
Else:
#do the other

How can I obtain that name, which is established in settings.py?

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-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
-~--~~~~--~~--~--~---



DecimalField's and lots of math

2009-08-16 Thread John M

I'm wondering how people deal with the DecimalField in django?

I've just discovered the amount of typecasting I have to do to work
with this field, example:

field1 = models.DecimalField(...)

you can't do :

y = field1 / 100.0

you have to do y = field1 / Decimal(100)

But then you can't do this either:

y = field1 / Decimal(a + b / 2.0)

Am I missing something, or does the Decimal field just require a ton
of typecasting to keep it sane?

Thanks

John
--~--~-~--~~~---~--~~
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: easy way of display an user bar?

2009-08-16 Thread Mirat Bayrak
I have that problem too, is there any other solution?

--~--~-~--~~~---~--~~
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 in Vista

2009-08-16 Thread Thiago511

Sam. YOU ARE A LIFE SAVER! while writing down the Path thing for you,
I noticed my problema simple spelling error.

here it is:

before I started my path I forgot to but  a semicolon.
so my path was this:

Previous path\C:\Python26\Scripts

INSTEAD OF:

Previous Path\; C:\Python26\Scripts

Sam if it wasn't for you asking me this question, I would never have
found it. THANK-YOU SO MUCH!!


On Aug 16, 12:01 am, Sam Lai  wrote:
> You added the directory containing django-admin.py to your PATH right,
> not the path of django-admin.py itself?
>
> If you want, type 'set path' (without quotes) into your command prompt
> and paste the result here and we'll see if you did it right.
>
> 2009/8/16 Thiago511 :
>
>
>
> > UPDATE:
> > Well I added django-admin.py to my PATH and I still get an error
> > message:
>
> > python: cannot open 'django-admin.py' : [Errno 2] No such file to
> > directory
>
> > On Aug 15, 11:30 am, CLIFFORD ILKAY 
> > wrote:
> >> On 15/08/09 01:43 PM, Thiago511 wrote:
>
> >> > mark how do I add a file to %PATH% ?
>
> >> This isn't a Django issue so much as a (very basic) system
> >> administration issue. I suggest you read about the PATH environment
> >> variable and grasp that instead of blindly following someone else's
> >> instructions about how to do something as simple as adding something to
> >> the PATH. This isn't something that started with Vista. It dates back to
> >> the earliest days of DOS so there are plenty of resources on the web
> >> explaining this. Better yet, you should strive for understanding of
> >> environment variables in general. If you fixate on PATH alone and don't
> >> understand what an environment variable is, you'll have difficulties
> >> with PYTHONPATH as well.
>
> >> Once you understand these concepts, they're universally-applicable, with
> >> minor variations, to DOS/Windows, OS X, Linux, and a host of other
> >> operating systems. When you decide to deploy your completed Django
> >> project on the server of a hosting provider, in all likelihood, that
> >> server won't be running Windows anyway so it helps to develop this
> >> understanding.
>
> >> One of our Django hosting clients asked why he was getting import errors
> >> for Reportlab on our VPS when he wasn't on his local development
> >> environment. He suspected it was because Reportlab wasn't installed. He
> >> was right. We replied to him:
>
> >> "We've installed:
>
> >> python-reportlab - ReportLab library to create PDF documents using Python
>
> >> python-reportlab-accel - C coded extension accelerator for the ReportLab
> >> Toolkit
>
> >> For future reference, you don't necessarily have to wait for us to
> >> install Python libraries into the global Python site-packages. You could
> >> install the Python libraries somewhere in your home directory and put
> >> that directory in PYTHONPATH, as you did with Django itself."
>
> >> He replied:
>
> >> "Thanks for that. I should have realised I have access to the Python
> >> installation."
>
> >> In response, we replied:
>
> >> "You don't have access to the Python installation in /usr/lib/python.
> >> You have access to your home directory into which you can put Python
> >> libraries and add to PYTHONPATH. There is a big difference. The former
> >> is global. The latter can be different even on a per project basis so I
> >> hesitate to say it's local. If you build another Django project for
> >> another client, nothing stops you from having a different PYTHONPATH for
> >> that project. In fact, we do exactly that because we may have different
> >> versions of Django, or other Python libraries on which we depend, for
> >> each project."
>
> >> If you understood what I wrote above, you may be wondering, "How can you
> >> have a different PYTHONPATH for each application?" The excerpt below
> >> from the shell script that we use to start|stop|restart the fcgi(*) will
> >> illustrate.
>
> >> PROJDIR="/home/someuser/projects/someproject/"
> >> PYTHONPATH="/home/someuser/django/:/home/someuser/:/home/someuser/lib/"
>
> >> /usr/bin/python $PROJDIR/manage.py runfcgi umask=000 pidfile=$PIDFILE
> >> socket=$SOCKET method=$METHOD --pythonpath=$PYTHONPATH
>
> >> (Watch the line wrapping above. Everything from /usr/bin to PYTHONPATH
> >> below it is on one line.)
>
> >> (*) The above is for deployment via fcgi using the nginx web server.
> >> --
> >> Regards,
>
> >> Clifford Ilkay
> >> Dinamis
> >> 1419-3266 Yonge St.
> >> Toronto, ON
> >> Canada  M4N 3P6
>
> >> 
> >> +1 416-410-3326
--~--~-~--~~~---~--~~
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 in Vista

2009-08-16 Thread Sam Lai

You added the directory containing django-admin.py to your PATH right,
not the path of django-admin.py itself?

If you want, type 'set path' (without quotes) into your command prompt
and paste the result here and we'll see if you did it right.

2009/8/16 Thiago511 :
>
> UPDATE:
> Well I added django-admin.py to my PATH and I still get an error
> message:
>
> python: cannot open 'django-admin.py' : [Errno 2] No such file to
> directory
>
> On Aug 15, 11:30 am, CLIFFORD ILKAY 
> wrote:
>> On 15/08/09 01:43 PM, Thiago511 wrote:
>>
>> > mark how do I add a file to %PATH% ?
>>
>> This isn't a Django issue so much as a (very basic) system
>> administration issue. I suggest you read about the PATH environment
>> variable and grasp that instead of blindly following someone else's
>> instructions about how to do something as simple as adding something to
>> the PATH. This isn't something that started with Vista. It dates back to
>> the earliest days of DOS so there are plenty of resources on the web
>> explaining this. Better yet, you should strive for understanding of
>> environment variables in general. If you fixate on PATH alone and don't
>> understand what an environment variable is, you'll have difficulties
>> with PYTHONPATH as well.
>>
>> Once you understand these concepts, they're universally-applicable, with
>> minor variations, to DOS/Windows, OS X, Linux, and a host of other
>> operating systems. When you decide to deploy your completed Django
>> project on the server of a hosting provider, in all likelihood, that
>> server won't be running Windows anyway so it helps to develop this
>> understanding.
>>
>> One of our Django hosting clients asked why he was getting import errors
>> for Reportlab on our VPS when he wasn't on his local development
>> environment. He suspected it was because Reportlab wasn't installed. He
>> was right. We replied to him:
>>
>> "We've installed:
>>
>> python-reportlab - ReportLab library to create PDF documents using Python
>>
>> python-reportlab-accel - C coded extension accelerator for the ReportLab
>> Toolkit
>>
>> For future reference, you don't necessarily have to wait for us to
>> install Python libraries into the global Python site-packages. You could
>> install the Python libraries somewhere in your home directory and put
>> that directory in PYTHONPATH, as you did with Django itself."
>>
>> He replied:
>>
>> "Thanks for that. I should have realised I have access to the Python
>> installation."
>>
>> In response, we replied:
>>
>> "You don't have access to the Python installation in /usr/lib/python.
>> You have access to your home directory into which you can put Python
>> libraries and add to PYTHONPATH. There is a big difference. The former
>> is global. The latter can be different even on a per project basis so I
>> hesitate to say it's local. If you build another Django project for
>> another client, nothing stops you from having a different PYTHONPATH for
>> that project. In fact, we do exactly that because we may have different
>> versions of Django, or other Python libraries on which we depend, for
>> each project."
>>
>> If you understood what I wrote above, you may be wondering, "How can you
>> have a different PYTHONPATH for each application?" The excerpt below
>> from the shell script that we use to start|stop|restart the fcgi(*) will
>> illustrate.
>>
>> PROJDIR="/home/someuser/projects/someproject/"
>> PYTHONPATH="/home/someuser/django/:/home/someuser/:/home/someuser/lib/"
>>
>> /usr/bin/python $PROJDIR/manage.py runfcgi umask=000 pidfile=$PIDFILE
>> socket=$SOCKET method=$METHOD --pythonpath=$PYTHONPATH
>>
>> (Watch the line wrapping above. Everything from /usr/bin to PYTHONPATH
>> below it is on one line.)
>>
>> (*) The above is for deployment via fcgi using the nginx web server.
>> --
>> Regards,
>>
>> Clifford Ilkay
>> Dinamis
>> 1419-3266 Yonge St.
>> Toronto, ON
>> Canada  M4N 3P6
>>
>> 
>> +1 416-410-3326
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---