ANN: django-email-extras

2009-08-13 Thread opensou...@citrus.com.au

Hello django-users,

My company has allowed me to open source another small django
application I've built that I've named django-email-extras.

What it does is provide some extra features around sending email such
as PGP encryption with key management and using the django templating
system to send multipart text/html emails.

I've chosen google code to host the project and welcome any feedback.

http://code.google.com/p/django-email-extras/

Regards,

Stephen McDonald
TECHNICAL RESEARCH & DEVELOPMENT
Citrus
Level 5, 100 Albert Road South Melbourne Victoria Australia 3205
T. +613 9681 5333F. +613 9682 5586   W. www.citrus.com.au
--~--~-~--~~~---~--~~
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-13 Thread Graham Dumpleton



On Aug 14, 3:08 pm, NiJoMi  wrote:
> Hi
> I am a complete novice with Django, and have run into a problem
> getting it to run on a wamp server.
> I have managed to install Python v2.6.1, WampServer2, mod_wsgi,
> PostgreSql, psycopg2 and Django onto WindowsXP Professional SP3 in
> order to make a local development server.
>
> I am able to create a Django test project and use it's inbuilt server
> to access the project, so I assume that Python and Django are
> correctly installed.
>
> The problem is when trying to serve the project from WampServer2 I get
> the error 403 Forbidden.
>
> -
> WampServer2 Components:
>
> Apache 2.2.11
> PHP 5.3.0
> MySQL 5.1.36
> Phpmyadmin
> -
> Install locations:
>
> Python
> C:\Python26
>
> Django
> C:\Python26\Lib\site-packages\django
>
> WampServer2
> C:\imfree
> --
> Edits to files:
>
> httpd.conf
>
> added following to top of LoadModule section:
> LoadModule wsgi_module modules/mod_wsgi.so
>
> uncommented:
> Include conf/extra/httpd-vhosts.conf
> -
> httpd-vhosts.conf
>
> commented out examples and added following:
>
> 
>     ServerAdmin webmas...@localhost
>     DocumentRoot "C:/imfree/www"
>     ServerName localhost
>     #ServerAliaswww.dummy-host.localhost
>     ErrorLog "c:/imfree/logs/localhost.log"
>     CustomLog "c:/imfree/logs/localhost-access.log" common
> 
>
> 
>    ServerAdmin webmas...@testproject
>    DocumentRoot "E:/Django/testproject/apache"
>    ServerName testproject.lc
>    ErrorLog "c:/imfree/logs/testproject.lc-error.log"
>    CustomLog "c:/imfree/logs/testproject.lc-access.log" common
>
> WSGIScriptAlias / /usr/local/testproject/apache/django.wsgi
>
> 
> Order allow,deny
> Allow from all
> 

If your Django site is installed in:

  E:/Django/testproject

and the WSGI script file in:

  E:/Django/testproject/apache

The above should be:

  WSGIScriptAlias / E:/Django/testproject/apache/django.wsgi

  
  Order allow,deny
  Allow from all
  

Graham

