Re: Django Training

2008-12-09 Thread Skylar Saveland
+1, Perhaps building a fully-working site using all parts of Django,
implementing interesting and useful features.  Also setting-up with reverse
proxy/static server with lean, fast networking.  Depends on how long the
class is I suppose.

On Tue, Dec 9, 2008 at 3:32 PM, Jane <[EMAIL PROTECTED]> wrote:

>
> I think it would be good to ask students how they plan to use django.
> For myself, we'd like to deploy databases on a web page, and I'm
> interested to learn how much of that can be done in python and django,
> then what do you add to make the database look pretty for outside
> users.
>
> On Dec 8, 11:06 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> > I am looking at expanding our training offerings for the coming year,
> > and a short course in Django looks like it might be popular. There
> > don't seem to be many Django classes at the moment, and several of the
> > students from our introductory Python classes expressed interest in
> > Django.
> >
> > Without wanting anyone on the list to do my work for me, it would be
> > useful to see some opinions about what to include. The tutorial gives
> > people a good start: should we assume that anyone who wants to take
> > the class has already run through that, or would it be better to start
> > from scratch?
> >
> > Django is such a rich platform it would be possible to write several
> > classes: what material do readers regard as the "essentials of
> > Django", and what should be relegated to more advanced classes? What
> > can I do to put a compelling introductory class together?
> >
> > regards
> >  Steve
>
> >
>

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



Re: referencing the current instance inside limit_choices_to

2008-12-09 Thread Alex Koshelev
There is no way to have per-instance limit_choices_to.


On Wed, Dec 10, 2008 at 03:56, GuyBowden <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I've looked about but can't find the answer to this.
>
> I'd like to set the limit_choices_to value of a ForeignKey field based
> on another selection in the current instance.
>
> i.e. - filter the choices based on another field of the same instance.
>
> something like this:
>
> my_fk.limit_choices_to = my_fk.objects.get(Q(type = self.fk_type))
>
> but that fails as self is not defined by then obviously...
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request parsing

2008-12-09 Thread Vicky

hey can u plse attach and sent me a sample project that uses forms if
possible. I need to knw wr anw hw to create forms, should we include
anything in settings.py or urls.py?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Index page using flatpages

2008-12-09 Thread Jeff FW

Do you have CommonMiddleware enabled in your settings.py?

http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.common

On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm using flatpages to display some static content in a site. The
> "about" page is working flawlessly (URL = mysite.com/about) but now
> I'm trying to define the index (URL = mysite.com) using flatpages.
>
> I'm having troubles defining the URL in the administration panel:
>
> If I put / in the URL field, I need to write "mysite.com//" to get
> access to my index page. This is not good for visitors!
>
> Your help is much appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: coercing to Unicode: need string or buffer, tuple found

2008-12-09 Thread DragonSlayre

Oh ok, thanks a lot!!

Yes, I'm learning python too at the same time as django...

On Dec 10, 4:35 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-12-09 at 19:23 -0800, DragonSlayre wrote:
> > Hi,
>
> > I've just made a new 'Student' model, and was trying to create a new
> > Student in the admin interface, and I got the following error:
>
> > Environment:
>
> > Request Method: POST
> > Request URL:http://localhost:8000/admin/student/student/add/
> > Django Version: 1.0.2 final
> > Python Version: 2.5.2
> > Installed Applications:
> > ['django.contrib.auth',
> >  'django.contrib.contenttypes',
> >  'django.contrib.sessions',
> >  'django.contrib.sites',
> >  'django.contrib.admin',
> >  'mysite.student']
> > Installed Middleware:
> > ('django.middleware.common.CommonMiddleware',
> >  'django.contrib.sessions.middleware.SessionMiddleware',
> >  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> > Traceback:
> > File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> > in get_response
> >   86.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > in root
> >   157.                 return self.model_page(request, *url.split('/',
> > 2))
> > File "/usr/lib/python2.5/site-packages/django/views/decorators/
> > cache.py" in _wrapped_view_func
> >   44.         response = view_func(request, *args, **kwargs)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > in model_page
> >   176.         return admin_obj(request, rest_of_url)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in __call__
> >   191.             return self.add_view(request)
> > File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
> > _commit_on_success
> >   238.                 res = func(*args, **kw)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in add_view
> >   499.                 self.log_addition(request, new_object)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in log_addition
> >   294.             object_repr     = force_unicode(object),
> > File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
> > force_unicode
> >   49.                 s = unicode(s)
>
> > Exception Type: TypeError at /admin/student/student/add/
> > Exception Value: coercing to Unicode: need string or buffer, tuple
> > found
>
> > My model looks like this:
> > class Student(models.Model):
>
> [...]
>
> >     def __unicode__(self):
> >         return self.user.username, ", ", self.user.first_name, " ",
> > self.user.last_name
>
> You are returning a tuple here and you must return a unicode object. If
> you want to concatenate strings, do it with "+", or use format markers
> like so:
>
>         return u"%s, %s %s" % (self.user.username, self.user.first_name, 
> self.user.last_name)
>
> Using commas to separate objects, even without the surrounding
> parentheses, is how you specify a tuple in Python.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: coercing to Unicode: need string or buffer, tuple found

2008-12-09 Thread Malcolm Tredinnick


On Tue, 2008-12-09 at 19:23 -0800, DragonSlayre wrote:
> Hi,
> 
> I've just made a new 'Student' model, and was trying to create a new
> Student in the admin interface, and I got the following error:
> 
> Environment:
> 
> Request Method: POST
> Request URL: http://localhost:8000/admin/student/student/add/
> Django Version: 1.0.2 final
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'mysite.student']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
> 
> 
> Traceback:
> File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> in get_response
>   86. response = callback(request, *callback_args,
> **callback_kwargs)
> File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> in root
>   157. return self.model_page(request, *url.split('/',
> 2))
> File "/usr/lib/python2.5/site-packages/django/views/decorators/
> cache.py" in _wrapped_view_func
>   44. response = view_func(request, *args, **kwargs)
> File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> in model_page
>   176. return admin_obj(request, rest_of_url)
> File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> options.py" in __call__
>   191. return self.add_view(request)
> File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
> _commit_on_success
>   238. res = func(*args, **kw)
> File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> options.py" in add_view
>   499. self.log_addition(request, new_object)
> File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> options.py" in log_addition
>   294. object_repr = force_unicode(object),
> File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
> force_unicode
>   49. s = unicode(s)
> 
> Exception Type: TypeError at /admin/student/student/add/
> Exception Value: coercing to Unicode: need string or buffer, tuple
> found
> 
> 
> 
> 
> My model looks like this:


> class Student(models.Model):

[...]
> def __unicode__(self):
> return self.user.username, ", ", self.user.first_name, " ",
> self.user.last_name

You are returning a tuple here and you must return a unicode object. If
you want to concatenate strings, do it with "+", or use format markers
like so:

return u"%s, %s %s" % (self.user.username, self.user.first_name, 
self.user.last_name)

Using commas to separate objects, even without the surrounding
parentheses, is how you specify a tuple in Python.

Regards,
Malcolm



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



coercing to Unicode: need string or buffer, tuple found

2008-12-09 Thread DragonSlayre

Hi,

I've just made a new 'Student' model, and was trying to create a new
Student in the admin interface, and I got the following error:

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/student/student/add/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'mysite.student']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in root
  157. return self.model_page(request, *url.split('/',
2))
File "/usr/lib/python2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in model_page
  176. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in __call__
  191. return self.add_view(request)
File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
_commit_on_success
  238. res = func(*args, **kw)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in add_view
  499. self.log_addition(request, new_object)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in log_addition
  294. object_repr = force_unicode(object),
File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
force_unicode
  49. s = unicode(s)

Exception Type: TypeError at /admin/student/student/add/
Exception Value: coercing to Unicode: need string or buffer, tuple
found




My model looks like this:

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

GENDER_CHOICES = (
('m', 'male'),
('f', 'female'),
)


# Create your models here.
class Student(models.Model):

# This is the only required field
user = models.ForeignKey(User, unique=True)

# Being nosey
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
birth_date = models.DateField()

# Addressing details
street_address = models.CharField(max_length=50, blank=False)
suburb = models.CharField(max_length=20, blank=True)
city = models.CharField(max_length=20, blank=False)
post_code = models.PositiveSmallIntegerField(blank=False)

# Contact details
contact_phone = models.CharField(max_length=11, blank=False)
cell_phone = models.CharField(max_length=11, blank=True)

def __unicode__(self):
return self.user.username, ", ", self.user.first_name, " ",
self.user.last_name


I'm quite new to Django, so aren't sure about what's going on at all.
I appreciate any help people can give,


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



Re: ModelForm removing blank=True

2008-12-09 Thread tenni

Brilliant. Thanks James.

I went down this path of thinking but tried blank=True instead of
required=False which, when it failed, confused my underslept mind :)

Appreciate it.
Andrew.


On Dec 10, 1:03 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 7:50 PM, tenni <[EMAIL PROTECTED]> wrote:
> > "optional_field" becomes a required field in the Admin. I assume
> > something is overriding the model's blank=True for this field.
>
> Yes. *You* are overriding that.
>
> The moment you override a field's definition in a ModelForm is the
> moment Django assumes you know best, and so Django doesn't do *any*
> automatic introspection of the model for that field. It simply assumes
> that the field definition you've given is correct in every respect,
> and that if it's somehow not correct you will fix it. So if the field
> has "blank=True" in the model, but you give Django your own custom
> definition for that field in the form, then Django goes with your
> custom field (which, in this case, has "required=True" since that's
> the default for all form fields unless you say otherwise).
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm removing blank=True

2008-12-09 Thread James Bennett

On Tue, Dec 9, 2008 at 7:50 PM, tenni <[EMAIL PROTECTED]> wrote:
> "optional_field" becomes a required field in the Admin. I assume
> something is overriding the model's blank=True for this field.

Yes. *You* are overriding that.

The moment you override a field's definition in a ModelForm is the
moment Django assumes you know best, and so Django doesn't do *any*
automatic introspection of the model for that field. It simply assumes
that the field definition you've given is correct in every respect,
and that if it's somehow not correct you will fix it. So if the field
has "blank=True" in the model, but you give Django your own custom
definition for that field in the form, then Django goes with your
custom field (which, in this case, has "required=True" since that's
the default for all form fields unless you say otherwise).


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

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



ModelForm removing blank=True

2008-12-09 Thread tenni

If I do this in admin.py

class UnitAdminModelForm(forms.ModelForm):
optional_field = forms.CharField(widget=WYMEditor())

class Meta:
model = Unit

"optional_field" becomes a required field in the Admin. I assume
something is overriding the model's blank=True for this field.

If it helps I can paste the WYMEditor() class too...

All I want to do is render this particular field with a rich text
editor, which I used to do by adding a class to each field, but that
meant putting js =('jsfiles.js') everywhere. I thought this would be a
much cleaner method, as widgets can carry their own media files.

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



Re: Preserving pretty HTML output

2008-12-09 Thread Tonne

Good point, thanks very much, but I think I'll just live with the way
it currently works.

What I've done is to take a bit more care how and where I place
template tags, and this has improved things somewhat.

On Dec 4, 1:25 am, adelevie <[EMAIL PROTECTED]> wrote:
> You may also want to look at BeautifulSoup. It is an html parser
> writter for python. It has a method called soup.prettify() in  which
> "soup" is a string of html. prettify() outputs cleanly formatted html.
> Approximation:
> soup = "titlehello world"
> soup.pretiffy()>>> 
>
>             
>                  title
>                  hello world
>             
>        
>
> I hope this helps.
>
> On Dec 3, 3:00 am, Tonne <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thank you for the detailed response, Malcolm. I wasn't aware of the
> > complexities of the issue and understand better now why it is the way
> > it is. It was something that was really bugging me, but I feel like I
> > can let it go now :)
>
> > I'm not skilled enough in Python to take a crack at solving the
> > problem myself. Although I'd prefer my HTML source output to look
> > good, I'll take readability of template code (and performance) over
> > rendered output prettiness.
>
> > Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Really easy DateTimeField question

2008-12-09 Thread DragonSlayre

Thanks a lot !

On Dec 10, 1:24 pm, friggstad <[EMAIL PROTECTED]> wrote:
> It is the human-friendly name used in the 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Too Many Connections

2008-12-09 Thread Eric Abrahamsen


On Dec 10, 2008, at 1:30 AM, DULMANDAKH Sukhbaatar wrote:

>
>>  File
>> "/usr/local/python2.5/lib/python2.5/site-packages/ 
>> MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/__init__.py",
>> line 74, in Connect
>>
>>  File
>> "/usr/local/python2.5/lib/python2.5/site-packages/ 
>> MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/connections.py",
>> line 170, in __init__\nsuper(Connection, self).__init__(*args,
>> **kwargs2)
>>
>> OperationalError: (1040, 'Too many connections')

It's probably worth using django-logging or one of the other 3rd party  
packages to check how many queries your views are executing. The only  
time I ever saw this error was with high load on an extremely  
inefficient view (something like 60 queries in one view), and tweaking  
your use of the ORM can reduce those problems significantly.

Eric



>>
>
> as you can see above, it's mysql problem. mysql server have some
> default limitation on concurrent connections. you can increase
> max_connections in my.cnf. depending on your linux distro my.cnf may
> be located in different places. for me, or on ubuntu it's at
> /etc/mysql/my.cnf, and you need to uncomment the line, and increase
> the value.
>
> by default mysql gets 100 concurrent connections. and the question is
> why is dev site is getting that much connection?
>
>
> -- 
> Regards
> Dulmandakh
>
> >


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



Re: I got 'invalid literal for int() with base 10: 'AA'' error, please help

2008-12-09 Thread Malcolm Tredinnick


On Tue, 2008-12-09 at 16:12 -0800, Chr1s wrote:
> 
> ValueError at /vote/add/
> 
> invalid literal for int() with base 10: 'AA'
> 
> Request Method:   POST
> Request URL:  http://localhost:8000/vote/add/
> Exception Type:   ValueError
> Exception Value:
> 
> invalid literal for int() with base 10: 'AA'

So it sounds like you're trying to save a string into an integer field.
Please show a short fragment of your view code that shows what you are
trying to do that causes this.

Also, when you're pasting a traceback, please, please, please click on
the "switch to cut-and-paste" view link on the debug page and paste that
version. It's a few hundred lines shorter (and, yes, I realise it's not
obvious that that line *is* a link -- it's a bit of a design wart, in my
opinion -- but it  is there).

Regards,
Malcolm



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



