Re: test cannot find assertContains

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 23:23 -0800, Mike Ramirez wrote:
> On Friday, March 11, 2011 11:21:02 pm you wrote:
> > The problem here is that assertContains is not part of
> unittest/unittest2.
> > 
> > It's defined in TransactionTestCase in django.test, which extends
> > unittest2.TestCase and adds in assertContains, assertNotContains,
> > assetFormError, basically django specific assertions.
> > 
> > 
> > Mike
> 
> Sorry faster trigger finger tonight.  But I want to add, I think we're
> meant 
> to use the stuff in django.test for our tests. 

*now* I understand. I replaced 

from django.utils import unittest
with
from django.test import TestCase

and all is well. I think the dev docs need to be clearer on this point
and mention this at the outset. After all they *are* dev docs.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: test cannot find assertContains

2011-03-11 Thread Mike Ramirez
On Friday, March 11, 2011 11:21:02 pm you wrote:
> The problem here is that assertContains is not part of unittest/unittest2.
> 
> It's defined in TransactionTestCase in django.test, which extends
> unittest2.TestCase and adds in assertContains, assertNotContains,
> assetFormError, basically django specific assertions.
> 
> 
> Mike

Sorry faster trigger finger tonight.  But I want to add, I think we're meant 
to use the stuff in django.test for our tests. 

Mike
-- 
The worst sin towards our fellow creatures is not to hate them,
but to be indifferent to them; that's the essence of inhumanity.
-- G.B. Shaw

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



Re: test cannot find assertContains

2011-03-11 Thread Mike Ramirez
On Friday, March 11, 2011 11:11:21 pm Kenneth Gonsalves wrote:
> On Fri, 2011-03-11 at 23:04 -0800, Mike Ramirez wrote:
> > > from django.utils import unittest
> > 
> > from django.test import TestCase
> > 
> > the stuff in utils.unittest is unittest2 stuff if you're using python
> > <2.7
> > (unittest2 is part of 2.7 now as unittest).
> 
> I am using 2.6, but according to the django docs, django has a bundled
> version of unittest2 which is accessed from django.utils.unittest which
> is meant for python <2.7.


The problem here is that assertContains is not part of unittest/unittest2.

It's defined in TransactionTestCase in django.test, which extends 
unittest2.TestCase and adds in assertContains, assertNotContains, 
assetFormError, basically django specific assertions.


Mike


-- 
 The real value of KDE is that they inspired and push the
  development of GNOME :-)
-- #Debian

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



Re: test cannot find assertContains

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 23:04 -0800, Mike Ramirez wrote:
> > 
> > from django.utils import unittest
> 
> from django.test import TestCase
> 
> the stuff in utils.unittest is unittest2 stuff if you're using python
> <2.7 
> (unittest2 is part of 2.7 now as unittest). 

I am using 2.6, but according to the django docs, django has a bundled
version of unittest2 which is accessed from django.utils.unittest which
is meant for python <2.7.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: test cannot find assertContains

2011-03-11 Thread Mike Ramirez
On Friday, March 11, 2011 11:04:39 pm Mike Ramirez wrote:

> assertContains is a django specific test and located in test.TestCase with
> the others (you can find TransactionTestCase in there also).
> 

I should also add, TransactionTestCase is the base for TestCase and TestCase 
is really a patch to convince TransactionTestCase that a transaction occured, 
but the transaction does nothing.

TestCase's docstring:

"Does basically the same as TransactionTestCase, but surrounds every test with 
a transaction, monkey-patches the real transaction management routines to do 
nothing, and rollsback the test transaction at the end of the test. You have 
to use TransactionTestCase, if you need transaction management inside a test."

Mike


-- 
Work without a vision is slavery, Vision without work is a pipe dream,
But vision with work is the hope of the world.

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



Re: test cannot find assertContains

2011-03-11 Thread Mike Ramirez
On Friday, March 11, 2011 10:19:27 pm Kenneth Gonsalves wrote:
> hi,
> 
> I am trying to run a test using assertContains, but get this error:
> 
> AttributeError: 'SourceTestCase' object has no attribute
> 'assertContains'
> 
> my code:
> 
> from django.utils import unittest

from django.test import TestCase

the stuff in utils.unittest is unittest2 stuff if you're using python <2.7 
(unittest2 is part of 2.7 now as unittest).

assertContains is a django specific test and located in test.TestCase with the 
others (you can find TransactionTestCase in there also).


Mike



-- 
The British are coming!  The British are coming!

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



test cannot find assertContains

2011-03-11 Thread Kenneth Gonsalves
hi,

I am trying to run a test using assertContains, but get this error:

AttributeError: 'SourceTestCase' object has no attribute
'assertContains'

my code:

from django.utils import unittest
from incident.models import Source
from django.test.client import Client



class SourceTestCase(unittest.TestCase):
fixtures = ['source.json']
def setUp(self):
self.client = Client()


def testSource(self):
response = self.client.get('/incident/sources/')
self.assertEqual(response.status_code, 200)
self.assertContains(response,'phone')
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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. Please specify the steps.

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 05:34 -0800, balu wrote:
> 1. When I open "http://localhost/; page, it is an error message
> "Forbidden. You don't have permission to access / on this server". 

see if your home directory has an 'x' permission at the end:

drwx--x--x 103 lawgon   lawgon   4096 2011-03-11 18:11 lawgon

and that all the directories that you are accessing under it also have
the 'x' permission at the end.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



file upload size problem

2011-03-11 Thread vamsy krishna
Hi,

I'm doing a file upload from one of my forms and writing the content
to a temp file on the server. The problem is any file of size more
than 250 KB is throwing the below error:

Request Entity Too Large
The requested resource
/tera/tera_upload/
does not allow request data with POST requests, or the amount of data
provided in the request exceeds the capacity limit.

I read through the django file uploads documentation and it says the
default file upload size in memory is about 2.5 MB. Can anyone tell me
what I'm overlooking? Also how do I set a maximum file size limit and
handle it?

Thanks,
Vamsy

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



Re: What is it with Django and 2008?

2011-03-11 Thread Venkatraman S
On Fri, Mar 11, 2011 at 5:59 AM, Benjamin Roberts wrote:

> So I don't mean to be confrontational at all.  I am learning Django
> and really like it.


We all do :)


> I'm forming a startup and we've already decided
> to go with it to build our applications.


I think Python/Django is perfect for a startup as your get RAD and also the
code
is easy to read and maintain. Good choice.


> I look forward to getting
> involved in the community, too.  Something has me a bit weirded out
> though, it seems 75% of what I see on the web about django (whether it
> is blog posts, tutorials, stack questions, etc.) came out in 2008.
> Can anyone explain this?
>

I am not exactly sure. The Django planet seems to be pretty active. You
might want
to drop at #django sometime.

-- 
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: Sum in html template using template tag

2011-03-11 Thread Victor Harada
Hi

You should use {{ list | running_total }}

and the filter should look like this:

from django.template import Library
register = Library()
@register.filter
def running_total(role_total):
 return sum( [d.get('total') for d in role_total] )

2011/3/11 sushanth Reddy 

> Hi ,
>
> I am trying to sum in HTML,but template tag return 0 ,
>
>
> View.py
>
> def gen_Report(request):
>
> ### query returns below output
> list=[{'total': 1744, 'user': u'x'}, {'total': 13, 'user': u'y'},
> {'total': 126, 'user': u'z'}, {'total': 46, 'user': u'm'}, {'total': 4,
> 'user': u'n'}, {'total': 8, 'user': u'o'},  {'total': 3, 'user': u'p'}]
>
> return render_to_response('user.html', locals(),
> context_instance = RequestContext(request))
>
> Template :
>
> user.html
>
>   {% load temptags %}
>
>  
> 
> 
>
> S.No
> role
> Count
>
> 
> 
> {% for fetch in list %}
>
> 
> {{forloop.counter}}
> {{fetch.user}}
> {{fetch.total}}
>
>
>
> {% endfor %}
> {{ list.total|running_total}}
> 
>
> 
>
> Template tag:
>
>
> from django.template import Library
> register = Library()
> @register.filter
> def running_total(role_total):
>   return sum(d.get('list_sum') for d in list_total)
>
>
>
> output :
>
> S.Nouser  Count
> 1  x  1744
> 2  y13
> 3  z126
> 4  m46
> 5  n  4
> 6  o 8
> Sum-->   0  (it returns zero)
>
> I am doing anything wrong here ?
>
> can you please help me,how to return sum total using template tag 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.
>

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread greenie2600
werefr0g—

Yep, that's actually the solution I'm looking into right now. However,
I'm getting an error when trying to save a new instance of the
Restaurant model:

"'Restaurant' instance needs to have a primary key value before a many-
to-many relationship can be used."

Here's the new code that's triggering this error:


from django.db import models
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError

class Restaurant( models.Model ):

