Re: set model field some value before add

2010-05-26 Thread ev
Sounds good! I'm going to try ))

On May 27, 6:45 am, Rendy Anthony  wrote:
> I think the best way is to override the Model's save method:
>
> class Structure(models.Model):
>     parent
> = models.ForeignKey('site.Structure',blank=True,null=True,default=0)
>     title = models.CharField(max_length=128,verbose_name=u'Заголовок')
>     url = models.CharField(max_length=48,verbose_name=u'URL')
>     ordering = models.IntegerField(blank=True,editable=False,default=1)
>     level = models.SmallIntegerField(blank=True,editable=False,default=1)
>
>     def save(self, *args, **kwargs):
>         if not self.id:
>             # If the primary key is not defined, this is a new insertion
>             self.ordering = 42 # set magic values
>             self.level = 99
>         super(Structure, self).save(*args, **args)
>
> 2010/5/27 ev 
>
>
>
> > class Structure(models.Model):
> >        parent =
> > models.ForeignKey('site.Structure',blank=True,null=True,default=0)
> >        title = models.CharField(max_length=128,verbose_name=u'Заголовок')
> >        url = models.CharField(max_length=48,verbose_name=u'URL')
> >        ordering = models.IntegerField(blank=True,editable=False,default=1)
> >        level =
> > models.SmallIntegerField(blank=True,editable=False,default=1)
>
> > I'd like to set Structure.ordering and Structure.level with special
> > values, based on something.
>
> > Is there way to provide Structure.before_add(self) method? I need this
> > method to be called every time after saving model data.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



making this app re-usable

2010-05-26 Thread Jeffrey Taggarty
Hey Guys,

I am trying to build this app so we ca re-use it throughout all of the
projects we build.

The re-usable app has it's own model and a FK to a specific model that
it is related to, this is required. Right now I have a setting in my
project settings.py that uses the re-usable that has this:
APP_RELATED_MODEL = 'officesupplies.Supply' where officesupplies is
the appname and Supply is the model it is related to, then in my re-
usable app I just have ForeignKey(settings.APP_RELATED_MODEL) which
works fine.

The real problem lies in my import statements in the reusable app, I
have right now this:

from officesupplies.models import Supply # this is hardcoded, need to
dynamically load the app/model from the settings.APP_RELATED_MODEL

How can I load up the APP_RELATED_MODEL settings into my import so I
can do my DB queries etc?

Jeff

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



Re: set model field some value before add

2010-05-26 Thread Rendy Anthony
I think the best way is to override the Model's save method:

class Structure(models.Model):
parent
= models.ForeignKey('site.Structure',blank=True,null=True,default=0)
title = models.CharField(max_length=128,verbose_name=u'Заголовок')
url = models.CharField(max_length=48,verbose_name=u'URL')
ordering = models.IntegerField(blank=True,editable=False,default=1)
level = models.SmallIntegerField(blank=True,editable=False,default=1)

def save(self, *args, **kwargs):
if not self.id:
# If the primary key is not defined, this is a new insertion
self.ordering = 42 # set magic values
self.level = 99
super(Structure, self).save(*args, **args)

2010/5/27 ev 

> class Structure(models.Model):
>parent =
> models.ForeignKey('site.Structure',blank=True,null=True,default=0)
>title = models.CharField(max_length=128,verbose_name=u'Заголовок')
>url = models.CharField(max_length=48,verbose_name=u'URL')
>ordering = models.IntegerField(blank=True,editable=False,default=1)
>level =
> models.SmallIntegerField(blank=True,editable=False,default=1)
>
> I'd like to set Structure.ordering and Structure.level with special
> values, based on something.
>
> Is there way to provide Structure.before_add(self) method? I need this
> method to be called every time after saving model data.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Redirect from a called function

2010-05-26 Thread shacker
Bingo! Thanks much.

./s