referencing the current instance inside limit_choices_to

2008-12-09 Thread GuyBowden

Hi,

I've looked about but can't find the answer to this.

I'd like to set the limit_choices_to value of a ForeignKey field based
on another selection in the current instance.

i.e. - filter the choices based on another field of the same instance.

something like this:

my_fk.limit_choices_to = my_fk.objects.get(Q(type = self.fk_type))

but that fails as self is not defined by then obviously...

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



Re: Really easy DateTimeField question

2008-12-09 Thread friggstad

It is the human-friendly name used in the 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Index page using flatpages

2008-12-09 Thread Nuno Machado

Hi,

I'm using flatpages to display some static content in a site. The
"about" page is working flawlessly (URL = mysite.com/about) but now
I'm trying to define the index (URL = mysite.com) using flatpages.

I'm having troubles defining the URL in the administration panel:

If I put / in the URL field, I need to write "mysite.com//" to get
access to my index page. This is not good for visitors!


Your help is much appreciated.

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



Re: Memory Footprint

2008-12-09 Thread Malcolm Tredinnick


On Tue, 2008-12-09 at 09:10 -0700, Jeff Anderson wrote:
[...]
> I am running memcached, which does seem to help my sites go faster, but
> it isn't helping the memory footprint go down (obviously.)

Although memcached is usually "the answer" to a lot of caching issues,
it does have that obvious requirement of using memory. There's partially
conflicting requirements there -- if your site is so big and heavy that
the only cache that will work is memcached, then you simply can't run it
on a box with insufficient memory. Fact of life. That's the bad news.

The good news is that that's probably not going to be the case. Try
switching to the file cache. You can set a maximum number of objects in
the cache (max_entries) as a form of resource management. I use the file
cache on pointy-stick.com, since it's fairly RAM-limited for all the
things it does (for similar $$$ reasons, I only have one box, and it has
database and webserver on the same machine there, since it's just a play
space) and it certainly helps performance whilst not chewing up any more
RAM than is available.

(Btw, recent experience suggests being Slashdotted isn't what it used to
be, so we need a new euphemism. With the file cache, the box was barely
breathing. I know plenty of sites running Django installations that get
more traffic in 24 hours than Slashdot sent out to me. Although I doubt
I saw the full brunt of the Slashdot effect, it was *very* peaky and the
cache completely did its job.)

Regards,
Malcolm


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



Really easy DateTimeField question

2008-12-09 Thread DragonSlayre

Hi,
I've seen some code with the following in, but can't find what the
string 'date added' is representing in the documentation.

What is the string for?

models.DateTimeField('date added')



Thank you!

I know it's easy, but it'd take me forever to find out.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



I got 'invalid literal for int() with base 10: 'AA'' error, please help

2008-12-09 Thread Chr1s


ValueError at /vote/add/

invalid literal for int() with base 10: 'AA'

Request Method: POST
Request URL:http://localhost:8000/vote/add/
Exception Type: ValueError
Exception Value:

invalid literal for int() with base 10: 'AA'

Exception Location: /usr/lib/python2.5/site-packages/django/db/models/
fields/__init__.py in get_db_prep_value, line 353
Python Executable:  /usr/bin/python
Python Version: 2.5.2
Python Path:['/home/chris/workspace/veryvote', '/usr/lib/
python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/
local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-
packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/
python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/
gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/
site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0', '/
usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
Server time:星期二, 9 十二月 2008 20:53:18 +0800
Traceback Switch to copy-and-paste view

* /usr/lib/python2.5/site-packages/django/core/handlers/base.py in
get_response
79. # Apply view middleware
80. for middleware_method in self._view_middleware:
81. response = middleware_method(request, callback,
callback_args, callback_kwargs)
82. if response:
83. return response
84.
85. try:
86. response = callback(request, *callback_args,
**callback_kwargs) ...
87. except Exception, e:
88. # If the view raised an exception, run it through
exception
89. # middleware, and if the exception middleware returns a
90. # response, use that. Otherwise, reraise the exception.
91. for middleware_method in self._exception_middleware:
92. response = middleware_method(request, e)
  ▶ Local vars
  Variable  Value
  callback
  
  callback_args
  ()
  callback_kwargs
  {'template': 'vote/add.html'}
  e
  ValueError("invalid literal for int() with base 10: 'AA'",)
  exc_info
  (, ValueError("invalid literal for
int() with base 10: 'AA'",), )
  exceptions
  
  middleware_method
  >
  receivers
  [(, None)]
  request
  , POST:, COOKIES:{'sessionid': 'e5e21e8250914db63f93569c0bdb282c'}, META:
{'CLASSPATH': '.:/usr/lib/jvm/java-6-sun/lib', 'COLORTERM': 'gnome-
terminal', 'CONTENT_LENGTH': '308', 'CONTENT_TYPE': 'application/x-www-
form-urlencoded', 'DBUS_SESSION_BUS_ADDRESS': 'unix:abstract=/tmp/dbus-
BPEscXYXhI,guid=c67f4dd4a61cf9ff8b84e559493dedc5', 'DESKTOP_SESSION':
'default', 'DESKTOP_STARTUP_ID': '', 'DISPLAY': ':0.0',
'DJANGO_SETTINGS_MODULE': 'veryvote.settings', 'GATEWAY_INTERFACE':
'CGI/1.1', 'GDMSESSION': 'default', 'GDM_LANG': 'zh_CN.UTF-8',
'GDM_XSERVER_LOCATION': 'local', 'GNOME_DESKTOP_SESSION_ID':
'Default', 'GNOME_KEYRING_PID': '6157', 'GNOME_KEYRING_SOCKET': '/tmp/
keyring-v5G1n2/socket', 'GPG_AGENT_INFO': '/tmp/seahorse-EcHJt8/S.gpg-
agent:6219:1', 'GTK_IM_MODULE': 'scim-bridge', 'GTK_RC_FILES': '/etc/
gtk/gtkrc:/home/chris/.gtkrc-1.2-gnome2', 'HISTCONTROL': 'ignoreboth',
'HOME': '/home/chris', 'HTTP_ACCEPT': 'text/html,application/xhtml
+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'gb2312,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
'HTTP_ACCEPT_LANGUAGE': 'zh-cn,zh;q=0.5', 'HTTP_CACHE_CONTROL': 'max-
age=0', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE':
'sessionid=e5e21e8250914db63f93569c0bdb282c', 'HTTP_HOST': 'localhost:
8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://localhost:
8000/vote/add/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; U; Linux i686;
zh-CN; rv:1.9.0.4) Gecko/2008111317 Ubuntu/8.04 (hardy) Firefox/
3.0.4', 'JAVA_HOME': '/usr/lib/jvm/java-6-sun', 'LANG': 'zh_CN.UTF-8',
'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'LESSOPEN': '| /usr/bin/
lesspipe %s', 'LOGNAME': 'chris', 'LS_COLORS':
'no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.

Re: time it takes django to read database?

2008-12-09 Thread garagefan

haha yeah, i just submitted a ticket to godaddy. They're usually
really good with getting back.

On Dec 9, 6:31 pm, "Colin Bean" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 3:22 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> > ok, server time is 2 hours and 11 minutes behind... this could explain
> > the issue then. The admin section, when creating a new entry takes the
> > time current actual time. So it makes 100% sense that django/python is
> > reading the incorrect time. I've attempted to update the server time
> > using the usual date "time" crap and was told the procedure was not
> > allowed, i assume this is due the server being a virtual server.
>
> > what would the best way to fix this?
>
> Call tech support...
>
> Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time it takes django to read database?

2008-12-09 Thread Colin Bean

On Tue, Dec 9, 2008 at 3:22 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> ok, server time is 2 hours and 11 minutes behind... this could explain
> the issue then. The admin section, when creating a new entry takes the
> time current actual time. So it makes 100% sense that django/python is
> reading the incorrect time. I've attempted to update the server time
> using the usual date "time" crap and was told the procedure was not
> allowed, i assume this is due the server being a virtual server.
>
> what would the best way to fix this?
>

Call tech support...

Colin

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



Re: time it takes django to read database?

2008-12-09 Thread garagefan

ok, server time is 2 hours and 11 minutes behind... this could explain
the issue then. The admin section, when creating a new entry takes the
time current actual time. So it makes 100% sense that django/python is
reading the incorrect time. I've attempted to update the server time
using the usual date "time" crap and was told the procedure was not
allowed, i assume this is due the server being a virtual server.

what would the best way to fix this?

the detail.html does not use latest however

On Dec 9, 4:40 pm, garagefan <[EMAIL PROTECTED]> wrote:
> awesome, i will take a look at the server date. It is possible that it
> is off.
>
> On Dec 9, 3:57 pm, "Colin Bean" <[EMAIL PROTECTED]> wrote:
>
> > On Tue, Dec 9, 2008 at 12:16 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> > > Server is Red Hat 7, set up by godaddy, its a virtual server. Python
> > > 2.5 w/ mod_python and python-devel installed. running latest django.
>
> > > I am using webmonkey.com's tutorial for this:
> > >http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First...
>
> > > so you can find the blog app as well as the templates in there. The
> > > part that is working instantly is the "secondary" section located in
> > > the base.html template that the other two blog templates extend
>
> > > thanks for lookin
>
> > Ah, didn't realize that it was showing one part of the page and not
> > another.  Looks like the template tag in the "secondary" section
> > queries all of the blog post objects, while the main section uses the
> > "latest" variable from django.views.generic.date_based.archive_index.
> > According to the docs, "Objects with a date in the future are not
> > included (in latest) unless you set allow_future to True."
>
> >http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-...
>
> > Any chance the dates on your posts are set to the future?  Is the date
> > set correctly on your server?
>
> > Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using random.random() while running on server

2008-12-09 Thread Chris

Thanks Daniel Roseman That did the trick. I did not think to do a
lambda

> I _very_ strongly suggest you take some time learning Python. In this
> case, the parens are actually the call operator. Not applying this
> operator results in getting a reference to the function (or whatever
> callable).

bruno desthuilliers - Yes I understand that! I _very_ strongly suggest
that you read up on the issue with datetime as to why you pass it in
that way when passing it through something like so:

date = models.DateTimeField(default=datetime.datetime.now)

Thanks for the effort though!

And thanks for all your responses.

Cheers!



bruno desthuilliers

On Dec 9, 1:25 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
> Also, as an aside to all of that--what you're generating is in no way
> guaranteed to be unique.  If you really need a unique string, use a
> UUID or hash of the primary key.
>
> On Dec 9, 3:48 pm, bruno desthuilliers <[EMAIL PROTECTED]>
> wrote:
>
> > On 9 déc, 11:32, Chris <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
> > > when django is running on a server, I want to make a call to:
> > > random.random().  When I make a call to this again, I can't. I think
> > > this related to a similar issue datetime.datetime.now() where you
> > > leave off the () to get a current date each time each time you call
> > > it.
>
> > I _very_ strongly suggest you take some time learning Python. In this
> > case, the parens are actually the call operator. Not applying this
> > operator results in getting a reference to the function (or whatever
> > callable).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom distinct() method

2008-12-09 Thread Russell Keith-Magee

On Tue, Dec 9, 2008 at 7:05 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> please, maybe anyone now how to perform distinct() filtering for
> certain attribute(column), not the whole objects(rows)? :)

First off - patience. Only 10 hours passed between your original
request and your repeat. This is an international mailing list, we're
spread all over the globe, and we're all volunteers. Sometimes is may
take a day for someone to find the time to help you. If you need a
more immediate response, consider trying in the IRC channel.

> In case not - please tell me what's the best practice when coming to a
> situation when django orm is not powerfull enough. Can writting custom
> sql queries become a serious problem later on? i could, of course,
> write a custom SQL query and get the result as tuples, but that's only
> for representation of data, manipulation gets realy tricky, as you
> can't refer to the given data as the objects of django. And there is
> that feeling that after the first custom sql query, 10 more new will
> be neccessary later on and you may end up writting all the webapp the
> good-old SQLObject way.

The Django ORM is good for writing the very common query types.
However, if you can't bend the ORM to do what you need, raw SQL is
always an option. Will this become a maintenance hassle? Maintaining
non-ORM code is always going to be a little bit of a hassle, but if
the alternative is not finishing a project because your code doesn't
meet your requirements...

If the issue is converting SQL cursor data into Django objects -
that's trivial - just take the row of data from the cursor and use it
to instantiate an object instance:

cursor = self.connection.cursor()
cursor.execute(sql, params)
row = cursor.fetchone()[:-len(results.ordering_aliases)]
newobject = MyObject(*row)

Regarding your specific problem - I think the first step is to clarify
in your own mind what it is that you want. Your example doesn't match
up with the code you are giving. You say that the Django ORM doesn't
do what you want, but the SQL sample you give:

SELECT DISTINCT column1, column2 FROM table WHERE column1='name';

is exactly what is produced by the query:

Table.objects.filter(column='name').distinct()

If you don't believe me,

print Table.objects.filter(column='name').distinct().query

will tell you what is going to be executed by the cursor. It sounds
like the first step in your case is to work out what SQL you want.
Once you have that worked out, we can tell you your options with the
Django ORM.

Yours,
Russ Magee %-)

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



Re: Django Training

2008-12-09 Thread Jane

I think it would be good to ask students how they plan to use django.
For myself, we'd like to deploy databases on a web page, and I'm
interested to learn how much of that can be done in python and django,
then what do you add to make the database look pretty for outside
users.

On Dec 8, 11:06 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> I am looking at expanding our training offerings for the coming year,
> and a short course in Django looks like it might be popular. There
> don't seem to be many Django classes at the moment, and several of the
> students from our introductory Python classes expressed interest in
> Django.
>
> Without wanting anyone on the list to do my work for me, it would be
> useful to see some opinions about what to include. The tutorial gives
> people a good start: should we assume that anyone who wants to take
> the class has already run through that, or would it be better to start
> from scratch?
>
> Django is such a rich platform it would be possible to write several
> classes: what material do readers regard as the "essentials of
> Django", and what should be relegated to more advanced classes? What
> can I do to put a compelling introductory class together?
>
> regards
>  Steve

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



Re: time it takes django to read database?

2008-12-09 Thread garagefan

awesome, i will take a look at the server date. It is possible that it
is off.

On Dec 9, 3:57 pm, "Colin Bean" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 12:16 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> > Server is Red Hat 7, set up by godaddy, its a virtual server. Python
> > 2.5 w/ mod_python and python-devel installed. running latest django.
>
> > I am using webmonkey.com's tutorial for this:
> >http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First...
>
> > so you can find the blog app as well as the templates in there. The
> > part that is working instantly is the "secondary" section located in
> > the base.html template that the other two blog templates extend
>
> > thanks for lookin
>
> Ah, didn't realize that it was showing one part of the page and not
> another.  Looks like the template tag in the "secondary" section
> queries all of the blog post objects, while the main section uses the
> "latest" variable from django.views.generic.date_based.archive_index.
> According to the docs, "Objects with a date in the future are not
> included (in latest) unless you set allow_future to True."
>
> http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-...
>
> Any chance the dates on your posts are set to the future?  Is the date
> set correctly on your server?
>
> Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread prem1er

w00t.  Thanks.  After a bunch more import statements I finally got it
working. Thanks again!!!

On Dec 9, 4:22 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Dec 9, 9:12 pm, prem1er <[EMAIL PROTECTED]> wrote:
>
> > Still no luck. I have this line added to the top of views.py.
>
> > from xxx.register.forms import ContactForm
>
> > It can't seem to find forms 'No module named forms'.
>
> Sorry, I misread your original post. For some reason you have put your
> form in your models.py, so that's what you'll need to import - ie
> from whatever.register.models import ContactForm
>
> I would however recommend keeping your forms in a forms.py file,
> separate from your models.
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using random.random() while running on server

2008-12-09 Thread Jeff FW

Also, as an aside to all of that--what you're generating is in no way
guaranteed to be unique.  If you really need a unique string, use a
UUID or hash of the primary key.

On Dec 9, 3:48 pm, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 9 déc, 11:32, Chris <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > when django is running on a server, I want to make a call to:
> > random.random().  When I make a call to this again, I can't. I think
> > this related to a similar issue datetime.datetime.now() where you
> > leave off the () to get a current date each time each time you call
> > it.
>
> I _very_ strongly suggest you take some time learning Python. In this
> case, the parens are actually the call operator. Not applying this
> operator results in getting a reference to the function (or whatever
> callable).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread Daniel Roseman

On Dec 9, 9:12 pm, prem1er <[EMAIL PROTECTED]> wrote:
> Still no luck. I have this line added to the top of views.py.
>
> from xxx.register.forms import ContactForm
>
> It can't seem to find forms 'No module named forms'.
>

Sorry, I misread your original post. For some reason you have put your
form in your models.py, so that's what you'll need to import - ie
from whatever.register.models import ContactForm

I would however recommend keeping your forms in a forms.py file,
separate from your models.
--
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin caching querysets

2008-12-09 Thread lingrlongr

Thanks Karen.

I removed the custom form from admin.py and added a constructor to the
model:

def __init__(self, *args, **kwargs):
  super(BannerImage, self).__init__(*args, **kwargs)
  self._meta.get_field('url')._choices = get_urls()

It seems to work now.

Keith

On Dec 9, 2:52 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 1:58 PM, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > I have a function called get_urls that returns a list of absolute_urls
> > for various models in the same project.  This function is used for
> > another model in a way so that when a particular model appears on the
> > site, I can choose which part of the site this model links to.
>
> > # utils.py
> > def get_urls():
> >  urls = []
> >  for flatpage in FlatPage.objects.order_by('title')
> >    urls.append(flatpage.url, '%s: %s' % ('Flatpage',
> > flatpage.title),))
> >  return urls
>
> > There are more objects, this is just a sample with the well-known
> > FlatPage model.
>
> > The particular model I use this with looks like this:
>
> > # models.py
> > from utils import get_urls
> > class BannerImage(models.Model):
> >  image = models.ImageField(etc)
> >  url = models.CharField(max_length=100, choices=get_urls())
> >  etc...
>
> Here you have put your call to get_urls() in code that is executed only when
> the class is defined, not each time the class is instantiated.  You probably
> want to read the last paragraph of the description of choices here:
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#choices
>
> > So it turned out that the admin seemed to be caching the choices.  So,
> > if I added a new flatpage, it would not be listed there until I
> > restarted the webserver.  So instead of referring to
> > Flatpage.objects.etc... directly in get_urls, I made a function that
> > returns the queryset instead:
>
> Admin was not caching anything, it is Python that only executes the code
> once given where it had been placed.
>
> > # utils.py
> > def get_flatpages():
> >  return FlatPage.objects.order_by('title')
>
> > Problem still seemed to exist.  I tried making a custom ModelForm in
> > admin.py for this BannerImage model:
>
> > # admin.py
> > from utils import get_urls
> > class BannerImageForm(forms.ModelForm):
> >  url = forms.ChoiceField(choices=get_urls())
> >  class Meta:
> >    model = BannerImage
>
> Here you have still put the determination of choices into code that is only
> executed when the class (this time the form class) is defined.  You could
> fix it for the form case by moving the setting of choices into an __init__
> routine for the form.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Memory Footprint