> ---
> hosts file
>
> added:
>
> 127.0.0.1       testproject.lc # django test
> --- 
> ---
> created file E:/Django/testproject/apache/django.wsgi
>
> import os, sys
> sys.path.append('/usr/local/django')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
> --- 
> --
>
> the logs:
>
> apache_error.log
>
> [Fri Aug 14 05:48:35 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0
> mod_wsgi/2.5 Python/2.6.1 configured -- resuming normal operations
> [Fri Aug 14 05:48:35 2009] [notice] Server built: Dec 10 2008 00:10:06
> [Fri Aug 14 05:48:35 2009] [notice] Parent: Created child process 2924
> [Fri Aug 14 05:48:35 2009] [notice] Child 2924: Child process is
> running
> [Fri Aug 14 05:48:35 2009] [notice] Child 2924: Acquired the start
> mutex.
> [Fri Aug 14 05:48:35 2009] [notice] Child 2924: Starting 64 worker
> threads.
> [Fri Aug 14 05:48:35 2009] [notice] Child 2924: Starting thread to
> listen on port 80.
> [Fri Aug 14 05:48:46 2009] [notice] Parent: Received shutdown signal
> -- Shutting down the server.
> [Fri Aug 14 05:48:46 2009] [notice] Child 2924: Exit event signaled.
> Child process is ending.
> [Fri Aug 14 05:48:47 2009] [notice] Child 2924: Released the start
> mutex
> [Fri Aug 14 05:48:48 2009] [notice] Child 2924: All worker threads
> have exited.
> [Fri Aug 14 05:48:48 2009] [notice] Child 2924: Child process is
> exiting
> [Fri Aug 14 05:48:48 2009] [notice] Parent: Child process exited
> successfully.
> [Fri Aug 14 05:48:48 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0
> mod_wsgi/2.5 Python/2.6.1 configured -- resuming normal operations
> [Fri Aug 14 05:48:48 2009] [notice] Server built: Dec 10 2008 00:10:06
> [Fri Aug 14 05:48:48 2009] [notice] Parent: Created child process 1124
> [Fri Aug 14 05:48:49 2009] [notice] Child 1124: Child process is
> running
> [Fri Aug 14 05:48:49 2009] [notice] Child 1124: Acquired the start
> mutex.
> [Fri Aug 14 05:48:49 2009] [notice] Child 1124: Starting 64 worker
> threads.
> [Fri Aug 14 05:48:49 2009] [notice] Child 1124: Starting thread to
> listen on port 80.
>
> access.log is empty
>
> testproject.lc-error.log
>
> [Fri Aug 14 05:51:14 2009] [error] [client 127.0.0.1] client denied by
> server configuration: C:/usr
>
> testproject.lc-access.log
>
> 127.0.0.1 - - [14/Aug/2009:05:51:14 +0100] "GET / HTTP/1.1" 403 202
> --- 
> -
>
> I hope this is enough info for someone to spot what I am doing wrong
> as I have a 

"django-pagination" and generic.views.date_based.archive_index()

2009-08-13 Thread tezro

The question is that "django.views.generic.date_based.archive_index()"
takes an optional argument "num_latest" which is 15 by default.
Setting it manually to num_latest=10 is way off to correct to
me. It works. I suppose that it even doesn't retrieve all the tons of
data from the DB, but what if I have 10 + 1 record :)

What's the right way to use "django-pagination" and the "archive_index
()" or am I missing something?

Example code.
___

def index(request):
qs = News.objects.filter(is_published=1)
return archive_index(request, qs, 'date', num_latest=1)
___

Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with getting setting up apache server for django

2009-08-13 Thread NiJoMi

Hi
I am a complete novice with Django, and have run into a problem
getting it to run on a wamp server.
I have managed to install Python v2.6.1, WampServer2, mod_wsgi,
PostgreSql, psycopg2 and Django onto WindowsXP Professional SP3 in
order to make a local development server.

I am able to create a Django test project and use it's inbuilt server
to access the project, so I assume that Python and Django are
correctly installed.

The problem is when trying to serve the project from WampServer2 I get
the error 403 Forbidden.

-
WampServer2 Components:

Apache 2.2.11
PHP 5.3.0
MySQL 5.1.36
Phpmyadmin
-
Install locations:

Python
C:\Python26

Django
C:\Python26\Lib\site-packages\django

WampServer2
C:\imfree
--
Edits to files:

httpd.conf

added following to top of LoadModule section:
LoadModule wsgi_module modules/mod_wsgi.so

uncommented:
Include conf/extra/httpd-vhosts.conf
-
httpd-vhosts.conf

commented out examples and added following:


ServerAdmin webmas...@localhost
DocumentRoot "C:/imfree/www"
ServerName localhost
#ServerAlias www.dummy-host.localhost
ErrorLog "c:/imfree/logs/localhost.log"
CustomLog "c:/imfree/logs/localhost-access.log" common



   ServerAdmin webmas...@testproject
   DocumentRoot "E:/Django/testproject/apache"
   ServerName testproject.lc
   ErrorLog "c:/imfree/logs/testproject.lc-error.log"
   CustomLog "c:/imfree/logs/testproject.lc-access.log" common

WSGIScriptAlias / /usr/local/testproject/apache/django.wsgi


Order allow,deny
Allow from all

---
hosts file

added:

127.0.0.1   testproject.lc # django test
--
created file E:/Django/testproject/apache/django.wsgi

import os, sys
sys.path.append('/usr/local/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
-

the logs:

apache_error.log

[Fri Aug 14 05:48:35 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0
mod_wsgi/2.5 Python/2.6.1 configured -- resuming normal operations
[Fri Aug 14 05:48:35 2009] [notice] Server built: Dec 10 2008 00:10:06
[Fri Aug 14 05:48:35 2009] [notice] Parent: Created child process 2924
[Fri Aug 14 05:48:35 2009] [notice] Child 2924: Child process is
running
[Fri Aug 14 05:48:35 2009] [notice] Child 2924: Acquired the start
mutex.
[Fri Aug 14 05:48:35 2009] [notice] Child 2924: Starting 64 worker
threads.
[Fri Aug 14 05:48:35 2009] [notice] Child 2924: Starting thread to
listen on port 80.
[Fri Aug 14 05:48:46 2009] [notice] Parent: Received shutdown signal
-- Shutting down the server.
[Fri Aug 14 05:48:46 2009] [notice] Child 2924: Exit event signaled.
Child process is ending.
[Fri Aug 14 05:48:47 2009] [notice] Child 2924: Released the start
mutex
[Fri Aug 14 05:48:48 2009] [notice] Child 2924: All worker threads
have exited.
[Fri Aug 14 05:48:48 2009] [notice] Child 2924: Child process is
exiting
[Fri Aug 14 05:48:48 2009] [notice] Parent: Child process exited
successfully.
[Fri Aug 14 05:48:48 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0
mod_wsgi/2.5 Python/2.6.1 configured -- resuming normal operations
[Fri Aug 14 05:48:48 2009] [notice] Server built: Dec 10 2008 00:10:06
[Fri Aug 14 05:48:48 2009] [notice] Parent: Created child process 1124
[Fri Aug 14 05:48:49 2009] [notice] Child 1124: Child process is
running
[Fri Aug 14 05:48:49 2009] [notice] Child 1124: Acquired the start
mutex.
[Fri Aug 14 05:48:49 2009] [notice] Child 1124: Starting 64 worker
threads.
[Fri Aug 14 05:48:49 2009] [notice] Child 1124: Starting thread to
listen on port 80.

access.log is empty

testproject.lc-error.log

[Fri Aug 14 05:51:14 2009] [error] [client 127.0.0.1] client denied by
server configuration: C:/usr

testproject.lc-access.log

127.0.0.1 - - [14/Aug/2009:05:51:14 +0100] "GET / HTTP/1.1" 403 202


I hope this is enough info for someone to spot what I am doing wrong
as I have a project that I would like to develop with django.

Thank you for your 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
-~--~~~~--~~--~--~---



Theory: Models/Apps

2009-08-13 Thread Vadivel Kumar
I have recently started on Django .. going awesome .. I know, this question
might have popped out several times before, but since Google does not yield
me any results, I am writing this post. However, do point out resources if
any in this mailing list.

1. What is the fundamental difference of APP versus PROJECT in Django
terminology. For instance, is it right to say, POSTS is an APP and BLOG is a
PROJECT or ORDERS is an APP and ORDER_MANAGEMENT is a PROJECT ..

2. Particularly, I don't like the idea of using a single models.py for many
entities, I would rather to keep separate files for each of entity .. in a
scenario like a huge team is working on a project, this approach will create
unnecessary noise. Any answers?

I sincerely appreciate your answers.

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



Does Django use prepared statement when generating SQL for postgresql?

2009-08-13 Thread Continuation

If not, is there a way to do 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: am i missing something ?

2009-08-13 Thread Karen Tracey
On Thu, Aug 13, 2009 at 8:25 PM, Nicolas Aggelidis wrote:

>
> hi to all, i am a real newbie when it comes to django(4days).
> I have the following question:
>
> Let's say i have the following files
>
> #views.py
> from django.contrib.auth.models import User
>
>
> def aview(request):
>a_user = User.objects.filter(username="djanog")
>users = User.objects.all()
>return render_to_response('temp.html',
>  {
>  'user' : a_user,
>  'users' : users,
>  }
> )
>
> #temp.html
>
> 
> 
>
>
>Django Entry Page -- aggelidis09
>
> 
> 
>Demo for user model
>{{ user }} has the following fields
>s{{ user.username }}
>{{ user.email }}
>{{ user.last_name }}
>{{ user.first_name }}
>Demo for user model
>{% for object in users %}
>A user:
>{{ object.username }}
>{{ object.email }}
>{{ object.last_name }}
>{{ object.first_name }}
>
>{% endfor %}
> 
> 
>
> The for loop with users works as expected, meaning it prints the
> requested attributes of each user.
> But the invocation of user only prints the {{ user }}, but not
> user.username or any other attribute...
>
> any ideas why is this happening??
>

 a_user = User.objects.filter(username="djanog")

returns a QuerySet, not a single instance of a user.  If you want it to be a
single instance, change the 'filter' call to 'get'.  As it is your {{ user
}} in the template is "working" because it prints the representation of the
query set, but the attempts to access the individual User attributes don't
work since those are not attributes of a QuerySet.

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



Reorder models in admin application

2009-08-13 Thread Keith Gray
Can anyone tell me how to reorder the list of models shown in the admin
interface for a particular application?  For example, I have the following
models in my proposal application: Clients, Expenses, Proposals, Rates,
Subtasks, Tasks, and Works.  Currently they appear in alphabetical order.  I
would like them to be in the following order: Rates, Proposals, Tasks,
Subtasks, Works, Expenses, Clients.

Any help or pointers are appreciated.  Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using Max()

2009-08-13 Thread Karen Tracey
On Thu, Aug 13, 2009 at 5:01 PM, neri...@gmail.com wrote:

>
> Hello,
>
> Do I need t convert the value returned from Max() to an int, or am I
> using it incorrectly? I'm getting this template error:
>
> Caught an exception while rendering: (1064, "You have an error in your
> SQL syntax; check the manual that corresponds to your MySQL server
> version for the right syntax to use near ''id__max': '2'} )' at line
> 1")
> 1
>
> from django.db.models import Max
>
> def preview(request, template_name='listings/preview.html',
> order_num=Order.objects.aggregate(Max('id'))):


One problem here is that Order.objects.aggregate(Max('id')) is going to
return a dictionary, not an integer.  You never pull the integer value out
of the dictionary so your subsequent attempt to pass that dictionary as a
filter value results in invalid SQL.

Also, note that that aggregate call is going to be evaluated only once, when
the function is defined at import time.  If you want that value to reflect
Orders that have been created since the file containing this function was
loaded, you need to move that code into the body of the function.

Karen


>num = order_num
>user = request.user
>listings = Listing.objects.filter
> (order__customer__user__username=user)
>gallery = Photo.objects.filter
> (order__customer__user__username=user, order=num)
>return render_to_response(template_name, { 'user': user,
> 'listings': listings, 'order': num, 'gallery': gallery })
>
>
> Thanks,
>
> Jason
>

--~--~-~--~~~---~--~~
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: Notify about a bug

2009-08-13 Thread Karen Tracey
On Thu, Aug 13, 2009 at 4:08 PM, Peter2108  wrote:

>
> I just ran into bug #6138 which is two years old now. There is a patch
> supplied but it has not made it into the version I am using (1.1 rc1,
> 11,332). Is there anyway to tell the Django Trace to notify me by
> email when this bug is updated?
>

Since you've commented on the ticket, you'll automatically get mail when
anyone updates the ticket.  The other way to ensure you get updates in email
is to add yourself to the cc list.

As for why the patch has not been checked in -- the person who supplied the
patch subsequently marked the ticket as "patch needs improvement" noting
that the patch addressed only one aspect of the reported problem.  Since
then no one has supplied a complete patch.  If you'd like to see the problem
fixed, contributing a complete path would make the ticket more likely to
move along in the process.  I also don't see any tests in the existing
patch, nor any reason why they wouldn't be necessary, so that is another
thing a complete patch would likely need to include before the fix made it
into the code base.

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: Reloading a page with new data

2009-08-13 Thread Tom

Thanks Margie, that has set me off on the right direction.  Like
yourself I do not have much experience with javascript, but I guess
this is a great time to learn!  I will investigate both the admin
javascript and jquery to see what the best option is.  I will report
back once I have something useful to say.

Thanks again,

Tom

On Aug 13, 8:26 pm, Margie  wrote:
> I have been able to mimic the admin behavior in my own app.   I
> started off with the admin js functions showAddAnotherPopup and
> dismissAddAnotherPopup.   Study these in the context of how they are
> used in the admin app and they should get you going.  The best method
> for me was to use firebug and put breakpoints at the begninning of
> showAddAnotherPopup and dismissAddAnotherPopup and then print the
> variables in those functions.  They basically encode the id of the
> input that you need filled in in the window name of of the popup
> window, and then when the popup is closed, then return an httpResponse
> that calls dismissAddAnotherPopup() and that extracts the window name
> of the popup, uses it to identify the id where to place the result,
> and then fills in the input appropriately.
>
> It is also useful to put a pdb breakpoint into the admin code in the
> response_add() function, ie:
>
>         import pdb
>         pdb.set_trace()
>
> This will make your server drop into pdb right before sending back the
> response that calls dismissAddAnother().  If you do all of this and
> then click on an "add another" (green "+") in the admin you should be
> able to trace the process they use.
>
> I thought it was all pretty slick myself.  I don't have a ton of
> javascript experience, so am not sure if this is the best way to do
> things or not.  There might be something simpler in jquery, please
> post if you do identify something simpler!
>
> This is not really in the realm of "django", since django doesn't
> really have much to do with the javascript side of things, but still,
> I'd be interested to know how others in this django community are
> creating popup windows that fill in information and then pass it back
> to some "main" window.
>
> Margie
>
> On Aug 13, 9:40 am, Thomas Scrace  wrote:
>
> >
>
>
--~--~-~--~~~---~--~~
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 much python do i need to know to learn/use Django?

2009-08-13 Thread Jonas Obrist

snfctech wrote:
> I currently know zero Python and want to start a project with Django
> ASAP.  I've got the opportunity through my work to either take a 5-day
> Python bootcamp or a Django bootcamp - not both.
>
> I don't anticipate having a whole bunch of time to brush up on Python
> before the Django class - but is that necessary?  How much Python do I
> need to know before learning/using Django?  Would a little brush up on
> Python + intensive Django be okay?  Or should I use my resources for
> intensive Python and then use online tutorials/ books for Django?
>
> Also important to note:  The project I want to start may involve using
> SQLAlchemy and/or Elixir if the Django ORM doesn't support multiple
> database connections in time.
>
> Thanks for the tips.
> >
>   
Hi again snfctech

In my personal opinion, python is rather easy to learn (I tried a couple 
of other languages but had huge problems learning them). Also I find 
django pretty straight forward, so after learning the basics of python, 
the syntax etc, I'd say you can learn it by coding django. It'll be a 
bit hard in the beginning and your code will be buggy but that's the way 
you learn! I learned the basics of python in about a day and 'okay' 
python skills in about a month of casual coding. Now after a bit more 
than half a year I'd say I'm rather good at it, only learning from other 
code and online stuff.

Jonas

PS: I also highly recommend hopping into some IRC channels once you got 
some code which you need help with, usually there's helpful people on 
there (eg. #django or #python)

--~--~-~--~~~---~--~~
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 much python do i need to know to learn/use Django?

2009-08-13 Thread snfctech

I currently know zero Python and want to start a project with Django
ASAP.  I've got the opportunity through my work to either take a 5-day
Python bootcamp or a Django bootcamp - not both.

I don't anticipate having a whole bunch of time to brush up on Python
before the Django class - but is that necessary?  How much Python do I
need to know before learning/using Django?  Would a little brush up on
Python + intensive Django be okay?  Or should I use my resources for
intensive Python and then use online tutorials/ books for Django?

Also important to note:  The project I want to start may involve using
SQLAlchemy and/or Elixir if the Django ORM doesn't support multiple
database connections in time.

Thanks for the tips.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



am i missing something ?

2009-08-13 Thread Nicolas Aggelidis

hi to all, i am a real newbie when it comes to django(4days).
I have the following question:

Let's say i have the following files

#views.py
from django.contrib.auth.models import User


def aview(request):
a_user = User.objects.filter(username="djanog")
users = User.objects.all()
return render_to_response('temp.html',
  {
  'user' : a_user,
  'users' : users,
  }
 )

#temp.html





Django Entry Page -- aggelidis09



Demo for user model
{{ user }} has the following fields
s{{ user.username }}
{{ user.email }}
{{ user.last_name }}
{{ user.first_name }}
Demo for user model
{% for object in users %}
A user:
{{ object.username }}
{{ object.email }}
{{ object.last_name }}
{{ object.first_name }}

{% endfor %}



The for loop with users works as expected, meaning it prints the
requested attributes of each user.
But the invocation of user only prints the {{ user }}, but not
user.username or any other attribute...

any ideas why is this happening??

thanks in advance,
nicolas

--~--~-~--~~~---~--~~
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: if forloop.counter

2009-08-13 Thread When ideas fail

Thanks!

On 13 Aug, 20:52, Jonas Obrist  wrote:
> When ideas fail wrote:
> > Hello, i know you can have things like {% if forloop.last %}
> > but is it possible to have an if statement that matches the value of a
> > forloop counter
> > so it would be like:
>
> > {% if forloop.counter = 6 % }
>
> > or similar and how could i do that?
>
> > Thanks
>
> {% ifequal forloop.counter 6 %}
> ...
> {% endif %}
>
> 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: is Django a good choice for a LAN app?

2009-08-13 Thread snfctech

@Torsten: Grüß Gott!  Agreed, I'm sold that the web client/server
model is the way to go for my project.

@Jonas: Thanks for the tip!  I found the multi-db thread.  Looks like
multi-db support is just around the corner, and I probably wont need
it for a few months, so I think I'm going to give Django a go!

Btw, I researched the Rails camp on this topic, and found multi-db
support there to be equally lacking.  A couple folks said they came up
with solutions (rails gems): connection_ninja and
magic_multi_connections.  But these seemed like beta, individual, side-
projects (not to mention that the Google group associated with the
second project was infested with spam).

Hopefully the multi-db support they are talking about in django-
developers will be a more integral part of the Django core.

On Aug 13, 5:57 am, Jonas Obrist  wrote:
>  From what I read on django-developers, multi-db support is being
> actively worked on.
>
> roberto wrote:
> > snfctech,
> > As far as I know, Django doesn't have an option to set more than one
> > database. If I am mistaken, please, let me know.
> > I am not sure if there is any project to add this capability in the
> > future tough.
> > Maybe you should investigate a bit more in the site
> > (djangoproject.com).
> > Regards.
>
> > On Aug 12, 4:31 pm, snfctech  wrote:
>
> >> Thanks, Jonas.
>
> >> And do you think Django's ORM will be able to handle my multiple DB
> >> connections, with read/write fields from different DB producs/ servers
> >> on the same view (most of which will hopefully be ODBC compliant, but
> >> some might not)?
>
> >> On Aug 12, 11:32 am, Jonas Obrist  wrote:
>
> >>> In my opinion writing it in django/html/... is a lot easier and faster
> >>> than doing it in a real python GUI tool. Also you have the networking in
> >>> your LAN taken care of by the browser.
>
> >>> snfctech wrote:
>
>  One more question:  Any advantage to just using a Python GUI toolkit
>  instead?
>
>  On Aug 12, 9:18 am, snfctech  wrote:
>
> > Thanks for all of the good feedback!
>
> > At the very least I am enthusiastic about the health of this list! ;-)
>
> > @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> > sales/week).
>
> > Sounds like the community feels Django is a good choice for my type of
> > project.
>
> > Thanks!
>
> > On Aug 12, 5:18 am, Philippe Raoult  wrote:
>
> >> I don't know what you mean by mid-sized but I deployed exactly what
> >> you're describing in a 45-strong company. We have occasional browser
> >> incompatibilities with ajax but overall django was very much the right
> >> tool for the job. As a bonus the company's clients can now access a
> >> restricted part of the application to monitor their files and dealings
> >> over https. Employees can also log in from home over https without any
> >> software/hardware prerequisite. We're also planning on adding some
> >> smartphone friendly pages for specific tasks (billing when employees
> >> are working offsite).
>
> >> My app is around 25k lines of python+templates
>
> >> Hope this helps you make your mind.
>
> >> On Aug 11, 9:06 pm, snfctech  wrote:
>
> >>> I'm about to start a fairly large project for a mid-sized business
> >>> with a lot of integration with other systems (POS, accounting,
> >>> website, inventory, purchasing, etc.) The purpose of the system is to
> >>> try to reduce current data siloing and give employees role-based
> >>> access to the specific data entry and reports they need, as well as to
> >>> replace some manual and redundant business processes. The system needs
> >>> to be cross-platform (Windows/Linux), open source and is primarily for
> >>> LAN use.
>
> >>> My experience is mostly PHP/web/app development, but I have developed
> >>> a few LAN apps using Java/Servoy (like Filemaker). I am leaning
> >>> towards Python/Django - but wondering whether this may be
> >>> unnecessarily web-specific. I really felt Servoy development was very
> >>> rapid, and it was cross-paltform, but it was not open source (not to
> >>> mention that anything custom needed to be Java which I find too
> >>> verbose/ slow to develop in). Or maybe Open Office Base and some
> >>> scripting is sufficient to handle my needs.
>
> >>> So, my main question is: Does a web framework like Django sound like a
> >>> reasonable platform to build a LAN Dashboard for a mid-sized company?
> >>> Or am I thinking too much like a web developer?
>
> >>> Any tips or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to 

Re: Django, CMS, CSS newbie question

2009-08-13 Thread Matthias Kestenholz

On Thu, Aug 13, 2009 at 11:55 PM, eldonp2 wrote:
>
> Thanks.
>
> I've gone through the book and done the tutorial on djangoproject.com
>
> Basically, my qyestion is still not answered - how do I start with a
> CSS template and bring Django and Django-CMS in afterward? The problem
> is with learning Python, HTML and Django, it will take a long time
> before I get to know CSS.
>

Trying  to start with Django-CMS (or any comparable software package
for that matter) before you know how to work with CSS files inside
Django is akin to trying to run before you can walk. You'll have to do
lots of reading and some coding before you'll be able to do what you
want to do. Django isn't a turn-key solution. It's a programmers tool.
And nobody can teach you to program using lots of emails, you have to
learn it yourself. And yes, it will take a long time[0].

If you have a more specific question I (and others) will be happy to
try to answer it. One could write a book trying to answer your
question and still not succeed. And there _are_ good books which will
bring you there. www.djangobook.com is one of these.

I do not want to offend or discourage you, but I doubt that you really
went through the book if you still need to ask how to get started with
Django and CSS. Really, try to start with the basics, that is, set up
a simple site with Django, and only then start thinking about working
with prebuilt CMS systems.



[0]: http://norvig.com/21-days.html : Teach Yourself Programming in Ten Years

-- 
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: Django, CMS, CSS newbie question

2009-08-13 Thread eldonp2

Thanks.

I've gone through the book and done the tutorial on djangoproject.com

Basically, my qyestion is still not answered - how do I start with a
CSS template and bring Django and Django-CMS in afterward? The problem
is with learning Python, HTML and Django, it will take a long time
before I get to know CSS.

On Aug 11, 5:57 pm, Juan Hernandez  wrote:
> you can start here
>
> www.djangobook.com
>
> On Tue, Aug 11, 2009 at 10:58 AM, eldonp2  wrote:
> > I would like to start my own website. I
> > figured, since I don't know much, that I would start with a CSS
> > template and work back. How can I use a free template and then
> > integrate Django-Cms and Django into 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: new session ID is created for every request from IE 7

2009-08-13 Thread humble

Hi Malcolm

Thanks for your suggestion. I did to try using a FQDN to configure IE
for cookies. I am still seeing requests coming in from IE do not carry
a cookie..

What am I doing wrong?

On Aug 12, 9:48 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-08-12 at 19:21 -0700, humble wrote:
> > Hi,
>
> > I am writing a web application that involves session management with
> > the corporate backend module. I wrote my own authentication backend
> > plugin to satisfy the corporate requirement, not the default
> > authentication backend. I use file based session engine to avoid
> > sqlite crap. Everything works fine in firefox and chrome. But it seems
> > to be a problem with IE: response includes a new session ID (actually
> > a test cookie) for each request from IE. It seems IE never sends back
> > the previous cookie given by the server in subsequent request. Check
> > in /tmp/ (where I store all session files), I see the previous session
> > file is replaced with a new empty session file.
>
> > Looking in to contrib.session.middleware.py confirms
> > "request.session.session_key" is different for each request. However,
> > this only happens when I use IE.  I configured IE 7 to allow cookies,
> > so it does not reject cookies from django. What might be the problem?
> > Has any one seen this issue before?
>
> I've seen it before when the domain being used for the cookie wasn't a
> valid domain name. Browsers have blacklists of sets of domains that they
> won't accept/send cookies for and they typically won't allow you to set
> a cookie for .com, say.
>
> That might be the problem in this case.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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: Securing files held by FileField.

2009-08-13 Thread Javier Guerra

On Thu, Aug 13, 2009 at 3:43 PM, stupidgeek wrote:
> Thanks to both of you for the advice - Ben, yours seems to be like a
> step four to Javier's solution. I like it, but will only say I'll
> maybe try it once I've got the serving done Javier's way.

what i get from Ben's comment is more like my step 2, but with a
couple extra hoops to get to the URL.  doesn't do anything for
security, since in he ends serving the file with Django anyway.

> Javier, could you post some example code? I'm pretty sure this is bang-
> on what I want, although as I said, I'm using apache.

this is what i do on views.py: http://dpaste.com/80251/

for Apache, you have to use 'X-Sendfile' instead of
'X-Accel-Redirect'.  i don't know if you have to add the private
directory to some configuration.  (in nginx i had to register the
directory with a 'private' flag)


-- 
Javier

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



using Max()

2009-08-13 Thread neri...@gmail.com

Hello,

Do I need t convert the value returned from Max() to an int, or am I
using it incorrectly? I'm getting this template error:

Caught an exception while rendering: (1064, "You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near ''id__max': '2'} )' at line
1")
1

from django.db.models import Max

def preview(request, template_name='listings/preview.html',
order_num=Order.objects.aggregate(Max('id'))):
num = order_num
user = request.user
listings = Listing.objects.filter
(order__customer__user__username=user)
gallery = Photo.objects.filter
(order__customer__user__username=user, order=num)
return render_to_response(template_name, { 'user': user,
'listings': listings, 'order': num, 'gallery': gallery })


Thanks,

Jason
--~--~-~--~~~---~--~~
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: Securing files held by FileField.

2009-08-13 Thread stupidgeek

Thanks to both of you for the advice - Ben, yours seems to be like a
step four to Javier's solution. I like it, but will only say I'll
maybe try it once I've got the serving done Javier's way.

Javier, could you post some example code? I'm pretty sure this is bang-
on what I want, although as I said, I'm using apache.

Cheers,
Brenton.

On Aug 13, 3:10 pm, BenW  wrote:
> If you want to prevent hotlinking to your documents or illicit access,
> then I would suggest writing a view that generates a unique URL per
> access.  For instance, a user hits your view, they get a randomly
> generated link to access the file.  You store that random link in
> their session as a one-to-one mapping to the pk of the file they want
> to download -- then you have a url/view that will take that random
> link and lookup the file.  Afterward that random link is purged from
> their session.  Of course, this also means that Django would have to
> either serve the file itself, or you would have to rename the file on
> disk after every access .. which would be lame.
>
> On Aug 13, 11:00 am, stupidgeek  wrote:
>
> > Hi there,
>
> > So I'm practically done with my first django site (i've worked with
> > PHP for years, and I'm so glad I found django), but I am having some
> > trouble with securing files; let me explain:
>
> > I've written a faculty review system, with tight checks on access for
> > reviews, based on committees, etc. Each review contains a document,
> > held by a models.FileField, and I would like to restrict access to the
> > file; ie not put it under my DocumentRoot (/var/www), so that it can
> > only be accessed from within django only (and, of course, access will
> > be limited by my views).
>
> > Is this possible? As far as I understand, when you access a FileField,
> > you get back the filename, which you then use somehow to link to it.
> > This of course means that the file must be under the document root,
> > which doesn't secure it for me (as anyone with the URL will be able to
> > access it) - this is NOT an option.
>
> > I'd be happy if someone could even link me to relevant docs.
>
> > Thanks,
> > Brenton.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Cursor resource cleanup?

2009-08-13 Thread Joshua Russo
Do you need to do any cleanup of resources when you use a cursor (closing of
connection/cursor)?
I have the following method, do I need to do anything to cleanup resources?

def get_next_NumOrd(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT COALESCE(max(NumOrd), 1000) FROM matriz_matriz")
row = cursor.fetchone()
return (row[0] + 1)

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



Notify about a bug

2009-08-13 Thread Peter2108

I just ran into bug #6138 which is two years old now. There is a patch
supplied but it has not made it into the version I am using (1.1 rc1,
11,332). Is there anyway to tell the Django Trace to notify me by
email when this bug is updated?

Thanks,

Peter
--~--~-~--~~~---~--~~
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: mass-updating question

2009-08-13 Thread Jonas Obrist

Alex Gaynor wrote:
> On Thu, Aug 13, 2009 at 2:51 PM, Jonas Obrist wrote:
>   
>> Hi django-users
>>
>> I try to do as much as I can in ORM without python looping etc. So I
>> wonder if the following code could be done in one update:
>>
>> for parent in thread.forum.allparents.all():
>>parent.postcount += 1
>>parent.lastpost = post
>>parent.save()
>>
>> Basically do something like:
>>
>> thread.forums.allparents.update(postcount += 1, lastpost=post)
>>
>> I'm well aware that += is completely wrong there, it's just to
>> illustrate my idea.
>>
>> Jonas
>>
>> 
>
> If you're using django 1.1 you can use the new F() objects so it'd look like:
>
> thread.forums.allparents.update(postcount = F('postcount')+1, lastpost=post)
>
> Alex
>
>   
I read in the docs that F is for filters... but if that works, thanks!

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: mass-updating question

2009-08-13 Thread Alex Gaynor

On Thu, Aug 13, 2009 at 2:51 PM, Jonas Obrist wrote:
>
> Hi django-users
>
> I try to do as much as I can in ORM without python looping etc. So I
> wonder if the following code could be done in one update:
>
> for parent in thread.forum.allparents.all():
>    parent.postcount += 1
>    parent.lastpost = post
>    parent.save()
>
> Basically do something like:
>
> thread.forums.allparents.update(postcount += 1, lastpost=post)
>
> I'm well aware that += is completely wrong there, it's just to
> illustrate my idea.
>
> Jonas
>
> >
>

If you're using django 1.1 you can use the new F() objects so it'd look like:

thread.forums.allparents.update(postcount = F('postcount')+1, lastpost=post)

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: if forloop.counter

2009-08-13 Thread Jonas Obrist

When ideas fail wrote:
> Hello, i know you can have things like {% if forloop.last %}
> but is it possible to have an if statement that matches the value of a
> forloop counter
> so it would be like:
>
> {% if forloop.counter = 6 % }
>
> or similar and how could i do that?
>
> Thanks
>
> >
>   
{% ifequal forloop.counter 6 %}
...
{% endif %}

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



mass-updating question

2009-08-13 Thread Jonas Obrist

Hi django-users

I try to do as much as I can in ORM without python looping etc. So I 
wonder if the following code could be done in one update:

for parent in thread.forum.allparents.all():
parent.postcount += 1
parent.lastpost = post
parent.save()

Basically do something like:

thread.forums.allparents.update(postcount += 1, lastpost=post)

I'm well aware that += is completely wrong there, it's just to 
illustrate my idea.

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



if forloop.counter

2009-08-13 Thread When ideas fail

Hello, i know you can have things like {% if forloop.last %}
but is it possible to have an if statement that matches the value of a
forloop counter
so it would be like:

{% if forloop.counter = 6 % }

or similar and how could i do that?

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Easy question

2009-08-13 Thread Margie

When you pass in an instance, when you later use the form.save()
method, it will save any new data back to that instance.  IE, if you
pass in both an instance and POST data, it will basically give you a
form that merges the instance data with the POST data, and now you can
just save back to the instance.

If you give just initial data, then I believe when you save it just
creates a new object, since it is not bound to any existing object.
If you give initial and POST data, then it will merge those together
(with the post data winning) and create your new object based on that.

Margie

On Aug 13, 10:01 am, George Laskowsky 
wrote:
> Hi,
>
>  I was wondering about forms (and modelforms), what is the difference
> between passing it an object (in the 'instance' attribute) and passing it an
> dictionary with the same data (in the 'initial' attribute)?
>
>  Thanks
> --
> George Laskowsky Ziguilinsky
--~--~-~--~~~---~--~~
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: Reloading a page with new data

2009-08-13 Thread Margie

I have been able to mimic the admin behavior in my own app.   I
started off with the admin js functions showAddAnotherPopup and
dismissAddAnotherPopup.   Study these in the context of how they are
used in the admin app and they should get you going.  The best method
for me was to use firebug and put breakpoints at the begninning of
showAddAnotherPopup and dismissAddAnotherPopup and then print the
variables in those functions.  They basically encode the id of the
input that you need filled in in the window name of of the popup
window, and then when the popup is closed, then return an httpResponse
that calls dismissAddAnotherPopup() and that extracts the window name
of the popup, uses it to identify the id where to place the result,
and then fills in the input appropriately.

It is also useful to put a pdb breakpoint into the admin code in the
response_add() function, ie:

import pdb
pdb.set_trace()


This will make your server drop into pdb right before sending back the
response that calls dismissAddAnother().  If you do all of this and
then click on an "add another" (green "+") in the admin you should be
able to trace the process they use.

I thought it was all pretty slick myself.  I don't have a ton of
javascript experience, so am not sure if this is the best way to do
things or not.  There might be something simpler in jquery, please
post if you do identify something simpler!

This is not really in the realm of "django", since django doesn't
really have much to do with the javascript side of things, but still,
I'd be interested to know how others in this django community are
creating popup windows that fill in information and then pass it back
to some "main" window.

Margie


On Aug 13, 9:40 am, Thomas Scrace  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi all,
>
> My app has a page where you can enter new data into the database through
> a form.  All is working well, except that some of the fields require a
> choice from a drop down menu.  If the choice for these fields the user
> wants is not already in the database then they have to enter that new
> choice.  To facilitate that I have added a little '+' sign next the the
> drop down which opens a new page where they can enter the new choice,
> click save, and go back to the old page.
>
> It does work, but my problem is that, as you would expect, when they go
> back to the original page the new choice does not show up in the drop
> down menu.  You have to refresh the page in order to get it to show up.
>  In addition, my new page shows up in a new tab, rather than a new
> window as I intended (using 'target='_blank').
>
> So, I need a way to:
>
> 1. Open a new window with a specified view.
> 2. On clicking 'submit' in the new window, have the new window close
> down and auto-reload the original page while retaining the information
> already entered in other fields.
>
> It seems like this should be relatively simple, but I cannot find a way
> to do it.  I notice that Django's admin interface allows exactly this
> functionality, and I have attempted to figure out their javascript but
> with no success.  Is there a more simple 'Djangofied' way to do this.
>
> Thanks very much for any help you can offer,
>
> - --
> Tom 
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (Darwin)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkqEQgsACgkQqeeO1ChsKHTOrgCg6W7JnbQEJsAXlwI0iYfAJuat
> xe4An36q7vGtGFTzuM+IOF0xQJF10XEe
> =7avd
> -END PGP SIGNATURE-
--~--~-~--~~~---~--~~
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: Securing files held by FileField.

2009-08-13 Thread BenW

If you want to prevent hotlinking to your documents or illicit access,
then I would suggest writing a view that generates a unique URL per
access.  For instance, a user hits your view, they get a randomly
generated link to access the file.  You store that random link in
their session as a one-to-one mapping to the pk of the file they want
to download -- then you have a url/view that will take that random
link and lookup the file.  Afterward that random link is purged from
their session.  Of course, this also means that Django would have to
either serve the file itself, or you would have to rename the file on
disk after every access .. which would be lame.

On Aug 13, 11:00 am, stupidgeek  wrote:
> Hi there,
>
> So I'm practically done with my first django site (i've worked with
> PHP for years, and I'm so glad I found django), but I am having some
> trouble with securing files; let me explain:
>
> I've written a faculty review system, with tight checks on access for
> reviews, based on committees, etc. Each review contains a document,
> held by a models.FileField, and I would like to restrict access to the
> file; ie not put it under my DocumentRoot (/var/www), so that it can
> only be accessed from within django only (and, of course, access will
> be limited by my views).
>
> Is this possible? As far as I understand, when you access a FileField,
> you get back the filename, which you then use somehow to link to it.
> This of course means that the file must be under the document root,
> which doesn't secure it for me (as anyone with the URL will be able to
> access it) - this is NOT an option.
>
> I'd be happy if someone could even link me to relevant docs.
>
> Thanks,
> Brenton.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



over-riding queryset for admin inlines

2009-08-13 Thread smcoll

i'm having trouble getting some instances to show up as inlines in the
admin.  Since i'm managing multiple sites from one domain, many of
those instances won't show up because the condition in their default
manager ("is it on this site?") fails.

i'd like my admin to use `objects` for everything, so nothing is
filtered out.  So far, i over-rode each ModelAdmin's queryset() to use
`objects`, but i'm having trouble doing the same for the inlines.

The furthest i've gotten is to override get_queryset() in an instance
of django.forms.models.BaseInlineFormSet, which does get the instances
to appear in the admin- i just can't save anything.  i get "Please
correct the errors below." but no errors show- when i inspect the
debug info, i see a number of "Select a valid choice. That choice is
not one of the available choices." errors corresponding with the
number of inline objects that are attached.

How can i solve this without making `objects` the default manager?
Here's a stripped-down, working app that illustrates all this:

http://dpaste.com/80185/

Since we can override the queryset for ModelAdmins, i'm sure there's a
way to do it for inlines as well.
--~--~-~--~~~---~--~~
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: Securing files held by FileField.

2009-08-13 Thread Javier Guerra

On Thu, Aug 13, 2009 at 1:00 PM, stupidgeek wrote:
> I've written a faculty review system, with tight checks on access for
> reviews, based on committees, etc. Each review contains a document,
> held by a models.FileField, and I would like to restrict access to the
> file; ie not put it under my DocumentRoot (/var/www), so that it can
> only be accessed from within django only (and, of course, access will
> be limited by my views).

i've done this, three steps:

1.- move your files out of the dirs normally accesible by the HTTP
server.  now you can't access them anymore, your site is broken.

2.- add the urls to urls.py to make Django itself manage the file
serving.  add your own views (maybe as wrappers to the normal media
handling views), so that you can check the required privileges.  Now
you can again access the files and your site is functional again; but
it's unbearably slow, and quite possibly breaks on big files.

3.- replace the data-serving (last) step on your views with the
server-specific headers on the response object that tell your HTTP
server to serve the file.  be sure to delete (or comment) the part
where you put the file's content in the response.

done!

in my case, i'm using NginX, so i had to add an 'X-Accel-Redirect'
with the path to the file.  i think for Apache and lightttpd you do
something similar, but pass an URL instead of a local path.  be sure
to make that URL work only when asked locally.

-- 
Javier

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

2009-08-13 Thread Jonas Obrist

Igor Sobreira wrote:
>
>
> On Thu, Aug 13, 2009 at 2:50 PM, Jonas Obrist  > wrote:
>
> [...]
> > >
> Caching isn't really an options since I only have  VPS with very
> little
> RAM and from reading the docs good caching is done with memcached...
> which uses loads of RAM. Once I have the app stable and everything
> I'll
> write some benchmarking for it and I'll run some tests without
> psyco as
> well. This will probably take quite a while though.
>
>
> Filesystem cache should work. Not as fast as memcached (of course), 
> but I would certainly try it.
>
> Good luck.
>
> -- 
> Igor Sobreira
> www.igorsobreira.com 
> www.smartnutstechnology.com 
>
> >
What about caching things which require pickle? I was thinking of 
caching some regex objects. Or to be more precise, I write a forum which 
makes use of BB Code which is stored in a database. I'm trying to 
optimize it now that for each request it has to compile the bbcodes only 
once (they're regular expressiosn). Right now they're just a filter 
which loops through all rows in the database.

All other issues I had performance wise have to be reanalyzed since I 
change the database model completely so it hopefully works faster...

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

2009-08-13 Thread Igor Sobreira
On Thu, Aug 13, 2009 at 2:50 PM, Jonas Obrist  wrote:

> [...]
> > >
> Caching isn't really an options since I only have  VPS with very little
> RAM and from reading the docs good caching is done with memcached...
> which uses loads of RAM. Once I have the app stable and everything I'll
> write some benchmarking for it and I'll run some tests without psyco as
> well. This will probably take quite a while though.
>

Filesystem cache should work. Not as fast as memcached (of course), but I
would certainly try it.

Good luck.

-- 
Igor Sobreira
www.igorsobreira.com
www.smartnutstechnology.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Remove unique from user model

2009-08-13 Thread Vitaly Babiy
Hello Guys,
So  I need to remove the unique flag off the username field in the user
model. I already extend the auth user model but I can't override the
username field. ( Django does not allow this )

What is the best way to do this?

Thanks
Vitaly Babiy

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



Securing files held by FileField.

2009-08-13 Thread stupidgeek

Hi there,

So I'm practically done with my first django site (i've worked with
PHP for years, and I'm so glad I found django), but I am having some
trouble with securing files; let me explain:

I've written a faculty review system, with tight checks on access for
reviews, based on committees, etc. Each review contains a document,
held by a models.FileField, and I would like to restrict access to the
file; ie not put it under my DocumentRoot (/var/www), so that it can
only be accessed from within django only (and, of course, access will
be limited by my views).

Is this possible? As far as I understand, when you access a FileField,
you get back the filename, which you then use somehow to link to it.
This of course means that the file must be under the document root,
which doesn't secure it for me (as anyone with the URL will be able to
access it) - this is NOT an option.

I'd be happy if someone could even link me to relevant docs.

Thanks,
Brenton.
--~--~-~--~~~---~--~~
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-rosetta issue

2009-08-13 Thread Gilles Bassière

Hi list,

I've installed the django-rosetta app in my project. It works pretty
well except that it seems to give precedence to its own translations.

For example, in the admin interface "Home" is translated as "Racine" in
french. This translation comes from:
$project/rosetta/locale/fr/LC_MESSAGES/django.mo
whereas it should be taken in:
$site-packages/django/conf/locale/fr/LC_MESSAGES/django.po
When rosetta is disabled, "Home" is normally translated as "Accueil".

Here is my i18n config in settings.py :
TEMPLATE_CONTEXT_PROCESSORS = (
...,
"django.core.context_processors.i18n",
...,
)
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
...,
)
LANGUAGE_CODE = 'en'
LOCALE_PATHS = (
os.path.join(PROJECT_ROOT_PATH, '../opencarto/locale'),
os.path.join(PROJECT_ROOT_PATH, '../templates/locale'),
)

I don't know the internals of gettext but I've always believed it is
able to map a reference string in the code to the proper .mo/.po file.
Am I wrong? If not is there something wrong with my i18n settings?


Regards,
Gilles

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

2009-08-13 Thread Jonas Obrist

Igor Sobreira wrote:
>
>
> On Thu, Aug 13, 2009 at 12:35 PM, Jonas Obrist  > wrote:
>
>
> Torsten Bronger wrote:
> > Hallöchen!
> >
> > Jonas Obrist writes:
> >
> >
> >> Is anyone using psyco in django? Does it work and is it useful (as
> >> in: do you get great speed improvements)?
> >>
> >
> > I've once seen a benchmark indicating considerable improvements of
> > Django performance with psyco, but only on 32 bit systems.  On 64
> > bit, psyco was a slight drawback.
> >
> > Tschö,
> > Torsten.
> >
> >
> As far as I knew psyco is 32bit only anyway...
>
> Also: does anyone know if I have to put 'import psyco; psyco.full()'
> into every file or if there's a central place where I can enable
> it for
> the whole django and my whole app? I'm on a 32bit system and have
> performance issues...
>
>
> Maybe you should cache everything possible before trying psyco. 
> But I'm curious about Psyco improvements in Django too. Let us know if 
> you get any speed improvements.
>
>
> -- 
> Igor Sobreira
> www.igorsobreira.com 
> www.smartnutstechnology.com 
>
> >
Caching isn't really an options since I only have  VPS with very little 
RAM and from reading the docs good caching is done with memcached... 
which uses loads of RAM. Once I have the app stable and everything I'll 
write some benchmarking for it and I'll run some tests without psyco as 
well. This will probably take quite a while though.

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

2009-08-13 Thread David De Sousa

searching "psyco django" in your friend, google brings
http://code.djangoproject.com/wiki/PsycoMiddleware maybe you should
read it.

On Fri, Aug 14, 2009 at 13:04, Igor Sobreira wrote:
>
>
> On Thu, Aug 13, 2009 at 12:35 PM, Jonas Obrist  wrote:
>>
>> Torsten Bronger wrote:
>> > Hallöchen!
>> >
>> > Jonas Obrist writes:
>> >
>> >
>> >> Is anyone using psyco in django? Does it work and is it useful (as
>> >> in: do you get great speed improvements)?
>> >>
>> >
>> > I've once seen a benchmark indicating considerable improvements of
>> > Django performance with psyco, but only on 32 bit systems.  On 64
>> > bit, psyco was a slight drawback.
>> >
>> > Tschö,
>> > Torsten.
>> >
>> >
>> As far as I knew psyco is 32bit only anyway...
>>
>> Also: does anyone know if I have to put 'import psyco; psyco.full()'
>> into every file or if there's a central place where I can enable it for
>> the whole django and my whole app? I'm on a 32bit system and have
>> performance issues...
>
> Maybe you should cache everything possible before trying psyco.
> But I'm curious about Psyco improvements in Django too. Let us know if you
> get any speed improvements.
>
> --
> Igor Sobreira
> www.igorsobreira.com
> www.smartnutstechnology.com
>
> >
>



-- 
David E. De Sousa M.
Linux User #417969
Running Debian and Gentoo, Fuck RPM
Estudiante de Ingeniería de la Computación
Universidad Simón Bolívar
Caracas - Venezuela

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

2009-08-13 Thread Igor Sobreira
On Thu, Aug 13, 2009 at 12:35 PM, Jonas Obrist  wrote:

>
> Torsten Bronger wrote:
> > Hallöchen!
> >
> > Jonas Obrist writes:
> >
> >
> >> Is anyone using psyco in django? Does it work and is it useful (as
> >> in: do you get great speed improvements)?
> >>
> >
> > I've once seen a benchmark indicating considerable improvements of
> > Django performance with psyco, but only on 32 bit systems.  On 64
> > bit, psyco was a slight drawback.
> >
> > Tschö,
> > Torsten.
> >
> >
> As far as I knew psyco is 32bit only anyway...
>
> Also: does anyone know if I have to put 'import psyco; psyco.full()'
> into every file or if there's a central place where I can enable it for
> the whole django and my whole app? I'm on a 32bit system and have
> performance issues...


Maybe you should cache everything possible before trying psyco.
But I'm curious about Psyco improvements in Django too. Let us know if you
get any speed improvements.


-- 
Igor Sobreira
www.igorsobreira.com
www.smartnutstechnology.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Psyco

2009-08-13 Thread Jonas Obrist

Matthias Kestenholz wrote:
> On Thu, Aug 13, 2009 at 5:35 PM, Jonas Obrist wrote:
>   
>> Torsten Bronger wrote:
>> 
>>> Hallöchen!
>>>
>>> Jonas Obrist writes:
>>>
>>>
>>>   
 Is anyone using psyco in django? Does it work and is it useful (as
 in: do you get great speed improvements)?

 
>>> I've once seen a benchmark indicating considerable improvements of
>>> Django performance with psyco, but only on 32 bit systems.  On 64
>>> bit, psyco was a slight drawback.
>>>
>>> Tschö,
>>> Torsten.
>>>
>>>
>>>   
>> As far as I knew psyco is 32bit only anyway...
>>
>> Also: does anyone know if I have to put 'import psyco; psyco.full()'
>> into every file or if there's a central place where I can enable it for
>> the whole django and my whole app? I'm on a 32bit system and have
>> performance issues...
>>
>> 
>
> Are you using WSGI? runner.wsgi (or whatever your wsgi script is
> named) might be a good point to put the psyco import. I'm not sure if
> it works as expected though.
>
> I'm asking myself a bit whether it is really the python code which is
> running too slow on your system. Have you profiled your website /
> webapplication? Maybe the reason for the slowness lies elsewhere? F.e.
> complicated Javascript code, too many DB queries or something else?
>
>
> Matthias
>
>
>   
Well it's generally bad design, I'm working on that now. But some extra 
speed can never harm... I'm using WSGI and will try putting it into the 
wsgi script.

--~--~-~--~~~---~--~~
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 put logged-in user.username in model's textbox default value ?

2009-08-13 Thread Rami

Hi al,
how can you put the logged-in user.username in model's textbox default
value ?
You don't have the "request" object in a model.

ex:
class PizzaOrder(models.Model):
  submitter = models.CharField(max_length=50, default='   ...,< logged-
in username >')

thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Easy question

2009-08-13 Thread George Laskowsky
Hi,

 I was wondering about forms (and modelforms), what is the difference
between passing it an object (in the 'instance' attribute) and passing it an
dictionary with the same data (in the 'initial' attribute)?

 Thanks
-- 
George Laskowsky Ziguilinsky

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



Spellchecker gives error when clicked with empty textarea.

2009-08-13 Thread Sonal Breed

Hello all,

I installed Pyenchant package and have spellchecker in the tinymce
toolbar. The spellchecker button works fine when there is some text in
associated text area. However, when I click the button with empty text
area, following error is displayed in a dialog box:

Error response: Error running spellchecker
  Request

Does anybody know the solution to this??

Thanks in advance,
Sonal.
--~--~-~--~~~---~--~~
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: Error: ce is not defined

2009-08-13 Thread Sonal Breed

Hello all,

All I needed to was add spellchecker in editor_template.js's
theme_advanced_buttons1
and that gave me the button in toolbar.

Thanks in advance,
Sonal.

On Aug 13, 9:05 am, Sonal Breed  wrote:
> Hello Joost, everyone,
>
> I am trying to add specllchecker in tinymce toolbar.
> I installed PyEnchant package and in settings.py have added
> following:-
> TINYMCE_DEFAULT_CONFIG = {
>   'plugins': "table,spellchecker,paste,searchreplace, emotions,
> inlinepopups",
>   'theme': "advanced",
>   'cleanup_on_startup': True,
>   'custom_undo_redo_levels': 10,
>   'language': "{{ language }}",
>   'directionality': "{{ directionality }}",
>   'spellchecker_languages' : "{{ spellchecker_languages }}",
>   'spellchecker_rpc_url' : "{{ spellchecker_rpc_url }}"
>
> }
>
> I still am not able to see the spellchecker in the toolbar,
> I am definitely missing something, can anybody tell me wht
> additional steps I need to take??
>
> Thanks in advance,
> Sincerely,
> Sonal.
>
> On Jul 15, 11:24 am, Sonal Breed  wrote:
>
> > I will keep you posted, Joost, on this issue...
>
> > On Jul 15, 2:43 am, Joost Cassee  wrote:
>
> > > On Jul 14, 10:51 pm,SonalBreed  wrote:
>
> > > > After I made TINYMCE_COMPRESSOR as False, I could get tinymce toolbar.
> > > > However, the style dropdown is showing empty, and there are couple of
> > > > other things I would like to have, like spell checker and color.
> > > > Have to go through tinymce docs, do u have any tips?
>
> > > Setting the TinyMCE options (as documented in the TinyMCE wiki [1]) in
> > > TINYMCE_DEFAULT_CONFIG, as you have done, should just work. You will
> > > need a language pack for every language in LANGUAGES and the Enchant
> > > library as explained in the django-tinymce documentation [2].
>
> > > [1]http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
> > > [2]http://django-tinymce.googlecode.com/svn/trunk/docs/.build/html/insta...
>
> > > There have been reports that django-tinymce has a problem with
> > > languages with non-ASCII characters. I'm still trying to reproduce
> > > this.
>
> > > If you have more specific questions I may be able to help you
> > > better. :-)
>
> > > Regards,
>
> > > Joost
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Reloading a page with new data

2009-08-13 Thread Thomas Scrace

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi all,

My app has a page where you can enter new data into the database through
a form.  All is working well, except that some of the fields require a
choice from a drop down menu.  If the choice for these fields the user
wants is not already in the database then they have to enter that new
choice.  To facilitate that I have added a little '+' sign next the the
drop down which opens a new page where they can enter the new choice,
click save, and go back to the old page.

It does work, but my problem is that, as you would expect, when they go
back to the original page the new choice does not show up in the drop
down menu.  You have to refresh the page in order to get it to show up.
 In addition, my new page shows up in a new tab, rather than a new
window as I intended (using 'target='_blank').

So, I need a way to:

1. Open a new window with a specified view.
2. On clicking 'submit' in the new window, have the new window close
down and auto-reload the original page while retaining the information
already entered in other fields.

It seems like this should be relatively simple, but I cannot find a way
to do it.  I notice that Django's admin interface allows exactly this
functionality, and I have attempted to figure out their javascript but
with no success.  Is there a more simple 'Djangofied' way to do this.

Thanks very much for any help you can offer,

- --
Tom 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqEQgsACgkQqeeO1ChsKHTOrgCg6W7JnbQEJsAXlwI0iYfAJuat
xe4An36q7vGtGFTzuM+IOF0xQJF10XEe
=7avd
-END PGP SIGNATURE-

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

2009-08-13 Thread Matthias Kestenholz

On Thu, Aug 13, 2009 at 5:35 PM, Jonas Obrist wrote:
>
> Torsten Bronger wrote:
>> Hallöchen!
>>
>> Jonas Obrist writes:
>>
>>
>>> Is anyone using psyco in django? Does it work and is it useful (as
>>> in: do you get great speed improvements)?
>>>
>>
>> I've once seen a benchmark indicating considerable improvements of
>> Django performance with psyco, but only on 32 bit systems.  On 64
>> bit, psyco was a slight drawback.
>>
>> Tschö,
>> Torsten.
>>
>>
> As far as I knew psyco is 32bit only anyway...
>
> Also: does anyone know if I have to put 'import psyco; psyco.full()'
> into every file or if there's a central place where I can enable it for
> the whole django and my whole app? I'm on a 32bit system and have
> performance issues...
>

Are you using WSGI? runner.wsgi (or whatever your wsgi script is
named) might be a good point to put the psyco import. I'm not sure if
it works as expected though.

I'm asking myself a bit whether it is really the python code which is
running too slow on your system. Have you profiled your website /
webapplication? Maybe the reason for the slowness lies elsewhere? F.e.
complicated Javascript code, too many DB queries or something else?


Matthias




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



Is there any way to automatize caching of particular model?

2009-08-13 Thread Evgeny

Hi,
is there any right way to automatize caching of instances of
particular model, e.g. User from standard auth middleware?
My users are referenced by a lots of objects in templates and I'm
trying to avoid unnesessary queries (including select_related()).
--~--~-~--~~~---~--~~
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: Error: ce is not defined

2009-08-13 Thread Sonal Breed

Hello Joost, everyone,

I am trying to add specllchecker in tinymce toolbar.
I installed PyEnchant package and in settings.py have added
following:-
TINYMCE_DEFAULT_CONFIG = {
  'plugins': "table,spellchecker,paste,searchreplace, emotions,
inlinepopups",
  'theme': "advanced",
  'cleanup_on_startup': True,
  'custom_undo_redo_levels': 10,
  'language': "{{ language }}",
  'directionality': "{{ directionality }}",
  'spellchecker_languages' : "{{ spellchecker_languages }}",
  'spellchecker_rpc_url' : "{{ spellchecker_rpc_url }}"

}

I still am not able to see the spellchecker in the toolbar,
I am definitely missing something, can anybody tell me wht
additional steps I need to take??


Thanks in advance,
Sincerely,
Sonal.

On Jul 15, 11:24 am, Sonal Breed  wrote:
> I will keep you posted, Joost, on this issue...
>
> On Jul 15, 2:43 am, Joost Cassee  wrote:
>
> > On Jul 14, 10:51 pm,SonalBreed  wrote:
>
> > > After I made TINYMCE_COMPRESSOR as False, I could get tinymce toolbar.
> > > However, the style dropdown is showing empty, and there are couple of
> > > other things I would like to have, like spell checker and color.
> > > Have to go through tinymce docs, do u have any tips?
>
> > Setting the TinyMCE options (as documented in the TinyMCE wiki [1]) in
> > TINYMCE_DEFAULT_CONFIG, as you have done, should just work. You will
> > need a language pack for every language in LANGUAGES and the Enchant
> > library as explained in the django-tinymce documentation [2].
>
> > [1]http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
> > [2]http://django-tinymce.googlecode.com/svn/trunk/docs/.build/html/insta...
>
> > There have been reports that django-tinymce has a problem with
> > languages with non-ASCII characters. I'm still trying to reproduce
> > this.
>
> > If you have more specific questions I may be able to help you
> > better. :-)
>
> > Regards,
>
> > Joost
>
>
--~--~-~--~~~---~--~~
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: Psyco

2009-08-13 Thread Jonas Obrist

Torsten Bronger wrote:
> Hallöchen!
>
> Jonas Obrist writes:
>
>   
>> Is anyone using psyco in django? Does it work and is it useful (as
>> in: do you get great speed improvements)?
>> 
>
> I've once seen a benchmark indicating considerable improvements of
> Django performance with psyco, but only on 32 bit systems.  On 64
> bit, psyco was a slight drawback.
>
> Tschö,
> Torsten.
>
>   
As far as I knew psyco is 32bit only anyway...

Also: does anyone know if I have to put 'import psyco; psyco.full()' 
into every file or if there's a central place where I can enable it for 
the whole django and my whole app? I'm on a 32bit system and have 
performance issues...

--~--~-~--~~~---~--~~
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: Complex model produces > 400 queries with one pageview

2009-08-13 Thread Daniel Roseman

On Aug 13, 2:59 pm, tom  wrote:
> Hi,
>
> i want to save a lot of data (measurement values). The structure is,
> that i have dataloggers (which produce data), sensors (are connected
> to the datalogger with foreignkey), and projects. every logger is
> connected to one project (foreignkey). then, there is a app called
> Data.
>
> i have the following data model:
>
> class Entry(models.Model):
>     """
>     a data entry. Normaly, it is one row from a measurement file
>     a new entry has one datetime, a project, and a logger_serial
>     """
>     project = models.ForeignKey(Project)
>     logger = models.ForeignKey(Logger)
>     original_file = models.ForeignKey(OriginalFile)
>     datetime = models.DateTimeField(help_text='the date and time of
> the measurement entry', db_index=True)
>
>     class Meta:
>         unique_together = [('logger', 'datetime')]
>         ordering = ['project', 'logger', 'datetime']
>
> class Measurand(models.Model):
>     """
>     A Model for measurement data
>     """
>     entry = models.ForeignKey(Entry)
>     sensor = models.ForeignKey(Sensor)
>
>     class Meta:
>         unique_together = [('entry','sensor')]
>         ordering = ['entry', 'status']
>
> class MeasurandAverage(models.Model):
>     """
>     Model to store the average value for a measurand
>     """
>     measurand = models.OneToOneField(Measurand, parent_link=True)
>     value = models.FloatField(help_text='the average measurement
> value', db_index=True)
>     unit = models.CharField(help_text='the unit of the measurement
> value', max_length=20, db_index=True)
>
> class MeasurandMax(models.Model):
>     """
>     Model to store the max value for a measurand
>     """
>     measurand = models.OneToOneField(Measurand, parent_link=True)
>     value = models.FloatField(help_text='the max measurement value',
> db_index=True)
>     unit = models.CharField(help_text='the unit of the measurement
> value', max_length=20, db_index=True)
>
> class MeasurandMin(models.Model):
>     """
>     Model to store the min value for a measurand
>     """
>     measurand = models.OneToOneField(Measurand, parent_link=True)
>     value = models.FloatField(help_text='the min measurement value',
> db_index=True)
>     unit = models.CharField(help_text='the unit of the measurement
> value', max_length=20, db_index=True)
>
> class MeasurandSigma(models.Model):
>     """
>     Model to store the standard derivation (sigma) value for a
> measurand
>     """
>     measurand = models.OneToOneField(Measurand, parent_link=True)
>     value = models.FloatField(help_text='the sigma measurement value',
> db_index=True)
>     unit = models.CharField(help_text='the unit of the measurement
> value', max_length=20, db_index=True)
>
> now, i want to receive a list with all Measurand and also the Average,
> Max, Min, Sigma Values for every measurand.
> The problem is, that when i have a list with 50 measurands and access
> the measurandmax in my template with {{measurand.measurandmax.value}},
> this produce a query. and also every access to max, min and sigma
> produces a query.
>
> When i have a list with 100 Measurand, i have about 400 queries to get
> the data.
>
> The queries look like this:
>
> SELECT "data_measurandaverage"."id",
> "data_measurandaverage"."measurand_id",
> "data_measurandaverage"."value", "data_measurandaverage"."unit" FROM
> "data_measurandaverage" WHERE "data_measurandaverage"."measurand_id" =
> 1
> SELECT "data_measurandmin"."id", "data_measurandmin"."measurand_id",
> "data_measurandmin"."value", "data_measurandmin"."unit" FROM
> "data_measurandmin" WHERE "data_measurandmin"."measurand_id" = 1
> SELECT "data_measurandmax"."id", "data_measurandmax"."measurand_id",
> "data_measurandmax"."value", "data_measurandmax"."unit" FROM
> "data_measurandmax" WHERE "data_measurandmax"."measurand_id" = 1
> SELECT "data_measurandsigma"."id",
> "data_measurandsigma"."measurand_id", "data_measurandsigma"."value",
> "data_measurandsigma"."unit" FROM "data_measurandsigma" WHERE
> "data_measurandsigma"."measurand_id" = 1
>
> Any ideas how i can improve the queries or the structure of my models?
>
> cheers,
>
> tom

You haven't shown any of the ORM calls that are generating the
queries. But you will almost certainly find that select_related is
your friend here - it can massively cut down the number of queries
when accessing related items.

I would wonder however if Max, Min, Average and Sigma really need to
live in separate models. Since they're just one-to-ones, you're not
gaining anything in terms of normalization by keeping them separate -
you still have seperate value and unit fields for each one. I would
recommend bringing all that back into the main Measurand model, so you
would have average_value and average_unit, etc.

Also, it won't help with efficiency, but you might want to set choices
on the unit fields, to avoid people typing in slightly different
versions of the same unit type - eg centimetre, 

Re: noob question about part 2 of the tutorial

2009-08-13 Thread egrommet

Star! Thanks for that, I'd tried doing it and failed - but wasn't sure
where it was going wrong.

Have done it now and am moving onwards.
Cheers

On Aug 10, 11:17 am, nostradamnit  wrote:
> It means you remove the line that says admin.site.register(Choice), as
> the choices will be integrated in the Poll admin page now.
>
> On Aug 10, 11:28 am, egrommet  wrote:
>
> > I've just 
> > reachedhttp://docs.djangoproject.com/en/1.0/intro/tutorial02/#adding-related...
> > in the tutorial and am trying then to follow on.
>
> > I've hit the par "Remove the register() call for the Choice model.
> > Then, edit the Poll registration code to read:
> > class ChoiceInline(admin.StackedInline):
> >     model = Choice
> >     extra = 3
>
> > class PollAdmin(admin.ModelAdmin):
> >     fieldsets = [
> >         (None,               {'fields': ['question']}),
> >         ('Date information', {'fields': ['pub_date'], 'classes':
> > ['collapse']}),
> >     ]
> >     inlines = [ChoiceInline]
>
> > admin.site.register(Poll, PollAdmin)"
>
> > But I'm lost, not quite sure what remove the register() call means and
> > when I try deleting that line the whole thing goes pear shaped.
> > Anybody got an example of what the polls admin.py file should look
> > like?
>
> > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin problems with the docu

2009-08-13 Thread Karen Tracey
On Thu, Aug 13, 2009 at 9:49 AM, Alexandru-Emil Lupu
wrote:

> HI!
> the doc is updated for the 1.1 version ..
> try this
>
> urlpatterns = patterns('',
>(r'^admin/',admin.site.root),
> )
>
> see more here: http://code.djangoproject.com/ticket/10050
>

Indeed, since the Django version shown on the debug page is 1.0.2 this is
the correct url pattern for admin.  However there's something else going
wrong here also.


> On Thu, Aug 13, 2009 at 3:52 PM, quant <
> spielm...@th.physik.uni-frankfurt.de> wrote:
>
>>
>> hi
>>
>> i am pretty new to django and i started to check the docu out to see
>> how it works and i had a problem to get the admin interface working...
>>
>> i followed all the steps from the doco and if i set the options in the
>> urls.py on i got many errors ans nothing work anymore
>>
>> i set the following in the urls.py:
>>
>> from django.conf.urls.defaults import *
>>
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>>(r'^admin/', include(admin.site.urls)),
>> )
>>
>>
What are you trying to get to work here: the basic admin or the admin
documentation?  The url pattern you show is for admin, not the admin docs.
As mentioned above, it is also the wrong pattern for the version of Django
you are running.  But based on the debug info posted, this url pattern
doesn't appear to be what is being used.  If that pattern were used with
Django 1.0.2, you would get an AttributeError: 'AdminSite' object has no
attribute 'urls'.  Instead what is on the dpaste page is a
TemplateDoesNotExist for admin_doc/missing_docutils.html.  The only way I
can recreate that is if I take the admindoc url pattern:

(r'^admin/doc/', include('django.contrib.admindocs.urls')),

and remove the trailing doc/ part.  Did you do that?


>>
>> and i got the following error, if i tryed to start the
>> http://127.0.0.1:8000/admin/
>> page
>>
>> http://dpaste.com/79236/
>>
>
The TemplateDoesNotExist error is because you have not included
'django.contrib.admindocs' in your INSTALLED_APPS in settings.py.  But the
fact that the url /admin/ is being routed to an admin docs view would seem
to indicate you've got something misconfigured in your urlpatterns also, as
noted above.  What you should have in your urlpatterns, if you want to use
admindocs and admin on Django 1.0.2, is:

(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),

Then when you go to /admin/ you will get the main admin page.  In the upper
right there will be a "Documentation" link, and when you click there (after
putting django.contrib.admindocs in your INSTALLED_APPS) you will likely
(based on the template that admindocs is trying to render) get a message
that you need to install Python's docutils library before you can use Django
admin docs.

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: Dynamically adapting admin page for editting xml data?

2009-08-13 Thread spacetaxi

On 13 Aug., 11:53, spacetaxi  wrote:
> I'd like to implement an admin page (field, widget, template...
> whatever) to edit xml-formatted contents of TextFields. Every child
> node of the xml data has to be editable in a *separate* TextField.

Ok guys, just in case anybody is interested: I got this problem
solved. I don't know why it was *that* difficult for me. ;-) The
section about "Custom Widgets" in the book "Pro Django" by Marty
Alchin was very helpful.

Regards,
-Stephan


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

2009-08-13 Thread Torsten Bronger

Hallöchen!

Jonas Obrist writes:

> Is anyone using psyco in django? Does it work and is it useful (as
> in: do you get great speed improvements)?

I've once seen a benchmark indicating considerable improvements of
Django performance with psyco, but only on 32 bit systems.  On 64
bit, psyco was a slight drawback.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Complex model produces > 400 queries with one pageview

2009-08-13 Thread tom

Hi,

i want to save a lot of data (measurement values). The structure is,
that i have dataloggers (which produce data), sensors (are connected
to the datalogger with foreignkey), and projects. every logger is
connected to one project (foreignkey). then, there is a app called
Data.

i have the following data model:

class Entry(models.Model):
"""
a data entry. Normaly, it is one row from a measurement file
a new entry has one datetime, a project, and a logger_serial
"""
project = models.ForeignKey(Project)
logger = models.ForeignKey(Logger)
original_file = models.ForeignKey(OriginalFile)
datetime = models.DateTimeField(help_text='the date and time of
the measurement entry', db_index=True)

class Meta:
unique_together = [('logger', 'datetime')]
ordering = ['project', 'logger', 'datetime']

class Measurand(models.Model):
"""
A Model for measurement data
"""
entry = models.ForeignKey(Entry)
sensor = models.ForeignKey(Sensor)

class Meta:
unique_together = [('entry','sensor')]
ordering = ['entry', 'status']


class MeasurandAverage(models.Model):
"""
Model to store the average value for a measurand
"""
measurand = models.OneToOneField(Measurand, parent_link=True)
value = models.FloatField(help_text='the average measurement
value', db_index=True)
unit = models.CharField(help_text='the unit of the measurement
value', max_length=20, db_index=True)

class MeasurandMax(models.Model):
"""
Model to store the max value for a measurand
"""
measurand = models.OneToOneField(Measurand, parent_link=True)
value = models.FloatField(help_text='the max measurement value',
db_index=True)
unit = models.CharField(help_text='the unit of the measurement
value', max_length=20, db_index=True)


class MeasurandMin(models.Model):
"""
Model to store the min value for a measurand
"""
measurand = models.OneToOneField(Measurand, parent_link=True)
value = models.FloatField(help_text='the min measurement value',
db_index=True)
unit = models.CharField(help_text='the unit of the measurement
value', max_length=20, db_index=True)


class MeasurandSigma(models.Model):
"""
Model to store the standard derivation (sigma) value for a
measurand
"""
measurand = models.OneToOneField(Measurand, parent_link=True)
value = models.FloatField(help_text='the sigma measurement value',
db_index=True)
unit = models.CharField(help_text='the unit of the measurement
value', max_length=20, db_index=True)



now, i want to receive a list with all Measurand and also the Average,
Max, Min, Sigma Values for every measurand.
The problem is, that when i have a list with 50 measurands and access
the measurandmax in my template with {{measurand.measurandmax.value}},
this produce a query. and also every access to max, min and sigma
produces a query.

When i have a list with 100 Measurand, i have about 400 queries to get
the data.

The queries look like this:

SELECT "data_measurandaverage"."id",
"data_measurandaverage"."measurand_id",
"data_measurandaverage"."value", "data_measurandaverage"."unit" FROM
"data_measurandaverage" WHERE "data_measurandaverage"."measurand_id" =
1
SELECT "data_measurandmin"."id", "data_measurandmin"."measurand_id",
"data_measurandmin"."value", "data_measurandmin"."unit" FROM
"data_measurandmin" WHERE "data_measurandmin"."measurand_id" = 1
SELECT "data_measurandmax"."id", "data_measurandmax"."measurand_id",
"data_measurandmax"."value", "data_measurandmax"."unit" FROM
"data_measurandmax" WHERE "data_measurandmax"."measurand_id" = 1
SELECT "data_measurandsigma"."id",
"data_measurandsigma"."measurand_id", "data_measurandsigma"."value",
"data_measurandsigma"."unit" FROM "data_measurandsigma" WHERE
"data_measurandsigma"."measurand_id" = 1



Any ideas how i can improve the queries or the structure of my models?

cheers,

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



Psyco

2009-08-13 Thread Jonas Obrist

Hi djang-users

Is anyone using psyco in django? Does it work and is it useful (as in: 
do you get great speed improvements)?

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: admin problems with the docu

2009-08-13 Thread Alexandru-Emil Lupu
HI!
the doc is updated for the 1.1 version ..
try this

urlpatterns = patterns('',
   (r'^admin/',admin.site.root),
)

see more here: http://code.djangoproject.com/ticket/10050


Alecs

On Thu, Aug 13, 2009 at 3:52 PM, quant  wrote:

>
> hi
>
> i am pretty new to django and i started to check the docu out to see
> how it works and i had a problem to get the admin interface working...
>
> i followed all the steps from the doco and if i set the options in the
> urls.py on i got many errors ans nothing work anymore
>
> i set the following in the urls.py:
>
> from django.conf.urls.defaults import *
>
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>(r'^admin/', include(admin.site.urls)),
> )
>
>
>
> and i got the following error, if i tryed to start the
> http://127.0.0.1:8000/admin/
> page
>
> http://dpaste.com/79236/
>
> hope anyone can help me here
>
> >
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

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

2009-08-13 Thread Tim Chase

> I would like to develop a small internal tool in my company for
> telesales agents to fill in orders of different products then finance
> can approve them and send them to the shipping department. I was going
> to use php and dreamweaver but I have some python and django
> knowledge. My impression is that Django mainly works like a CMS. Is it
> possible to use it for the purpose I have? Are there better suited
> Python frameworks? or should I stick with PHP?

Russell has already addressed the "Django is mainly for CMS 
development" myth.

I've done this in Django -- just created a simple 
finite-state-machine of available states and the transitions 
available between those states.  Attributes on the states & 
transitions drive the workflows.  All state-changes get logged to 
a state-history table so the flow is tracked.  The models look 
something like:

   class State(Model):
 name = CharField()
 # ... other attributes germane to a State

   class Transition(Model):
 from_state = ForeignKey(State)
 to_state = ForeignKey(State)
 # ... other attributes germane to a transition

   class MyThing(Model):
 state = ForeignKey(State)
 state_last_changed = TimeStamp(...)
 def get_available_states(self):
   "Returns the states to which this thing can transition"
   # good for populating dropdown fields
   available_ids = Transition.objects.filter(
 from_state=self.state).values_list('id', flat=True)
   return State.objects.filter(id__inavailable_ids)
 def save(...):
   # implement state-changed tracking and history logging

   class StateHistory(Model):
 thing = ForeignKey(MyThing)
 state_changed = TimeStamp(...)
 from_state = ForeignKey(State)
 to_state = ForeignKey(State)
 who = ForeignKey(User)
 #  ... other attributes you want to log re. the change

Hope this gives you a good place to start.

-tkc






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



serializing

2009-08-13 Thread elminio

Hello,
I have problem with serialization of querysets.

I use methos:


json = serializers.serialize('json', [Grade.objects.get(pk=pk)])
return HttpResponse(json, content_type='application/json; charset=
%s' % settings.DEFAULT_CHARSET)

And I get this error:
'Grade' object has no attribute 'get_absolute_url'

Why do I ahve to implement get_absolute_url ??

When I use

simplejson.dumps([Grade.objects.get(pk=pk)])

I get error:   is not JSON serializable

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



Using Psycopg2 on Windows

2009-08-13 Thread James Walmsley

Hi,

I'm trying to get started with Django, and everything was going
wonderfully until I tried to use models (and I had to set up
postgreSQL).

I've installed psycopg2 from the provided compiled binaries, but when
I run:

manage.py runserver

I get the following errors:

Error loading psycopg2 module: DLL load failed: The applicatio has
failed to start because its side-by-side configuration is incorrect.
Please see the application event log for more detail.

The application event log in Vista says:

Activation context generation failed for "C:\Python26\lib\site-packages
\psycopg2\_psycopg.pyd". Dependent Assembly
Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.4053"
could not be found. Please use sxstrace.exe for detailed diagnosis.

Any help would be appreciated, I also tried to build psycopg2 from
source, build I still get a DLL load fail.

James



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



admin problems with the docu

2009-08-13 Thread quant

hi

i am pretty new to django and i started to check the docu out to see
how it works and i had a problem to get the admin interface working...

i followed all the steps from the doco and if i set the options in the
urls.py on i got many errors ans nothing work anymore

i set the following in the urls.py:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)



and i got the following error, if i tryed to start the 
http://127.0.0.1:8000/admin/
page

http://dpaste.com/79236/

hope anyone can help me here

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: is Django a good choice for a LAN app?

2009-08-13 Thread Jonas Obrist


 From what I read on django-developers, multi-db support is being 
actively worked on.

roberto wrote:
> snfctech,
> As far as I know, Django doesn't have an option to set more than one
> database. If I am mistaken, please, let me know.
> I am not sure if there is any project to add this capability in the
> future tough.
> Maybe you should investigate a bit more in the site
> (djangoproject.com).
> Regards.
>
> On Aug 12, 4:31 pm, snfctech  wrote:
>   
>> Thanks, Jonas.
>>
>> And do you think Django's ORM will be able to handle my multiple DB
>> connections, with read/write fields from different DB producs/ servers
>> on the same view (most of which will hopefully be ODBC compliant, but
>> some might not)?
>>
>> On Aug 12, 11:32 am, Jonas Obrist  wrote:
>>
>> 
>>> In my opinion writing it in django/html/... is a lot easier and faster
>>> than doing it in a real python GUI tool. Also you have the networking in
>>> your LAN taken care of by the browser.
>>>   
>>> snfctech wrote:
>>>   
 One more question:  Any advantage to just using a Python GUI toolkit
 instead?
 
 On Aug 12, 9:18 am, snfctech  wrote:
 
> Thanks for all of the good feedback!
>   
> At the very least I am enthusiastic about the health of this list! ;-)
>   
> @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> sales/week).
>   
> Sounds like the community feels Django is a good choice for my type of
> project.
>   
> Thanks!
>   
> On Aug 12, 5:18 am, Philippe Raoult  wrote:
>   
>> I don't know what you mean by mid-sized but I deployed exactly what
>> you're describing in a 45-strong company. We have occasional browser
>> incompatibilities with ajax but overall django was very much the right
>> tool for the job. As a bonus the company's clients can now access a
>> restricted part of the application to monitor their files and dealings
>> over https. Employees can also log in from home over https without any
>> software/hardware prerequisite. We're also planning on adding some
>> smartphone friendly pages for specific tasks (billing when employees
>> are working offsite).
>> 
>> My app is around 25k lines of python+templates
>> 
>> Hope this helps you make your mind.
>> 
>> On Aug 11, 9:06 pm, snfctech  wrote:
>> 
>>> I'm about to start a fairly large project for a mid-sized business
>>> with a lot of integration with other systems (POS, accounting,
>>> website, inventory, purchasing, etc.) The purpose of the system is to
>>> try to reduce current data siloing and give employees role-based
>>> access to the specific data entry and reports they need, as well as to
>>> replace some manual and redundant business processes. The system needs
>>> to be cross-platform (Windows/Linux), open source and is primarily for
>>> LAN use.
>>>   
>>> My experience is mostly PHP/web/app development, but I have developed
>>> a few LAN apps using Java/Servoy (like Filemaker). I am leaning
>>> towards Python/Django - but wondering whether this may be
>>> unnecessarily web-specific. I really felt Servoy development was very
>>> rapid, and it was cross-paltform, but it was not open source (not to
>>> mention that anything custom needed to be Java which I find too
>>> verbose/ slow to develop in). Or maybe Open Office Base and some
>>> scripting is sufficient to handle my needs.
>>>   
>>> So, my main question is: Does a web framework like Django sound like a
>>> reasonable platform to build a LAN Dashboard for a mid-sized company?
>>> Or am I thinking too much like a web developer?
>>>   
>>> Any tips or suggestions would be greatly appreciated.
>>>   
> >
>   


--~--~-~--~~~---~--~~
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: ModelForm limit m2m choices

2009-08-13 Thread alain31

Hi,
sorry for the first duplicate and incomplete posts (eepc keyboard ...)
My problem actually was to pass an dynamic argument to define queryset
'somevalue' (because ModelForm uses class atributes...).
I solved it writing a function:

def getModel(somevalue)
   class MyForm(ModelForm)
 myqueryset = ... using somevalue ...
 field1 = forms.ModelMultipleChoiceField(queryset=myqueryset)
 class Meta:
 model = ...
  return MyForm()

Thanks

>
> myform = MyForm(..)
> myqueryset = myform.base_fields['field1'].queryset
> myqueryset = myqueryset.filter_by(somefield='somevalue')
> myform.base_fields['field1'].queryset = myqueryset
>
> Regards,
> -Stephan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: is Django a good choice for a LAN app?

2009-08-13 Thread roberto

snfctech,
As far as I know, Django doesn't have an option to set more than one
database. If I am mistaken, please, let me know.
I am not sure if there is any project to add this capability in the
future tough.
Maybe you should investigate a bit more in the site
(djangoproject.com).
Regards.

On Aug 12, 4:31 pm, snfctech  wrote:
> Thanks, Jonas.
>
> And do you think Django's ORM will be able to handle my multiple DB
> connections, with read/write fields from different DB producs/ servers
> on the same view (most of which will hopefully be ODBC compliant, but
> some might not)?
>
> On Aug 12, 11:32 am, Jonas Obrist  wrote:
>
> > In my opinion writing it in django/html/... is a lot easier and faster
> > than doing it in a real python GUI tool. Also you have the networking in
> > your LAN taken care of by the browser.
>
> > snfctech wrote:
> > > One more question:  Any advantage to just using a Python GUI toolkit
> > > instead?
>
> > > On Aug 12, 9:18 am, snfctech  wrote:
>
> > >> Thanks for all of the good feedback!
>
> > >> At the very least I am enthusiastic about the health of this list! ;-)
>
> > >> @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> > >> sales/week).
>
> > >> Sounds like the community feels Django is a good choice for my type of
> > >> project.
>
> > >> Thanks!
>
> > >> On Aug 12, 5:18 am, Philippe Raoult  wrote:
>
> > >>> I don't know what you mean by mid-sized but I deployed exactly what
> > >>> you're describing in a 45-strong company. We have occasional browser
> > >>> incompatibilities with ajax but overall django was very much the right
> > >>> tool for the job. As a bonus the company's clients can now access a
> > >>> restricted part of the application to monitor their files and dealings
> > >>> over https. Employees can also log in from home over https without any
> > >>> software/hardware prerequisite. We're also planning on adding some
> > >>> smartphone friendly pages for specific tasks (billing when employees
> > >>> are working offsite).
>
> > >>> My app is around 25k lines of python+templates
>
> > >>> Hope this helps you make your mind.
>
> > >>> On Aug 11, 9:06 pm, snfctech  wrote:
>
> >  I'm about to start a fairly large project for a mid-sized business
> >  with a lot of integration with other systems (POS, accounting,
> >  website, inventory, purchasing, etc.) The purpose of the system is to
> >  try to reduce current data siloing and give employees role-based
> >  access to the specific data entry and reports they need, as well as to
> >  replace some manual and redundant business processes. The system needs
> >  to be cross-platform (Windows/Linux), open source and is primarily for
> >  LAN use.
>
> >  My experience is mostly PHP/web/app development, but I have developed
> >  a few LAN apps using Java/Servoy (like Filemaker). I am leaning
> >  towards Python/Django - but wondering whether this may be
> >  unnecessarily web-specific. I really felt Servoy development was very
> >  rapid, and it was cross-paltform, but it was not open source (not to
> >  mention that anything custom needed to be Java which I find too
> >  verbose/ slow to develop in). Or maybe Open Office Base and some
> >  scripting is sufficient to handle my needs.
>
> >  So, my main question is: Does a web framework like Django sound like a
> >  reasonable platform to build a LAN Dashboard for a mid-sized company?
> >  Or am I thinking too much like a web developer?
>
> >  Any tips or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
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 for workflow

2009-08-13 Thread Russell Keith-Magee

On Thu, Aug 13, 2009 at 4:21 PM, Caisys wrote:
>
> Hi Everyone,
> I would like to develop a small internal tool in my company for
> telesales agents to fill in orders of different products then finance
> can approve them and send them to the shipping department. I was going
> to use php and dreamweaver but I have some python and django
> knowledge. My impression is that Django mainly works like a CMS.

This isn't the best way to describe Django. Django isn't a CMS.
However, it is a magnificent toolkit with which you can build a CMS.
It's also a magnificent tool for building any number of other
web-based applications.

> Is it
> possible to use it for the purpose I have? Are there better suited
> Python frameworks? or should I stick with PHP?

You are the only person that knows your exact requirements. Could you
do this in Django? Certainly. There may be some Django applications
out there that you will be able to reuse to make the job easier. There
might even be a turn-key solution - you'll need to do some searching
to find out if any of the tools in the community meet your
requirements.

Of course, the same is true of PHP, and any other Python framework.
Some frameworks (e.g., Plone) are more CMS-like at the cost of general
flexibility. PHP is just a language for building web apps; language
and programming model differences aside, there's not going to be that
much difference between building your tool in PHP and building your
tool in Django.

If you need a solution _right now_, then I suspect your best options
are to try and find a turn-key solution that meets your requirements,
or to stick to what you know. However, if you have some time at your
disposal, and you're interested in learning a new tool, Django is
certainly capable of doing what you describe.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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: Strange problem with LDAP authentication backend

2009-08-13 Thread David De La Harpe Golden

stupidgeek wrote:
> David, you are a champ, thank you.
> I find it strange that this made the difference, since this line is in
> the docs:
> 
> "The get_user method takes a user_id -- which could be a username,
> database ID or whatever -- and returns a User object."
> 

We-ell, the "user_id" it passes to the backend comes from
session[auth.SESSION_KEY], so it's probably possible to arrange for that
value in the session to be something other than a normal User.id, with a
custom login() and auth middleware in addition to a custom auth
backend... I imagine it's not something most people need to do though.

Also, python being python it _could_ do something like look up a User
instance by id if passed an int and by username if passed a string. Not
saying that's a good idea though, best keep security things as simple as
possible to reason 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: ModelForm limit m2m choices

2009-08-13 Thread spacetaxi

Hello alain31,

On 12 Aug., 21:41, alain31  wrote:
> [...]
> How can I use a custom QuerySet for the choices of field1  ?

I think it should work like this:

myform = MyForm(..)
myqueryset = myform.base_fields['field1'].queryset
myqueryset = myqueryset.filter_by(somefield='somevalue')
myform.base_fields['field1'].queryset = myqueryset

Regards,
-Stephan


--~--~-~--~~~---~--~~
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: adapt admin interface

2009-08-13 Thread Sven Richter
Uhm, yes, i already asked my first question here on that list.
I just thought that mail never got posted, thats why i asked
once more.
So the first one is answered on:
http://groups.google.com/group/django-users/browse_thread/thread/110f0d4e3c146fdc

I suspect that the answer to question two is basically the same as to
question
one?


Greetings
Sven

On Thu, Aug 13, 2009 at 10:33 AM, Sven Richter wrote:

> Hi everybody,
>
> i have two questions regarding the admin interface.
>
> 1. Is it possible to make on column be dependent of the choice of another
> one?
> For example, i have to columns in my model: Party and Politician. If i
> choose a party
> now i want only the politicians belonging to that party to be shown in the
> politician
> drop down box.
>
> 2. I am using django-tagging for some days now which is really a great
> work.
> What isnt so great is comparing text with the tags that i already have to
> make sure
> i always use the same text.
> So, when i enter my text for a model in the admin interface i need a button
> which calls
> a function "compare". "compare" now should compare the text from an input
> field with
> the tags already entered and if  there are identical tags found, insert
> them into
> the "tags" column in the admin interface.
>
> I didnt really find much about customizing the admin interface that way
> that i want it.
>
>
> Greetings
> Sven
>

--~--~-~--~~~---~--~~
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: One-to-many relationship (the opposite of many-to-one)

2009-08-13 Thread spacetaxi

Hi Fredrik,

you could define a customized subclass of Site:

--
from django.contrib.sites.models import Site

class Company(models.Model):
name = models.CharField(max_length = 30)
url = models.CharField(max_length = 100)

class CompanySite(Site):
company = models.ForeignKey(Company)
--

Regards,
-Stephan

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



Dynamically adapting admin page for editting xml data?

2009-08-13 Thread spacetaxi

Hello fellow djangonauts,

I'd like to implement an admin page (field, widget, template...
whatever) to edit xml-formatted contents of TextFields. Every child
node of the xml data has to be editable in a *separate* TextField.

Simple example:
I want to store some information about books, but for every book there
is a different set of information available. So I am going to store
the xml-formatted information set into a single TextField.
(Unfortunately it is not possible to split up the information set into
a 1:n-relation - for internal reasons). The only information available
for all books is the book's name. So I define this Book class:

class Book(models.Model):
name = models.CharField('name of the book', max_length=200)
infoset_xml = models.TextField('additional info')

The contents of infoset_xml are expected to look like this:


John Smith
234


or


>1987-06-05
42
$1,50


The "ordinary user"'s admin page should contain one TextField for the
book's name and one additional TextField for every info-node within
infoset_xml.

The "administrator"'s admin page should contain one TextField for the
book's name and one TextField for editing the raw infoset_xml.

Unfortunately I've failed in implemeting the "ordinary user"'s admin
page (using MultiValueField and MultiWidget, and lxml for xml
parsing). The problem is, that it's not determined how many info-nodes
infoset_xml may contain. So the admin page has to dynamically adapt to
the number of info-nodes.

Is that possible? I'm desperately hoping that somebody can give me a
hint on how to implement it.

TIA and regards,
-Stephan


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



One-to-many relationship (the opposite of many-to-one)

2009-08-13 Thread Fredde

Hi!

I am using the Site app to serve multiple sites with shared content in
the same django project. Now I want to be able to assign a owner
company for each site to display different copyright info, etc. So
what I would like to do is to add a ForeignKey to the site model
without having to create my own copy of the site app. Is there a one-
to-many relationship (the opposite of the ForeignKey that is many-to-
one) that I can add to the Company model?

What I would like to do is something like:

---
company.models.py:
---
from django.contrib.sites.models import Site

class Company(models.Model):
name = models.CharField(max_length = 30)
url = models.CharField(max_length = 100)
sites = models.OneToMany(Site, related_name = 'company')

---
In the views
---
from django.contrib.sites.models import Site

current_site = Site.objects.get_current()
company = current_site.company

---

I guess this could be done with a many-to-many relationship in the
Company model as well, but that is kind of ugly. Is this possible or
is there some other way to solve this. It cant be such a uncommon
scenario.

/Fredrik

--~--~-~--~~~---~--~~
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: override _display_login_form

2009-08-13 Thread Davo

After some digging it seems that in new django (SVN) the function
is located somewhere else.

This worked for me.

-
from django.contrib.admin import sites

def _redirect_login(request, *args, **kwargs):
return HttpResponseRedirect('http://www.google.com')

sites.AdminSite.display_login_form = _redirect_login
-

Regards,
A. Davo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need for an internationalization/translation system not request-based

2009-08-13 Thread Malcolm Tredinnick

On Thu, 2009-08-13 at 10:11 +0200, Jarek Zgoda wrote:
> Wiadomość napisana w dniu 2009-08-13, o godz. 09:38, przez Enrico  
> Sartorello:
> 
> > Nice information, so we can go ahead working with activate() :-)
> >
> > Let me ask you one more question: in your code, i see you're using  
> > django.util.translation.get_language(), it's not a documented  
> > function and according to django policies it can be changed or  
> > removed in any new release.
> > Perhaps it's better using request.LANGUAGE_CODE?
> 
> 
> This function looks like part of public interface and the page 
> http://docs.djangoproject.com/en/dev/misc/api-stability/ 
>   lists the whole internationalization subsystem as stable API so I'd  
> not worry.

Well, it says that anything documented in the internationalization
subsystem is stable API. So the original poster still has a point.

But let's not worry about semantics too much here. I am quite willing to
say that get_language() is stable API (I'm kind of the de-factor i18n
sub-system maintainer, so I doubt I'll get any real arguments there). It
hasn't changed in years and it does what is advertised. It's also
needed, for exactly the reasons Jarek points out. Let's just document it
and help people out.

Generally, we haven't documented a lot of the internals of the i18n
stuff for low-level customisation. Ramiro Morales has been doing some
good work over the past few months helping sort out the documentation
there -- splitting up some confusing single file i18n stuff into i18n
and l10n and template versus backend. We're now in a position to start
filling in some of the gaps.

In short: feel free to use get_language() and unless some amazingly
hidden bug or security hole is found in it, the API will not change. I'm
happy to take a documentation patch that documents what it does (Jarek's
code example is a good place to start -- that's the sort of thing I
would include in the docs).

Regards,
Malcolm



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



adapt admin interface

2009-08-13 Thread Sven Richter
Hi everybody,

i have two questions regarding the admin interface.

1. Is it possible to make on column be dependent of the choice of another
one?
For example, i have to columns in my model: Party and Politician. If i
choose a party
now i want only the politicians belonging to that party to be shown in the
politician
drop down box.

2. I am using django-tagging for some days now which is really a great work.
What isnt so great is comparing text with the tags that i already have to
make sure
i always use the same text.
So, when i enter my text for a model in the admin interface i need a button
which calls
a function "compare". "compare" now should compare the text from an input
field with
the tags already entered and if  there are identical tags found, insert them
into
the "tags" column in the admin interface.

I didnt really find much about customizing the admin interface that way that
i want it.


Greetings
Sven

--~--~-~--~~~---~--~~
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-tinymce not appearing in admin

2009-08-13 Thread diogobaeder

Hehehehe... indeed, it's a curious problem...

Well, I'll try to stick to your posting suggestions, then. About the
TinyMCE, I'm getting some errors, but it must be some typo
somewhere... I'll post the results here when I make the changes.

Thanks!

Diogo



On Aug 12, 9:27 pm, Kenneth Gonsalves  wrote:
> On Wednesday 12 Aug 2009 9:35:30 pm diogobaeder wrote:
>
> > Oops, sorry... it's version 1.1 final.
>
> > I'll try to create the Media subclass with the media, then, although
> > it's not specified in the django-tinymce use documentation.
>
> > About dpaste, I'm confused, because in another post I pasted exception
> > content and someone advised me to use dpaste to make the thread more
> > readable. Are you really sure this is a recommendation for this list?
>
> it is not a recommendation - it is my personal opinion. I have been flamed in
> the past for both not posting enough of the error traceback and also for
> posting too much of the error traceback. I have also been bitten in the
> archives where the dpaste has expired. I suppose the best way would be to
> paste the relevant lines of the traceback inline and the full traceback
> somewhere else. But then one has to know which lines are relevant - and if one
> does know that, usually one can solve the problem himself.
> --
> regards
> kghttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 for workflow

2009-08-13 Thread Caisys

Hi Everyone,
I would like to develop a small internal tool in my company for
telesales agents to fill in orders of different products then finance
can approve them and send them to the shipping department. I was going
to use php and dreamweaver but I have some python and django
knowledge. My impression is that Django mainly works like a CMS. Is it
possible to use it for the purpose I have? Are there better suited
Python frameworks? or should I stick with PHP?
Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need for an internationalization/translation system not request-based

2009-08-13 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-13, o godz. 09:38, przez Enrico  
Sartorello:

> Nice information, so we can go ahead working with activate() :-)
>
> Let me ask you one more question: in your code, i see you're using  
> django.util.translation.get_language(), it's not a documented  
> function and according to django policies it can be changed or  
> removed in any new release.
> Perhaps it's better using request.LANGUAGE_CODE?


This function looks like part of public interface and the page 
http://docs.djangoproject.com/en/dev/misc/api-stability/ 
  lists the whole internationalization subsystem as stable API so I'd  
not worry.

get_language() gives you current language for the thread, which may be  
already different than request.LANGUAGE_CODE.

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need for an internationalization/translation system not request-based

2009-08-13 Thread Enrico Sartorello
Nice information, so we can go ahead working with activate() :-)

Let me ask you one more question: in your code, i see you're using
django.util.translation.get_language(), it's not a documented function and
according to django policies it can be changed or removed in any new
release.
Perhaps it's better using request.LANGUAGE_CODE?

2009/8/13 Jarek Zgoda 

>
> Wiadomość napisana w dniu 2009-08-12, o godz. 17:11, przez Andrea Zilio:
>
> > I'm sorry, can you explain a little bit this problem? Or where I can
> > get info about it?
> >
> > On Aug 12, 3:48 pm, Jarek Zgoda  wrote:
> >> Wiadomość napisana w dniu 2009-08-12, o godz. 13:00, przez Enrico
> >> Sartorello:
> >>
> >>> i'm facing a problem developing with Django a Web Application: in
> >>> response to some events (for example, after an admin action) i
> >>> need to
> >>> sendemailsto some users of my site.
> >>
> >>> The problem arises when i want theseemailsto be translated in any
> >>> user-specific language: the Request object i have just contains the
> >>> language infos of the user that trigger the event, so it's not
> >>> what i
> >>> need.
> >>> Generally, LocaleMiddleware behaviour can't do that job, because is
> >>> based on sessions and cookies of a particular user.
> >>> Roughly speaking i need (at least) a way to manually decide which is
> >>> the language to apply for translations.
> >>
> >> OnceIneededtosendemailsinHungarianfromEnglishapplication and
> >> this worked.
> >>
> >> Before translating any string you need to know which language to use.
> >> If you have this information handy somewhere you can just switch the
> >> translation catalog safely in separated process environments
> >> (FastCGI,
> >> WSGI). As translation.activate() is process-wide, this approach is
> >> not
> >> safe in multithreaded environment if using static translation (not
> >> request-based).
>
>
> The problem: translate some text to language other than specified in
> request or statically in settings (but of course already known).
> The solution:
>
> def to_german():
> cur_lang = translation.get_language()
> try:
> translation.activate('de')
> german_text = translation.ugettext(u'This is some text')
> finally:
> translation.activate(cur_lang)
> return german_text
>
> I stand corrected that translation activation **is** thread safe and
> does not affect code running in another threads (mod_python might be
> the cause of my problems).
>
> --
> Artificial intelligence stands no chance against natural stupidity
>
> Jarek Zgoda, R, Redefine
> jarek.zg...@redefine.pl
>
>
> >
>


-- 
Enrico Sartorello

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need for an internationalization/translation system not request-based

2009-08-13 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-12, o godz. 17:11, przez Andrea Zilio:

> I'm sorry, can you explain a little bit this problem? Or where I can
> get info about it?
>
> On Aug 12, 3:48 pm, Jarek Zgoda  wrote:
>> Wiadomość napisana w dniu 2009-08-12, o godz. 13:00, przez Enrico
>> Sartorello:
>>
>>> i'm facing a problem developing with Django a Web Application: in
>>> response to some events (for example, after an admin action) i  
>>> need to
>>> sendemailsto some users of my site.
>>
>>> The problem arises when i want theseemailsto be translated in any
>>> user-specific language: the Request object i have just contains the
>>> language infos of the user that trigger the event, so it's not  
>>> what i
>>> need.
>>> Generally, LocaleMiddleware behaviour can't do that job, because is
>>> based on sessions and cookies of a particular user.
>>> Roughly speaking i need (at least) a way to manually decide which is
>>> the language to apply for translations.
>>
>> OnceIneededtosendemailsinHungarianfromEnglishapplication and
>> this worked.
>>
>> Before translating any string you need to know which language to use.
>> If you have this information handy somewhere you can just switch the
>> translation catalog safely in separated process environments  
>> (FastCGI,
>> WSGI). As translation.activate() is process-wide, this approach is  
>> not
>> safe in multithreaded environment if using static translation (not
>> request-based).


The problem: translate some text to language other than specified in  
request or statically in settings (but of course already known).
The solution:

def to_german():
 cur_lang = translation.get_language()
 try:
 translation.activate('de')
 german_text = translation.ugettext(u'This is some text')
 finally:
 translation.activate(cur_lang)
 return german_text

I stand corrected that translation activation **is** thread safe and  
does not affect code running in another threads (mod_python might be  
the cause of my problems).

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need for an internationalization/translation system not request-based

2009-08-13 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-13, o godz. 04:31, przez Malcolm  
Tredinnick:

>> As translation.activate() is process-wide, this approach is not
>> safe in multithreaded environment if using static translation (not
>> request-based).
>
> This is not correct. The translation.activate() call is thread- 
> specific
> and definitely thread-safe. Otherwise Django's entire translation
> infrastructure wouldn't work.


Hmmm. Must be some kind of race condition in mod_python... Anyway, I  
was wrong, activate() is thread safe.

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


--~--~-~--~~~---~--~~
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: Inheritance at runtime (per model instance)

2009-08-13 Thread Thomas Guettler

Hi Malcolm,

Malcolm Tredinnick schrieb:
> On Wed, 2009-08-12 at 14:24 +0200, Thomas Guettler wrote:
>> Hi Malcolm and others,
>>
>> Malcolm Tredinnick schrieb:
> [...]
> 
>  
>>> You already have the content type table for referring to other model
>>> objects. Why not use that so that you can maintain some referential
>>> integrity?
>> Content Types use serial keys. Take something like a ticket system:
>> Serial keys are good for the tickets. But if you have something like a
>> TicketTypeModel it is not a good solution. The customer uses the live
>> system and can create new TicketTypes. But during the same time,
>> I might create new TicketTypes in my development system. The serial IDs 
>> clash.
> 
> Ah, ok. So you'll end up with something like your own version of the
> content type system. Makes sense. Providing your model names are going
> to be different from your customer's developed versions, your plan makes
> sense. 

It's a compliment for me, if you say "makes sense". Thank you.

I uploaded my implementation called ImportObject here:
http://www.djangosnippets.org/snippets/1681/

> This is the only reason I would be tempted not to just use the import
> path. You really want to namespace the identifiers and model names might
> clash if they're common enough.

The import path should be absolute. Example: myapp.models.MyModel or 
myapp.foo.MyPlainPythonClass.
Theses paths should be unique. The drawback is, that is harder to refactor 
code. You
need to modify the DB tables if you change the layout of the code.

If a customer needs a different class, you could add a hook somewhere to load 
it.

 Regards,
   Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~-~--~~~---~--~~
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: Deploying django on apache - cant access database

2009-08-13 Thread consiglieri

Graham,

I'll take a look at mod_wsgi.

But first i have to figure out proper urls and settings for css and
javascript.

Once again thanks a lot.

Thomas


On 12 Aug, 11:09, Graham Dumpleton  wrote:
> On Aug 12, 3:43 pm, consiglieri  wrote:
>
>
>
>
>
> > Thanks Graham!
>
> > The absolute path was the issue. Can't believe I couldnt find that
> > anywhere.
>
> > As for the Alias, well i was just testing to make sure that wasnt an
> > issue.And its in the httpd.conf , for perl-cgi you need that so since
> > i was having issues i decided to try and see if it was causing my
> > issues. (Which it wasnt). As the apaches conf says
>
> >     # ScriptAlias: This controls which directories contain server
> > scripts.
> >     # ScriptAliases are essentially the same as Aliases, except that
> >     # documents in the target directory are treated as applications
> > and
> >     # run by the server when requested rather than as documents sent
> > to the
> >     # client.  The same rules about trailing "/" apply to ScriptAlias
> >     # directives as to Alias.
>
> > So i was thinking maybe i need to set an alias so that apache executes
> > the python scripts.
>
> > The only thing i have noted now is that that when i go to the admin
> >urlthecssdoesnt seem to follow but probably its just a sethandler
> > issue.
>
> For mod_python it is a bit of a fiddle for getting static files to be
> served if logically under mount point of mod_python hosted
> application. As you say, you need to disable mod_python for the URLs
> using 'SetHandler None'. FWIW, mod_wsgi is a lot more saner in this
> respect as it respect resource stuff and so an Alias is enough to have
> static files mounted. For more details of using mod_wsgi instead of
> mod_python see:
>
>  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> The mod_wsgi module also will make it easier for you if developing
> code under Apache, as you can use daemon mode and just touch WSGI
> script file to trigger a reload, or setup a code monitor so it behaves
> just like Django development server. For more details on code
> reloading in mod_wsgi see:
>
>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
>
> Graham
>
>
>
> > Anyway Graham I really appreciate your input. At least now i know my
> > setup is working and I ca get on with actually developing the app
> > better as well as trying to master the django framework
>
> > Thomas
>
> > On 12 Aug, 00:02, Graham Dumpleton  wrote:
>
> > > For SQLite database, the directory the database is in must also be
> > > writable to user that Apache runs as. The location of the database in
> > > settings file must also be an absolute path, can't use a relative
> > > path.
>
> > > BTW, what is:
>
> > >   Alias test.django.com "/Users/someone/djangoproject/appname"
>
> > > for in configuration? It will have no effect and normall your wouldn't
> > > have anything like that in configuration for Django.
>
> > > Graham
>
> > > On Aug 12, 4:45 am, consiglieri  wrote:
>
> > > > Thanks for the tip, however it does not make a difference. I moved the
> > > > app to another catalogue and made sure that the database file was
> > > > chmod to 755 and also that all directories have the same permissions.
> > > > The error remains.
>
> > > > There is something happening that i dont understand. I'm beginning to
> > > > think there is someting wrong with the django or mod_python
> > > > installation but i am at a loss understanding what it can be.
>
> > > > Thomas
>
> > > > On 11 Aug, 19:04, Mike Ramirez  wrote:
>
> > > > > On Tuesday 11 August 2009 09:43:38 am consiglieri wrote:
>
> > > > > > Hi
>
> > > > > > I'm new with django and have made a small test app which works as it
> > > > > > should with the development server.
>
> > > > > > However when i try and deploy it with apache and mod_python I cant 
> > > > > > get
> > > > > > it to work. I have tested that mod_python works. I can do the
> > > > > > recommended mod_python test. When i try to run the django app via
> > > > > > apache it works well as long as the page being displayed does not
> > > > > > actually try and access the database. In other words if I enter aurl
> > > > > > that just pops up an empty page with no django tags in it the page 
> > > > > > is
> > > > > > displayed as it should.
>
> > > > > > These are my settings.
>
> > > > > > Apache 2.2.11
> > > > > > mod_python 3.3.2-dev
> > > > > > I am on a Mac (Leopard 10.5.8)
> > > > > > I have the latest stable version of django 1.1
>
> > > > > > When I start apache the following can be found in the logs
>
> > > > > > Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7l DAV/2 mod_python/
> > > > > > 3.3.2-dev-20080819 Python/2.5.1 configured -- resuming normal
> > > > > > operations
>
> > > > > > The necessary settings in httpd.conf with regards to django is as
> > > > > > follows
>
> > > > > > Alias 

Re: RuntimeError: Unable to create a new session key.

2009-08-13 Thread Vinu[theinvinciblemaster]
Sorry a typo, Please read that like this

Hi all,

 I have apache + mod_wsgi, use memcache as session backend and
cmemcache as api , but at times the server stops responding. when i
checked thru the log I saw RuntimeError: Unable to create a new
session key.

The app starts working when I restart, what could be reason

regards
Vinu




Vinu Varghese wrote:
> Hi all,
>
>  I have apache + mod_wsgi, use memcache as session backend and
> cmemcache as api , but at time the server starts responding. when i
> checked thru the log I saw RuntimeError: Unable to create a new
> session key.
>
> The app starts working when I restart, what could be reason
>
> regards
> Vinu
>
>
>   

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



RuntimeError: Unable to create a new session key.

2009-08-13 Thread Vinu Varghese

Hi all,

 I have apache + mod_wsgi, use memcache as session backend and
cmemcache as api , but at time the server starts responding. when i
checked thru the log I saw RuntimeError: Unable to create a new
session key.

The app starts working when I restart, what could be reason

regards
Vinu


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

2009-08-13 Thread Kenneth Gonsalves

On Thursday 13 Aug 2009 10:47:36 am Kenneth Gonsalves wrote:
> On Thursday 13 Aug 2009 10:16:19 am Malcolm Tredinnick wrote:
> > On Thu, 2009-08-13 at 07:22 +0530, Kenneth Gonsalves wrote:
> > > hi,
> > >
> > > was trying out django_openidconsumer and get this error:
> > >
> > > complete() takes exactly 3 arguments (2 given) - I cannot figure it out
> > > as this is the definition of complete:
> > >
> > > def complete(request, on_success=None, on_failure=None):
> >
> > That's certainly one complete() function. But it's not the one in the
> > traceback. :-)
>
> thanks - apparently openid.consumer.complete is being called wrongly - that
> has the correct number of arguments.

and now it like django_openid is not maintained any more - so I give up
-- 
regards
kg
http://lawgon.livejournal.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---