user = models.ForeignKey( User )
name = models.CharField( max_length = 128 )
slug = models.CharField( max_length = 24, unique = True )
cuisines = models.ManyToManyField( 'Cuisine', help_text = 'Choose
up to three' )

def __unicode__(self):
return self.name

def clean( self ):
raise ValidationError( type( self.cuisines ).__name__ )

class Cuisine( models.Model ):
name = models.CharField( max_length = 32 )
def __unicode__(self):
return self.name
class Meta:
ordering = ['name']


As you can see, my custom clean() method simply raises an error
containing the type of the cuisines property. And even this is enough
to trigger the error shown above. Doing len( self.cuisines ) gives the
same result. (Raising an error containing a literal string, without
attempting to inspect the cuisines property, works as expected.)

Any ideas? It really seems like it should be possible to perform this
check at the model level. (bagheera, I'll resort to form-level
validation if I have to—but only if I have to. Client-side checks are
for UI convenience only, which is a peripheral issue.)

I'm new to Django and Python, and at this point I'm more interested in
learning the Right Way to do this (if there is one), or *why* I can't
do it at the model level (if, in fact, I can't).




On Mar 11, 4:11 pm, gontran  wrote:
> I didn't try  it, but werefr0g may be right. It seems that
> Model.clean() is the method do you need. And you can still add a
> javascript control for more convenience without the risk that if a
> user deactivate javascript, the error will be saved.
>
> Let us know greenie if it's ok with this method.
>
> On 11 mar, 22:03, werefr0g  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > Can Model.clean() method help you? [1] You'll still have to pay
> > attention to validation before trying to save your instances.[2]
>
> > Regards,
>
> > [1]http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db
> > [2]http://docs.djangoproject.com/en/dev/releases/1.2/#model-validation

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



Authentication Using django.contrib.auth.middleware.AuthenticationMiddleware

2011-03-11 Thread hank23
I'm trying to use the the built-in authentication framework/middlework
but so far haven't figured out how to use it correctly. I'm just
starting a new project with this and I have placed the
"@login_required" decorator in front of my first view and want to
force the user to login at this time. I have coded the
"settings.LOGIN_URL" with a value of "/admin/" and this forces the
user to the admin screen, but doesn't redirect after that point it
does not redirect, though the new url that is displayed in the browser
window's address field shows the correct original url but appended
after the "/admin/" portion of the request like this:

/admin/?next=/mymedia/

It just stays on the successfull login/admin screen. What am I
missing? I would appreciate any help I can get on this. 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.



How to use CreateView?

2011-03-11 Thread hassan
Hi,

I am testing django 1.3 class based generic views. I have a model like
this one:

class Book(models.Model):
name = models.CharField(max_length=50)
author = models.CharField(max_length=50)

and in views.py:

class BookUpdateView(CreateView):
model = Book
template_name = "create_book.html"

and in create_book.html

...



But when i press the save button it form it does nothing!
What's wrong with 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: Apache mod_wgsi

2011-03-11 Thread Karen Tracey
On Fri, Mar 11, 2011 at 4:21 PM, groovyroovy  wrote:

> On Ubuntu 10.10, the libmod_wgsi uses Python 3.1. Will this be
> incompatible with Django? Must I compile the mod_wgsi for Python 2.6?
>
>
I don't believe so, per this thread:
http://groups.google.com/group/modwsgi/browse_thread/thread/796974f795989519

Sounds like it will work OK with default Python 2.6, it's just (oddly)
packaged to also require/pull down Python 3.1.

Karen
-- 
http://tracey.org/kmt/

-- 
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 I run test and get results programmatically? (django, south, fixtures, sqlite)

2011-03-11 Thread Jumpfroggy
I have an app that I'm starting to write tests for.  The app uses
south for all migrations and mysql for the db.

I wrote some tests and also created an initial_data.json fixture to
provide some default data.  If I run "python manage.py test", the
database is created via sqlite, the tests are run, and then the report
is spit out.  This works fine.

However, I want to automate this where I can programmatically run
tests, find the failures, and do some custom logging/saving of the
failures.  How do I run the tests in python?

I've tried a few variations of the below code, but the problem is the
database.  When I run the "python manage.py test" command, it
automatically uses sqlite3 as the backend, creates the database, and
uses it for all tests.  However, when I run my own tests, it uses the
mysql backend.  If I force it to use sqlite, is has problems with the
fixtures because the migrations are not run before installing the
fixtures.

How do I run tests manually using the same database setup that happens
when using the manage.py test command?

My code:

import my_application.settings

# NOTE: Use this to force the testing database to use the sqlite
engine.
my_application.settings.DATABASE_ENGINE = 'sqlite3'

from django.core.management import setup_environ
setup_environ(my_application.settings)

from django.conf import settings
from django.test.utils import get_runner

verbosity = 1
interactive = False
failfast = True
TestRunner = get_runner(settings)

test_labels = ()

test_runner = TestRunner(verbosity=verbosity,
interactive=interactive, failfast=failfast)
failures = test_runner.run_tests(test_labels)

And this is the error I get:

calling TestRunner.run_tests()
  verbosity: 1
  interactive: False
  failfast: True
  test_labels: ()
connection.settings_dict: {'ENGINE': 'django.db.backends.sqlite3',
'TEST_MIRROR': None, 'NAME': 'my_application', 'TEST_CHARSET': None,
'TIME_ZONE': 'America/New_York', 'TEST_COLLATION': None, 'OPTIONS':
{}, 'HOST': '', 'USER': 'my_application', 'TEST_NAME': None,
'PASSWORD': 'my_application', 'PORT': ''}
test_databases: {('', '', 'django.db.backends.sqlite3',
'my_application'): ['default']}
Creating test database 'default'...
Syncing...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table south_migrationhistory
Installing index for admin.LogEntry model
Installing index for auth.Permission model
Installing index for auth.Group_permissions model
Installing index for auth.User_user_permissions model
Installing index for auth.User_groups model
Installing index for auth.Message model
No fixtures found.

Synced:
 > django.contrib.admin
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > south

Not synced (use migrations):
 - my_application
(use ./manage.py migrate to migrate these)
test_db_name: ':memory:'
Problem installing fixture 'C:\virtualenv-my_application\lib
\site-packages\django\contrib\auth\fixtures\authtestdata.json':
Traceback (most recent call last):
  File "C:\virtualenv-my_application\lib\site-packages\django\core
\management\commands\loaddata.py", line 174, in handle
obj.save(using=using)
  File "C:\virtualenv-my_application\Lib\site-packages\django\core
\serializers\base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
  File "C:\virtualenv-my_application\Lib\site-packages\django\db
\models\base.py", line 566, in save_base
created=(not record_exists), raw=raw)
  File "C:\virtualenv-my_application\Lib\site-packages\django
\dispatch\dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
  File "C:\my_application\..\my_application\models.py", line 1175,
in _create_profile_for_user
profile.save()
  File "C:\virtualenv-my_application\Lib\site-packages\django\db
\models\base.py", line 456, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "C:\virtualenv-my_application\Lib\site-packages\django\db
\models\base.py", line 549, in save_base
result = manager._insert(values, return_id=update_pk,
using=using)
  File "C:\virtualenv-my_application\Lib\site-packages\django\db
\models\manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
  File "C:\virtualenv-my_application\Lib\site-packages\django\db
\models\query.py", line 1518, in insert_query
return 

Apache mod_wgsi

2011-03-11 Thread groovyroovy
On Ubuntu 10.10, the libmod_wgsi uses Python 3.1. Will this be
incompatible with Django? Must I compile the mod_wgsi for Python 2.6?

Thanks much in advance,
gr

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread gontran
I didn't try  it, but werefr0g may be right. It seems that
Model.clean() is the method do you need. And you can still add a
javascript control for more convenience without the risk that if a
user deactivate javascript, the error will be saved.

Let us know greenie if it's ok with this method.



On 11 mar, 22:03, werefr0g  wrote:
> Hello,
>
> Can Model.clean() method help you? [1] You'll still have to pay
> attention to validation before trying to save your instances.[2]
>
> Regards,
>
> [1]http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db
> [2]http://docs.djangoproject.com/en/dev/releases/1.2/#model-validation

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread werefr0g

Hello,

Can Model.clean() method help you? [1] You'll still have to pay 
attention to validation before trying to save your instances.[2]


Regards,

[1] 
http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean

[2] http://docs.djangoproject.com/en/dev/releases/1.2/#model-validation

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread bagheera

Dnia 11-03-2011 o 21:39:01 bagheera  napisał(a):

Dnia 11-03-2011 o 21:29:29 greenie2600   
napisał(a):



bagheera -

I had seen the limit_choices_to parameter, but I thought it controlled
*which* choices are available to the user - not *how many* they're
allowed to choose.

I want to show the user a list of 20 or 30 cuisines, but forbid them
from checking more than three.

Can you show me an example of how I'd use limit_choices_to to limit
the *number* of choices the user can select?



Form validation.

this should work

class RestaurantForm(forms.ModelForm):
 cuisines = forms.ModelMultipleChoiceField(Sklep)

 class Meta:
 model = Restaurant
 def clean_sklepy(self):
 cuisines_clean = self.cleaned_data[cuisines]
 if len(cuisines_clean) > 3:
 raise forms.ValidationError('You can't choose more than  
three items!')

 return cuisines_clean





Sorry, i left some of my code :P But u got the idea.

--
Linux user

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread bagheera

Dnia 11-03-2011 o 21:29:29 greenie2600  napisał(a):


bagheera -

I had seen the limit_choices_to parameter, but I thought it controlled
*which* choices are available to the user - not *how many* they're
allowed to choose.

I want to show the user a list of 20 or 30 cuisines, but forbid them
from checking more than three.

Can you show me an example of how I'd use limit_choices_to to limit
the *number* of choices the user can select?



On Mar 11, 2:35 pm, bagheera  wrote:
Dnia 11-03-2011 o 18:06:43 greenie2600   
napisał(a):


> Hi all -

> I have two models with a many-to-many relationship: Restaurant and
> Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican",
> "Chinese", etc. Each Restaurant record can be associated with one or
> more Cuisines.

> Here's the thing: I'd like to limit this to three Cuisines per
> Restaurant. So when editing the record for "Bob's Pan-Asian Buffet",
> the user would be able to check "Japanese", "Chinese", and "Korean",
> but wouldn't be able to check a fourth box.

> My question: can this be enforced within the model, or is this
> something I'd have to build into my interface layer?



or u can add a js script to this form field that will disallow selecting  
more than three items instead validating model (or do both).


--
Linux user

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread bagheera

Dnia 11-03-2011 o 21:29:29 greenie2600  napisał(a):


bagheera -

I had seen the limit_choices_to parameter, but I thought it controlled
*which* choices are available to the user - not *how many* they're
allowed to choose.

I want to show the user a list of 20 or 30 cuisines, but forbid them
from checking more than three.

Can you show me an example of how I'd use limit_choices_to to limit
the *number* of choices the user can select?



Form validation.

this should work

class RestaurantForm(forms.ModelForm):
cuisines = forms.ModelMultipleChoiceField(Sklep)

class Meta:
model = Restaurant
def clean_sklepy(self):
cuisines_clean = self.cleaned_data[cuisines]
if len(cuisines_clean) > 3:
raise forms.ValidationError('You can't choose more than  
three items!')

return cuisines_clean




--
Linux user

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread bagheera

Dnia 11-03-2011 o 21:23:38 greenie2600  napisał(a):


gontran -

Thanks.

However, I tried the sample code in your link, and I don't think it
will work. Returning a string from the overridden save() method
prevents the record from being saved to the database, but by the time
the save() method is invoked, my ModelForm (and consequently, I
presume, the underlying Model) has already been tested as valid. The
Restaurant isn't saved, but the form isn't redisplayed and no error
message is shown, and code execution proceeds as if the form were
valid (because it *is* valid; it just wasn't saved).

I think I need to override the model validation instead. Perhaps I
need to override Model.clean_fields()?



Right, i just get to that point, there is a cave rat about limiting  
choices on form level.

Depending on limiting query it may make problems if you edit this object.

afik U can't validate m2m fields on model level, but u can do it on form  
level and rise forms.ValidationError if needed in clean_field().


--
Linux user

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread greenie2600
bagheera -

I had seen the limit_choices_to parameter, but I thought it controlled
*which* choices are available to the user - not *how many* they're
allowed to choose.

I want to show the user a list of 20 or 30 cuisines, but forbid them
from checking more than three.

Can you show me an example of how I'd use limit_choices_to to limit
the *number* of choices the user can select?



On Mar 11, 2:35 pm, bagheera  wrote:
> Dnia 11-03-2011 o 18:06:43 greenie2600  napisał(a):
>
> > Hi all -
>
> > I have two models with a many-to-many relationship: Restaurant and
> > Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican",
> > "Chinese", etc. Each Restaurant record can be associated with one or
> > more Cuisines.
>
> > Here's the thing: I'd like to limit this to three Cuisines per
> > Restaurant. So when editing the record for "Bob's Pan-Asian Buffet",
> > the user would be able to check "Japanese", "Chinese", and "Korean",
> > but wouldn't be able to check a fourth box.
>
> > My question: can this be enforced within the model, or is this
> > something I'd have to build into my interface layer?
>
> You can limit choices on model level:
>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.mod...
>
> If query is too complicated (cuz u want to access object's data, witch  
> isn't yet available), you still can limit choices on form level, by  
> overriding __init__
>
> class RestaurantForm(forms.ModelForm):
>      cuisines = forms.ModelMultipleChoiceField(Sklep)
>
>      class Meta:
>          model = Restaurant
>
>      def __init__(self, *args, **kwargs):
>          super(RestaurantForm, self).__init__(*args, **kwargs)
>          self.fields[cuisines].queryset =  
> Cuisine.objects.filter(pk__in=[fancy query])
>
> --
> Linux user

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread greenie2600
gontran -

Thanks.

However, I tried the sample code in your link, and I don't think it
will work. Returning a string from the overridden save() method
prevents the record from being saved to the database, but by the time
the save() method is invoked, my ModelForm (and consequently, I
presume, the underlying Model) has already been tested as valid. The
Restaurant isn't saved, but the form isn't redisplayed and no error
message is shown, and code execution proceeds as if the form were
valid (because it *is* valid; it just wasn't saved).

I think I need to override the model validation instead. Perhaps I
need to override Model.clean_fields()?

-- 
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 frontend to openmesh radius

2011-03-11 Thread yolabingo
I think proxies are the solution.
I am struggling to wrap my head 'round this concept, but I believe
this will be helpful: 
http://lincolnloop.com/blog/2010/dec/16/using-proxy-models-customize-django-admin/

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread bagheera

Dnia 11-03-2011 o 18:06:43 greenie2600  napisał(a):


Hi all -

I have two models with a many-to-many relationship: Restaurant and
Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican",
"Chinese", etc. Each Restaurant record can be associated with one or
more Cuisines.

Here's the thing: I'd like to limit this to three Cuisines per
Restaurant. So when editing the record for "Bob's Pan-Asian Buffet",
the user would be able to check "Japanese", "Chinese", and "Korean",
but wouldn't be able to check a fourth box.

My question: can this be enforced within the model, or is this
something I'd have to build into my interface layer?




You can limit choices on model level:

http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to

If query is too complicated (cuz u want to access object's data, witch  
isn't yet available), you still can limit choices on form level, by  
overriding __init__



class RestaurantForm(forms.ModelForm):
cuisines = forms.ModelMultipleChoiceField(Sklep)

class Meta:
model = Restaurant

def __init__(self, *args, **kwargs):
super(RestaurantForm, self).__init__(*args, **kwargs)
self.fields[cuisines].queryset =  
Cuisine.objects.filter(pk__in=[fancy query])





--
Linux user

--
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: Help with Apache/Nginx combo

2011-03-11 Thread maciekjbl
Reload, restart and still nothing.

I have my admin-media syn-linked to my media folder, is it wrong ?
Because I see alias to this folder.

>From apache error log I know only that every request get [error
500].

On 11 Mar, 13:42, krzysiekpl  wrote:
> In my opinion you should add alias in nginx.conf for admin media
> files. Put this code in server{}
>
> # admin uses admin-media/
>         # alias works different than root above by dropping admin-
> media
>         location ^~ /media/admin/ {
>             alias /usr/local/lib/python2.6/dist-packages/django/
> contrib/admin/media/;
>         }
>
> or this code for your static files
>
> location  /static/ {
>                 root      /path/to/project/where/static_folder_is;
>                 expires max;
>                 autoindex off;
>         }
>
> On 11 Mar, 11:41, maciekjbl  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I know this topic was discussed a lot, but in every post for this
> > topic there are diffrent configuration and this stop helping for me.
>
> > Long story short : I changed DEBUG = True to False and all static
> > media are gone, so this is something wrong in web server conf.
>
> > #settings.py#
>
> > import os.path
> > PROJECT_DIR = os.path.dirname(__file__)
>
> > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
>
> > MEDIA_URL = 'http://aplikacje/media/'
>
> > ADMIN_MEDIA_PREFIX = '/media/admin/'
>
> > nginx configuration 
> > nginx.conf:
>
> > user www-data;
> > worker_processes  1;
>
> > error_log  /var/log/nginx/error.log;
> > pid        /var/run/nginx.pid;
>
> > events {
> >     worker_connections  1024;
> >     # multi_accept on;
>
> > }
>
> > http {
> >     include       /etc/nginx/mime.types;
>
> >     access_log  /var/log/nginx/access.log;
>
> >     sendfile        on;
> >     #tcp_nopush     on;
>
> >     #keepalive_timeout  0;
> >     keepalive_timeout  65;
> >     tcp_nodelay        on;
>
> >     gzip  on;
> >     gzip_disable "MSIE [1-6]\.(?!.*SV1)";
>
> >     upstream webcluster {
> >         server aplikacje:8000;
> >     }
>
> >     include /etc/nginx/conf.d/*.conf;
> >     include /etc/nginx/sites-enabled/*;
>
> > }
>
> > #sites conf :
>
> > server {
> >         listen 80;
> >         server_name media.aplikacje;
> >         access_log /var/log/nginx/aplikacje.media.access.log;
> >         location / {
> >                 autoindex on;
> >                 index index.html;
> >                 root /var/www/web_aplikacje/web_aplikacje/media;
> >         }
>
> > }
>
> > server {
> >         listen 80;
> >         server_name aplikacje;
> >         access_log /var/log/nginx/aplikacje.django.access.log;
> >         if ($host !~* "^aplikacje") {
> >                 rewrite ^(.*)$http://aplikacje/$1permanent;
> >                 break;
> >         }
> >         location / {
> >                 proxy_passhttp://webcluster;
> >                 include /etc/nginx/proxy.conf;
> >         }
>
> > }
>
> > ###Apache conf ##
> > 
>
> >         #Basic Setup
> >         ServerAdmin maciej.jablon...@hydrosolar.pl
> >         ServerName aplikacje
> >         ServerAlias media.aplikacje
> >         ServerAlias aplikacje
>
> >         DocumentRoot /var/www/web_aplikacje/web_aplikacje/media
>
> >         WSGIScriptAlias / /var/www/web_aplikacje/web_aplikacje/apache/
> > django.wsgi
>
> >         
> >                 Order deny,allow
> >                 Allow from all
> >         
> > 
>
> > Server is for the intranet use only. I have dns pointing tohttp://aplikacje/
> > and django works fine, only media ( css, img, admin media) gone.
>
> > I will be every thankful if someone can point what is wrong with this
> > conf a why it is wrong.

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

2011-03-11 Thread ydjango
I see this project is an old project http://code.google.com/p/django-voting/

Not sure if it is actively maintained anymore. is this the one I
should look into using or is there a newer one that super seeded this
app.

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread gontran
edit: you don't need to raise an error if the restaurant already has 3
Cuisine's objects associated, you just need to return a string with
the explanation of the error.

On 11 mar, 20:11, gontran  wrote:
> Hi greenie,
>
> you just need to override the save method from your model Restaurant.
> Before saving each instance, you check if the restaurant already  has
> 3 Cuisine's objects associated. If yes, you don't save the instance
> and raise an error for exemple, if no, just call the standard method
> of the super class Model.
> You will find more infos in the django 
> documentation:http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-pre...
>
> On 11 mar, 18:06, greenie2600  wrote:
>
>
>
>
>
>
>
> > Hi all -
>
> > I have two models with a many-to-many relationship: Restaurant and
> > Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican",
> > "Chinese", etc. Each Restaurant record can be associated with one or
> > more Cuisines.
>
> > Here's the thing: I'd like to limit this to three Cuisines per
> > Restaurant. So when editing the record for "Bob's Pan-Asian Buffet",
> > the user would be able to check "Japanese", "Chinese", and "Korean",
> > but wouldn't be able to check a fourth box.
>
> > My question: can this be enforced within the model, or is this
> > something I'd have to build into my interface layer?
>
> > Here's my models.py.
>
> > from django.db import models
> > from django.contrib.auth.models import User
>
> > class Restaurant( models.Model ):
>
> >     user = models.ForeignKey( User )
> >     name = models.CharField( max_length = 128 )
> >     slug = models.CharField( max_length = 24, unique = True )
> >     cuisines = models.ManyToManyField( 'Cuisine' )
>
> >     def __unicode__(self):
> >         return self.name
>
> > class Cuisine( models.Model ):
>
> >     name = models.CharField( max_length = 32 )
>
> >     def __unicode__(self):
> >         return self.name
>
> >     class Meta:
> >         ordering = ['name']

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



Re: How to limit a ManyToManyField to three choices?

2011-03-11 Thread gontran
Hi greenie,

you just need to override the save method from your model Restaurant.
Before saving each instance, you check if the restaurant already  has
3 Cuisine's objects associated. If yes, you don't save the instance
and raise an error for exemple, if no, just call the standard method
of the super class Model.
You will find more infos in the django documentation:
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods

On 11 mar, 18:06, greenie2600  wrote:
> Hi all -
>
> I have two models with a many-to-many relationship: Restaurant and
> Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican",
> "Chinese", etc. Each Restaurant record can be associated with one or
> more Cuisines.
>
> Here's the thing: I'd like to limit this to three Cuisines per
> Restaurant. So when editing the record for "Bob's Pan-Asian Buffet",
> the user would be able to check "Japanese", "Chinese", and "Korean",
> but wouldn't be able to check a fourth box.
>
> My question: can this be enforced within the model, or is this
> something I'd have to build into my interface layer?
>
> Here's my models.py.
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class Restaurant( models.Model ):
>
>     user = models.ForeignKey( User )
>     name = models.CharField( max_length = 128 )
>     slug = models.CharField( max_length = 24, unique = True )
>     cuisines = models.ManyToManyField( 'Cuisine' )
>
>     def __unicode__(self):
>         return self.name
>
> class Cuisine( models.Model ):
>
>     name = models.CharField( max_length = 32 )
>
>     def __unicode__(self):
>         return self.name
>
>     class Meta:
>         ordering = ['name']

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



How to have user defined fields

2011-03-11 Thread ydjango
How can I have  "user defined fields" ( not field types).

So user will define some custom fields (with standard types) and it
will be shown and available to all members of his group on screens and
forms.


-- 
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 models and inheritance

2011-03-11 Thread Michal Petrucha
> If I have my abstract super classes inherit models.Model,  things
> technically can work. However, I arrive with a rather overly complex
> SQL design generated from them (like needless tables for abstract
> super classes).
> 
> On the other hand, if I have my abstract super classes NOT inherit
> models.Model and then use multiple inheritance on my subclasses (ie.
> have the subclasses inherit both models.Model and their Super class),
> then I end up with non-functional SQL tables (ie. the SQL table for a
> model would not contain critical fields that in the model had been
> inherited from their super class).
> 
> Am I missing something? Is there a way to have my models include
> properties inherited from an abstract super class into the SQL it
> generates? And ideally without creating tables for each abstract super
> class? Or is this just too much in the way of complex OO for
> models.py, and maybe I'm just over-doing it and  an experienced Django
> developer will point out the futility of what I'm trying.

When you define an abstract model, you have to define the ``abstract''
property inside its Meta.
http://docs.djangoproject.com/en/1.2/ref/models/options/#abstract
http://docs.djangoproject.com/en/1.2/topics/db/models/#abstract-base-classes

That way your abstract class can inherit models.Model and will have no
database table created.

Michal Petrucha


signature.asc
Description: Digital signature


Re: request.user.save() doesnt work

2011-03-11 Thread Jason Culverhouse

On Mar 11, 2011, at 10:46 AM, Daniel Roseman wrote:

> On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote:
> Hi guys. Am using django non-rel on appengine. I am using django's 
> auth backend for my authentication, since I did not want to have to 
> force my users to use gmail logins, and appengine models 
> {google.appengine.ext.db} for the other models. I have a form where I 
> allow users to edit their email. So : 
> 
> if settings_form.is_valid() : 
> user = request.user 
> user.email = request.POST['email'] 
> user.save() 
> 
> print request.POST['email']  returns the correct data entered in the 
> form. But user.save() just doesnt save! 
> Am I doing it correctly ? Is there something else I shopuld be doing ? 
> -- 
> Regards, 
> Guy-at-the-end-of-the-tether :-)
> 
> Are you sure that the condition is true - that the form is valid? Put some 
> logging in to be sure.

Are you sure that user is a django.contrib.auth.models.User and not at  
django.contrib.auth.models.AnonymousUser. 

http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user

if request.user.is_authenticated():
# Do something for logged-in users.
else:
# Do something for anonymous users.



> --
> DR. 
> 
> -- 
> 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.

-- 
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: request.user.save() doesnt work

2011-03-11 Thread Daniel Roseman
On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote:
>
> Hi guys. Am using django non-rel on appengine. I am using django's 
> auth backend for my authentication, since I did not want to have to 
> force my users to use gmail logins, and appengine models 
> {google.appengine.ext.db} for the other models. I have a form where I 
> allow users to edit their email. So : 
>
> if settings_form.is_valid() : 
> user = request.user 
> user.email = request.POST['email'] 
> user.save() 
>
> print request.POST['email']  returns the correct data entered in the 
> form. But user.save() just doesnt save! 
> Am I doing it correctly ? Is there something else I shopuld be doing ? 
> -- 
> Regards, 
> Guy-at-the-end-of-the-tether :-)


Are you sure that the condition is true - that the form is valid? Put some 
logging in to be sure.
--
DR. 

-- 
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 frontend to openmesh radius

2011-03-11 Thread yolabingo
I put a simple Django site (using only admin so far) in front of a
MySQL DB used as a backend by a freeradius server.

For each radius user, I need to update the 'radcheck' table, which
contains one or more attributes for each user.

+---+--
| Field| Type
+---+--
| id | int(11) unsigned
| username  | varchar(64)
| attribute  | varchar(32)
| op| char(2)
| value   | varchar(253)
+---+-

So, a user might have values like:
+--+-+---+
| username | attribute  | value
+--+-+---+
| joe | User-Password | mysappword
| joe | Session-Timeout  | 24000

and so on.

I'm thinking I can use inheritance in some manner, but not sure how to
have changes to `username` to cascade to all of these entries.  I am
not particular about how this happens (I believe it can be done using
'save_to()' for each model), but am curious if there is a more elegant
way to do this via model definitions.

Thanks in advance,
Todd

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



cache and anonymous only

2011-03-11 Thread plungerman
greetings,

we are using django trunk, updated from time to time.  we were using
revision 13303, and then wanted to update to the current revision
(15776 at the time). upon updating to 15776, the caching behaviour of
our apps changed. we are using CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
and authenticated users will need different content served up at the
template level for any given view. for example, they will see icons
for editing content, a "dashboard" bar for administrative purposes,
etc. anonymous visitors will see the same content, without all of the
administrative features.

at 13303, this was not a problem.  at 15776, it appears as though the
CACHE_MIDDLEWARE_ANONYMOUS_ONLY flag is not working properly.  an
anonymous user will go to a view, that page will be cached, and then
an authenticated user will visit the same page and see the "anonymous"
version. and vice versa, which is a problem since anonymous users will
then see a page with administrative content.  by using django
authority, we prevent any anonymous users from doing anything
administrative, but it's still a problem from a UI perspective.

NOTE: we are not using the cache middleware. we are using cache_page
decorator for our views.  should we be using the middleware in
conjunction with cache_page?

basically, with CACHE_MIDDLEWARE_ANONYMOUS_ONLY set to True,
authenticated users should be served up content dynamically, built at
request time. anonymous users should see cached content, if available,
and if not, the page is built dynamically at request time, and then
cached for subsequent anonymous requests.

i am aware of ticket #15260

http://code.djangoproject.com/ticket/15260

and it seems to have been closed, but we are still experiencing issues
with caching.

any thoughts?

thanks in advance.

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



caching static/domain tables

2011-03-11 Thread Cesar Devera
I have in my models, some tables that hold static information, like
status codes, types and descriptions, for example:

in models.py:

class CustomerStatus(models.Model):
name = models.CharField()

class CustomerType(models.Model):
name = models.CharField()

class Customer(models.Model):
name = models.CharField()
type = models.ForeignKey(CustomerType)
status = models.ForeignKey(CustomerStatus)

so, we may have statuses like 'active', 'inactive', 'blocked',
'waiting', 'whatever',
and types like 'small', 'medium', 'other'
this statuses and types will *never* ever change.

and I use them in the templates to show select inputs, so my pre-form
view is like:

def newCustomer(request):
customer = Customer()
statuses = CustomerStatus.objects.all()
types = CustomerTypes.objects.all()
c = locals()
c.update(csrf(request))
return render_to_response('customer/customerform.html', c)

oka, okay, I could use a ModelForm on Customer, but for sake of the
example, let's consider the code above. (albeit I think the final
effect would be the same)

so, in every request, Django hits the database twice, to get the types
and statuses. but I know that they will never change. so, I'm
wondering about caching the results of those hits.

but I if query them explicitly, Django will still hit the database in
every other access to that tables.

so I thought  I could use a custom manager ou something to override
the get_query_set method and check the cache before going to the
database.

this way, even if Django queries those tables by key, or by any other
way, the results would be cached on every second try.

but I don't want to install any awesome caching solution for my app,
and cache everything and have to worry about expiring caches and all
those side-effects. I just want a simple spartan solution, to cache
forever those kind of tables. I would probably mark them somehow, or
by creating a new attribute like cache=True, or by injecting a new
manager, or extending some class and adding mixings... I'm no sure.

here is the point: what is the best point to do this? use a new
manager and intercept the get_query_set method, and return a custom
cachedQuerySet? and if this is the better way, is there any snippet
explaining how to extend the QuerySet class (which methods are
mandatory to override, etc)? it seems a little complex to mess with
without proper skills...

any other suggestion?

thanks in advance,

Cesar

-- 
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 on aggragate function-Count

2011-03-11 Thread Jason Culverhouse

On Mar 11, 2011, at 5:02 AM, pols wrote:

> hai
> I have two models as shown belove
> 
> from django.db import models
> from django.db.models import Sum
> # Create your models here.
> class polls(models.Model):
>  question = models.CharField(max_length=200)
>  pubish_date = models.DateTimeField('Date published')
> 
>  def __unicode__(self):
>return self.question
>  def getCount(self):
> count =
> choice.objects.filter(polls=self.id).annotate(test=Sum('vote'))
> return count.test
>  getCount.allow_tags = 'true'
>  getCount.short_description = 'Total Answers'
> 

> 
> class choice(models.Model):
>  polls = models.ForeignKey(polls)
>  choice = models.CharField(max_length=200)
>  vote = models.IntegerField()
> 
> 
> 
> Here i need to get sum of votes for each question.So I need to edit
> the code in the function getCount(). I try with the above code but
> getting 'none'.then what may be the problem??.This is for the listing
> in django admin polls listing
> 

# if you have a poll (this could also be the 'self' in your method)
poll = polls.objects.get(1)

choice.objects.filter(polls = poll).aggregate(Sum('vote'))

SELECT SUM("polls_choice"."vote") AS "vote__sum"
FROM "polls_choice"
WHERE "polls_choice"."polls_id" = 1

or

poll.choice_set.aggregate(Sum('vote'))
SELECT SUM("polls_choice"."vote") AS "vote__sum"
FROM "polls_choice"
WHERE "polls_choice"."polls_id" = 1

you would use annotate to add columns to a queryset

polls.objects.annotate((Sum('choice__vote'))

SELECT "polls_polls"."id", "polls_polls"."question", 
"polls_polls"."pubish_date", SUM("polls_choice"."vote") AS "choice__vote__sum"
FROM "polls_polls"
LEFT OUTER JOIN "polls_choice" ON ("polls_polls"."id" = 
"polls_choice"."polls_id")
GROUP BY "polls_polls"."id",
   "polls_polls"."question",
   "polls_polls"."pubish_date",
  "polls_polls"."id",
  "polls_polls"."question",
  "polls_polls"."pubish_date"

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

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



How to limit a ManyToManyField to three choices?

2011-03-11 Thread greenie2600
Hi all -

I have two models with a many-to-many relationship: Restaurant and
Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican",
"Chinese", etc. Each Restaurant record can be associated with one or
more Cuisines.

Here's the thing: I'd like to limit this to three Cuisines per
Restaurant. So when editing the record for "Bob's Pan-Asian Buffet",
the user would be able to check "Japanese", "Chinese", and "Korean",
but wouldn't be able to check a fourth box.

My question: can this be enforced within the model, or is this
something I'd have to build into my interface layer?

Here's my models.py.

from django.db import models
from django.contrib.auth.models import User

class Restaurant( models.Model ):

user = models.ForeignKey( User )
name = models.CharField( max_length = 128 )
slug = models.CharField( max_length = 24, unique = True )
cuisines = models.ManyToManyField( 'Cuisine' )

def __unicode__(self):
return self.name

class Cuisine( models.Model ):

name = models.CharField( max_length = 32 )

def __unicode__(self):
return self.name

class Meta:
ordering = ['name']

-- 
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 remove unicode from query result ?

2011-03-11 Thread sushanth Reddy
Hi JAson,

Thanks a ton,it worked

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



Sum in html template using template tag

2011-03-11 Thread sushanth Reddy
Hi ,

I am trying to sum in HTML,but template tag return 0 ,


View.py

def gen_Report(request):

### query returns below output 
list=[{'total': 1744, 'user': u'x'}, {'total': 13, 'user': u'y'}, 
{'total': 126, 'user': u'z'}, {'total': 46, 'user': u'm'}, {'total': 4, 
'user': u'n'}, {'total': 8, 'user': u'o'},  {'total': 3, 'user': u'p'}]

return render_to_response('user.html', locals(),
context_instance = RequestContext(request))

Template :

user.html

  {% load temptags %}

 



S.No
role
Count
  


{% for fetch in list %}


{{forloop.counter}}
{{fetch.user}}
{{fetch.total}}



{% endfor %}
{{ list.total|running_total}}




Template tag:


from django.template import Library
register = Library()
@register.filter
def running_total(role_total):
  return sum(d.get('list_sum') for d in list_total)



output :

S.Nouser  Count
1  x  1744
2  y13
3  z126
4  m46
5  n  4
6  o 8
Sum-->   0  (it returns zero)

I am doing anything wrong here ?

can you please help me,how to return sum total using template tag 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.



Chaining stacked inline

2011-03-11 Thread gontran
Hi,

I'm wondering if it's possible to chain StackedInlined object in a
django admin page.
Let me explain it:
I have a class UserProfile which is linked by a OneToOneField to the
django auth module class User. By this way (which is recommended) I
store additionnal informations about my users. In those informations,
I have a ForeignKey to the school of the user.
With a StackedInline class, I can edit user's profile in a user admin
page but I also want to be able to edit the school of a inside this
page, not with a pop-up.

Is it possible to achieve this?

Just to sum-up:

My model:
Class UserProfile(models.Model):
user  = models.OneToOneField(User)
 extra fields
school = models.ForeignKey(School)

My admin.py:
admin.site.unregister(User)

class UserProfileInline(admin.StackedInline):

model = UserProfile

class UserProfileAdmin(UserAdmin):

inlines = [UserProfileInline]

admin.site.register(User, UserProfileAdmin)




Thank you for your help

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



Re: Packaging and development workflow for decoupled apps.

2011-03-11 Thread Tom Evans
On Fri, Mar 11, 2011 at 3:52 PM, DaleB  wrote:
> I guess i wasn't clear enough. I am not so much concerned with when to
> use tags and when to use branches.
> I am still looking for a smooth development workflow.
> I created a libs-dir which i put on my python path an put my different
> apps in it.
> Okay, now i can refer to my apps from any project without copying the
> files. Great and a lot better than before.
>
> So now i start to create different branches for an app, i create a
> development branch an change stuff.
> As the app is on my path my projects initially refer to the state/
> branch of an app that ist currently checked out, right?
> That's what i refered to by "switching branches" (= changing the
> branch of my app in my libs-dir)
>
> Another (better?) idea i had looking at pip's docs was to take my libs-
> dir off the python path, put them in a git-repo and use pip to install
> my app.
> Pip's option to refer to certain tags and branches (http://
> pip.openplans.org/requirement-format.html#version-control) seems
> pretty ideal in this situation.
> The only drawback i see is that i have to install and uninstall quite
> often if i want to test different branches/states of my app in a
> project.
>
> And now i am not sure which route is more promising or if there's even
> an easier way i don't regard at the moment.
> Hope that's more clear.
>
> Thanks fpr you patience,
> Andreas
>

Exactly, I use a pip requirements file, and if its an app that I'm
working on, it gets installed from svn. Eg:

-e svn+https://svn.nubtek.com/libraries/python/rc/trunk#egg=rc

this gets installed to venv_dir/src/rc, which is then a full svn
checkout, which I can manually switch branches, merge/test etc. When I
want to make it permanent, I can simply update my requirements.pip,
blow away my venv dir and reinstall (or remember the full invocation
for pip install --upgrade -e etc).

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.



Re: Packaging and development workflow for decoupled apps.

2011-03-11 Thread Bill Freeman
On Fri, Mar 11, 2011 at 3:41 AM, DaleB  wrote:

> One last point.
> Now, how do i deal best with different versions/branches of my app? Do
> you just switch branches while developing or do you use pip in project
> env to refer and switch to different tags/branches in your sourcecode.
> The first approach feels more dynamic, the latter more 'stable'. In
> the end i guess both work, but what do you do?
>
> Greetings,
> Andreas

One possibility is to use a development egg with is a revision control
checkout.  (The whole distutils/setuptools/distribute thing seems to be
specifically aware of subversion at some level, offering to use revision
information in version numbers.  I haven't noticed support for other
VCSs, but there could be ways to use them by having script wrappers
on your shell path...).  Then you can simply update to another revision
to test with it.

Bill

-- 
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: Why does Django Fail on Date Field?

2011-03-11 Thread octopusgrabbus
I could easily have used the Informix "null" date of 12/31/1899, but
chose that instead. I put the dates into a table, so when they were
processed they'd be set to a real date, today's.

On Mar 11, 7:39 am, Kenneth Gonsalves  wrote:
> On Fri, 2011-03-11 at 04:28 -0800, octopusgrabbus wrote:
> > It's a date format MySQL will accept into a date field.
>
> I suppose it can be used for recording Adam's date of birth?
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

-- 
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: Packaging and development workflow for decoupled apps.

2011-03-11 Thread Mike Ramirez
On Friday, March 11, 2011 07:52:22 am DaleB wrote:
> I guess i wasn't clear enough. I am not so much concerned with when to
> use tags and when to use branches.
> I am still looking for a smooth development workflow.
> I created a libs-dir which i put on my python path an put my different
> apps in it.
> Okay, now i can refer to my apps from any project without copying the
> files. Great and a lot better than before.
> 
> So now i start to create different branches for an app, i create a
> development branch an change stuff.
> As the app is on my path my projects initially refer to the state/
> branch of an app that ist currently checked out, right?
> That's what i refered to by "switching branches" (= changing the
> branch of my app in my libs-dir)
> 
> Another (better?) idea i had looking at pip's docs was to take my libs-
> dir off the python path, put them in a git-repo and use pip to install
> my app.
> Pip's option to refer to certain tags and branches (http://
> pip.openplans.org/requirement-format.html#version-control) seems
> pretty ideal in this situation.
> The only drawback i see is that i have to install and uninstall quite
> often if i want to test different branches/states of my app in a
> project.
> 
> And now i am not sure which route is more promising or if there's even
> an easier way i don't regard at the moment.
> Hope that's more clear.
> 
> Thanks fpr you patience,
> Andreas

In this case, I'm sorry, I'm not sure. I don't use pip, given the arguments 
I've seen for it, I've never had a reason to really investigate it myself. 
Setuputils/distribute/easy_install are 'good enough' for me.  A long time ago 
james bennet posted a big why you want to use pip on this list, I can't 
remember much more about it, but you might want to search for that posting.

I do things manually with checkouts. If I want to work on a branch, this is 
checked out to a new location (since it's a radical change/fork of a project), 
i.e. same lib dir, different package name to let me know it's a branch. Tags 
are there for historical reasons, really I just use them to mark completion 
points and they are considered part of the main tree (usually). It's just 
easier to know how far back to go when searching for a revision that 
introduced a bug (usually). Or if I completely messed up the current branch, I 
can just go get the last tag. 



Mike.



-- 
mixed emotions:
Watching your mother-in-law back off a cliff...
in your brand new Mercedes.

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



Re: What is the best server for Django

2011-03-11 Thread andreap
Im using webfaction and its the best!


I have 2 question,

1 How can I make an online backup with webfaction?

2  I start to have new customers and I need a hosting to resell to my
customers. Can I use webfaction but actually I can only buy new ram
for my hostcan I buy one hosting per customer?

thx
Andrea

--
suite.guz.it django CRM e CMS



On 11 Mar, 10:46, Kenneth Gonsalves  wrote:
> On Fri, 2011-03-11 at 01:33 -0800, shofty wrote:
> > i tried djangohosting.ch after webfaction. webfaction have better
> > support
> > response times which as a noob i needed. wf have some incredibly
> > knowledgable staff on their support team. so it depends what you want.
> > dh
> > have a great installer, so long as you know what you're doing they're
> > a good
> > choice. first installation might not be too easy but after that...
>
> you do not really need to use their installer. I have set up some sites
> there and I just do the standard virtualenv stuff - feels like I am on
> my laptop. The do not give root access, but one gets ones own
> configurable instance of apache - what more do you want?
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

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



Introspecting a ManyRelatedManager

2011-03-11 Thread mukappa
Hi,

I am looking for the most straightforward way to introspect
the model field name a ManyRelatedManager is bound to.

from django.db import models

class Topping(models.Model):
pass

class Pizza(models.Model):
toppings = models.ManyToManyField(Topping)

def get_fieldname(manager):
"""Dig out field name the manager is bound to.

manager - a ManyRelatedManager
"""
return "toppings"

pizza = Pizza().save()
print get_fieldname(pizza.toppings)

-- 
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: Packaging and development workflow for decoupled apps.

2011-03-11 Thread DaleB
I guess i wasn't clear enough. I am not so much concerned with when to
use tags and when to use branches.
I am still looking for a smooth development workflow.
I created a libs-dir which i put on my python path an put my different
apps in it.
Okay, now i can refer to my apps from any project without copying the
files. Great and a lot better than before.

So now i start to create different branches for an app, i create a
development branch an change stuff.
As the app is on my path my projects initially refer to the state/
branch of an app that ist currently checked out, right?
That's what i refered to by "switching branches" (= changing the
branch of my app in my libs-dir)

Another (better?) idea i had looking at pip's docs was to take my libs-
dir off the python path, put them in a git-repo and use pip to install
my app.
Pip's option to refer to certain tags and branches (http://
pip.openplans.org/requirement-format.html#version-control) seems
pretty ideal in this situation.
The only drawback i see is that i have to install and uninstall quite
often if i want to test different branches/states of my app in a
project.

And now i am not sure which route is more promising or if there's even
an easier way i don't regard at the moment.
Hope that's more clear.

Thanks fpr you patience,
Andreas

-- 
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: Packaging and development workflow for decoupled apps.

2011-03-11 Thread Mike Ramirez
On Friday, March 11, 2011 12:41:52 am DaleB wrote:

> One last point.
> Now, how do i deal best with different versions/branches of my app? Do
> you just switch branches while developing or do you use pip in project
> env to refer and switch to different tags/branches in your sourcecode.
> The first approach feels more dynamic, the latter more 'stable'. In
> the end i guess both work, but what do you do?
> 
> Greetings,
> Andreas

This is more of a policy situation. What that means is that it can be 
different. Depends on how you use them.

Tags, usually mark a completion point (or milestone). 

Branches are usually a fork or a radical change or a fork..

In django's history, when they added unicode support through out it, they had 
the main branch with work being aimed at generally improving django.

The unicode branch was were all the changes for adding unicode was done. We as 
users of django had our choice on what to use, checking out the main tree or 
the branch with the unicode system.

Personally,. I check out branches to a different location than the main 
project as I consider them different applications. 

Tags, I just use to mark important milestones for the code I'm working on.


Mike



-- 
I'm sorry if the following sounds combative and excessively personal,
but that's my general style.-- Ian Jackson

-- 
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 models and inheritance

2011-03-11 Thread Mark J. Nenadov
Hello folks,

I'm a long time Python developer that is new to Django.  I have a few
questions about the role of inheritance in the models for an app.

As I build my models, I'm finding at least somewhat of a need to start
doing some inheritance, and if not a need--at least a design-related
desire to do it Everything seems to work nicely and neatly in theory
if I stick with concrete super classes, but if I venture in the area
of abstract super classes, things seem to get messy.

If I have my abstract super classes inherit models.Model,  things
technically can work. However, I arrive with a rather overly complex
SQL design generated from them (like needless tables for abstract
super classes).

On the other hand, if I have my abstract super classes NOT inherit
models.Model and then use multiple inheritance on my subclasses (ie.
have the subclasses inherit both models.Model and their Super class),
then I end up with non-functional SQL tables (ie. the SQL table for a
model would not contain critical fields that in the model had been
inherited from their super class).

Am I missing something? Is there a way to have my models include
properties inherited from an abstract super class into the SQL it
generates? And ideally without creating tables for each abstract super
class? Or is this just too much in the way of complex OO for
models.py, and maybe I'm just over-doing it and  an experienced Django
developer will point out the futility of what I'm trying.

In any case, I don't want to give up a abstract super classes until
I've satisfied myself that there is no way to accomplish this.

Any help that can be offered is much appreciated!

Thanks,
~Mark

-- 
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 app and Amazon AWS (beginner)

2011-03-11 Thread Graham Dumpleton
One can if you want to get a development system closer to production use 
Apache/mod_wsgi in such a way that automatic code reloading on any change 
works, just like Django development server. See:

  http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html
  http://blog.dscpl.com.au/2009/02/source-code-reloading-with-modwsgi-on.html

Using that approach means you can properly test multithread and multiprocess 
configurations.

Also, if you have only been looking at mod_wsgi integration notes on the 
Django site, ensure that you also read what is on the official mod_wsgi 
site. Also ensure you try and get a hello world WSGI program going before 
you try to do Django itself. That can avoid a lot of problems and 
misunderstands when it comes to setting up Django. See:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

Graham

On Wednesday, March 9, 2011 10:48:25 PM UTC-5, CLIFFORD ILKAY wrote:
>
> On 03/09/2011 10:37 PM, nai wrote:
> > According to djangoproject, deploying Django with apache and mod_wsgi
> > is the way to go. I keep seeing these terms over and over again but
> > I've had it explained to me over and over but I still don't get it. I
> > know this is getting a bit off topic but it would be great if someone
> > could take another stab and explain how apache and mod_wsgi fits in
> > with the deployment.
>
> The built-in dev server isn't intended to be run in production. It can 
> only handle one connection at a time and has never been security 
> audited. It's purely for the convenience of the developer and not 
> intended for production deployment.
>
> Apache is a web server. Simplistically, mod_wsgi is the means by which 
> Apache can pass requests to and from the Python interpreter. I prefer 
> nginx and fcgi as alternatives to Apache and mod_wsgi. Feel free to 
> contact me if you would rather have someone else get this setup for you 
> so that you can concentrate on your development.
> -- 
> Regards,
>
> Clifford Ilkay
> Dinamis
> 1419-3266 Yonge St.
> Toronto, ON
> Canada  M4N 3P6
>
> 
> +1 416-410-3326
>
>

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



Re: Deploying django. Please specify the steps.

2011-03-11 Thread Graham Dumpleton
Go watch:

http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations

That presentation explains a lot about permissions and other errors you can.

Recommend that before you even try and get Django running that you get a 
WSGI hello world script running. Use what is shown in:

  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

Graham

On Friday, March 11, 2011 7:46:31 AM UTC-5, balu wrote:
>
> Here is the error log sir. 
>
>
>
> [Wed Feb 09 22:23:25 2011] [notice] Apache/2.2.16 (Ubuntu) configured 
> -- resuming normal operations 
> [Wed Feb 09 23:28:09 2011] [notice] caught SIGTERM, shutting down 
> [Wed Mar 09 20:10:30 2011] [notice] Apache/2.2.16 (Ubuntu) configured 
> -- resuming normal operations 
> [Wed Mar 09 20:12:55 2011] [error] [client 127.0.0.1] File does not 
> exist: /var/www/favicon.ico 
> [Wed Mar 09 20:12:58 2011] [error] [client 127.0.0.1] File does not 
> exist: /var/www/favicon.ico 
> [Wed Mar 09 20:37:40 2011] [notice] caught SIGTERM, shutting down 
> [Wed Mar 09 20:37:41 2011] [warn] mod_wsgi: Compiled for Python/2.6.5. 
> [Wed Mar 09 20:37:41 2011] [warn] mod_wsgi: Runtime using Python/ 
> 2.6.6. 
> [Wed Mar 09 20:37:41 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/ 
> 3.2 Python/2.6.6 configured -- resuming normal operations 
> [Wed Mar 09 22:15:57 2011] [error] Exception KeyError: 
> KeyError(-1217283440,) in  threading.pyc'> ignored 
> [Wed Mar 09 22:15:57 2011] [error] Exception KeyError: 
> KeyError(-1217283440,) in  threading.pyc'> ignored 
> [Wed Mar 09 22:15:57 2011] [notice] caught SIGTERM, shutting down 
> [Wed Mar 09 22:15:58 2011] [warn] mod_wsgi: Compiled for Python/2.6.5. 
> [Wed Mar 09 22:15:58 2011] [warn] mod_wsgi: Runtime using Python/ 
> 2.6.6. 
> [Wed Mar 09 22:15:58 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/ 
> 3.2 Python/2.6.6 configured -- resuming normal operations 
> [Wed Mar 09 22:36:18 2011] [error] Exception KeyError: 
> KeyError(-1216181616,) in  threading.pyc'> ignored 
> [Wed Mar 09 22:36:18 2011] [error] Exception KeyError: 
> KeyError(-1216181616,) in  threading.pyc'> ignored 
> [Wed Mar 09 22:36:18 2011] [notice] caught SIGTERM, shutting down 
> [Thu Mar 10 17:00:59 2011] [warn] mod_wsgi: Compiled for Python/2.6.5. 
> [Thu Mar 10 17:00:59 2011] [warn] mod_wsgi: Runtime using Python/ 
> 2.6.6. 
> [Thu Mar 10 17:00:59 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/ 
> 3.2 Python/2.6.6 configured -- resuming normal operations 
> [Thu Mar 10 17:01:45 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to / denied 
> [Thu Mar 10 17:01:45 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to /favicon.ico denied 
> [Thu Mar 10 17:01:48 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to /favicon.ico denied 
> [Thu Mar 10 17:01:58 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to / denied 
> [Thu Mar 10 17:02:05 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to / denied 
> [Thu Mar 10 17:02:12 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to / denied 
> [Thu Mar 10 17:06:08 2011] [error] Exception KeyError: 
> KeyError(-1217029488,) in  threading.pyc'> ignored 
> [Thu Mar 10 17:06:08 2011] [error] Exception KeyError: 
> KeyError(-1217029488,) in  threading.pyc'> ignored 
> [Thu Mar 10 17:06:08 2011] [notice] SIGHUP received.  Attempting to 
> restart 
> [Thu Mar 10 17:06:08 2011] [warn] mod_wsgi: Compiled for Python/2.6.5. 
> [Thu Mar 10 17:06:08 2011] [warn] mod_wsgi: Runtime using Python/ 
> 2.6.6. 
> [Thu Mar 10 17:06:08 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/ 
> 3.2 Python/2.6.6 configured -- resuming normal operations 
> [Thu Mar 10 17:06:24 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to / denied 
> [Thu Mar 10 17:06:30 2011] [error] Exception KeyError: 
> KeyError(-1217029488,) in  threading.pyc'> ignored 
> [Thu Mar 10 17:06:30 2011] [error] Exception KeyError: 
> KeyError(-1217029488,) in  threading.pyc'> ignored 
> [Thu Mar 10 17:06:30 2011] [notice] caught SIGTERM, shutting down 
> [Thu Mar 10 17:06:47 2011] [warn] mod_wsgi: Compiled for Python/2.6.5. 
> [Thu Mar 10 17:06:47 2011] [warn] mod_wsgi: Runtime using Python/ 
> 2.6.6. 
> [Thu Mar 10 17:06:47 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/ 
> 3.2 Python/2.6.6 configured -- resuming normal operations 
> [Thu Mar 10 17:13:32 2011] [error] [client 127.0.0.1] (13)Permission 
> denied: access to / denied 
> [Thu Mar 10 17:13:49 2011] [error] Exception KeyError: 
> KeyError(-1217340784,) in  threading.pyc'> ignored 
> [Thu Mar 10 17:13:49 2011] [error] Exception KeyError: 
> KeyError(-1217340784,) in  threading.pyc'> ignored 
> [Thu Mar 10 17:13:49 2011] [notice] SIGHUP received.  Attempting to 
> restart 
> [Thu Mar 10 17:13:49 2011] [warn] mod_wsgi: Compiled for Python/2.6.5. 
> [Thu Mar 10 17:13:49 2011] [warn] mod_wsgi: Runtime using Python/ 
> 2.6.6. 
> [Thu Mar 10 17:13:49 2011] [notice] Apache/2.2.16 (Ubuntu) 

Re: What is it with Django and 2008?

2011-03-11 Thread Artem
I guess it's because of Django v1.0 release - people started to
consider it like stable production-safe framework. So most of Django
books came out after that, though most of them have few revisions to
be up to date, but in searches first revision usually most noticeable.

-- 
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. Please specify the steps.

2011-03-11 Thread balu
1. When I open "http://localhost/; page, it is an error message
"Forbidden. You don't have permission to access / on this server".

2. with in /etc/apache2/sites-available/ directory I created a file
named "locahost". In that I placed the Virtual Host settings.

NameVirtualHost *:80



DocumentRoot /home/balu/Django/workspace/mysite/

WSGIScriptAlias / /home/balu/Django/workspace/mysite/apache/
django.wsgi



  Order allow, deny
  Allow from all





3.
* django.wsgi **

import os, sys

wsgi_dir = os.path.abspath(os.path.dirname(__file__))

project_dir = os.path.dirname(wsgi_dir)

sys.path.append(project_dir)

project_settings = os.path.join(project_dir,'settings')

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

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

On Mar 11, 5:58 pm, Kenneth Gonsalves  wrote:
> On Fri, 2011-03-11 at 04:46 -0800, balu wrote:
> > Here is the error log sir.
>
> nobody asked you for the apache error log. To repeat:
>
> please paste the following:
>
> 1. what error does your browser show
> 2. the relevant part of your apache config file (please do not post the
> whole config file)
> 3. your django.wsgi file
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

-- 
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: When do we stop using Django admin?

2011-03-11 Thread Dan Gentry
I tend to use the Admin for internal tasks - ones that would be
performed by a application or system administrator.  These are people
that understand the data structure and know things like the effects of
a cascaded delete.

For users, even a customer 'admin' person, I would write my own views
that will handle additional conditions rather than asking that user to
make the decision.

-- 
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. Please specify the steps.

2011-03-11 Thread Jirka Vejrazka
OK - I'm going to ask the obvious question here - have you made sure
that Apache web server user can read ALL your configuration files? The
log reveals that there are permission problems on .htaccess file that
is stored in your home directory (where Apache can't reach by
default). I'm going to make a guess that there's where your
WSGI-related Apache configuration is.

 HTH

   Jirka

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



Error on aggragate function-Count

2011-03-11 Thread pols
hai
 I have two models as shown belove

from django.db import models
from django.db.models import Sum
# Create your models here.
class polls(models.Model):
  question = models.CharField(max_length=200)
  pubish_date = models.DateTimeField('Date published')

  def __unicode__(self):
return self.question
  def getCount(self):
 count =
choice.objects.filter(polls=self.id).annotate(test=Sum('vote'))
 return count.test
  getCount.allow_tags = 'true'
  getCount.short_description = 'Total Answers'


class choice(models.Model):
  polls = models.ForeignKey(polls)
  choice = models.CharField(max_length=200)
  vote = models.IntegerField()



Here i need to get sum of votes for each question.So I need to edit
the code in the function getCount(). I try with the above code but
getting 'none'.then what may be the problem??.This is for the listing
in django admin polls listing

-- 
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. Please specify the steps.

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 04:46 -0800, balu wrote:
> Here is the error log sir.

nobody asked you for the apache error log. To repeat:

please paste the following:

1. what error does your browser show
2. the relevant part of your apache config file (please do not post the
whole config file)
3. your django.wsgi file
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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: No fixtures found

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 16:48 +0530, Shakthi Kannan wrote:
> No fixtures found.

I tried this out after you brought it up in IRC and made the smallest
possible test. It works for me regardless of what name I give the
fixtures file as long as it is in the fixtures directory of the
application. You must be doing something wrong - although as far as I
can see your code is identical to mine.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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. Please specify the steps.

2011-03-11 Thread balu
Here is the error log sir.



[Wed Feb 09 22:23:25 2011] [notice] Apache/2.2.16 (Ubuntu) configured
-- resuming normal operations
[Wed Feb 09 23:28:09 2011] [notice] caught SIGTERM, shutting down
[Wed Mar 09 20:10:30 2011] [notice] Apache/2.2.16 (Ubuntu) configured
-- resuming normal operations
[Wed Mar 09 20:12:55 2011] [error] [client 127.0.0.1] File does not
exist: /var/www/favicon.ico
[Wed Mar 09 20:12:58 2011] [error] [client 127.0.0.1] File does not
exist: /var/www/favicon.ico
[Wed Mar 09 20:37:40 2011] [notice] caught SIGTERM, shutting down
[Wed Mar 09 20:37:41 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Wed Mar 09 20:37:41 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Wed Mar 09 20:37:41 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Wed Mar 09 22:15:57 2011] [error] Exception KeyError:
KeyError(-1217283440,) in  ignored
[Wed Mar 09 22:15:57 2011] [error] Exception KeyError:
KeyError(-1217283440,) in  ignored
[Wed Mar 09 22:15:57 2011] [notice] caught SIGTERM, shutting down
[Wed Mar 09 22:15:58 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Wed Mar 09 22:15:58 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Wed Mar 09 22:15:58 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Wed Mar 09 22:36:18 2011] [error] Exception KeyError:
KeyError(-1216181616,) in  ignored
[Wed Mar 09 22:36:18 2011] [error] Exception KeyError:
KeyError(-1216181616,) in  ignored
[Wed Mar 09 22:36:18 2011] [notice] caught SIGTERM, shutting down
[Thu Mar 10 17:00:59 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Thu Mar 10 17:00:59 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Thu Mar 10 17:00:59 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Thu Mar 10 17:01:45 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to / denied
[Thu Mar 10 17:01:45 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to /favicon.ico denied
[Thu Mar 10 17:01:48 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to /favicon.ico denied
[Thu Mar 10 17:01:58 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to / denied
[Thu Mar 10 17:02:05 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to / denied
[Thu Mar 10 17:02:12 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to / denied
[Thu Mar 10 17:06:08 2011] [error] Exception KeyError:
KeyError(-1217029488,) in  ignored
[Thu Mar 10 17:06:08 2011] [error] Exception KeyError:
KeyError(-1217029488,) in  ignored
[Thu Mar 10 17:06:08 2011] [notice] SIGHUP received.  Attempting to
restart
[Thu Mar 10 17:06:08 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Thu Mar 10 17:06:08 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Thu Mar 10 17:06:08 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Thu Mar 10 17:06:24 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to / denied
[Thu Mar 10 17:06:30 2011] [error] Exception KeyError:
KeyError(-1217029488,) in  ignored
[Thu Mar 10 17:06:30 2011] [error] Exception KeyError:
KeyError(-1217029488,) in  ignored
[Thu Mar 10 17:06:30 2011] [notice] caught SIGTERM, shutting down
[Thu Mar 10 17:06:47 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Thu Mar 10 17:06:47 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Thu Mar 10 17:06:47 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Thu Mar 10 17:13:32 2011] [error] [client 127.0.0.1] (13)Permission
denied: access to / denied
[Thu Mar 10 17:13:49 2011] [error] Exception KeyError:
KeyError(-1217340784,) in  ignored
[Thu Mar 10 17:13:49 2011] [error] Exception KeyError:
KeyError(-1217340784,) in  ignored
[Thu Mar 10 17:13:49 2011] [notice] SIGHUP received.  Attempting to
restart
[Thu Mar 10 17:13:49 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Thu Mar 10 17:13:49 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Thu Mar 10 17:13:49 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Thu Mar 10 17:23:21 2011] [error] Exception KeyError:
KeyError(-1217340784,) in  ignored
[Thu Mar 10 17:23:21 2011] [error] Exception KeyError:
KeyError(-1217340784,) in  ignored
[Thu Mar 10 17:23:21 2011] [notice] SIGHUP received.  Attempting to
restart
[Thu Mar 10 17:23:21 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Thu Mar 10 17:23:21 2011] [warn] mod_wsgi: Runtime using Python/
2.6.6.
[Thu Mar 10 17:23:21 2011] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
3.2 Python/2.6.6 configured -- resuming normal operations
[Thu Mar 10 17:32:22 2011] [error] [client 127.0.0.1] File does not
exist: /var/www/exam
[Thu Mar 10 17:32:24 2011] [error] [client 127.0.0.1] File does not
exist: /var/www/exam
[Thu Mar 10 17:32:52 2011] [error] [client 127.0.0.1] File does not

Re: Deploying django. Please specify the steps.

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 13:40 +0100, Xavier Ordoquy wrote:
> >> I had gone through the official site. But couldn't understand it
> >> completely the configuration process.
> >> 
> >> apache, mod_wsgi, nginx, mysql on ubuntu 10.10 
> > 
> > first make up your mind - do you want apache or nginx? You cannot
> have
> > both. Secondly post the configuration you have tried and post the
> *full*
> > error messages.
> 
> Actually, you can have apache/mod_wsgi behind a nginx because of
> static files. 

true - but this is for a beginner.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



No fixtures found

2011-03-11 Thread Shakthi Kannan
Hi,

I am just getting started with Django (1.2.5) on Fedora. I would like
to create separate test data files to be loaded to the test database
for each test case for the mysite/ app. I have the following code
snippets (based on the Django tutorial):

=== mysite/polls/tests.py ===

from django.test import TestCase

from polls.models import Poll

class SimpleTestCase(TestCase):
fixtures = ['poll.json',]

=== mysite/polls/models.py ===

from django.db import models

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return self.question

def show(self):
string = "show"
return string

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()

def __unicode__(self):
return self.choice

=== mysite/polls/fixtures/poll.json ===

[
  {
"model": "polls.poll",
"pk": 1,
"fields": {
  "question": "What is your date of birth?",
  "pub_date": "2011-03-08 12:30:45"
}
  }
]

=== Output ===

$  ./manage.py test polls
Creating test database 'default'...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table polls_poll
Creating table polls_choice
Installing index for auth.Permission model
Installing index for auth.Group_permissions model
Installing index for auth.User_user_permissions model
Installing index for auth.User_groups model
Installing index for auth.Message model
Installing index for admin.LogEntry model
Installing index for polls.Choice model
No fixtures found.

--
Ran 0 tests in 0.000s

OK
Destroying test database 'default'...

If I use a file initial_data.json in mysite/polls/fixtures, and
running ./manage.py test polls, it loads the file, even if I specify
'poll.json' in the tests.py file. I have tried using the following in
settings.py to no avail.

  FIXTURE_DIRS = ( '/tmp/mysite/polls/fixtures/', )

What could be missing? If you have a working app/ solution for that
above that I can refer, it will be very helpful, or if you suggest any
other methods to load dynamic test data, please let me know.

Thanks!

SK

-- 
Shakthi Kannan
http://www.shakthimaan.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.



request.user.save() doesnt work

2011-03-11 Thread Ndungi Kyalo
Hi guys. Am using django non-rel on appengine. I am using django's
auth backend for my authentication, since I did not want to have to
force my users to use gmail logins, and appengine models
{google.appengine.ext.db} for the other models. I have a form where I
allow users to edit their email. So :

if settings_form.is_valid() :
user = request.user
user.email = request.POST['email']
user.save()

print request.POST['email']  returns the correct data entered in the
form. But user.save() just doesnt save!
Am I doing it correctly ? Is there something else I shopuld be doing ?
--
Regards,
Guy-at-the-end-of-the-tether :-)

-- 
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: Help with Apache/Nginx combo

2011-03-11 Thread krzysiekpl
In my opinion you should add alias in nginx.conf for admin media
files. Put this code in server{}

# admin uses admin-media/
# alias works different than root above by dropping admin-
media
location ^~ /media/admin/ {
alias /usr/local/lib/python2.6/dist-packages/django/
contrib/admin/media/;
}

or this code for your static files

location  /static/ {
root  /path/to/project/where/static_folder_is;
expires max;
autoindex off;
}



On 11 Mar, 11:41, maciekjbl  wrote:
> Hi,
>
> I know this topic was discussed a lot, but in every post for this
> topic there are diffrent configuration and this stop helping for me.
>
> Long story short : I changed DEBUG = True to False and all static
> media are gone, so this is something wrong in web server conf.
>
> #settings.py#
>
> import os.path
> PROJECT_DIR = os.path.dirname(__file__)
>
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
>
> MEDIA_URL = 'http://aplikacje/media/'
>
> ADMIN_MEDIA_PREFIX = '/media/admin/'
>
> nginx configuration 
> nginx.conf:
>
> user www-data;
> worker_processes  1;
>
> error_log  /var/log/nginx/error.log;
> pid        /var/run/nginx.pid;
>
> events {
>     worker_connections  1024;
>     # multi_accept on;
>
> }
>
> http {
>     include       /etc/nginx/mime.types;
>
>     access_log  /var/log/nginx/access.log;
>
>     sendfile        on;
>     #tcp_nopush     on;
>
>     #keepalive_timeout  0;
>     keepalive_timeout  65;
>     tcp_nodelay        on;
>
>     gzip  on;
>     gzip_disable "MSIE [1-6]\.(?!.*SV1)";
>
>     upstream webcluster {
>         server aplikacje:8000;
>     }
>
>     include /etc/nginx/conf.d/*.conf;
>     include /etc/nginx/sites-enabled/*;
>
> }
>
> #sites conf :
>
> server {
>         listen 80;
>         server_name media.aplikacje;
>         access_log /var/log/nginx/aplikacje.media.access.log;
>         location / {
>                 autoindex on;
>                 index index.html;
>                 root /var/www/web_aplikacje/web_aplikacje/media;
>         }
>
> }
>
> server {
>         listen 80;
>         server_name aplikacje;
>         access_log /var/log/nginx/aplikacje.django.access.log;
>         if ($host !~* "^aplikacje") {
>                 rewrite ^(.*)$http://aplikacje/$1permanent;
>                 break;
>         }
>         location / {
>                 proxy_passhttp://webcluster;
>                 include /etc/nginx/proxy.conf;
>         }
>
> }
>
> ###Apache conf ##
> 
>
>         #Basic Setup
>         ServerAdmin maciej.jablon...@hydrosolar.pl
>         ServerName aplikacje
>         ServerAlias media.aplikacje
>         ServerAlias aplikacje
>
>         DocumentRoot /var/www/web_aplikacje/web_aplikacje/media
>
>         WSGIScriptAlias / /var/www/web_aplikacje/web_aplikacje/apache/
> django.wsgi
>
>         
>                 Order deny,allow
>                 Allow from all
>         
> 
>
> Server is for the intranet use only. I have dns pointing tohttp://aplikacje/
> and django works fine, only media ( css, img, admin media) gone.
>
> I will be every thankful if someone can point what is wrong with this
> conf a why it is wrong.

-- 
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. Please specify the steps.

2011-03-11 Thread Xavier Ordoquy

Le 11 mars 2011 à 13:25, Kenneth Gonsalves a écrit :

> On Fri, 2011-03-11 at 04:17 -0800, balu wrote:
>> I tried to deploy django with the following. But I couldn't able
>> succeed. Please let me know the exact steps in configuring apache
>> server, configuring mod_wsgi.
>> 
>> I had gone through the official site. But couldn't understand it
>> completely the configuration process.
>> 
>> apache, mod_wsgi, nginx, mysql on ubuntu 10.10 
> 
> first make up your mind - do you want apache or nginx? You cannot have
> both. Secondly post the configuration you have tried and post the *full*
> error messages.

Actually, you can have apache/mod_wsgi behind a nginx because of static files.

Anyway, without the errors, there's little we can do.
The documentation 
(http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/) gives the 
directions. There isn't much to do to get django working with mod_wsgi.

Steps are:
- install apache
- install mod_wsgi
- configure both
- configure your virtual host
- follow the documentation

Regards,
Xavier.

-- 
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: Why does Django Fail on Date Field?

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 04:28 -0800, octopusgrabbus wrote:
> It's a date format MySQL will accept into a date field.

I suppose it can be used for recording Adam's date of birth?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
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: Simple Django Report Generator

2011-03-11 Thread Gennadiy Zlobin
> [0] http://geraldoreports.org/
>
Doesn't work without www
http://www.geraldoreports.org


- Gennadiy 

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



Order of WHERE statements in filter

2011-03-11 Thread galgal
I want to make a specific odrer of WHERE statements in my query to use 
multicolumn index in database.
But oder in code is not the same as result query:
code:
filter(user=self.user, province=self.province, city=self.city)

Mysql result:
WHERE (`accounts_usercity`.`province_id` = 6 AND 
`accounts_usercity`.`city_id` = 32 AND `accounts_usercity`.`user_id` = 26 )

How to force my own order?

-- 
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: Why does Django Fail on Date Field?

2011-03-11 Thread octopusgrabbus
It's a date format MySQL will accept into a date field.

On Mar 10, 8:07 pm, Kenneth Gonsalves  wrote:
> On Thu, 2011-03-10 at 09:46 -0800, octopusgrabbus wrote:
> > load_date = '-00-00'
>
> what on earth is this?
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

-- 
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. Please specify the steps.

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 04:17 -0800, balu wrote:
> I tried to deploy django with the following. But I couldn't able
> succeed. Please let me know the exact steps in configuring apache
> server, configuring mod_wsgi.
> 
> I had gone through the official site. But couldn't understand it
> completely the configuration process.
> 
> apache, mod_wsgi, nginx, mysql on ubuntu 10.10 

first make up your mind - do you want apache or nginx? You cannot have
both. Secondly post the configuration you have tried and post the *full*
error messages.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Deploying django. Please specify the steps.

2011-03-11 Thread balu
Hi all :)

I tried to deploy django with the following. But I couldn't able
succeed. Please let me know the exact steps in configuring apache
server, configuring mod_wsgi.

I had gone through the official site. But couldn't understand it
completely the configuration process.

apache, mod_wsgi, nginx, mysql on ubuntu 10.10

-- 
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: Simple Django Report Generator

2011-03-11 Thread Venkatraman S
On Fri, Mar 11, 2011 at 9:32 AM, Bruno Tikami  wrote:

> have you tried Geraldo Reports [0] ? It's flexible, easy to use and worth a
> look ;-)
>

Looks neat - i havent tried it, but does it support non-pdf output too?

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



Help with Apache/Nginx combo

2011-03-11 Thread maciekjbl
Hi,

I know this topic was discussed a lot, but in every post for this
topic there are diffrent configuration and this stop helping for me.

Long story short : I changed DEBUG = True to False and all static
media are gone, so this is something wrong in web server conf.

#settings.py#

import os.path
PROJECT_DIR = os.path.dirname(__file__)

MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')

MEDIA_URL = 'http://aplikacje/media/'

ADMIN_MEDIA_PREFIX = '/media/admin/'

nginx configuration 
nginx.conf:

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid/var/run/nginx.pid;

events {
worker_connections  1024;
# multi_accept on;
}

http {
include   /etc/nginx/mime.types;

access_log  /var/log/nginx/access.log;

sendfileon;
#tcp_nopush on;

#keepalive_timeout  0;
keepalive_timeout  65;
tcp_nodelayon;

gzip  on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";


upstream webcluster {
server aplikacje:8000;
}


include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

#sites conf :

server {
listen 80;
server_name media.aplikacje;
access_log /var/log/nginx/aplikacje.media.access.log;
location / {
autoindex on;
index index.html;
root /var/www/web_aplikacje/web_aplikacje/media;
}

}
server {
listen 80;
server_name aplikacje;
access_log /var/log/nginx/aplikacje.django.access.log;
if ($host !~* "^aplikacje") {
rewrite ^(.*)$ http://aplikacje/$1 permanent;
break;
}
location / {
proxy_pass http://webcluster;
include /etc/nginx/proxy.conf;
}
}

###Apache conf ##


#Basic Setup
ServerAdmin maciej.jablon...@hydrosolar.pl
ServerName aplikacje
ServerAlias media.aplikacje
ServerAlias aplikacje

DocumentRoot /var/www/web_aplikacje/web_aplikacje/media

WSGIScriptAlias / /var/www/web_aplikacje/web_aplikacje/apache/
django.wsgi



Order deny,allow
Allow from all



Server is for the intranet use only. I have dns pointing to http://aplikacje/
and django works fine, only media ( css, img, admin media) gone.

I will be every thankful if someone can point what is wrong with this
conf a why it is wrong.

-- 
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: Multiple modelforms in single POST

2011-03-11 Thread bruno desthuilliers


On 11 mar, 07:58, Anoop Thomas Mathew  wrote:
> Hi all,
>
> I have a Profile model, which has a ForiegnKey to User model. I want to edit
> both of it at same form.
>
> this is what I tried,http://dpaste.de/ODOJ/
> Still, no success. Please help.

You'll have to provide a bit more informations if you hope to get some
help - like, what "no success" means *exactly*

Now just for the record, chances are your Profile.id is not the same
as User.id so there's probably something wrong with your view.

Also and FWIW, I had the same need (editing user and profile fields in
a same form) in a couple apps, and always ended up writing my own (non-
model) form. ModelForms are quite handy, but it's sometimes easier and
quicker to write a custom form instead.

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



Re: What is the best server for Django

2011-03-11 Thread Kenneth Gonsalves
On Fri, 2011-03-11 at 01:33 -0800, shofty wrote:
> i tried djangohosting.ch after webfaction. webfaction have better
> support 
> response times which as a noob i needed. wf have some incredibly 
> knowledgable staff on their support team. so it depends what you want.
> dh 
> have a great installer, so long as you know what you're doing they're
> a good 
> choice. first installation might not be too easy but after that...
> 
> 

you do not really need to use their installer. I have set up some sites
there and I just do the standard virtualenv stuff - feels like I am on
my laptop. The do not give root access, but one gets ones own
configurable instance of apache - what more do you want?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: What is the best server for Django

2011-03-11 Thread shofty
i tried djangohosting.ch after webfaction. webfaction have better support 
response times which as a noob i needed. wf have some incredibly 
knowledgable staff on their support team. so it depends what you want. dh 
have a great installer, so long as you know what you're doing they're a good 
choice. first installation might not be too easy but after that...

-- 
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: Packaging and development workflow for decoupled apps.

2011-03-11 Thread DaleB
Thank you for all your insights.

> I think you are stuck in the monolithic point of view.  I'm also not sure if
> you understand that django apps are python modules and the same rules apply.  
>
> The apps location within the PYTHONPATH is immaterial to a project, as long as
> the project can find the app. With this in mind, I tend to have a lib
> directory, that contains apps that are in development or checkouted out from
> other developers versioning system. This lib directory is added to the python
> path for each project that needs an app from this location. Please note this
> is a directory seperate from python${VERSION}/site-packages.

Indeed. With my shiny new installation package i totally forgot about
the fact that the package just needs no be on the path,
no matter where the files are actually stored. That really clears
things up for me.

And thanks for for your example Tom.

One last point.
Now, how do i deal best with different versions/branches of my app? Do
you just switch branches while developing or do you use pip in project
env to refer and switch to different tags/branches in your sourcecode.
The first approach feels more dynamic, the latter more 'stable'. In
the end i guess both work, but what do you do?

Greetings,
Andreas

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