2008-12-09 Thread Graham Dumpleton



On Dec 10, 3:10 am, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> Hello,
>
> First, I'm gonna say that I have DEBUG turned off, and it's not Django's
> fault.
>
> My Django sites seem to eat lots of memory. This is fine, and it isn't a
> huge deal except that I am using all of my VPS's memory plus swap. The
> real solution is to upgrade memory on the VPS, but I'm a poor college
> student so I want to reduce the memory footprint any way I can. I'm
> using mod_python and apache.
>
> I've seen discussion about mod_python specifically where it was
> suggested to set large variables to None when you're done with them.
> Django does most of the grunt work, and my views don't seem to load any
> very large variables. It seems like any variables instantiated by my
> views would go out of scope after the view function has returned, and
> the Python garbage collection will show up.
>
> I'm curious to know if anyone has ever tried to optimize their code to
> reduce the overall memory footprint. I haven't found any blog posts
> about it yet. I'm willing to resort to making my Django code as
> non-persistent as possible. My sites are all low traffic, so
> non-persistent processes plus memcached shouldn't be too terrible, even
> if I get slashdotted. I just need to squeeze out as much as I can out of
> the ram I have. Swapping makes the Django requests painfully slow.
>
> I am running memcached, which does seem to help my sites go faster, but
> it isn't helping the memory footprint go down (obviously.) I'm also
> considering switching to lighttpd. I've read it has a smaller footprint
> than apache. I've also read that mod_wsgi performs better than mod_python.
>
> Please let me know if you have any other ideas! I'm also curious to know
> if anyone thinks that one of the things I mention trying would help or
> hurt. Thanks!

Definitely stop using mod_python and use mod_wsgi instead. When using
mod_wsgi ensure you use daemon mode with single multithreaded process.
Set maximum-requests and inactivity-timeout for daemon process to
ensure that process is recycled to reclaim memory every so often or
when idle. Also ensure that Apache uses worker MPM and not prefork
MPM. Limit maximum number of Apache child processes to 2 with about 25
threads each. The default of one mod_wsgi daemon process with 15
threads would be adequate.

If you want to get even more aggressive about it, add nginx in front
of Apache as proxy and have nginx serve static files, also turn keep
alive off in Apache. This will make static file serving better and
ensure that Apache doesn't hold connections and unnecessarily use
memory doing that.

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



Re: 'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread prem1er

Still no luck. I have this line added to the top of views.py.

from xxx.register.forms import ContactForm

It can't seem to find forms 'No module named forms'.


On Dec 9, 3:45 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Dec 9, 8:43 pm, prem1er <[EMAIL PROTECTED]> wrote:
>
> > Thank you. That cleared that up. Now getting the error. "global name
> > 'ContactForm' is not defined" in my 'views.py' file.  Any ideas?
>
> Well, as with all Python code, if you define an object in one file and
> refer to it in another, you have to import it. So at the top of your
> views.py you'll need something like:
> from xxx.forms import ContactForm
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time it takes django to read database?

2008-12-09 Thread Jay Parlar

On Tue, Dec 9, 2008 at 3:57 PM, Colin Bean <[EMAIL PROTECTED]> wrote:
> Ah, didn't realize that it was showing one part of the page and not
> another.  Looks like the template tag in the "secondary" section
> queries all of the blog post objects, while the main section uses the
> "latest" variable from django.views.generic.date_based.archive_index.
> According to the docs, "Objects with a date in the future are not
> included (in latest) unless you set allow_future to True."
>
> http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-index
>
> Any chance the dates on your posts are set to the future?  Is the date
> set correctly on your server?


Those were my thoughts as well. Depending on how the date gets set
when storing an item in the database, and what date/time gets used
when pulling it from the db, you could run into issues here. Try
passing allow_future=True in with the other arguments to the dict()

Jay P.

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



m2m relationship

2008-12-09 Thread Lavoie Francis

Hi,

I have a question regarding m2m relationship.

I've created I table that contain product and has a manytomany  
relationship with an other table that stores images. I would like to  
add the image in the product admin form. I don't want to see all the  
images in the product table, but just those that belongs to the  
current product item. Is that possible?

Thank you

Francis


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



Re: time it takes django to read database?

2008-12-09 Thread Colin Bean

On Tue, Dec 9, 2008 at 12:16 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> Server is Red Hat 7, set up by godaddy, its a virtual server. Python
> 2.5 w/ mod_python and python-devel installed. running latest django.
>
> I am using webmonkey.com's tutorial for this:
> http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First_App
>
> so you can find the blog app as well as the templates in there. The
> part that is working instantly is the "secondary" section located in
> the base.html template that the other two blog templates extend
>
> thanks for lookin
>

Ah, didn't realize that it was showing one part of the page and not
another.  Looks like the template tag in the "secondary" section
queries all of the blog post objects, while the main section uses the
"latest" variable from django.views.generic.date_based.archive_index.
According to the docs, "Objects with a date in the future are not
included (in latest) unless you set allow_future to True."

http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-index

Any chance the dates on your posts are set to the future?  Is the date
set correctly on your server?

Colin

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



Re: Using random.random() while running on server

2008-12-09 Thread bruno desthuilliers

On 9 déc, 11:32, Chris <[EMAIL PROTECTED]> wrote:
> Hello,
> when django is running on a server, I want to make a call to:
> random.random().  When I make a call to this again, I can't. I think
> this related to a similar issue datetime.datetime.now() where you
> leave off the () to get a current date each time each time you call
> it.

I _very_ strongly suggest you take some time learning Python. In this
case, the parens are actually the call operator. Not applying this
operator results in getting a reference to the function (or whatever
callable).


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



Re: 'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread Daniel Roseman

On Dec 9, 8:43 pm, prem1er <[EMAIL PROTECTED]> wrote:
> Thank you. That cleared that up. Now getting the error. "global name
> 'ContactForm' is not defined" in my 'views.py' file.  Any ideas?
>

Well, as with all Python code, if you define an object in one file and
refer to it in another, you have to import it. So at the top of your
views.py you'll need something like:
from xxx.forms import ContactForm

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



Re: Using random.random() while running on server

2008-12-09 Thread Daniel Roseman

On Dec 9, 7:34 pm, Chris <[EMAIL PROTECTED]> wrote:
> Here is a code snippet:http://dpaste.com/97475/so basically when I
> login to the backend and try to add a couple rows. I get the same
> random id each time.

As you might realise, what's happening is that Django is evaluating
your call to make_random_password at startup time, and using the
result as the value every time. The easy way round this is to make it
into a lambda:

default=lambda: make_random_password(ID_FIELD_LENGTH)

This just turns it into an inline function that is called each time.
--
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread prem1er

Thank you. That cleared that up. Now getting the error. "global name
'ContactForm' is not defined" in my 'views.py' file.  Any ideas?