On May 26, 6:57 pm, Rendy Anthony  wrote:
> You also need to return the result of bar() from foo. Example:
>
> def bar(request):
>    print "In bar"
>    return HttpResponseRedirect('"http://example.com;)
>
> def foo(request):
>     return bar()
>
> Regards,
> Rendy Anthonyhttp://solyaris.wordpress.com
>
>
>
> On Thu, May 27, 2010 at 9:50 AM, shacker  wrote:
> > I'm trying to figure out why HttpResponseRedirect doesn't work when
> > called from within another function. For example, this works, of
> > course:
>
> > def foo(request):
> >  return HttpResponseRedirect('"http://example.com;)
>
> > But this does not:
>
> > def bar(request):
> >  print "In bar"
> >  return HttpResponseRedirect('"http://example.com;)
>
> > def foo(request):
> >  bar()
>
> > In this second case, django will print "In bar" but the redirect does
> > not occur - it fails silently. Feel like I'm not understanding
> > something fundamental here.
>
> > Clues? 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Redirect from a called function

2010-05-26 Thread Rendy Anthony
You also need to return the result of bar() from foo. Example:

def bar(request):
   print "In bar"
   return HttpResponseRedirect('"http://example.com;)

def foo(request):
return bar()

Regards,
Rendy Anthony
http://solyaris.wordpress.com

On Thu, May 27, 2010 at 9:50 AM, shacker  wrote:

> I'm trying to figure out why HttpResponseRedirect doesn't work when
> called from within another function. For example, this works, of
> course:
>
> def foo(request):
>  return HttpResponseRedirect('"http://example.com;)
>
> But this does not:
>
> def bar(request):
>  print "In bar"
>  return HttpResponseRedirect('"http://example.com;)
>
> def foo(request):
>  bar()
>
> In this second case, django will print "In bar" but the redirect does
> not occur - it fails silently. Feel like I'm not understanding
> something fundamental here.
>
> Clues? 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Redirect from a called function

2010-05-26 Thread shacker
I'm trying to figure out why HttpResponseRedirect doesn't work when
called from within another function. For example, this works, of
course:

def foo(request):
  return HttpResponseRedirect('"http://example.com;)

But this does not:

def bar(request):
  print "In bar"
  return HttpResponseRedirect('"http://example.com;)

def foo(request):
  bar()

In this second case, django will print "In bar" but the redirect does
not occur - it fails silently. Feel like I'm not understanding
something fundamental here.

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



Re: can convert django docs of txt format to html format

2010-05-26 Thread pts
I've  installed Sphinx, when I type "make html" under docs directory,
but system shows that it cannot find this command.
because I'm under windows xp system???

On May 18, 2:38 am, Daniel Roseman  wrote:
> On May 17, 5:05 pm, pts  wrote:
>
> > After download django 1.2,i want to read docs offline,but can i
> > convert all txt files to html format under windows xp?
>
> http://docs.djangoproject.com/en/1.1/internals/documentation/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Speed Comparison of Django on CPython to Jython

2010-05-26 Thread Eric
Some basic searching hasn't answered my question if django running on
CPython or Jython is faster. I know its not that simple of an issue,
but I'm about to start a large django project that is moderately
resource intensive, and will have to scale to pretty large sizes.
Could anyone link some benchmarks comparing the performance of CPython
django and Jython django, or share any relevant information?
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Target WSGI script not found or unable to stat

2010-05-26 Thread Graham Dumpleton


On May 27, 8:42 am, mojito  wrote:
> Hello,
> I am trying to set up django 1.1.1 with mod_wsgi 2.3  and Apache
> 2.0.63 on Windows XP. My Python version is 2.4.4
>
> I followed the instructions for installing and configuring mod_wsgi
> fromhttp://code.google.com/p/modwsgi/.
>
> I set up the "Hello world " test first to see if my mod_wsgi install
> is correct. That works.
>
> When I come to deploy my django app on Apache , I get this error.
>
>  [error] [client 127.0.0.1] Target WSGI script not found or unable to
> stat: C:/wsgi-django-app
> /testing/apache/django.wsgi

This will occur where the user that the Apache service runs as does
not have the necessary access permissions to the directory containing
the WSGI script file. In other works, if the access controls on your
directories only allow access to yourself and no one else, Apache
service will not be able to see the WSGI script file.

Graham

> Please help ...
> Thanks
> MP
>
> My set up is as follows:
> httpd.conf
> -
> WSGIScriptAlias / C:/wsgi-django-app/testing/apache/django.wsgi
>
> 

It is more secure to have:

  

Graham

> AllowOverride None
> Options None
> Order deny,allow
> Allow from all
> 
>
> apache/django.wsgi
> ---
> import os, sys
> sys.path.append('C:/wsgi-django-app')
> sys.path.append('C:/wsgi-django-app/testing/apache')
> sys.path.append('C:/Python24/Lib/site-packages/django')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()

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



Target WSGI script not found or unable to stat

2010-05-26 Thread mojito
Hello,
I am trying to set up django 1.1.1 with mod_wsgi 2.3  and Apache
2.0.63 on Windows XP. My Python version is 2.4.4

I followed the instructions for installing and configuring mod_wsgi
from http://code.google.com/p/modwsgi/.

I set up the "Hello world " test first to see if my mod_wsgi install
is correct. That works.

When I come to deploy my django app on Apache , I get this error.

 [error] [client 127.0.0.1] Target WSGI script not found or unable to
stat: C:/wsgi-django-app
/testing/apache/django.wsgi

Please help ...
Thanks
MP

My set up is as follows:
httpd.conf
-
WSGIScriptAlias / C:/wsgi-django-app/testing/apache/django.wsgi


AllowOverride None
Options None
Order deny,allow
Allow from all


apache/django.wsgi
---
import os, sys
sys.path.append('C:/wsgi-django-app')
sys.path.append('C:/wsgi-django-app/testing/apache')
sys.path.append('C:/Python24/Lib/site-packages/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

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



Re: apache wsgi deployment on non-root URL and absolute URLs for the auth contrib app

2010-05-26 Thread Javier Rojas
Silly me can't write

>
> What should I do? change the LOGIN_*_URL settings somehow? to what
> value should I change them? I checked some pinax code lying around
> here, and I see that it simply prepends the

url of deployment

> under which the app is deployed

to all the LOGIN_*_URL settings.

> I'd rather avoid that path as that
> would imply a few extra hacks to get the development and production
> servers working properly.

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



apache wsgi deployment on non-root URL and absolute URLs for the auth contrib app

2010-05-26 Thread Javier
Hi all,

I'm trying to deploy my app under a non-root url (http://myserver.com/
myapp), using apache and wsgi, but I'm having troubles with the
configuration of the authentication framework.

When trying to log in, I get redirected to the url I defined for that
in the settings file (LOGIN_URL), but that URL doesn't have the "/
myapp" prefix, even though I defined the proper prefix in the apache
configuration file (WSGIScriptAlias /myapp .)

As far as I understand, I must use absolute URLs for both the
LOGIN_URL and LOGIN_REDIRECT_URL settings. However, that seems to
yield problems when deploying to a non-root url.

I tried using reverse() in the settings file, but that doesn't work.

I read the mod_wsgi wiki, in the section for using it with django, and
it mostly says that deploying with non-root urls should work out of
the box with django 1.0+ (django 1.2 here).

I'm kind of lost with this, and I have a few questions:

What should I do? change the LOGIN_*_URL settings somehow? to what
value should I change them? I checked some pinax code lying around
here, and I see that it simply prepends the to these settings the url
under which the app is deployed. I'd rather avoid that path as that
would imply a few extra hacks to get the development and production
servers working properly.

Maybe is there something wrong with the apache config or the wsgi
file? I copy the contents of both of them below.

Thanks,


WSGI File

import os
import sys
sys.path.append("/srv/cargue_archivos_1.0")

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

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



Apache Config File


WSGIScriptAlias /cargue_comedores /srv/cargue_archivos_1.0/fu/apache/
django.wsgi

Order allow,deny
Allow from all


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



Custom model field validation with `clean_fields()`

2010-05-26 Thread kRON
I've recently read about `clean_fields()` and decided to move some
stuff to I that I was doing in my `pre_save` handler previously. My
tests failed and then I noticed that neither `clean_fields()` nor
`full_clean()` was ever called before saving the model.

The documentation says that only `clean()` needs to be explicitly
called on the model by the user, so I'm wondering when is
`clean_fields` invoked?

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



Re: Help me with render_to_response!

2010-05-26 Thread Nate
def my_root_page(request):
#t = get_template('root.html')
html = 'Please Work!'
#t.render(Context({}))
return HttpResponse(html)

def current_datetime(request):
now = datetime.datetime.now()
return render_to_response('current_datetime.html',
{'current_date': now})

These are the views.  my_root_page displays as desired, but
current_datetime prints out:




The current time


My helpful timestamp site
It is now May 26, 2010, 5:13 p.m..

Thanks for visiting my site.



If you want to see the template I used, its




{% block title %}{% endblock %}


My helpful timestamp site
{% block content %}{% endblock %}
{% block footer %}

Thanks for visiting my site.
{% endblock %}



and

{% extends "base.html" %}
{% block title %}The current time{% endblock %}
{% block content %}
It is now {{ current_date }}.
{% endblock %}

On May 26, 5:05 pm, Daniel Roseman  wrote:
> On May 26, 8:19 pm, Nate  wrote:
>
> > I'm teaching myself django and I'm having an issue with
> > render_to_response.  I am passing it a template and a dictionary.
> > When I view the page on a local host, it displays the entire template,
> > including HTML tags, instead of formatting the page according to the
> > tags.  I don't have this issue when I hard code in the template
> > rendering and use HttpResponse.  Any suggestions would be
> > appreciated.  Thanks!
>
> Show your code, please.
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help me with render_to_response!

2010-05-26 Thread Daniel Roseman
On May 26, 8:19 pm, Nate  wrote:
> I'm teaching myself django and I'm having an issue with
> render_to_response.  I am passing it a template and a dictionary.
> When I view the page on a local host, it displays the entire template,
> including HTML tags, instead of formatting the page according to the
> tags.  I don't have this issue when I hard code in the template
> rendering and use HttpResponse.  Any suggestions would be
> appreciated.  Thanks!

Show your code, please.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Safe and easy internationalization

2010-05-26 Thread Baurzhan Ismagulov
On Mon, May 24, 2010 at 01:47:14AM -0700, Pascal wrote:
> From what I've read so far, using translation "tags" (or quick
> phrases) in the code, and translating them to every target language
> (including english) sounds a better approach than using, for example,
> final english wordings as translation tags. The setup is longer via
> the first way, but at least if you change english wordings later, you
> don't break all other translations at the same time.

This is an interesting point. I'm using both "tags" and final wordings,
albeit my goal is differently translating some strings that are the same
in English. Not breaking other translations sounds tempting, especially
if you have many; however, the result will depend on how you change the
text: If you change its meaning (which does happen), then you do want
the translations to break, and have to ensure that you change the "tag",
too; TBH, I'm too lazy to think about that :) .


> * code safety : it seems default python string formatting technics (%
> operator, .format() method) are normally used when one needs to
> substitute placeholders in translated strings. But the thing is : I
> DONT want my view to raise an exception simply because one of the
> translations has forgotten a damn "%(myvar)s" placeholder. The only
> quick fix I can think of, is to always use substitution through
> defaultdicts instances (and still, exceptions could occur if abnormal
> "%s" placeholders are found in the translated string). Are there some
> utilities in django, to allow a safe string substitution (which might,
> for example, simply log an error if a buggy string si found)  ?
> Python's template strings' "safe_substitute()" won't fit, because it
> swallows errors without any notice...

I'm not aware of any. I suspect it shouldn't be that difficult to write
one, no?


> * unknown translatable strings : I have in different data files (eg.
> yaml), strings which will need translation, but that can't be detected
> by gettext and co, since they only appear in the code as variable i.e
> "_(yamlvar)". The easiest, I guess, would be to replace them by
> specific tags (like "TR_HOMEPAGE_TITLE"), and to have a tool browse
> the code to extract them and add them to the standard gettext
> translation chain. Such a tool shouldn't be too hard to code, but I'd
> rather know : doesn't such a tool already exist somewhere ? I've seen
> no such mention in gettext or babel tools, only recogniztion via
> function calls ( _(), tr()... ).

I'm not aware of any.


> * I have seen nowhere mention of how to remove deprecated/unused
> strings from gettext files - only merging translations seems to
> interest people. However, having a translation file which slowly fills
> itself with outdated data doesn't sound cool to me. Does anyone know
> tools/program flags which would list/extract translations that don't
> seem used anymore ?

makemessages should comment out unused strings.


With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.com/

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



Re: Django error in django's context.py

2010-05-26 Thread zayatzz


On May 26, 10:26 pm, Karen Tracey  wrote:
> On Wed, May 26, 2010 at 12:13 PM, zayatzz  wrote:
> > Hello
>
> > I created new project, added bunch of apps (which are required for
> > django cms 2.0) and when i proceeded to admin, to create first set of
> > pages i got this error:
>
> >http://pastebin.com/ZYKuuz85
>
> > I also mentioned it in django cms 2.0 group here :http://
> > groups.google.com/group/django-cms/browse_thread/thread/
> > 4bb7b51fcdad09f8
>
> > Can anyone take a guess how i could fix this?
>
> Please, when you are going to cut and paste a traceback somewhere, first
> click the link to switch to copy-and-paste view. It's extremely difficult to
> read the non-copy-and-paste-view version when it's been copy-and-pasted. You
> don't give many details of what you've done, exactly, but the traceback
> seems to indicate the admin views have been wrapped in a cache decorator,
> and that is causing a problem. What have you specified for your admin
> urlpattern(s), exactly?
>
i just uncommented the line that already existed in urls.py

Alan

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



Django v1.2 TestCase doesn't seem to load fixtures except 'initial_data'

2010-05-26 Thread Bryan
I am using Django v1.2

The fixture I defined "forum_fixtures.json" don't seem to be loading
when I run tests.

from django.test.client import Client
from django.test import TestCase
from utils import *
from forum.models import *
from forum import auth
from django.contrib.contenttypes.models import ContentType


class UserProfileTestCases(TestCase):
"""These are tests to verify that refactoring of UserProfile is
correct"""
fixtures = ['forum_fixtures.json'] ## @ forum/fixtures/
forum_fixtures.json
def setUp(self):
self.client = Client()
if self.client.login(username='DickCheney', password='test'):
print "client.login DickCheney successful";
else:
print "client.login FAILED"

def test_set_new_email(self):
orig_email = User.objects.get(username='DickCheney')
response = self.client.post('changeemail',
{u'email':'cockgobb...@nwo.gov'})
 
self.assertNotEqual(User.objects.get(username='DickCheney').email,
orig_email)

I ran the tests verbosely:
python manage.py test --verbosity=2

Django only looked for fixtures named 'initial_data'. Not once was
there are search for 'forum_fixtures.json'

I changed the fixture name to 'initial_data.json' and it now works.

I just thought I'd post the work around.

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



set model field some value before add

2010-05-26 Thread ev
class Structure(models.Model):
parent =
models.ForeignKey('site.Structure',blank=True,null=True,default=0)
title = models.CharField(max_length=128,verbose_name=u'Заголовок')
url = models.CharField(max_length=48,verbose_name=u'URL')
ordering = models.IntegerField(blank=True,editable=False,default=1)
level = models.SmallIntegerField(blank=True,editable=False,default=1)

I'd like to set Structure.ordering and Structure.level with special
values, based on something.

Is there way to provide Structure.before_add(self) method? I need this
method to be called every time after saving model data.

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



Re: Feedparser strange behaviour on Unix-platform Django

2010-05-26 Thread steve
Resolved.  Here it is, but don't throw a tomatoe at me or anything
when I tell you.

The database table that I was reading my feeds from - the record for
the yahoo field.. it had a tab character right before the feed string.

:\

On May 26, 12:33 pm, steve  wrote:
> Feedparser doesn't like, for some reason, the "http://
> rss.news.yahoo.com/rss/topstories" feed for some reason, but only
> under specific conditions.
>
> -Won't- work: (i.e. 'bozo_exception': SAXParseException('not well-
> formed (invalid token)',)
>      Inside a Django views.py file, and only on my live webfaction
> account.
>
> -Will- work:
>        In my Django App, but on my *Dev Server*, on my Win 95 PC -
> parses fine
>
>        In *any* separate Python script anywhere, whether on my win
> machine, or on Webfaction's system,
>        it gets parsed fine.
>
>          [  It just simply doesn't like this Yahoo feed, when on live
> Django views.py, on webfaction  ]
>
> If anyone is using feedparser, I would be grateful if you could try
> out the yahoo feed above, and tell me if it gets parsed successfully
> on your live unix-based Django server.
>
> If not, no prob, I'll narrow it down eventually.
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Image deduplication and upload_to

2010-05-26 Thread Ricardo Bánffy
Hi folks.

I want to prevent the duplication of uploaded images. For that, I am
using the upload_to property of ImageField set to a callable that
computes the md5 hash of the uploaded file data and returns a file
name. This should work _but_ when I save the model, the filename I
gave back in the function is getting a "_1", "_2" and so on suffix to
prevent my efforts at deduplication.

http://dpaste.com/199576/

Anyone has had a similar problem?

I understand I'll have to take care of other problems too, like
preventing the deletion of files that are referenced by more than one
ImageFile and could do something to prevent the actual overwriting of
the same data on the same file as before, but that's a start.


-- 
Ricardo Bánffy
http://www.dieblinkenlights.com
http://twitter.com/rbanffy

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



Feedparser strange behaviour on Unix-platform Django

2010-05-26 Thread steve
Feedparser doesn't like, for some reason, the "http://
rss.news.yahoo.com/rss/topstories" feed for some reason, but only
under specific conditions.

-Won't- work: (i.e. 'bozo_exception': SAXParseException('not well-
formed (invalid token)',)
 Inside a Django views.py file, and only on my live webfaction
account.


-Will- work:
   In my Django App, but on my *Dev Server*, on my Win 95 PC -
parses fine

   In *any* separate Python script anywhere, whether on my win
machine, or on Webfaction's system,
   it gets parsed fine.

 [  It just simply doesn't like this Yahoo feed, when on live
Django views.py, on webfaction  ]


If anyone is using feedparser, I would be grateful if you could try
out the yahoo feed above, and tell me if it gets parsed successfully
on your live unix-based Django server.

If not, no prob, I'll narrow it down eventually.

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



Re: Django error in django's context.py

2010-05-26 Thread Karen Tracey
On Wed, May 26, 2010 at 12:13 PM, zayatzz  wrote:

> Hello
>
> I created new project, added bunch of apps (which are required for
> django cms 2.0) and when i proceeded to admin, to create first set of
> pages i got this error:
>
> http://pastebin.com/ZYKuuz85
>
> I also mentioned it in django cms 2.0 group here :http://
> groups.google.com/group/django-cms/browse_thread/thread/
> 4bb7b51fcdad09f8
>
> Can anyone take a guess how i could fix this?
>

Please, when you are going to cut and paste a traceback somewhere, first
click the link to switch to copy-and-paste view. It's extremely difficult to
read the non-copy-and-paste-view version when it's been copy-and-pasted. You
don't give many details of what you've done, exactly, but the traceback
seems to indicate the admin views have been wrapped in a cache decorator,
and that is causing a problem. What have you specified for your admin
urlpattern(s), exactly?

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

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



Help me with render_to_response!

2010-05-26 Thread Nate
I'm teaching myself django and I'm having an issue with
render_to_response.  I am passing it a template and a dictionary.
When I view the page on a local host, it displays the entire template,
including HTML tags, instead of formatting the page according to the
tags.  I don't have this issue when I hard code in the template
rendering and use HttpResponse.  Any suggestions would be
appreciated.  Thanks!

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



Re: Django minimum deployment requirements

2010-05-26 Thread Jirka Vejrazka
As long as you have Django installed, yes. It's in the documentation.

  Cheers

 Jirka

On 26/05/2010, Murasame  wrote:
> Can a Django powered app run in a standard apache mod_python only
> webserver?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: problem with running test

2010-05-26 Thread irum
Sorry, I fixed it. It was a small overlook so I thought I should post
it here for newbies. After updating my django-trunk and including
installed apps,I was missing application name after test, i.e.,
command should be:  manage.py test [aapname]

BR,
Irum


On May 26, 7:12 pm, irum  wrote:
> Hi,
> I am working on django for a project and have to do some funcitonal
> testing.
>
> However, whenever I run manage.py test, I get the error shown below. I
> have tried searching threads in this group and they mention having
> these applications installed in my settings file:
> 'django.contrib.auth', 'django.contrib.sites', 'django.contrib.admin'.
> I have them all. Secondly, they mention this 
> ticket:http://code.djangoproject.com/changeset/10674
>
> I have dowloaded both the files remote_user.py and url.py and updated
> them in my trunk folder at the path mentioned in this ticket, but even
> then the problem did not resolve. I also tried subversion update of
> the django-trunk folder, but still the problem persists. Can someone
> kindly guide me where I am going wrong? I spent my whole day to fix
> this but to no avail.
>
> Thanks in advance.
>
> Creating test database...
> Creating table auth_permission
> Creating table auth_group
> Creating table auth_user
> Creating table auth_message
> Creating table django_content_type
> Creating table django_session
> Creating table django_site
> Creating table yaas_auction
> Creating table yaas_bid
> Creating table yaas_userprofile
> Creating table yaas_winner
> Creating table django_admin_log
> Installing index for auth.Permission model
> Installing index for auth.Message model
> Installing index for yaas.auction model
> Installing index for yaas.Bid model
> Installing index for yaas.winner model
> Installing index for admin.LogEntry model
> FFF.F...F.....
> ==
> ERROR: test_known_user
> (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
> --
> Traceback (most recent call last):
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
> line 160, in test_known_user
>     super(RemoteUserCustomTest, self).test_known_user()
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
> line 72, in test_known_user
>     self.assertEqual(response.context['user'].username, 'knownuser2')
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_last_login
> (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
> --
> Traceback (most recent call last):
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
> line 87, in test_last_login
>     self.assertNotEqual(default_login,
> response.context['user'].last_login)
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_no_remote_user
> (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
> --
> Traceback (most recent call last):
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
> line 33, in test_no_remote_user
>     self.assert_(isinstance(response.context['user'], AnonymousUser))
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_unknown_user
> (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
> --
> Traceback (most recent call last):
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
> line 168, in test_unknown_user
>     super(RemoteUserCustomTest, self).test_unknown_user()
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
> line 51, in test_unknown_user
>     self.assertEqual(response.context['user'].username, 'newuser')
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_known_user
> (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
> --
> Traceback (most recent call last):
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
> 

Django minimum deployment requirements

2010-05-26 Thread Murasame
Can a Django powered app run in a standard apache mod_python only
webserver?

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



Re: Django Hosting

2010-05-26 Thread piz...@gmail.com

Try HelioHost and AlwaysData

Cheers,
Oscar C.

El 26/05/2010, a las 18:27, Anjan Dwaraknath escribió:


Hey,

I have a startup company, I wish to setup a website for it, is it
possible to get free web hosting for my site, till i find out if it
works out or not

Thank you

--  
You received this message because you are subscribed to the Google  
Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to django-users 
+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/ 
group/django-users?hl=en.




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



Re: Session not working as i had hoped

2010-05-26 Thread Masklinn
On 2010-05-26, at 15:02 , Nuno Maltez wrote:
> 
> http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-sessions-in-views
> 
> 
>>if request.session.get('has_visited',True):
> 
> You're passing True as the default value to the get method  - get(key,
> default=None); this means that when 'has_visited' isn't set in your
> session (1st visit) it still returns True.
> 
> Just replace :
> 
>   if request.session.get('has_visited',True):
>   visited = True
>   else:
>   visited = False
> 
> with
> 
> visited = request.session.get('has_visited', False)
> 
> hth,
> Nuno


The `False` default isn't even mandatory.

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



Re: Session not working as i had hoped

2010-05-26 Thread daniels
Also move :
  request.session['has_visited'] = True
above the return statement.

On May 26, 4:02 pm, Nuno Maltez  wrote:
> http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-sess...
>
> >    if request.session.get('has_visited',True):
>
> You're passing True as the default value to the get method  - get(key,
> default=None); this means that when 'has_visited' isn't set in your
> session (1st visit) it still returns True.
>
> Just replace :
>
>    if request.session.get('has_visited',True):
>        visited = True
>    else:
>        visited = False
>
> with
>
> visited = request.session.get('has_visited', False)
>
> hth,
> Nuno

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



Django Hosting

2010-05-26 Thread Anjan Dwaraknath
Hey,

I have a startup company, I wish to setup a website for it, is it
possible to get free web hosting for my site, till i find out if it
works out or not

Thank you

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



Re: ModelForm always calls Model's clean method

2010-05-26 Thread Rendy Anthony
My mistake in the model definition. They are supposed to be foreign keys to
the same model.

Thank you for the explanation. I was expecting something like the errors
variable like in a Form. Unfortunately there is no equivalent "error"
variable in the model validation. Here is what I can do in forms:

class MyForm(forms.Form):
def clean(self):
if self.errors:
return # Skip validation if there are existing errors

if self.cleaned_data['departure'] == self.cleaned_data['arrival']:
raise ValidationError("Can't be the same")

I think the documentation should make it clear that the DoesNotExist
exception might be raised in the clean method when trying to access a
foreign key.

Regards,
Rendy Anthony

On Wed, May 19, 2010 at 9:16 PM, Karen Tracey  wrote:

> On Wed, May 19, 2010 at 1:12 AM, ak37  wrote:
>
>> I just tried the new Model Validation feature in Django 1.2 and I
>> found out that ModelForm always calls the Model's clean method even
>> when the form validation has errors. This causes problems when the
>> model has a foreign key, and the value is validated in the clean
>> method. Consider this example:
>>
>> class Flight(models.Model):
>>aircraft = models.ForeignKey(Aircraft)
>>departure = models.ForeignKey(Departure)
>>arrival = models.ForeignKey(Arrival)
>>
>>def clean(self):
>># There can never be flights departing and arriving to the
>> same place
>>if self.departure == self.arrival:
>>raise ValidationError("Departure is the same as Arrival")
>>
>> class FligthForm(forms.ModelForm):
>>class Meta:
>>model = Flight
>>
>> If the form is submitted with empty values, I will get a DoesNotExist
>> exception when trying to access the self.departure/self.arrival
>> attribute in the clean method. Is this by design? If it is then what
>> is the recommended practice to implement the Model's clean method?
>>
>
>
> Calling the model clean() even though validation errors have already been
> noted is consistent with the way form validation is done: the form-wide
> clean() is called even when validation errors have been raised for
> individual fields. It's up to the form-wide clean() to make sure the values
> it wants to work with survived the earlier cleaning attempts; this is noted
> for example here:
> http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other.
> Similarly a model clean() method must be aware that the values it has may
> not be valid per earlier validation that has been run.
>
> In this specific case one way to deal with the issue would be to use a
> try/except block and catch the DoesNotExist. If one is raised, you may
> assume that that error has already been noted by the form cleaning, and just
> ignore it.
>
> (I am a little confused by your model definition though -- you have
> departure and arrival defined as ForeignKeys to different models, so I don't
> see how they would ever compare as equal, unless your actual code is
> checking some attribute on each rather then equality of the foreign key
> values themselves?)
>
> Karen
> --
> http://tracey.org/kmt/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Creating a custom view in Django admin,

2010-05-26 Thread Dexter
Hi,

I am building a newsletter system, but I'm wondering how to incorporate it
into the django admin.
Just recently I started discovering the capabilities of the admin interface,
and finding out how things are supposed to be working.
I want to make an interface which follows the django "zen".

My situation is as follows, I have to models which need to be incorporated
into the newsletter,
An agenda, with events, and a messaging system to display announcements.
My newsletter model has two manytomanyfields pointing to the event and the
message models.

What I really want to do, is at creation of a new newsletter, the user
selects the events and messages that should be displayed in the newsletter.
Then, when the user saves the newsletter, a custom view is displayed (The
newsletter is not yet saved). In which the user can select the order in
which the objects (messages and events) should be displayed.(ie via drag and
drop)

The next step is confirmation, so the user sees the entire
newsletter, entirely formatted.

Is this the best way to do this kind of thing?, or should it be approached
differently?

Another thing:

At the event model, it is unnecessary to display all the events in the
admin. How can I make sure only the events coming (ie
date__gte=datetime.now()) are displayed in the admin?

 Thanks in advance for your help.

Greetings, Dexter

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



Re: ModelForm gives invalid option.

2010-05-26 Thread Joshua Frankenstein Lutes
That did it!  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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django error in django's context.py

2010-05-26 Thread zayatzz
Hello

I created new project, added bunch of apps (which are required for
django cms 2.0) and when i proceeded to admin, to create first set of
pages i got this error:

http://pastebin.com/ZYKuuz85

I also mentioned it in django cms 2.0 group here :http://
groups.google.com/group/django-cms/browse_thread/thread/
4bb7b51fcdad09f8

Can anyone take a guess how i could fix this?

Alan

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



problem with running test

2010-05-26 Thread irum
Hi,
I am working on django for a project and have to do some funcitonal
testing.

However, whenever I run manage.py test, I get the error shown below. I
have tried searching threads in this group and they mention having
these applications installed in my settings file:
'django.contrib.auth', 'django.contrib.sites', 'django.contrib.admin'.
I have them all. Secondly, they mention this ticket:
http://code.djangoproject.com/changeset/10674

I have dowloaded both the files remote_user.py and url.py and updated
them in my trunk folder at the path mentioned in this ticket, but even
then the problem did not resolve. I also tried subversion update of
the django-trunk folder, but still the problem persists. Can someone
kindly guide me where I am going wrong? I spent my whole day to fix
this but to no avail.

Thanks in advance.

Creating test database...
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table yaas_auction
Creating table yaas_bid
Creating table yaas_userprofile
Creating table yaas_winner
Creating table django_admin_log
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for yaas.auction model
Installing index for yaas.Bid model
Installing index for yaas.winner model
Installing index for admin.LogEntry model
FFF.F...F.....
==
ERROR: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 160, in test_known_user
super(RemoteUserCustomTest, self).test_known_user()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 72, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser2')
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 87, in test_last_login
self.assertNotEqual(default_login,
response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 33, in test_no_remote_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 168, in test_unknown_user
super(RemoteUserCustomTest, self).test_unknown_user()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 51, in test_unknown_user
self.assertEqual(response.context['user'].username, 'newuser')
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py",
line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File 

Re: EmailField etc. and VARCHAR / TEXT

2010-05-26 Thread Jonathan Hayward
Thank you!

On Wed, May 26, 2010 at 8:30 AM, Alex Robbins  wrote:

> If you are using 1.2, then you could make a TextField with an email
> validator. That gets bonus points for using a new feature :)
> http://docs.djangoproject.com/en/dev/ref/forms/validation/#using-validators
>
> Alex
>
> On May 26, 8:24 am, Jonathan Hayward
>  wrote:
> > Thanks!
> >
> > On Wed, May 26, 2010 at 5:32 AM, Daniel Roseman  >wrote:
> >
> >
> >
> > > On May 25, 10:49 pm, Jonathan Hayward
> > >  wrote:
> > > > For CharField, EmailField, URLField, etc., is VARCHAR implementation
> > > > (meaning a fixed limit on length) absolutely non-negotiable, or there
> a
> > > way
> > > > to make e.g. a CharField that won't truncate if you cross some
> arbitrary
> > > > length?
> >
> > > > (If you don't specify a length, does it assign a default length, or
> use
> > > TEXT
> > > > instead of VARCHAR so that a field of indefinite length is
> accommodated,
> > > > resources permitting?)
> >
> > > EmailField is a subclass of CharField, so it always uses a varchar. As
> > > the documentation notes, the default length if you don't specify one
> > > is 75.
> >
> > > If you really want an email field based on TEXT, you could subclass
> > > EmailField with a get_internal_type method that returns 'TextField'.
> > > --
> > > 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-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > → Jonathan Hayward, christos.jonathan.hayw...@gmail.com
> > → An Orthodox Christian author: theology, literature, et cetera.
> > → My award-winning collection is available for free reading online:
> > ☩ I invite you to visit my main site athttp://JonathansCorner.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
→ Jonathan Hayward, christos.jonathan.hayw...@gmail.com
→ An Orthodox Christian author: theology, literature, et cetera.
→ My award-winning collection is available for free reading online:
☩ I invite you to visit my main site at http://JonathansCorner.com/

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



Re: Grouping of applications in admin

2010-05-26 Thread Alex Robbins
You should check out django-admin-tools [0]
It lets you make lots of changes to the admin index page.

Hope that helps,
Alex

[0]http://bitbucket.org/izi/django-admin-tools/wiki/Home
On May 25, 9:54 am, Dejan Noveski  wrote:
> Hello,
>
> Is there a way i can group admin models from different applications to show
> in one container in admin initial page?
>
> Thanks,
> Dejan
>
> --
> --
> Dejan Noveski
> Web Developer
> dr.m...@gmail.com
> Twitter:http://twitter.com/dekomote| 
> LinkedIn:http://mk.linkedin.com/in/dejannoveski
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: testing the comment framework using the test client

2010-05-26 Thread Alex Robbins
The way I've tested it in the past is:

GET the page, using the client. Scrape the values you need.
(BeautifulSoup makes this really easy, but you can do it with python's
builtin stdlib I guess.)
POST the comment message, along with all the values you just scraped.

Hope that helps,
Alex

On May 25, 10:41 am, Thierry  wrote:
> How do you guys test implementations of the django comment framework?
> A regular post doesnt seem to work because it depends on data from a
> previous get.
> An thoughts?
>
>     def test_comment(self):
>         item_url = reverse('item', args=['4558'])
>         self.client.login(username=self.username,
> password=self.password)
>         import datetime
>         test_message = 'test at %s' % datetime.datetime.today()
>         item_view = self.client.get(item_url)
>         comment_submit = self.client.post(item_url, {'comment':
> test_message})
>         test = open('test.html', 'w')
>         import os
>         print dir(test)
>         print test.name
>         print os.path.abspath(test.name)
>
>         test.write(unicode(comment_submit))
>         item_view = self.client.get(item_url)
>         self.assertContains(item_view, test_message)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: EmailField etc. and VARCHAR / TEXT

2010-05-26 Thread Alex Robbins
If you are using 1.2, then you could make a TextField with an email
validator. That gets bonus points for using a new feature :)
http://docs.djangoproject.com/en/dev/ref/forms/validation/#using-validators

Alex

On May 26, 8:24 am, Jonathan Hayward
 wrote:
> Thanks!
>
> On Wed, May 26, 2010 at 5:32 AM, Daniel Roseman wrote:
>
>
>
> > On May 25, 10:49 pm, Jonathan Hayward
> >  wrote:
> > > For CharField, EmailField, URLField, etc., is VARCHAR implementation
> > > (meaning a fixed limit on length) absolutely non-negotiable, or there a
> > way
> > > to make e.g. a CharField that won't truncate if you cross some arbitrary
> > > length?
>
> > > (If you don't specify a length, does it assign a default length, or use
> > TEXT
> > > instead of VARCHAR so that a field of indefinite length is accommodated,
> > > resources permitting?)
>
> > EmailField is a subclass of CharField, so it always uses a varchar. As
> > the documentation notes, the default length if you don't specify one
> > is 75.
>
> > If you really want an email field based on TEXT, you could subclass
> > EmailField with a get_internal_type method that returns 'TextField'.
> > --
> > 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> → Jonathan Hayward, christos.jonathan.hayw...@gmail.com
> → An Orthodox Christian author: theology, literature, et cetera.
> → My award-winning collection is available for free reading online:
> ☩ I invite you to visit my main site athttp://JonathansCorner.com/

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



ContentType for proxy models

2010-05-26 Thread TallFurryMan
Hello,

I wrote a model which is not abstract, and from which a few
specialized classes derive:

| class Action( Model ):
| item = ForeignKey( Item )
| # A few other properties
|
| class Move( Action ):
| class Meta:
| proxy = True
|
| class Pick( Action )
| class Meta:
| proxy = True
|

(the foreign key to Item may seem strange, but Actions change their
properties during the life cycle of an Item)

My Action could be abstract, but I'd like to be able to select generic
Actions. Am I correct in creating a non-abstract model for this
purpose?

My derived Actions add specialized interactions with other models, but
I don't need more fields and I want to avoid changing the db when
adding behaviours. Am I correct in creating proxy models for those
specialized Actions?

Consequently, my problem is that I can't restore a Move from an Action
once saved.

I tried to use ContentType, but its manager refers to the base model
and loses the proxy.

I could use a factory to instantiate the derived Actions, but fiddling
with dynamic import doesn't sound right and portable.

There is something I am missing here. Any tip?

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



Re: EmailField etc. and VARCHAR / TEXT

2010-05-26 Thread Jonathan Hayward
Thanks!

On Wed, May 26, 2010 at 5:32 AM, Daniel Roseman wrote:

> On May 25, 10:49 pm, Jonathan Hayward
>  wrote:
> > For CharField, EmailField, URLField, etc., is VARCHAR implementation
> > (meaning a fixed limit on length) absolutely non-negotiable, or there a
> way
> > to make e.g. a CharField that won't truncate if you cross some arbitrary
> > length?
> >
> > (If you don't specify a length, does it assign a default length, or use
> TEXT
> > instead of VARCHAR so that a field of indefinite length is accommodated,
> > resources permitting?)
>
> EmailField is a subclass of CharField, so it always uses a varchar. As
> the documentation notes, the default length if you don't specify one
> is 75.
>
> If you really want an email field based on TEXT, you could subclass
> EmailField with a get_internal_type method that returns 'TextField'.
> --
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
→ Jonathan Hayward, christos.jonathan.hayw...@gmail.com
→ An Orthodox Christian author: theology, literature, et cetera.
→ My award-winning collection is available for free reading online:
☩ I invite you to visit my main site at http://JonathansCorner.com/

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



Re: Session not working as i had hoped

2010-05-26 Thread Nuno Maltez
http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-sessions-in-views


>    if request.session.get('has_visited',True):

You're passing True as the default value to the get method  - get(key,
default=None); this means that when 'has_visited' isn't set in your
session (1st visit) it still returns True.

Just replace :

   if request.session.get('has_visited',True):
   visited = True
   else:
   visited = False

with

visited = request.session.get('has_visited', False)

hth,
Nuno

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



Re: Session not working as i had hoped

2010-05-26 Thread Jirka Vejrazka
Hi,

  a simple hint: try to point out a place in your code where
has_visited does exist and is set to False.

  Also, you probably don't want to have any code in your view after an
unconditional "return" statement - that code would never get executed.

  HTH

Jikra

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



Session not working as i had hoped

2010-05-26 Thread grimmus
Hi,

When the user enters a site for the first time they should see a flash
version of the logo. All other times they should see a gif image. My
home view looks like:

if request.session.get('has_visited',True):
visited = True
else:
visited = False

t = loader.get_template('static/home.html')
c = RequestContext(request,{
'visited': visited,
})
return HttpResponse(t.render(c))

request.session['has_visited'] = True

So, i set the value of the session after the page has been served.

Then in my template i have

{% if visited %}
visited already, show gif logo
{% else %}
new user, show flash logo
{% endif %}

It seems the Session is always True, even when i clear all browser
info, restart etc.

Could someone tell me what i am doing wrong ?

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



Re: disabling dashboard 'recent actions'

2010-05-26 Thread Dirk Eschler
Am Mittwoch 26 Mai 2010, 08:50:09 schrieb rahul jain:
> Hi Django,
> 
> How to disable the dashboard ('recent actions') on django admin main page ?

Hello,

you can override the admin/index.html template to disable the display. There's 
a sidebar block you might want to change/remove.

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 

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



Re: ModelForm gives invalid option.

2010-05-26 Thread Nuno Maltez
You simply need to provide a default value for your field, i.e. :
turtle_type = models.IntegerField(null=False, blank=False,
choices=TURTLE_TYPES, default=1)

See the notes on:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#field-types


hth,
Nuno

On Tue, May 25, 2010 at 10:05 PM, Joshua Frankenstein Lutes
 wrote:
> I have a Model that looks something like this:
>
> ==
> class Turtle(models.Model):
> turtle_type = models.IntegerField(null=False, blank=False,
> choices=TURTLE_TYPES)
> ==
>
> I use it to create a ModelForm:
>
> ==
> class TurtleForm(forms.ModelForm):
> class Meta:
> model = Turtle
>
> widgets = {
> 'turtle_type': forms.RadioSelect,
> }
> ==
>
> The problem is that when I display the TurtleForm, it shows a radio
> select for "-", which correlates to a null option. This
> doesn't validate when the form is submitted and I don't want it to be
> a selectable option. How can I prevent this from being displayed?
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Permissions of abstract model not added on syncdb

2010-05-26 Thread Dirk Eschler
Hello,

i've got an abstract model which has no fields and only defines permissions. 
The permission isn't added to the auth_permission table on syncdb nor is the 
content_type added to django_content_type. The app is in INSTALLED_APPS.

class Base(models.Model):
class Meta:
abstract = True
permissions = (
("can_do_foo", _(u"Can do foo")),
)

Is this a bug or am i missing something? I'm using django-1.2.1.

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 

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



Re: EmailField etc. and VARCHAR / TEXT

2010-05-26 Thread Daniel Roseman
On May 25, 10:49 pm, Jonathan Hayward
 wrote:
> For CharField, EmailField, URLField, etc., is VARCHAR implementation
> (meaning a fixed limit on length) absolutely non-negotiable, or there a way
> to make e.g. a CharField that won't truncate if you cross some arbitrary
> length?
>
> (If you don't specify a length, does it assign a default length, or use TEXT
> instead of VARCHAR so that a field of indefinite length is accommodated,
> resources permitting?)

EmailField is a subclass of CharField, so it always uses a varchar. As
the documentation notes, the default length if you don't specify one
is 75.

If you really want an email field based on TEXT, you could subclass
EmailField with a get_internal_type method that returns 'TextField'.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Resize uploaded file file with PIL

2010-05-26 Thread Igor Rubinovich
Dejan -

I think this was what I was looking for (and probably should have been
able to figure it out myself :)) Thanks!
Are you sure there's no problem with binary or other encodings?

Thanks,
Igor



On May 26, 10:15 am, Dejan Noveski  wrote:
> Why don't you try and copy request.FILES (request.FILES.copy()) and work
> with the new dictionary. As I understand request dictionaries are immutable.
> You can't change the reference of the image. Something like this:
>
> files_dict = request.FILES.copy()
> img = files_dict['image']
> img.thumbnail( (200,200), Image.ANTIALIAS)
> img.save(files_dict["image"], "JPG")
>
> At the end, change the reference to img
>
> files_dict["image"] = img
>
> and pass files_dict to the form instead of request.FILES
>
> On Wed, May 26, 2010 at 10:07 AM, Igor Rubinovich 
>
>
>
>
> > wrote:
> > In my photo class, the field is not ImageField but rather a custom
>
> >    image = PicasaImageField(upload_to=get_upload_to, blank=True,
> > storage=pwcs())
>
> > And storage=pwcs() is probably what you're asking about.
>
> > For the saving bit, here's some code with lots of detail omitted:
>
> > photo = Photo(owner=currentUser)
> > photo_form = forms.PhotoEditForm(request.POST, request.FILES,
> > instance=photo)
> > photo.upload_to = "user/%s/gallery/album/%s/photo/%s" %
> > (currentUser.username, album.title, request.FILES['image'].name)
>
> > photo = photo_form.save()
>
> > The path is emulated. I hardly use it in fact, but I could if I wanted
> > to. Most of the time though I use photo objects in conjunction with
> > gallery objects to which they have a foreign key.
>
> > Anyway, the idea is that with .save() the file goes to picasa and I
> > prefer to never touch it again, at least for now. But I would like to
> > resize it to sensible dimensions just before that.
>
> > On May 26, 9:47 am, Kenneth Gonsalves  wrote:
> > > On Wednesday 26 May 2010 13:07:50 Igor Rubinovich wrote:
>
> > > > This probably needs more explanation, otherwise I'll keep misleading
> > > > people into answering some question other then mine.
> > > > I store the file in a custom storage (picasaweb) that I've implemented
> > > > myself. The file never touches my filesystem and always stays a stream
> > > > or whatever file-like object it is until it's gone to the custom
> > > > storage for good.
>
> > > just a clarification - how do you tell django where to store the file?
> > > --
> > > Regards
> > > Kenneth Gonsalves
> > > Senior Associate
> > > NRC-FOSS at AU-KBC
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> --
> Dejan Noveski
> Web Developer
> dr.m...@gmail.com
> Twitter:http://twitter.com/dekomote| 
> LinkedIn:http://mk.linkedin.com/in/dejannoveski

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



Re: Email Backend setting needed, a potential bug

2010-05-26 Thread Lakshman Prasad
So, I see what has happened. (Interesting it is)

I upgraded django to 1.2 to try out:

$pip install --upgrade django

Then, back to work again:

$pip install django==1.1.2

I don't think pip removed the pyc files when replacing, which is making it
import mail module.

So, This problem should be solved if I removed all pycs. I did.

$find -name "*.pyc" -delete

I still have the same problem.

I am sure, I am using 1.1.1 right now, because in my view I do:

import django
django.get_version()

and it prints:
1.1.1

(This is no major problem, I know I can delete the entire folder and install
again. But it is interesting how it happened, which could be a bug in pip.)


On Wed, May 26, 2010 at 12:34 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Wed, May 26, 2010 at 2:54 AM, Lakshman Prasad 
> wrote:
> > Hi,
> > Since I upgraded to 1.1.2, I am unable to send mails as django seems
> > expecting a EMAIL_BACKEND.
>
> Something is severely broken with your setup, then. EMAIL_BACKEND is a
> setting that was introduced in Django 1.2, but it doesn't exist in
> 1.1.1 or 1.1.2.
>
> So - somehow you've managed to install Django 1.2, and that is what is
> being found by Python. Your stack trace also confirms this -
> django.core.mail is a module on Django 1.1.X, and a directory on 1.2.
> The stack trace you provide shows that you've got a directory.
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Email Backend setting needed, a potential bug

2010-05-26 Thread ankit rai
check your django version .It might be that you have django at two places .I
m using django 1.1 , have not fount such problem

On Wed, May 26, 2010 at 12:34 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Wed, May 26, 2010 at 2:54 AM, Lakshman Prasad 
> wrote:
> > Hi,
> > Since I upgraded to 1.1.2, I am unable to send mails as django seems
> > expecting a EMAIL_BACKEND.
>
> Something is severely broken with your setup, then. EMAIL_BACKEND is a
> setting that was introduced in Django 1.2, but it doesn't exist in
> 1.1.1 or 1.1.2.
>
> So - somehow you've managed to install Django 1.2, and that is what is
> being found by Python. Your stack trace also confirms this -
> django.core.mail is a module on Django 1.1.X, and a directory on 1.2.
> The stack trace you provide shows that you've got a directory.
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Resize uploaded file file with PIL

2010-05-26 Thread Dejan Noveski
Why don't you try and copy request.FILES (request.FILES.copy()) and work
with the new dictionary. As I understand request dictionaries are immutable.
You can't change the reference of the image. Something like this:

files_dict = request.FILES.copy()
img = files_dict['image']
img.thumbnail( (200,200), Image.ANTIALIAS)
img.save(files_dict["image"], "JPG")

At the end, change the reference to img

files_dict["image"] = img

and pass files_dict to the form instead of request.FILES

On Wed, May 26, 2010 at 10:07 AM, Igor Rubinovich  wrote:

> In my photo class, the field is not ImageField but rather a custom
>
>image = PicasaImageField(upload_to=get_upload_to, blank=True,
> storage=pwcs())
>
> And storage=pwcs() is probably what you're asking about.
>
> For the saving bit, here's some code with lots of detail omitted:
>
> photo = Photo(owner=currentUser)
> photo_form = forms.PhotoEditForm(request.POST, request.FILES,
> instance=photo)
> photo.upload_to = "user/%s/gallery/album/%s/photo/%s" %
> (currentUser.username, album.title, request.FILES['image'].name)
>
> photo = photo_form.save()
>
> The path is emulated. I hardly use it in fact, but I could if I wanted
> to. Most of the time though I use photo objects in conjunction with
> gallery objects to which they have a foreign key.
>
> Anyway, the idea is that with .save() the file goes to picasa and I
> prefer to never touch it again, at least for now. But I would like to
> resize it to sensible dimensions just before that.
>
>
>
>
> On May 26, 9:47 am, Kenneth Gonsalves  wrote:
> > On Wednesday 26 May 2010 13:07:50 Igor Rubinovich wrote:
> >
> > > This probably needs more explanation, otherwise I'll keep misleading
> > > people into answering some question other then mine.
> > > I store the file in a custom storage (picasaweb) that I've implemented
> > > myself. The file never touches my filesystem and always stays a stream
> > > or whatever file-like object it is until it's gone to the custom
> > > storage for good.
> >
> > just a clarification - how do you tell django where to store the file?
> > --
> > Regards
> > Kenneth Gonsalves
> > Senior Associate
> > NRC-FOSS at AU-KBC
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Re: Resize uploaded file file with PIL

2010-05-26 Thread Igor Rubinovich
In my photo class, the field is not ImageField but rather a custom

image = PicasaImageField(upload_to=get_upload_to, blank=True,
storage=pwcs())

And storage=pwcs() is probably what you're asking about.

For the saving bit, here's some code with lots of detail omitted:

photo = Photo(owner=currentUser)
photo_form = forms.PhotoEditForm(request.POST, request.FILES,
instance=photo)
photo.upload_to = "user/%s/gallery/album/%s/photo/%s" %
(currentUser.username, album.title, request.FILES['image'].name)

photo = photo_form.save()

The path is emulated. I hardly use it in fact, but I could if I wanted
to. Most of the time though I use photo objects in conjunction with
gallery objects to which they have a foreign key.

Anyway, the idea is that with .save() the file goes to picasa and I
prefer to never touch it again, at least for now. But I would like to
resize it to sensible dimensions just before that.




On May 26, 9:47 am, Kenneth Gonsalves  wrote:
> On Wednesday 26 May 2010 13:07:50 Igor Rubinovich wrote:
>
> > This probably needs more explanation, otherwise I'll keep misleading
> > people into answering some question other then mine.
> > I store the file in a custom storage (picasaweb) that I've implemented
> > myself. The file never touches my filesystem and always stays a stream
> > or whatever file-like object it is until it's gone to the custom
> > storage for good.
>
> just a clarification - how do you tell django where to store the file?
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC

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



Re: Resize uploaded file file with PIL

2010-05-26 Thread Kenneth Gonsalves
On Wednesday 26 May 2010 13:07:50 Igor Rubinovich wrote:
> This probably needs more explanation, otherwise I'll keep misleading
> people into answering some question other then mine.
> I store the file in a custom storage (picasaweb) that I've implemented
> myself. The file never touches my filesystem and always stays a stream
> or whatever file-like object it is until it's gone to the custom
> storage for good.
> 

just a clarification - how do you tell django where to store the file?
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



Re: Resize uploaded file file with PIL

2010-05-26 Thread Igor Rubinovich
Kenneth and all,

This probably needs more explanation, otherwise I'll keep misleading
people into answering some question other then mine.
I store the file in a custom storage (picasaweb) that I've implemented
myself. The file never touches my filesystem and always stays a stream
or whatever file-like object it is until it's gone to the custom
storage for good.
It's possible to resize it in the custom storage stage just before
saving, but it would be the wrong way since if I change the storage to
something else I would need to reimplement the bit. So the right place
is just before saving the form.
Another detail - I use ModelForm to reduce writing, so basically
everything is automated by Django.

So... now with this detail - would anyone have a suggestion?

Thanks,
Igor




On May 26, 9:00 am, Kenneth Gonsalves  wrote:
> On Wednesday 26 May 2010 12:12:39 Igor Rubinovich wrote:> But I really want 
> to do what I said I want to do.
>
> > Does anyone has a suggestion?
>
> http://docs.djangoproject.com/en/dev/ref/request-response/#httpreques...http://docs.djangoproject.com/en/dev/topics/files/#topics-files
>
> basically django stores the filename in the db and the actual file on the
> filesystem, so to manipulate, all you need to do is find the file on the
> filesystem and modify it using standard python.
>
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC

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



Re: Email Backend setting needed, a potential bug

2010-05-26 Thread Russell Keith-Magee
On Wed, May 26, 2010 at 2:54 AM, Lakshman Prasad  wrote:
> Hi,
> Since I upgraded to 1.1.2, I am unable to send mails as django seems
> expecting a EMAIL_BACKEND.

Something is severely broken with your setup, then. EMAIL_BACKEND is a
setting that was introduced in Django 1.2, but it doesn't exist in
1.1.1 or 1.1.2.

So - somehow you've managed to install Django 1.2, and that is what is
being found by Python. Your stack trace also confirms this -
django.core.mail is a module on Django 1.1.X, and a directory on 1.2.
The stack trace you provide shows that you've got a directory.

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



Re: Resize uploaded file file with PIL

2010-05-26 Thread Kenneth Gonsalves
On Wednesday 26 May 2010 12:12:39 Igor Rubinovich wrote:
> But I really want to do what I said I want to do.
> 
> Does anyone has a suggestion?
> 
http://docs.djangoproject.com/en/dev/ref/request-response/#httprequest-objects
http://docs.djangoproject.com/en/dev/topics/files/#topics-files

basically django stores the filename in the db and the actual file on the 
filesystem, so to manipulate, all you need to do is find the file on the 
filesystem and modify it using standard python.

-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

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



disabling dashboard 'recent actions'

2010-05-26 Thread rahul jain
Hi Django,

How to disable the dashboard ('recent actions') on django admin main page ?

--RJ

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



Just one action on all the objects

2010-05-26 Thread rahul jain
Hi Django,

Can i run an action without any need to select all. It should by
default select everything, basically all the objects. No separate
checkbox for every object, no select all.
Also, possibly no choices, just a single button which say "action"
which should perform that action on all the objects.

for ex:

HTML Button say "Delete" on the top of change list page. When I hit it
performs delete operation on all the objects.

I need it because I want to perform just one action on all the objects.

--RJ

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



Re: Resize uploaded file file with PIL

2010-05-26 Thread Igor Rubinovich
Thanks a lot for this :)

But I really want to do what I said I want to do.

Does anyone has a suggestion?

On May 26, 12:23 am, Gonzalo Delgado  wrote:
> El 25/05/10 19:12, Igor Rubinovich escribi :
>
>
>
>
>
> > I want to resize the uploaded file before saving a form. I'd like to
> > do something like
>
> > img = request.FILES['image']
> > img.thumbnail( (200,200), Image.ANTIALIAS)
> > img.save(request.FILES['image'], "JPG")
>
> > photo_form = forms.PhotoEditForm(request.POST, request.FILES,
> > instance=photo)
> > photo_form.save()
>
> > i.e. I'd like to put it into the form resized, and preferably without
> > a temporary file.
>
> > What I don't know is what FILES object really is so it's hard to
> > figure out what's the right way to achieve this.
>
> > Any ideas?
>
> You want to take a look at 
> easy-thumbnail:http://github.com/SmileyChris/easy-thumbnails
>
> --
> Gonzalo Delgado 

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