On Dec 9, 3:35 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Dec 9, 8:23 pm, prem1er <[EMAIL PROTECTED]> wrote:
>
> > Trying to follow along with the Form Tutorial on the Django site and
> > I'm running into a problem.  I keep getting the error page 'module'
> > object has not attribute 'ContactForm', when I just simply copy and
> > pasted the code from the tutorial into my models.py.  Here is my
> > source.  I feel like it has something to do with my urls.py since I'm
> > trying to use the template system.
> > 
> > Models.py
>
> > from django import forms
>
> > class ContactForm(forms.Form):
> >     subject = forms.CharField(max_length=100)
> >     message = forms.CharField()
> >     sender = forms.EmailField()
> >     cc_myself = forms.BooleanField(required=False)
> > 
> > urls.py
>
> > from django.conf.urls.defaults import *
> > from xxx django.contrib import admin
>
> > # Uncomment the next two lines to enable the admin:
> > #admin.autodiscover()
>
> > urlpatterns = patterns('xxx.register.views',
> >     (r'^$', 'ContactForm'),
>
> >     # Uncomment the next line to enable the admin:
> >     #(r'^admin/(.*)', admin.site.root),
>
> >     # Uncomment the admin/doc line below and add
> > 'django.contrib.admindocs'
> >     # to INSTALLED_APPS to enable admin documentation:
> >     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> > )
> > 
> > views.py
>
> > def contact(request):
>
> 
>
> You're right in thinking the problem is in your urls.py. It's here:
>     urlpatterns = patterns('xxx.register.views',
>         (r'^$', 'ContactForm'),
>
> This is looking in the views.py for a view called 'ContactForm'. But
> your view isn't called that, it's called 'contact', so that's what you
> should put in the second line above.
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread Daniel Roseman

On Dec 9, 8:23 pm, prem1er <[EMAIL PROTECTED]> wrote:
> Trying to follow along with the Form Tutorial on the Django site and
> I'm running into a problem.  I keep getting the error page 'module'
> object has not attribute 'ContactForm', when I just simply copy and
> pasted the code from the tutorial into my models.py.  Here is my
> source.  I feel like it has something to do with my urls.py since I'm
> trying to use the template system.
> 
> Models.py
>
> from django import forms
>
> class ContactForm(forms.Form):
>     subject = forms.CharField(max_length=100)
>     message = forms.CharField()
>     sender = forms.EmailField()
>     cc_myself = forms.BooleanField(required=False)
> 
> urls.py
>
> from django.conf.urls.defaults import *
> from xxx django.contrib import admin
>
> # Uncomment the next two lines to enable the admin:
> #admin.autodiscover()
>
> urlpatterns = patterns('xxx.register.views',
>     (r'^$', 'ContactForm'),
>
>     # Uncomment the next line to enable the admin:
>     #(r'^admin/(.*)', admin.site.root),
>
>     # Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
>     # to INSTALLED_APPS to enable admin documentation:
>     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> )
> 
> views.py
>
> def contact(request):


You're right in thinking the problem is in your urls.py. It's here:
urlpatterns = patterns('xxx.register.views',
(r'^$', 'ContactForm'),

This is looking in the views.py for a view called 'ContactForm'. But
your view isn't called that, it's called 'contact', so that's what you
should put in the second line above.

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



Django developers in Johannesburg/Pretoria, South Africa for collaboration

2008-12-09 Thread eldonp2

I'm looking for someone in the Johannesburg/Pretoria area who is
willing to collaborate with me on some aspects of a Django app. I have
done quite alot of work on getting the business logic right, but need
some guidance on many of the technical aspects. Anyone available, and
willing to assist?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



'module' object has no attribute 'ContactForm' (view does not exist)

2008-12-09 Thread prem1er

Trying to follow along with the Form Tutorial on the Django site and
I'm running into a problem.  I keep getting the error page 'module'
object has not attribute 'ContactForm', when I just simply copy and
pasted the code from the tutorial into my models.py.  Here is my
source.  I feel like it has something to do with my urls.py since I'm
trying to use the template system.

Models.py

from django import forms

class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)

urls.py

from django.conf.urls.defaults import *
from xxx django.contrib import admin

# Uncomment the next two lines to enable the admin:
#admin.autodiscover()

urlpatterns = patterns('xxx.register.views',
(r'^$', 'ContactForm'),

# Uncomment the next line to enable the admin:
#(r'^admin/(.*)', admin.site.root),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

)

views.py

def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST
data
if form.is_valid(): # All validation rules pass

subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
sender = form.cleaned_data['sender']
cc_myself = form.cleaned_data['cc_myself']

recipients = ['[EMAIL PROTECTED]']

if cc_myself:
recipients.append(sender)

from django.core.mail import send_mail
send_mail(subject, message, sender, recipients)
return HttpResponseRedirect('/thanks/')

else:
form = ContactForm()

return render_to_response('contact.html', {'form': form,})




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



Re: time it takes django to read database?

2008-12-09 Thread garagefan

Server is Red Hat 7, set up by godaddy, its a virtual server. Python
2.5 w/ mod_python and python-devel installed. running latest django.

I am using webmonkey.com's tutorial for this:
http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First_App

so you can find the blog app as well as the templates in there. The
part that is working instantly is the "secondary" section located in
the base.html template that the other two blog templates extend

thanks for lookin

On Dec 9, 2:58 pm, "Colin Bean" <[EMAIL PROTECTED]> wrote:
> On Sun, Dec 7, 2008 at 7:32 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> > following another tutorial to build a blog (webmonkey.com's) at it was
> > rather frustrating to see nothing show up after creating a new blog...
>
> > the admin section seems to see these right away, as they are there as
> > soon as you hit save. But it seems to take the one section 10-20(or
> > more?) minutes to read that they are there, while another section on
> > the same page (that lists the items by title) no time at all. though
> > when I update something that is listed already in the main section
> > (the area that takes a while to get new info) it gets updated
> > immediately... such as the title or entry
>
> >http://kennethdavid.net/mysite/blog/
>
> > most likely if you look within 5-10 minutes you'll see how there are
> > three entry titles, and two blogs... i'll go ahead and add another
> > entry, so at the very least there will be 4 titles and three available
> > entries...
>
> > what would possibly cause this?
>
> Also, what kind of server setup are you using?  Can you reproduce this
> issue on a local development server?
>
> Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time it takes django to read database?

2008-12-09 Thread Colin Bean

On Sun, Dec 7, 2008 at 7:32 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> following another tutorial to build a blog (webmonkey.com's) at it was
> rather frustrating to see nothing show up after creating a new blog...
>
> the admin section seems to see these right away, as they are there as
> soon as you hit save. But it seems to take the one section 10-20(or
> more?) minutes to read that they are there, while another section on
> the same page (that lists the items by title) no time at all. though
> when I update something that is listed already in the main section
> (the area that takes a while to get new info) it gets updated
> immediately... such as the title or entry
>
> http://kennethdavid.net/mysite/blog/
>
> most likely if you look within 5-10 minutes you'll see how there are
> three entry titles, and two blogs... i'll go ahead and add another
> entry, so at the very least there will be 4 titles and three available
> entries...
>
> what would possibly cause this?
> >
>

Also, what kind of server setup are you using?  Can you reproduce this
issue on a local development server?

Colin

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



Re: admin caching querysets

2008-12-09 Thread Karen Tracey
On Tue, Dec 9, 2008 at 1:58 PM, lingrlongr <[EMAIL PROTECTED]> wrote:

>
> I have a function called get_urls that returns a list of absolute_urls
> for various models in the same project.  This function is used for
> another model in a way so that when a particular model appears on the
> site, I can choose which part of the site this model links to.
>
> # utils.py
> def get_urls():
>  urls = []
>  for flatpage in FlatPage.objects.order_by('title')
>urls.append(flatpage.url, '%s: %s' % ('Flatpage',
> flatpage.title),))
>  return urls
>
> There are more objects, this is just a sample with the well-known
> FlatPage model.
>
> The particular model I use this with looks like this:
>
> # models.py
> from utils import get_urls
> class BannerImage(models.Model):
>  image = models.ImageField(etc)
>  url = models.CharField(max_length=100, choices=get_urls())
>  etc...
>

Here you have put your call to get_urls() in code that is executed only when
the class is defined, not each time the class is instantiated.  You probably
want to read the last paragraph of the description of choices here:

http://docs.djangoproject.com/en/dev/ref/models/fields/#choices


> So it turned out that the admin seemed to be caching the choices.  So,
> if I added a new flatpage, it would not be listed there until I
> restarted the webserver.  So instead of referring to
> Flatpage.objects.etc... directly in get_urls, I made a function that
> returns the queryset instead:
>

Admin was not caching anything, it is Python that only executes the code
once given where it had been placed.


> # utils.py
> def get_flatpages():
>  return FlatPage.objects.order_by('title')
>
> Problem still seemed to exist.  I tried making a custom ModelForm in
> admin.py for this BannerImage model:
>
> # admin.py
> from utils import get_urls
> class BannerImageForm(forms.ModelForm):
>  url = forms.ChoiceField(choices=get_urls())
>  class Meta:
>model = BannerImage
>

Here you have still put the determination of choices into code that is only
executed when the class (this time the form class) is defined.  You could
fix it for the form case by moving the setting of choices into an __init__
routine for the form.

Karen

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



Re: time it takes django to read database?

2008-12-09 Thread Jay Parlar

On Tue, Dec 9, 2008 at 9:33 AM, garagefan <[EMAIL PROTECTED]> wrote:
>
> sure thing:
>
> from django.conf.urls.defaults import *
> from mysite.blog.models import Entry
> from tagging.views import tagged_object_list
>
> info_dict = {
>'queryset': Entry.objects.filter(status=1),
>'date_field': 'pub_date',
> }
>
> urlpatterns = patterns('django.views.generic.date_based',
>(r'(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
> P[-\w]+)/$', 'object_detail', dict(info_dict,
> slug_field='slug',template_name='blog/detail.html')),
>(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
> P[-\w]+)/$', 'object_detail', dict(info_dict,
> template_name='blog/list.html')),
>(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/
> $','archive_day',dict(info_dict,template_name='blog/list.html')),
>(r'^(?P\d{4})/(?P[a-z]{3})/$','archive_month',
> dict(info_dict, template_name='blog/list.html')),
>(r'^(?P\d{4})/$','archive_year', dict(info_dict,
> template_name='blog/list.html')),
>(r'^$','archive_index', dict(info_dict, template_name='blog/
> list.html')),
> )


Sorry, the problem I suspected isn't there, so I'm not sure what's going on.

Know this though: It's not a problem with Django, esp. since the items
are showing up instantaneously in some places. It just sounds like a
problem in your code.

Could you show the template section that takes such a long time?

Jay P.

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



Using decorators like login_required with FormPreview

2008-12-09 Thread jb0t

Recently, I tried to add multiple decorators to FormPreview
http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-preview/


The only documented examples of how to accomplish this I could find
were here...
http://scompt.com/archives/2007/11/07/using-djangos-formpreview-with-login_required

The 3rd example is the cleanest and would be ideal.  However, using
trunk at rev 9550, I presumed that something had changed in the year
since the post because this no longer worked.  The FormPreview source
warns about overriding its methods, but in my case I had to do so.  In
doing that, I was able to use this approach to accomplish what I
needed to get done.  So I submit this example in both the hope that
someone else finds it useful, and also so if someone else has a
cleaner example of how to accomplish the same task I can benefit from
it.


class OrgEmailM2FormPreview(FormPreview):
form_template = 'groups/email_group.html'
preview_template = 'groups/email_group_preview.html'
temp_data = {}

def parse_params(self, *args, **kwargs):
...
...

def preview_get(self, request):

# this is a hack to get a permissions check inside this class
@login_required
@has_org_permission({'manage_member_write':True,})
@session_org_selected
def perm_check_here(request):
pass
response = perm_check_here(request)
if response != None:
return response

return render_to_response(self.form_template,

#

in my case, i have some custom permission checking done with a
decorator that bounces you to another location in the event you fail
the check.   i realized right away that using a lambda could reduce
this code a bit.  the verbosity of the rest of it is primarily for
readability.

anyway, hope someone finds it useful.  since i could not find much in
the way of examples on the topic out there, it seemed like i should do
my part and make a post.  thanks.. and I love Django!

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



Re: Using random.random() while running on server

2008-12-09 Thread Chris

Here is a code snippet: http://dpaste.com/97475/ so basically when I
login to the backend and try to add a couple rows. I get the same
random id each time.

On Dec 9, 10:27 am, Jeff FW <[EMAIL PROTECTED]> wrote:
> Can you show me exactly what you're trying to do?  That would make it
> much easier to help you.
>
> -Jeff
>
> On Dec 9, 1:19 pm, Chris <[EMAIL PROTECTED]> wrote:
>
> > I found this snippet:http://www.djangosnippets.org/snippets/814/and
> > noticed that it does not work as intended do to the issue that I
> > described. I tried passing it as default instead of using the save
> > method but does not work and since I am not passing random to default
> > directly, I cannot do this default=random.random. Any Ideas how I can
> > fix this? thanks.
>
> > On Dec 9, 6:00 am, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > > Chris,
>
> > > It depends on where you're calling random.random().  If you're trying
> > > to do it in a model definition, then you're always going to have the
> > > value it chose when it first executed the model's class definition--
> > > when the server starts up.  In that case, you should be able to pass
> > > an argument of default=random.random in the definition.  If it's
> > > somewhere else you're trying to call it, let us know.
>
> > > -Jeff
>
> > > On Dec 9, 5:32 am, Chris <[EMAIL PROTECTED]> wrote:
>
> > > > Hello,
> > > > when django is running on a server, I want to make a call to:
> > > > random.random().  When I make a call to this again, I can't. I think
> > > > this related to a similar issue datetime.datetime.now() where you
> > > > leave off the () to get a current date each time each time you call
> > > > it. If you dont do that, datetime.datetime.now() will give you the
> > > > date to which the server was instantiated instead of current
> > > > datetime.
>
> > > > Is there a similar way that I can do this for random so that I can get
> > > > a new number each time I call this instead of the number that it
> > > > created when the server was instantiated?
>
> > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Excel Generating Report

2008-12-09 Thread garces.85

Hello,

Sorry thats not the real template, it's this one:

{% for d in data %}

   {{ d.pregunta.id }}
  {{ d.pregunta.descripcion_pregunta}}
   {{ d.respuesta }}
   {{ 
d.pregunta.tipo_pregunta.nombre_tipo }}
{% ifequal forloop.counter 3 %}
 
{% endifequal %}


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



Re: Excel Generating Report

2008-12-09 Thread garces.85

Hello,

This is my template(actually is only the part where the for cycle
returns the results i need):

{% for r in rendicion %}




{{forloop.counter}}
{{r.comuna.nom_comuna|upper}}

{{r.comuna.region.nom_region}}

{{r.estado_rendicion.nombre_estado}}


{% endfor %}

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



Re: missing admin documentation

2008-12-09 Thread aparajita

> Right in your urls.py there should be commented out lines that's
> specifically tells you what to do to get the docs working. Once you do
> that then you will see the link.

Doh! I had deleted all that. Thanks, that did the trick (along with
adding admindocs to INSTALLED_APPS).

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



admin caching querysets

2008-12-09 Thread lingrlongr

I have a function called get_urls that returns a list of absolute_urls
for various models in the same project.  This function is used for
another model in a way so that when a particular model appears on the
site, I can choose which part of the site this model links to.

# utils.py
def get_urls():
  urls = []
  for flatpage in FlatPage.objects.order_by('title')
urls.append(flatpage.url, '%s: %s' % ('Flatpage',
flatpage.title),))
  return urls

There are more objects, this is just a sample with the well-known
FlatPage model.

The particular model I use this with looks like this:

# models.py
from utils import get_urls
class BannerImage(models.Model):
  image = models.ImageField(etc)
  url = models.CharField(max_length=100, choices=get_urls())
  etc...

So it turned out that the admin seemed to be caching the choices.  So,
if I added a new flatpage, it would not be listed there until I
restarted the webserver.  So instead of referring to
Flatpage.objects.etc... directly in get_urls, I made a function that
returns the queryset instead:

# utils.py
def get_flatpages():
  return FlatPage.objects.order_by('title')

Problem still seemed to exist.  I tried making a custom ModelForm in
admin.py for this BannerImage model:

# admin.py
from utils import get_urls
class BannerImageForm(forms.ModelForm):
  url = forms.ChoiceField(choices=get_urls())
  class Meta:
model = BannerImage

  ...etc...

I tested with the Python shell to see if the get_urls function returns
an updated list after a new object and it does.  Its just the admin
that seems to have the problem.  Is there any way I can get this to
work?

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



Re: OperationalError -- Table has no column named ..

2008-12-09 Thread djan

Thanks so much for the help! I deleted the database, made the changes
you suggested and ran syncdb again. I have two lingering issues.

1) At the django admin interface, I still only see a place to enter
data for 'Artist', and none of the tables that follow it in models.py
appear (the updated version appears below).

2) I was able to enter data into all the fields of 'Artist' table
without a problem--except for the image field.
SuspiciousOperation at /admin/archive/artist/1/
Attempted access to '/tmp/statement/headshot.jpg' denied.

Request Method: POST
Request URL:http://127.0.0.1:8000/admin/archive/artist/1/
Exception Type: SuspiciousOperation
Exception Value:Attempted access to '/tmp/statement/headshot.jpg'
denied.

I think I remember reading that it could have something to do with a
missing (or present, in this case) '/' before the upload_to argument.
I will look into that.from django.db import models

class Artist(models.Model):
salutation = models.CharField(max_length=10, blank=True)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
address = models.CharField(max_length=30, blank=True)
city = models.CharField(max_length=60, blank=True)
country = models.CharField(max_length=50, blank=True)
phone = models.CharField(max_length=13, blank=True)
email = models.EmailField(blank=True)
website = models.URLField(blank=True)
headshot = models.ImageField(upload_to='/tmp/statement',
blank=True)
statement = models.TextField(blank=True)

def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)

class Gallery(models.Model):
name = models.CharField(max_length=40)
address = models.CharField(max_length=30, blank=True)
city = models.CharField(max_length=60, blank=True)
country = models.CharField(max_length=50, blank=True)
phone = models.CharField(max_length=13, blank=True)
email = models.EmailField(blank=True)
website = models.URLField(blank=True)

def __unicode__(self):
return u'%s' % (self.name)

class Images(models.Model):
artist = models.ForeignKey(Artist)
gallery = models.ForeignKey(Gallery, blank=True)
file = models.ImageField(upload_to='/tmp/images')
title = models.CharField(max_length=50)
date = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.title, self.date)

class Videos(models.Model):
artist = models.ForeignKey(Artist)
gallery = models.ForeignKey(Gallery, blank=True)
file = models.FileField(upload_to='/tmp/videos')
title = models.CharField(max_length=50)
date = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.title, self.date)

class Sale_Item(models.Model):
artist = models.ForeignKey(Artist)
images = models.ManyToManyField(Images, blank=True)
videos = models.ManyToManyField(Videos, blank=True)
price = models.CharField(max_length=10)

def __unicode__(self):
return u'%s' % (self.price)

class On_Loan(models.Model):
artist = models.ForeignKey(Artist)
images = models.ManyToManyField(Images, blank=True)
videos = models.ManyToManyField(Videos, blank=True)
location = models.ForeignKey(Gallery)
expiry = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.location, self.expiry)








On Dec 9, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Dec 9, 5:02 am,djan<[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > I'm running OpenSuSE-11.0 with the lastest version of django and
> > sqlite3.
> > When I enter the admin interface to enter data into my database, I got
> > the error:
>
> > OperationalError at /admin/archive/artist/add/
>
> > table archive_artist has no column named salutation
>
> > Request Method:         POST
> > Request URL:    http://127.0.0.1:8000/admin/archive/artist/add/
> > Exception Type:         OperationalError
> > Exception Value:        table archive_artist has no column named salutation
>
> > This error is for the first field of the first table, so I suspect
> > there is a deeper issue. Perhaps related to this, when I enter the
> > admin interface, I only see a way to enter records for "Artist", and
> > not any of the other tables I described below (i.e. "Images",
> > "Gallery", "On_Loan"). I'm new to database design; perhaps the
> > relations are off? My models.py looks as follows. Thanks in advance
> > for any help or suggestions.
>
> > class Artist(models.Model):
> >     salutation = models.CharField(max_length=10, blank=True)
> >     first_name = models.CharField(max_length=30)
> >     last_name = models.CharField(max_length=40)
> >     headshot = models.ImageField(upload_to='/tmp/statement',
> > blank=True)
> >     statement = models.TextField(blank=True)
>
> >     def __unicode__(self):
> >         return u'%s %s' % (self.first_name, self.last_name)
>
> > class Images(models.Model):
> >     artist = models.ForeignKey(Artist)
> > 

Re: Memory Footprint

2008-12-09 Thread Rajesh Dhawan

> First, I'm gonna say that I have DEBUG turned off, and it's not Django's
> fault.
>
> My Django sites seem to eat lots of memory. This is fine, and it isn't a
> huge deal except that I am using all of my VPS's memory plus swap. The
> real solution is to upgrade memory on the VPS, but I'm a poor college
> student so I want to reduce the memory footprint any way I can. I'm
> using mod_python and apache.

If you have not already done so, start by reducing the values of these
Apache settings (as applicable to your case) from their defaults:

Timeout
StartServers
MinSpareServers
MaxSpareServers
MaxClients
MaxRequestsPerChild
ServerLimit

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



Re: Using random.random() while running on server

2008-12-09 Thread Jeff FW

Can you show me exactly what you're trying to do?  That would make it
much easier to help you.

-Jeff

On Dec 9, 1:19 pm, Chris <[EMAIL PROTECTED]> wrote:
> I found this snippet:http://www.djangosnippets.org/snippets/814/and
> noticed that it does not work as intended do to the issue that I
> described. I tried passing it as default instead of using the save
> method but does not work and since I am not passing random to default
> directly, I cannot do this default=random.random. Any Ideas how I can
> fix this? thanks.
>
> On Dec 9, 6:00 am, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > Chris,
>
> > It depends on where you're calling random.random().  If you're trying
> > to do it in a model definition, then you're always going to have the
> > value it chose when it first executed the model's class definition--
> > when the server starts up.  In that case, you should be able to pass
> > an argument of default=random.random in the definition.  If it's
> > somewhere else you're trying to call it, let us know.
>
> > -Jeff
>
> > On Dec 9, 5:32 am, Chris <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
> > > when django is running on a server, I want to make a call to:
> > > random.random().  When I make a call to this again, I can't. I think
> > > this related to a similar issue datetime.datetime.now() where you
> > > leave off the () to get a current date each time each time you call
> > > it. If you dont do that, datetime.datetime.now() will give you the
> > > date to which the server was instantiated instead of current
> > > datetime.
>
> > > Is there a similar way that I can do this for random so that I can get
> > > a new number each time I call this instead of the number that it
> > > created when the server was instantiated?
>
> > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using random.random() while running on server

2008-12-09 Thread Chris

I found this snippet: http://www.djangosnippets.org/snippets/814/ and
noticed that it does not work as intended do to the issue that I
described. I tried passing it as default instead of using the save
method but does not work and since I am not passing random to default
directly, I cannot do this default=random.random. Any Ideas how I can
fix this? thanks.



On Dec 9, 6:00 am, Jeff FW <[EMAIL PROTECTED]> wrote:
> Chris,
>
> It depends on where you're calling random.random().  If you're trying
> to do it in a model definition, then you're always going to have the
> value it chose when it first executed the model's class definition--
> when the server starts up.  In that case, you should be able to pass
> an argument of default=random.random in the definition.  If it's
> somewhere else you're trying to call it, let us know.
>
> -Jeff
>
> On Dec 9, 5:32 am, Chris <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > when django is running on a server, I want to make a call to:
> > random.random().  When I make a call to this again, I can't. I think
> > this related to a similar issue datetime.datetime.now() where you
> > leave off the () to get a current date each time each time you call
> > it. If you dont do that, datetime.datetime.now() will give you the
> > date to which the server was instantiated instead of current
> > datetime.
>
> > Is there a similar way that I can do this for random so that I can get
> > a new number each time I call this instead of the number that it
> > created when the server was instantiated?
>
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: missing admin documentation

2008-12-09 Thread Ronny Haryanto

On Wed, Dec 10, 2008 at 12:50 AM, aparajita
<[EMAIL PROTECTED]> wrote:
> I am using django release 1.0.2, nothing modified. My admin interface
> works fine, but the documentation link never appears. I have
> 'django.middleware.doc.XViewMiddleware' in the list of middleware, I
> have my IP address listed in INTERNAL_IPS.
>
> Any ideas?

Do you have 'django.contrib.admindocs' in your INSTALLED_APPS?

Ronny

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



Re: problems with 'formset.__name__' in save_formset()

2008-12-09 Thread Rajesh Dhawan


> im a bloody django and python beginner and right now playing arround
> with the code provided 
> onhttp://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser
>
> on storing the entry in the admin following error occur:
>
> AttributeError at /admin/news/post/add/
>
> 'CommentFormFormSet' object has no attribute '__name__'

Replace the following line:
if formset.__name__ == 'CommentInline':

with the line:
if formset.model == Comment:

I have updated this cook book entry with the above fix.

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



Re: missing admin documentation

2008-12-09 Thread Steve Phillips

Right in your urls.py there should be commented out lines that's
specifically tells you what to do to get the docs working. Once you do
that then you will see the link.

Steve

On 12/9/08, aparajita <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am using django release 1.0.2, nothing modified. My admin interface
> works fine, but the documentation link never appears. I have
> 'django.middleware.doc.XViewMiddleware' in the list of middleware, I
> have my IP address listed in INTERNAL_IPS.
>
> Any ideas?
>
> - Aparajiita
>
> >
>

-- 
Sent from my mobile device

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



missing admin documentation

2008-12-09 Thread aparajita

Hi,

I am using django release 1.0.2, nothing modified. My admin interface
works fine, but the documentation link never appears. I have
'django.middleware.doc.XViewMiddleware' in the list of middleware, I
have my IP address listed in INTERNAL_IPS.

Any ideas?

- Aparajiita

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



Re: How do wire Userprofile to UserAdmin ?

2008-12-09 Thread Timboy

The problem with this solution is that you are unable to sort and/or
filter by anything you "wire" to the User admin page. #9463 is one I
have posted a bit ago.

On Dec 9, 9:43 am, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 8:58 PM, mahesh <[EMAIL PROTECTED]> wrote:
> > How do wire Userprofile to UserAdmin ?
>
> Here's one way to do it:
>
> # admin.py
> from django.contrib import admin
> from django.contrib.auth.admin import UserAdmin
> from django.contrib.auth.models import User
>
> from myproj.myapp.models import UserProfile
>
> class UserProfileAdminInline(admin.TabularInline):
>     model = UserProfile
>
> class NewUserAdmin(UserAdmin):
>     inlines = [UserProfileAdminInline]
>
> admin.site.unregister(User)
> admin.site.register(User, NewUserAdmin)
>
> Ronny
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do wire Userprofile to UserAdmin ?

2008-12-09 Thread Ronny Haryanto

On Tue, Dec 9, 2008 at 8:58 PM, mahesh <[EMAIL PROTECTED]> wrote:
> How do wire Userprofile to UserAdmin ?

Here's one way to do it:

# admin.py
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

from myproj.myapp.models import UserProfile

class UserProfileAdminInline(admin.TabularInline):
model = UserProfile

class NewUserAdmin(UserAdmin):
inlines = [UserProfileAdminInline]

admin.site.unregister(User)
admin.site.register(User, NewUserAdmin)

Ronny

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



Re: Too Many Connections

2008-12-09 Thread DULMANDAKH Sukhbaatar

>   File
> "/usr/local/python2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/__init__.py",
> line 74, in Connect
>
>   File
> "/usr/local/python2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/connections.py",
> line 170, in __init__\nsuper(Connection, self).__init__(*args,
> **kwargs2)
>
> OperationalError: (1040, 'Too many connections')

as you can see above, it's mysql problem. mysql server have some
default limitation on concurrent connections. you can increase
max_connections in my.cnf. depending on your linux distro my.cnf may
be located in different places. for me, or on ubuntu it's at
/etc/mysql/my.cnf, and you need to uncomment the line, and increase
the value.

by default mysql gets 100 concurrent connections. and the question is
why is dev site is getting that much connection?


-- 
Regards
Dulmandakh

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



problems with 'formset.__name__' in save_formset()

2008-12-09 Thread hhanse

hello group,

im a bloody django and python beginner and right now playing arround
with the code provided on 
http://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser

on storing the entry in the admin following error occur:

AttributeError at /admin/news/post/add/

'CommentFormFormSet' object has no attribute '__name__'

Request Method: POST
Request URL:http://127.0.0.1:8000/admin/news/post/add/
Exception Type: AttributeError
Exception Value:

'CommentFormFormSet' object has no attribute '__name__'

Exception Location: /Users/hhanse/django/pct/../pct/news/admin.py in
save_formset, line 31
Python Executable:  /System/Library/Frameworks/Python.framework/
Versions/2.5/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.5.1

some more infos:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/news/post/add/
Django Version: 1.0.2 final
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'tagging',
 'pct.news']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'djangologging.middleware.LoggingMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"
in root
  157. return self.model_page(request, *url.split('/',
2))
File "/Library/Python/2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"
in model_page
  176. return admin_obj(request, rest_of_url)
File "/Library/Python/2.5/site-packages/django/contrib/admin/
options.py" in __call__
  191. return self.add_view(request)
File "/Library/Python/2.5/site-packages/django/db/transaction.py" in
_commit_on_success
  238. res = func(*args, **kw)
File "/Library/Python/2.5/site-packages/django/contrib/admin/
options.py" in add_view
  497. self.save_formset(request, form, formset,
change=False)
File "/Users/hhanse/django/pct/../pct/news/admin.py" in save_formset
  31. if formset.__name__ == 'CommentInline':

Exception Type: AttributeError at /admin/news/post/add/
Exception Value: 'CommentFormFormSet' object has no attribute
'__name__'

i can't find the matter for this - please 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Too Many Connections

2008-12-09 Thread Trivedi, Apaar
This may not even be a Django problem, but I saw this on two of my dev
sites today, both running the same code base, our version of django is
from the trunk, and maybe a week or so old.  One site was running the
light weight server, the other site was running apache/mod_python.  Both
are connected to the same database.  Here is the error:

 

Traceback (most recent call last):

  File
"/usr/local/python2.5/lib/python2.5/site-packages/mod_python/importer.py
", line 1537, in HandlerDispatch\ndefault=default_handler, arg=req,
silent=hlist.silent)

  File
"/usr/local/python2.5/lib/python2.5/site-packages/mod_python/importer.py
", line 1229, in _process_target\nresult = _execute_target(config,
req, object, arg)

  File
"/usr/local/python2.5/lib/python2.5/site-packages/mod_python/importer.py
", line 1128, in _execute_target\nresult = object(arg)

  File
"/usr/local/python2.5/lib/python2.5/site-packages/django/core/handlers/m
odpython.py", line 222, in handler\nreturn ModPythonHandler()(req)

  File
"/usr/local/python2.5/lib/python2.5/site-packages/django/core/handlers/m
odpython.py", line 199, in __call__\nresponse =
middleware_method(request, response)

  File
"/usr/local/lib/python2.5/site-packages/django/contrib/sessions/middlewa
re.py", line 33, in process_response

  File
"/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends
/db.py", line 52, in save

  File
"/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends
/base.py", line 152, in _get_session_key

  File
"/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends
/base.py", line 144, in _get_new_session_key

  File
"/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends
/db.py", line 25, in exists

  File
"/usr/local/lib/python2.5/site-packages/django/db/models/manager.py",
line 93, in get

  File
"/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line
298, in get

  File
"/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line
154, in __len__

  File
"/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line
269, in iterator

  File
"/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 206, in results_iter

  File
"/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 1699, in execute_sql

  File
"/usr/local/lib/python2.5/site-packages/django/db/backends/__init__.py",
line 56, in cursor

  File
"/usr/local/lib/python2.5/site-packages/django/db/backends/mysql/base.py
", line 262, in _cursor

  File
"/usr/local/python2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2
.5-linux-i686.egg/MySQLdb/__init__.py", line 74, in Connect

  File
"/usr/local/python2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2
.5-linux-i686.egg/MySQLdb/connections.py", line 170, in __init__\n
super(Connection, self).__init__(*args, **kwargs2)

OperationalError: (1040, 'Too many connections')

 

Obviously it's django going through mysqldb, and connection problem is
in mysqldb, but I was wondering if anyone on this list can shed some
light on this.  I did a bit of googling and noticed other people using
django were having similar problems.  Does anyone know what causes this
and how I can fix it?  These sites are both internal dev sites,
therefore not anywhere close to high traffic.  



Thank you

Apaar

 


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



Re: issue with django tagging

2008-12-09 Thread garagefan

I had the same issue... you need to do two things...

copy this into the setup.py

from django.conf import settings
settings.configure()

and make sure you have python-devel installed

On Dec 9, 8:24 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> hi
> I got it from trunk,and the version is 0.3. After I installed
> tagging , I cannot import it. The error information is following:
>
> Thank you very much
>
> ---
> IDLE 1.2.2
>
> >>> import tagging
>
> Traceback (most recent call last):
>   File "", line 1, in 
>     import tagging
>   File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in
> 
>     from tagging.managers import ModelTaggedItemManager, TagDescriptor
>   File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in
> 
>     from django.contrib.contenttypes.models import ContentType
>   File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
> \models.py", line 1, in 
>     from django.db import models
>   File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
> in 
>     if not settings.DATABASE_ENGINE:
>   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> 28, in __getattr__
>     self._import_settings()
>   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> 57, in _import_settings
>     raise ImportError("Settings cannot be imported, because
> environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Memory Footprint

2008-12-09 Thread Jeff Anderson
Hello,

First, I'm gonna say that I have DEBUG turned off, and it's not Django's
fault.

My Django sites seem to eat lots of memory. This is fine, and it isn't a
huge deal except that I am using all of my VPS's memory plus swap. The
real solution is to upgrade memory on the VPS, but I'm a poor college
student so I want to reduce the memory footprint any way I can. I'm
using mod_python and apache.

I've seen discussion about mod_python specifically where it was
suggested to set large variables to None when you're done with them.
Django does most of the grunt work, and my views don't seem to load any
very large variables. It seems like any variables instantiated by my
views would go out of scope after the view function has returned, and
the Python garbage collection will show up.

I'm curious to know if anyone has ever tried to optimize their code to
reduce the overall memory footprint. I haven't found any blog posts
about it yet. I'm willing to resort to making my Django code as
non-persistent as possible. My sites are all low traffic, so
non-persistent processes plus memcached shouldn't be too terrible, even
if I get slashdotted. I just need to squeeze out as much as I can out of
the ram I have. Swapping makes the Django requests painfully slow.

I am running memcached, which does seem to help my sites go faster, but
it isn't helping the memory footprint go down (obviously.) I'm also
considering switching to lighttpd. I've read it has a smaller footprint
than apache. I've also read that mod_wsgi performs better than mod_python.

Please let me know if you have any other ideas! I'm also curious to know
if anyone thinks that one of the things I mention trying would help or
hurt. Thanks!


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: issue with django tagging

2008-12-09 Thread Mario

Try typing the following:

python manage.py shell

from the python shell, type:

import tagging
tagging.VERSION

Regards


On Dec 9, 8:24 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> hi
> I got it from trunk,and the version is 0.3. After I installed
> tagging , I cannot import it. The error information is following:
>
> Thank you very much
>
> ---
> IDLE 1.2.2
>
> >>> import tagging
>
> Traceback (most recent call last):
>   File "", line 1, in 
>     import tagging
>   File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in
> 
>     from tagging.managers import ModelTaggedItemManager, TagDescriptor
>   File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in
> 
>     from django.contrib.contenttypes.models import ContentType
>   File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
> \models.py", line 1, in 
>     from django.db import models
>   File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
> in 
>     if not settings.DATABASE_ENGINE:
>   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> 28, in __getattr__
>     self._import_settings()
>   File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
> 57, in _import_settings
>     raise ImportError("Settings cannot be imported, because
> environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unique_together question

2008-12-09 Thread bruno desthuilliers

On 9 déc, 13:20, Alex Jonsson <[EMAIL PROTECTED]> wrote:
> Hey everyone,
>
> My model looks like the following:
>
> http://dpaste.com/97293/
>
> An album has a release date for every format, and one format can only
> have one release date per album. Hopefully you get what I'm trying to
> achieve here ;)

Then your model seems broken to me. If you set album as a unique key,
you can only have one single ReleaseDate instance per album. Idem for
format: if a unique key, you can only have one single ReleaseDate
instance per format. You want them to be unique _together_, not unique
in the whole table.


> The thing is though, that in my Album model I specify a ManyToMany
> relationship with the Format in order to specify what Formats an Album
> would be released in.
>
> Now when I create this model, it will allow me to set a release date
> for any Format - I would like to allow it to only specify a release
> date for the formats that are specified in the Album ManyToMany
> column.
>
> How would be the easiest way to do this?

overload the ReleaseDate save() method ?

class ReleaseDate(models.Model):
album = models.ForeignKey(Album) #, unique=True)
format = models.ForeignKey(Format) #, unique=True)
date = models.DateField()

class Meta:
verbose_name = _('release date')
verbose_name_plural = _('release dates')
unique_together = ('album', 'format')

def save(self, **kw):
if self.format not in album.format_set.all():
raise Whatever(
"%s is not an allowed format for alubm %s" \
% (self.format, self.album)
)
super(ReleaseDate, self).save(**kw)

Note that this might cause problem if you:
- allow a format for an album
- create a ReleaseDate for this album and format
- disallow the format for this album

You'll have to handle this correctly (most probably by overloading
Album.save too...)

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



Re: Excel Generating Report

2008-12-09 Thread Elvis Stansvik

Hello Kian,

Could you show us your template too? And why are you importing the csv
module when you're not using it? I would use the csv module to
generate the CSV completely in the view, but that's me.

2008/12/9, garces.85 <[EMAIL PROTECTED]>:
>
> Hello Kian,
>
> I have already tried this response, the problem is that in my excel
> output i get this strange characters.
> For example all my grammar words return like weird characters.
> Example :
>
> If i have this word : ( Módulo) It becomes something like this : (MA3-
> dulo).
>
> I am working with a latin applicattion, so in spanish we use alot the
> letter ñ.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time it takes django to read database?

2008-12-09 Thread garagefan

sure thing:

from django.conf.urls.defaults import *
from mysite.blog.models import Entry
from tagging.views import tagged_object_list

info_dict = {
'queryset': Entry.objects.filter(status=1),
'date_field': 'pub_date',
}

urlpatterns = patterns('django.views.generic.date_based',
(r'(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
P[-\w]+)/$', 'object_detail', dict(info_dict,
slug_field='slug',template_name='blog/detail.html')),
(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?
P[-\w]+)/$', 'object_detail', dict(info_dict,
template_name='blog/list.html')),
(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/
$','archive_day',dict(info_dict,template_name='blog/list.html')),
(r'^(?P\d{4})/(?P[a-z]{3})/$','archive_month',
dict(info_dict, template_name='blog/list.html')),
(r'^(?P\d{4})/$','archive_year', dict(info_dict,
template_name='blog/list.html')),
(r'^$','archive_index', dict(info_dict, template_name='blog/
list.html')),
)


On Dec 8, 7:29 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> Could you post your urls.py file for your blog app? It's very easy to
> make a mistake in there that results in confusing time-related errors.
>
> Jay P.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to do redirects with django?

2008-12-09 Thread Thomas Guettler

Hi,

def foo(request):

return django.http.HttpResponseRedirect(newlocation)

newlocation can be an URL. I create them with
django.core.urlresolvers.reverse().

  Thomas

nbv4 schrieb:
> If the user goes to /foobar, I want it to redirect him to /foobar-page-
> XX, XX being the last page. I have a this in my urlconf"
>
> (r'^foobar/
> $',
> 'project.main.views.foobar_no_page', ),
> (r'^foobar-page-(?P\d{1,4})/$',
> 'project.main.views.foobar', ),
>
> foobar() in my views in my main function, foobar_no_page() is have set
> as:
>
> def logbook_no_page(request):
>
>   return HttpResponse(location='/foobar-page-55')
>
>
> but that obviously doesn't work. How can I do this?
>
>   


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


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



issue with django tagging

2008-12-09 Thread [EMAIL PROTECTED]

hi
I got it from trunk,and the version is 0.3. After I installed
tagging , I cannot import it. The error information is following:

Thank you very much

---
IDLE 1.2.2
>>> import tagging

Traceback (most recent call last):
  File "", line 1, in 
import tagging
  File "C:\Python25\Lib\site-packages\tagging\__init__.py", line 3, in

from tagging.managers import ModelTaggedItemManager, TagDescriptor
  File "C:\Python25\Lib\site-packages\tagging\managers.py", line 5, in

from django.contrib.contenttypes.models import ContentType
  File "C:\Python25\Lib\site-packages\django\contrib\contenttypes
\models.py", line 1, in 
from django.db import models
  File "C:\Python25\Lib\site-packages\django\db\__init__.py", line 9,
in 
if not settings.DATABASE_ENGINE:
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
28, in __getattr__
self._import_settings()
  File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line
57, in _import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

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



Re: dynamic mod wsgi

2008-12-09 Thread Ben Eliott

Understood. Thanks.

On 9 Dec 2008, at 10:18, Graham Dumpleton wrote:

>
>
>
> On Dec 9, 8:05 pm, Ben Eliott <[EMAIL PROTECTED]> wrote:
>> Graham,
>> Thank you for coming back personally to such a lowly wsgi question! I
>> started reading your email and thinking the answer was 'no', then
>> ended up thinking 'definitely maybe'. I'll keep an eye out in case  
>> you
>> post more, otherwise i'll follow those links and your directions and
>> hope to report back with some progress.
>
> I'll definitely try and say more later when get a chance.
>
> Just do be aware of one thing. By using a single WSGI script file for
> multiple sites, you loose the ability with mod_wsgi daemon mode to
> touch the WSGI script file and cause a single site to be reloaded. One
> would normally use this as a way of reloading a single site without
> the need to restart the whole of Apache. When sharing the single WSGI
> script file across sites, touching the WSGI script file will restart
> all sites using that WSGI script file. If they share the code this may
> actually be want you want, so not a problem, but worth mentioning.
>
> In this arrangement, if you did want to reload one site, for example
> because you change its settings file, you would need to use 'ps' to
> identify process(es) in that daemon process group, based on what
> display-name option was set to, and send all those processes in that
> daemon process group a SIGINT using the 'kill' command. Alternatively,
> you would need to setup a background thread which monitored something
> like the distinct settings file for each site and have the process
> itself send a SIGINT to itself. This would be a variation on
> background reloader described in:
>
>  
> http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes
>
> More later.
>
> Graham
>
>> Thanks and Regards,
>> Ben
>>
>> On 9 Dec 2008, at 08:23, Graham Dumpleton wrote:
>>
>>
>>
>>> On Dec 9, 6:53 pm, "[EMAIL PROTECTED]"
>>> <[EMAIL PROTECTED]> wrote:
 Hi, I'm converting to the excellent mod_wsgi and wondering if it's
 possible to make a single httpd virtual host/wsgi file to manage
 wildcard subdomains.
>>
 Basically I have an app where i'm creating a new instance for each
 client and using subdomains. So client1.example.com and
 client2.example.com both point to the same app, but their own
 settings.py/django instance.
>>
 So far so fine.  I've been happily converting to mod_wsgi daemons,
 creating virtual hosts and independent .wsgi files for each one.  
 But
 now just wondering whether there is some way i can make this  
 process
 dynamic so one virtual host/.wsgi file will take care of all these
 subdomains.
>>
 I see the advice on the wsgi wiki to push domain sub-directories to
 different django instances, but i'd rather keep using the  
 subdomains
 if possible.
>>
 It looks possible to be able to parse information about the  
 incoming
 request in the wsgi file and push it to different settings. But i'm
 not sure what this will do in terms of spawning processes etc, it
 looks a little dangerous, or maybe this will work. Any advice
 appreciated thanks!
>>
>>> Start by reading recent discussion:
>>
>>>  http://groups.google.com/group/django-users/browse_frm/thread/dfd3521 
>>> ...
>>
>>> I'll post more tomorrow if have time, have to do some things tonight
>>> and then out most of the day tomorrow.
>>
>>> In short though, no support for dynamic transient daemon processes
>>> yet, ie.,:
>>
>>>  http://code.google.com/p/modwsgi/issues/detail?id=22
>>
>>> so, can't get away from using WSGIDaemonProcess for each instance at
>>> the moment.
>>
>>> One can use dynamic setting of WSGIApplicationGroup via a variable  
>>> set
>>> by mod_rewrite to select daemon process as well as set some name
>>> relevant to settings file. WSGI application wrapper can then be used
>>> to override DJANGO_SETTINGS_MODULE.
>>
>>> So, information is in that post, you just need to adapt it to your
>>> situation. That is, use SERVER_NAME rather than REMOTE_USER from
>>> authentication as basis of selecting daemon process group. You could
>>> though skip the rewrite maps that allowed multiple levels of
>>> indirection and made it further dynamic in nature.
>>
>>> Graham
> >


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



Re: Using random.random() while running on server

2008-12-09 Thread Jeff FW

Chris,

It depends on where you're calling random.random().  If you're trying
to do it in a model definition, then you're always going to have the
value it chose when it first executed the model's class definition--
when the server starts up.  In that case, you should be able to pass
an argument of default=random.random in the definition.  If it's
somewhere else you're trying to call it, let us know.

-Jeff

On Dec 9, 5:32 am, Chris <[EMAIL PROTECTED]> wrote:
> Hello,
> when django is running on a server, I want to make a call to:
> random.random().  When I make a call to this again, I can't. I think
> this related to a similar issue datetime.datetime.now() where you
> leave off the () to get a current date each time each time you call
> it. If you dont do that, datetime.datetime.now() will give you the
> date to which the server was instantiated instead of current
> datetime.
>
> Is there a similar way that I can do this for random so that I can get
> a new number each time I call this instead of the number that it
> created when the server was instantiated?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How do wire Userprofile to UserAdmin ?

2008-12-09 Thread mahesh

UserProfile

How do wire Userprofile to UserAdmin ?

I want to add some more fields to user class. I have added one class
in polls/admin.py (polls being my app) and added following attribute
in settings.py

>> code snippet <<

AUTH_PROFILE_MODULE='polls.MySiteProfile'

model.py 
gender = (
('M', 'Male'),
('F', 'Female'),
)

user_kind = (('MCH', 'Machine User'),
 ('HMN', 'Human User')
)


class MySiteProfile(models.Model):
gender = models.CharField(max_length=1, choices=gender)
user_kind = models.CharField(max_length=3, choices=user_kind)
user = models.ForeignKey(User,unique=True)


In Django Shell >>>

from django.contrib.auth.models import User
from mysite.polls import model, admin


u = User.objects.get(pk=1)
msp = sp = models.MySiteProfile(user=u, gender='M', user_kind='MCH')

u.get_profile().gender # Returns “M” No problem

Question

How do I wire this in admin page ?

Thank You in advance

[EMAIL PROTECTED]

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



Adding costum css classes to form labels based on validation rules outside the admin

2008-12-09 Thread Marco Louro

Hi,

I guess the subject sums it up.. Basicly, in the admin we have:

City:

But oustide there is no 'class="required"'. Is there a way to define
this so that it shows up? That would make my life much easier since I
could just code some javascript to do client side validation based on
css classes.


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



Re: "Legal" way to have foreign key field in the custom form

2008-12-09 Thread Jeff FW

To get the plus icon back, you need to wrap the field in a
RelatedFieldWidgetWrapper.  Here's an example from my code--obviously,
you'll have to adapt it to fit your situation.

class CategoryChoiceField(forms.ModelChoiceField):

def __init__(self, *args, **kwargs):
super(CategoryChoiceField, self).__init__(*args, **kwargs)
self.widget = widgets.RelatedFieldWidgetWrapper(
widgets.CategorySelect(
categories=models.Category.objects.order_by('parent',
'list_order')),
models.Category._meta.get_field('parent').rel,
admin.site,
)

-Jeff

On Dec 9, 6:50 am, Eugene Mirotin <[EMAIL PROTECTED]> wrote:
> Well, looks that the ModelChoiceField solves the problem except of the
> plus icon
>
> On Dec 9, 12:34 pm, Eugene Mirotin <[EMAIL PROTECTED]> wrote:
>
> > Hello. I'm working on the custom admin page  that will serve batch
> > items creation based on the uploaded file.
> > All these items should be linked to the single foreign key item.
> > This item should be selected on the form.
> > Of course, I can investigate the inner structure of the rendered admin
> > pages and mimic it my template, but it doesn't look DRY.
> > So I want to {% include %} the fieldset.html and pass the variable to
> > it that will make it to render the standard ForeignKey control (with
> > "+" icon).
> > Is there a legal way to do it?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Excel Generating Report

2008-12-09 Thread garces.85

Hello Kian,

I have already tried this response, the problem is that in my excel
output i get this strange characters.
For example all my grammar words return like weird characters.
Example :

If i have this word : ( Módulo) It becomes something like this : (MA3-
dulo).

I am working with a latin applicattion, so in spanish we use alot the
letter ñ.

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



Re: how to do redirects with django?

2008-12-09 Thread Alex Koshelev
http://docs.djangoproject.com/en/dev/ref/request-response/#httpresponse-subclasses
http://docs.djangoproject.com/en/dev/ref/contrib/redirects/#ref-contrib-redirects

On Tue, Dec 9, 2008 at 16:25, nbv4 <[EMAIL PROTECTED]> wrote:

>
> If the user goes to /foobar, I want it to redirect him to /foobar-page-
> XX, XX being the last page. I have a this in my urlconf"
>
> (r'^foobar/
> $',
> 'project.main.views.foobar_no_page', ),
> (r'^foobar-page-(?P\d{1,4})/$',
> 'project.main.views.foobar', ),
>
> foobar() in my views in my main function, foobar_no_page() is have set
> as:
>
> def logbook_no_page(request):
>
>return HttpResponse(location='/foobar-page-55')
>
>
> but that obviously doesn't work. How can I do this?
> >
>

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



how to do redirects with django?

2008-12-09 Thread nbv4

If the user goes to /foobar, I want it to redirect him to /foobar-page-
XX, XX being the last page. I have a this in my urlconf"

(r'^foobar/
$',
'project.main.views.foobar_no_page', ),
(r'^foobar-page-(?P\d{1,4})/$',
'project.main.views.foobar', ),

foobar() in my views in my main function, foobar_no_page() is have set
as:

def logbook_no_page(request):

return HttpResponse(location='/foobar-page-55')


but that obviously doesn't work. How can I do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: selected ModelMultipleChoiceField

2008-12-09 Thread Abdel Bolanos Martinez
That's rigth you hit the point
followed your advice and with these lines i resolved my problem, got
modelform filtered by a custom query 

yaho

the model (part of it)

class Indicacion(models.Model):
'''
 
@author: Abel Bolaños Martínez
@contact: [EMAIL PROTECTED]
'''
emisor = models.ForeignKey(Emisor)
responsables = models.ManyToManyField(Responsable)
participantes = models.ManyToManyField(Participante,blank=True)


the form (the hot line):

class indicacionForm(ModelForm):
'''  
Formulario del modelo que mapea a la clase Indicacion

@author: Abel Bolaños Martínez
@contact: [EMAIL PROTECTED]
'''
class Meta:
model = Indicacion

def __init__(self, *args, **kwargs):
  super(indicacionForm, self).__init__(*args, **kwargs)
  self.fields['responsables'].queryset =
devuelveTodosNoBorrados(Responsable) (this is a personal query)
  self.fields['emisor'].queryset =
devuelveTodosNoBorrados(Emisor) (this is a personal query)
  self.fields['participantes'].queryset =
devuelveTodosNoBorrados(Participante) (this is a personal query)





On Mon, 2008-12-08 at 21:00 +0100, Håkan Waara wrote:

> Yes, that's what my reply to you was about. The below examples work  
> for ModelChoiceField, you only need to use the same technique on a  
> ModelMultipleChoiceField, where I - like I wrote - guess you can use a  
> tuple of initial values, e.g. ("foo", "bar").
> 
> /Håkan
> 
> 8 dec 2008 kl. 18.30 skrev Abdel Bolanos Martinez:
> 
> > what I want is use ModelMultipleChoiceField with a queryset but I  
> > need that some of the  of the  generated be mareked  
> > as 

Re: python path

2008-12-09 Thread mangamonk

ok, I've added coltrane!..rock on!

I added an admin.py file to the coltrane folder..

---

#admin.py
from django.contrib import admin
from coltrane.models import Category

admin.site.register(Category)

---

and then ran:
[EMAIL PROTECTED]:~/django_projects/mysite$ python manage.py syncdb

rather than..

[EMAIL PROTECTED]:~/django_projects$ python manage.py syncdb

still a bit confused though as I thought that by exporting my python
path in the project folder I would be able to access manage.py from
the site-packages directory and therefore be able to run..

[EMAIL PROTECTED]:~/django_projects$ python manage.py syncdb


On Dec 9, 12:31 pm, mangamonk <[EMAIL PROTECTED]> wrote:
> >>>import sys; sys.path
>
> ['', '/home/mark/django_projects',
> '/home/mark/django_projects/coltrane',
> '/usr/lib/python25.zip',
> '/usr/lib/python2.5',
> '/usr/lib/python2.5/plat-linux2',
> '/usr/lib/python2.5/lib-tk',
> '/usr/lib/python2.5/lib-dynload',
> '/usr/local/lib/python2.5/site-packages',
> '/usr/lib/python2.5/site-packages',
> '/usr/lib/python2.5/site-packages/Numeric',
> '/usr/lib/python2.5/site-packages/PIL',
> '/usr/lib/python2.5/site-packages/gst-0.10',
> '/var/lib/python-support/python2.5',
> '/usr/lib/python2.5/site-packages/gtk-2.0',
> '/var/lib/python-support/python2.5/gtk-2.0']
>
> On Dec 9, 12:02 pm, mangamonk <[EMAIL PROTECTED]> wrote:
>
> > I'm working through 'practical django projects'
> > on page 46, in order to develop stanalone application, I need to add
> > my django 'project' to the python path. therefore..
>
> > export PYTHONPATH=/home/mark/django_projects/:$PYTHONPATH
>
> > then a little later in the tutorial after setting up the 'coltrane
> > application' I run the 'python manage.py syndb' command, from within
> > the project folder,
>
> > '[EMAIL PROTECTED]:~/django_projects$ python manage.py syncdb'
>
> > and get the following error...
>
> > 'python: can't open file 'manage.py': [Errno 2] No such file or
> > directory'
>
> > how I do I test to see what my python path is?
> > what am I doing 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with paginated page having checkbox

2008-12-09 Thread laspal

hi,

I am trying to get list of selected checkbox from the listing.

here is my code:

html


{% for companies in companylist.object_list %}

 
{% endfor %}





{% if is_paginated %}
Prev
| Page {{cur_page}} of {{paginator_company_list.num_pages}} |

Next

{% endif %}


and my views:
def reports( request, page=None):
selected_companies_id_list = request.POST.getlist
('selected_companies_id_list')

def report_companies_paginate( request, page):
return reports( request , page)

The problem I am facing here is I am only getting the list for the
page where I am submitting the form.
I mean above code does not work across pages.
How can I fix this. Does I have to do javascripting for getting all
the values.

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



Re: python path

2008-12-09 Thread mangamonk

>>>import sys; sys.path

['', '/home/mark/django_projects',
'/home/mark/django_projects/coltrane',
'/usr/lib/python25.zip',
'/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk',
'/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages/Numeric',
'/usr/lib/python2.5/site-packages/PIL',
'/usr/lib/python2.5/site-packages/gst-0.10',
'/var/lib/python-support/python2.5',
'/usr/lib/python2.5/site-packages/gtk-2.0',
'/var/lib/python-support/python2.5/gtk-2.0']

On Dec 9, 12:02 pm, mangamonk <[EMAIL PROTECTED]> wrote:
> I'm working through 'practical django projects'
> on page 46, in order to develop stanalone application, I need to add
> my django 'project' to the python path. therefore..
>
> export PYTHONPATH=/home/mark/django_projects/:$PYTHONPATH
>
> then a little later in the tutorial after setting up the 'coltrane
> application' I run the 'python manage.py syndb' command, from within
> the project folder,
>
> '[EMAIL PROTECTED]:~/django_projects$ python manage.py syncdb'
>
> and get the following error...
>
> 'python: can't open file 'manage.py': [Errno 2] No such file or
> directory'
>
> how I do I test to see what my python path is?
> what am I doing 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



unique_together question

2008-12-09 Thread Alex Jonsson

Hey everyone,

My model looks like the following:

http://dpaste.com/97293/

An album has a release date for every format, and one format can only
have one release date per album. Hopefully you get what I'm trying to
achieve here ;)

The thing is though, that in my Album model I specify a ManyToMany
relationship with the Format in order to specify what Formats an Album
would be released in.

Now when I create this model, it will allow me to set a release date
for any Format - I would like to allow it to only specify a release
date for the formats that are specified in the Album ManyToMany
column.

How would be the easiest way to do this?

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



Re: How to import DoesNotExist exception ???

2008-12-09 Thread Sérgio Durand

from  tutorial part 03:

from django.http import Http404
# ...
def detail(request, poll_id):
try:
p = Poll.objects.get(pk=poll_id)
except Poll.DoesNotExist:
raise Http404
return render_to_response('polls/detail.html', {'poll': p})


but, you can use "get_object_or_404(, 

python path

2008-12-09 Thread mangamonk

I'm working through 'practical django projects'
on page 46, in order to develop stanalone application, I need to add
my django 'project' to the python path. therefore..

export PYTHONPATH=/home/mark/django_projects/:$PYTHONPATH

then a little later in the tutorial after setting up the 'coltrane
application' I run the 'python manage.py syndb' command, from within
the project folder,

'[EMAIL PROTECTED]:~/django_projects$ python manage.py syncdb'

and get the following error...

'python: can't open file 'manage.py': [Errno 2] No such file or
directory'

how I do I test to see what my python path is?
what am I doing 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "Legal" way to have foreign key field in the custom form

2008-12-09 Thread Eugene Mirotin

Well, looks that the ModelChoiceField solves the problem except of the
plus icon

On Dec 9, 12:34 pm, Eugene Mirotin <[EMAIL PROTECTED]> wrote:
> Hello. I'm working on the custom admin page  that will serve batch
> items creation based on the uploaded file.
> All these items should be linked to the single foreign key item.
> This item should be selected on the form.
> Of course, I can investigate the inner structure of the rendered admin
> pages and mimic it my template, but it doesn't look DRY.
> So I want to {% include %} the fieldset.html and pass the variable to
> it that will make it to render the standard ForeignKey control (with
> "+" icon).
> Is there a legal way to do it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with django tagging: how to add tags??

2008-12-09 Thread Andrew Davison

> I am using django tagging and have problems adding tags to an object.
>
> There are 2 methods that enable adding a tag:
> - add_tag()
> - update_tags()
>
> --
> for tag in parse_inputs(form.cleaned_data['tags']):
>   Tag.objects.add_tag(tag)
> ---
>
> This seems to work fine, but if I pass something like "Feature
> Recognition" (A tag containing 2 word) I get an AttributeError
> "multiple tags were given".
>
> In the docs under "Tag input" they say that | apple "ball cat" dog |
> results in these tags [apple], [ball cat], [dog].
>
> So I tried to workaround this problem by using the update_tags method,
> but this just clears all existing and inserts the passed ones.
> So could someone please tell what I am doi9ng wrong, or how to add
> tags

I have the same problem. I think it would be nice if update_tags()
were renamed to set_tags(), and update_tags() behaved analogously to
dict.update(), i.e., not touching existing entries.

In the meantime, you can workaround it by making a local function that
replicates Tags.object.update_tags() but without the deletion step:

--
from tagging.models import Tag, TaggedItem
from tagging.utils import parse_tag_input
from django.contrib.contenttypes.models import ContentType
from django.conf import settings

def update_tags(obj, tag_names):
"""Tags.object.update_tags() deletes any existing tags that aren't
in the
passed list, so this is basically a copy of that method, without
tag removal."""
ctype = ContentType.objects.get_for_model(obj)
current_tags = list(Tag.objects.filter
(items__content_type__pk=ctype.pk,
items__object_id=obj.pk))
updated_tag_names = parse_tag_input(tag_names)
if hasattr(settings, 'FORCE_LOWERCASE_TAGS') and
settings.FORCE_LOWERCASE_TAGS:
updated_tag_names = [t.lower() for t in updated_tag_names]
current_tag_names = [tag.name for tag in current_tags]
for tag_name in updated_tag_names:
if tag_name not in current_tag_names:
tag, created = Tag.objects.get_or_create(name=tag_name)
TaggedItem._default_manager.create(tag=tag, object=obj)
--

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



"Legal" way to have foreign key field in the custom form

2008-12-09 Thread Eugene Mirotin

Hello. I'm working on the custom admin page  that will serve batch
items creation based on the uploaded file.
All these items should be linked to the single foreign key item.
This item should be selected on the form.
Of course, I can investigate the inner structure of the rendered admin
pages and mimic it my template, but it doesn't look DRY.
So I want to {% include %} the fieldset.html and pass the variable to
it that will make it to render the standard ForeignKey control (with
"+" icon).
Is there a legal way to do it?

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



Using random.random() while running on server

2008-12-09 Thread Chris

Hello,
when django is running on a server, I want to make a call to:
random.random().  When I make a call to this again, I can't. I think
this related to a similar issue datetime.datetime.now() where you
leave off the () to get a current date each time each time you call
it. If you dont do that, datetime.datetime.now() will give you the
date to which the server was instantiated instead of current
datetime.

Is there a similar way that I can do this for random so that I can get
a new number each time I call this instead of the number that it
created when the server was instantiated?

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



Re: dynamic mod wsgi

2008-12-09 Thread Graham Dumpleton



On Dec 9, 8:05 pm, Ben Eliott <[EMAIL PROTECTED]> wrote:
> Graham,
> Thank you for coming back personally to such a lowly wsgi question! I  
> started reading your email and thinking the answer was 'no', then  
> ended up thinking 'definitely maybe'. I'll keep an eye out in case you  
> post more, otherwise i'll follow those links and your directions and  
> hope to report back with some progress.

I'll definitely try and say more later when get a chance.

Just do be aware of one thing. By using a single WSGI script file for
multiple sites, you loose the ability with mod_wsgi daemon mode to
touch the WSGI script file and cause a single site to be reloaded. One
would normally use this as a way of reloading a single site without
the need to restart the whole of Apache. When sharing the single WSGI
script file across sites, touching the WSGI script file will restart
all sites using that WSGI script file. If they share the code this may
actually be want you want, so not a problem, but worth mentioning.

In this arrangement, if you did want to reload one site, for example
because you change its settings file, you would need to use 'ps' to
identify process(es) in that daemon process group, based on what
display-name option was set to, and send all those processes in that
daemon process group a SIGINT using the 'kill' command. Alternatively,
you would need to setup a background thread which monitored something
like the distinct settings file for each site and have the process
itself send a SIGINT to itself. This would be a variation on
background reloader described in:

  
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes

More later.

Graham

> Thanks and Regards,
> Ben
>
> On 9 Dec 2008, at 08:23, Graham Dumpleton wrote:
>
>
>
> > On Dec 9, 6:53 pm, "[EMAIL PROTECTED]"
> > <[EMAIL PROTECTED]> wrote:
> >> Hi, I'm converting to the excellent mod_wsgi and wondering if it's
> >> possible to make a single httpd virtual host/wsgi file to manage
> >> wildcard subdomains.
>
> >> Basically I have an app where i'm creating a new instance for each
> >> client and using subdomains. So client1.example.com and
> >> client2.example.com both point to the same app, but their own
> >> settings.py/django instance.
>
> >> So far so fine.  I've been happily converting to mod_wsgi daemons,
> >> creating virtual hosts and independent .wsgi files for each one. But
> >> now just wondering whether there is some way i can make this process
> >> dynamic so one virtual host/.wsgi file will take care of all these
> >> subdomains.
>
> >> I see the advice on the wsgi wiki to push domain sub-directories to
> >> different django instances, but i'd rather keep using the subdomains
> >> if possible.
>
> >> It looks possible to be able to parse information about the incoming
> >> request in the wsgi file and push it to different settings. But i'm
> >> not sure what this will do in terms of spawning processes etc, it
> >> looks a little dangerous, or maybe this will work. Any advice
> >> appreciated thanks!
>
> > Start by reading recent discussion:
>
> >  http://groups.google.com/group/django-users/browse_frm/thread/dfd3521...
>
> > I'll post more tomorrow if have time, have to do some things tonight
> > and then out most of the day tomorrow.
>
> > In short though, no support for dynamic transient daemon processes
> > yet, ie.,:
>
> >  http://code.google.com/p/modwsgi/issues/detail?id=22
>
> > so, can't get away from using WSGIDaemonProcess for each instance at
> > the moment.
>
> > One can use dynamic setting of WSGIApplicationGroup via a variable set
> > by mod_rewrite to select daemon process as well as set some name
> > relevant to settings file. WSGI application wrapper can then be used
> > to override DJANGO_SETTINGS_MODULE.
>
> > So, information is in that post, you just need to adapt it to your
> > situation. That is, use SERVER_NAME rather than REMOTE_USER from
> > authentication as basis of selecting daemon process group. You could
> > though skip the rewrite maps that allowed multiple levels of
> > indirection and made it further dynamic in nature.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom distinct() method

2008-12-09 Thread jamesjacksonn...@gmail.com

please, maybe anyone now how to perform distinct() filtering for
certain attribute(column), not the whole objects(rows)? :)

In case not - please tell me what's the best practice when coming to a
situation when django orm is not powerfull enough. Can writting custom
sql queries become a serious problem later on? i could, of course,
write a custom SQL query and get the result as tuples, but that's only
for representation of data, manipulation gets realy tricky, as you
can't refer to the given data as the objects of django. And there is
that feeling that after the first custom sql query, 10 more new will
be neccessary later on and you may end up writting all the webapp the
good-old SQLObject way.

and for the main question - if i mislooked something in the docs, just
please write rtfm or something, just to let me understand it's a well
documented feature, just i don't find it.

Thanks everyone,
enjoy the day,
j

On Dec 9, 2:15 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Here comes the question about the proper usage of queryset's distinct
> () method. As i have a queryset model.objects.filter
> (column='name').distinct() , the distinct method is applied to whole
> objects, but i'd like it to be applied to column. Django makes SQL
> query "SELECT DISTINCT column, column2, column3 from TABLE WHERE
> 'column'='name'. How could i tell django to make querie SELECT
> DISTINCT column from TABLE WHERE 'column'='name' so that the
> comparison would be made for the single attribute , not for whole
> objects. As i guess performing such filtering in SQL server is much
> resource-savy than in view level, or template level of django. thanks
> for any ideas!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon

I'll give it a go :) Thanks for your help Ben.

On Dec 9, 9:50 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
> hmm, don't know. that's the documented approach. you might want to  
> investigate intermediary tables/models etc.
>
> On 9 Dec 2008, at 09:24, Darthmahon wrote:
>
>
>
> > Ahh yes possibly. Any downsides to using this?
>
> > On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
> >> Do you want something like this?
> >> friends_new = models.ManyToManyField("self",symmetrical=False)
>
> >> On 9 Dec 2008, at 09:06, Darthmahon wrote:
>
> >>> Hi Guys,
>
> >>> Just bumping this up as I still can't figure out why this is
> >>> happening :/
>
> >>> On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote:
>  Hi Guys,
>
>  I've got a model that has a Many to Many relationship on one of the
>  fields. This relationship is basically on itself though like this:
>
>  #
>
>  class UserProfile(models.Model):
>
>          user                    = models.ForeignKey(User,
>  unique=True)
>          friends_new     = models.ManyToManyField('UserProfile',
>  blank=True,
>  related_name='friend_set_new')
>
>  #
>
>  I'm trying to "add" to the friends_new field using this code:
>
>  #
>
>  # get users
>  initiator_profile = UserProfile.objects.get(user=request.user.id)
>  recipient_profile = UserProfile.objects.get(user=username)
>
>  # now add them as a friend
>  initiator_profile.friends_new.add(recipient_profile)
>
>  #
>
>  Now the problem I'm having is that it is adding the friendship to
>  BOTH
>  userprofiles, initiator and recipient. And when I try to remove the
>  relationship, again it removes BOTH. So in the database it has two
>  entries when I only expect there to be one.
>
>  Hope I've made that clear enough, any ideas how to get around this?
>
>  Cheers,
>  Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request parsing

2008-12-09 Thread Polat Tuzla

File uploading is explained in detail at
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
In short you create a form consisting of a file field:

class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file  = forms.FileField()


then write a view function to save it:

def upload_file(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
f = request.FILES['file']
destination = open('some/file/name.txt', 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
...

Hope this helps.



On Dec 9, 11:30 am, Vicky <[EMAIL PROTECTED]> wrote:
> If we send a file by post method to a django function how can we
> separate the file from the request?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott

hmm, don't know. that's the documented approach. you might want to  
investigate intermediary tables/models etc.


On 9 Dec 2008, at 09:24, Darthmahon wrote:

>
> Ahh yes possibly. Any downsides to using this?
>
> On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
>> Do you want something like this?
>> friends_new = models.ManyToManyField("self",symmetrical=False)
>>
>> On 9 Dec 2008, at 09:06, Darthmahon wrote:
>>
>>
>>
>>> Hi Guys,
>>
>>> Just bumping this up as I still can't figure out why this is
>>> happening :/
>>
>>> On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote:
 Hi Guys,
>>
 I've got a model that has a Many to Many relationship on one of the
 fields. This relationship is basically on itself though like this:
>>
 #
>>
 class UserProfile(models.Model):
>>
 user= models.ForeignKey(User,
 unique=True)
 friends_new = models.ManyToManyField('UserProfile',
 blank=True,
 related_name='friend_set_new')
>>
 #
>>
 I'm trying to "add" to the friends_new field using this code:
>>
 #
>>
 # get users
 initiator_profile = UserProfile.objects.get(user=request.user.id)
 recipient_profile = UserProfile.objects.get(user=username)
>>
 # now add them as a friend
 initiator_profile.friends_new.add(recipient_profile)
>>
 #
>>
 Now the problem I'm having is that it is adding the friendship to
 BOTH
 userprofiles, initiator and recipient. And when I try to remove the
 relationship, again it removes BOTH. So in the database it has two
 entries when I only expect there to be one.
>>
 Hope I've made that clear enough, any ideas how to get around this?
>>
 Cheers,
 Chris
> >


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



Re: request parsing

2008-12-09 Thread Ben Eliott

request.FILES
If this is what you mean, I think this is kind of django 101, i'd  
recommend having a solid read through the docs which cover all these  
kind of bases really well.


On 9 Dec 2008, at 09:30, Vicky wrote:

>
> If we send a file by post method to a django function how can we
> separate the file from the request?
> >


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



Re: OperationalError -- Table has no column named ..

2008-12-09 Thread Daniel Roseman

On Dec 9, 5:02 am, djan <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm running OpenSuSE-11.0 with the lastest version of django and
> sqlite3.
> When I enter the admin interface to enter data into my database, I got
> the error:
>
> OperationalError at /admin/archive/artist/add/
>
> table archive_artist has no column named salutation
>
> Request Method:         POST
> Request URL:    http://127.0.0.1:8000/admin/archive/artist/add/
> Exception Type:         OperationalError
> Exception Value:        table archive_artist has no column named salutation
>
> This error is for the first field of the first table, so I suspect
> there is a deeper issue. Perhaps related to this, when I enter the
> admin interface, I only see a way to enter records for "Artist", and
> not any of the other tables I described below (i.e. "Images",
> "Gallery", "On_Loan"). I'm new to database design; perhaps the
> relations are off? My models.py looks as follows. Thanks in advance
> for any help or suggestions.
>
> class Artist(models.Model):
>     salutation = models.CharField(max_length=10, blank=True)
>     first_name = models.CharField(max_length=30)
>     last_name = models.CharField(max_length=40)
>     headshot = models.ImageField(upload_to='/tmp/statement',
> blank=True)
>     statement = models.TextField(blank=True)
>
>     def __unicode__(self):
>         return u'%s %s' % (self.first_name, self.last_name)
>
> class Images(models.Model):
>     artist = models.ForeignKey(Artist)
>     file = models.ImageField(upload_to='/tmp/images')
>     title = models.CharField(max_length=50)
>     date = models.DateField()
>
>     def __unicode__(self):
>         return u'%s %s' % (self.title, self.date)
>
> class Gallery(models.Model):
>     images = models.ForeignKey(Images, blank=True)
>     videos = models.ForeignKey(Videos, blank=True)
>     name = models.CharField(max_length=40)
>     address = models.CharField(max_length=30, blank=True)
>     city = models.CharField(max_length=60, blank=True)
>     country = models.CharField(max_length=50, blank=True)
>     phone = models.CharField(max_length=13, blank=True)
>     email = models.EmailField(blank=True)
>     website = models.URLField(blank=True)
>
>     def __unicode__(self):
>         return u'%s' % (self.name)
>
> class On_Loan(models.Model):
>     artist = models.ForeignKey(Artist)
>     images = models.ManyToManyField(Images, blank=True)
>     videos = models.ManyToManyField(Videos, blank=True)
>     location = models.ForeignKey(Gallery)
>     expiry = models.DateField()
>
>     def __unicode__(self):
>         return u'%s %s' % (self.location, self.expiry)


The problem isn't with your model structure (although there is one
issue there, see below), but with your database tables. Most probably,
you set up your database and ran manage.py syncdb, then made some
changes to your models afterwards. Django does *not* change existing
database tables when you edit the models - you need to do this
yourself, usually via SQL. Since you're running sqlite and you haven't
added any data yet, the easiest thing to do is delete your database
file and run syncdb again.

Your second problem, the lack of links to edit other tables, depends
on your admin.py file which you haven't posted. You just need to
remember to register in the admin every model you want to edit there.
If you're still having problems there, post your admin.py and we'll
try to help.

Finally, your model layout itself. It looks good except for one issue
- the relationship between Gallery and Images. You have a Foreign Key
from Gallery to Images, which means that each gallery has only one
image, and each image can belong to multiple galleries. I suspect you
didn't mean that... most likely you want this to be the other way
round, with the ForeignKey field on Images pointing to Gallery (and
the same for Videos, which you haven't posted).

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



  1   2   >