Re: settings.TIME_ZONE

2009-12-06 Thread XtraGreen
Ok, turns out when I set TIME_OUT to 'UTC' it was storing and
retrieving the dates correctly.  But when I was viewing the dates in
psql and pgAdmin III it was showing the dates using my system's time
zone 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: admin templates issue

2009-12-06 Thread gentlestone
I did not make any changes, just copied the original template to
template/admin

I tried to copy the tepmplate to root (templates/admin) for every app
and model

and also I tried copy the template to some app and model - the same
result

Because it didn't work, I put the line:



into base.html. After this (bug?) fixing everything works fine. But
the bad feeling remains. Here is a beginning of base.html after my
correction


http://www.w3.org/1999/xhtml; lang="{{ LANGUAGE_CODE }}"
xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
%}>

{% block title %}{% endblock %}


{% if LANGUAGE_BIDI %}{% endif %}




On 5. Dec., 05:21 h., Sam Lai  wrote:
> 2009/12/4gentlestone:
>
>
>
> > I've tried to folow the tutorial and customize the admin template and
> > made a copy of 'change_form.html' template into the 'templates/admin'
> > directory in my project. I also set the
> > TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
> > 'templates').replace('\\','/'),
>
> > After this, the result is BAD. In the result admin page source code,
> > the line
>
> > 
>
> > is missing. I recognized the change_form.html rewrites the stylesheet
> > block:
>
> > {% block stylesheet %}{% admin_media_prefix %}css/forms.css{% endblock
> > %}
>
> > so I know why, but the original non-copy version of change_form.html
> > is the SAME! How can it works in the original? I am totally confused.
>
> > What am I doing wrong? Some setting is missing?
>
> Are you trying to override the admin template for every app and model?
> Or only for a specific app or model?
>
> What changes have you made in your own templates/admin/change_form.html?

--

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: Pydev + Django + Ubuntu 9.10

2009-12-06 Thread Brian McKeever
I was having the same trouble you are when I installed eclipse from
the repository.
I fixed it by downloading it again from the website 
http://www.eclipse.org/downloads/
(Eclipse IDE for C/C++ Developers (79 MB) is the one I picked
specifically).

On Dec 6, 2:45 am, turkan  wrote:
> Hello Liam,
>
> I am sorry ... I can't access your provided link. Even after
> registering there, it says "You are not authorized to view this
> workspace.".
> I am also not sure why you suggest me Posgresql/PostGIS. I don't have
> any problems with setting up the database, just with setting up Pydev/
> Eclipse correctly.
> Any further suggestions?
>
> Regards,
> Kai
>
> On Dec 6, 12:08 am, Info Cascade  wrote:
>
> > Turkan,
>
> > Perhaps this will help. I just have done this
> > (PostGIS/Eclipse/Pydev/Django on Ubuntu 9.10) and it's working great!
> > After having problems because I had installed Postgres 8.4, I found the
> > script below, on the net somewhere.
> > Modify, as appropriate, if you don't need GIS.
>
> > You may also want this, for full support in pgadmin3:
> > apt-get install postgresql-contrib-8.3
> > cd /usr/share/postgresql/8.3/contrib
> > psql -U  postgres < adminpack.sql
>
> > Getting Eclipse working took some time, and I learned a lot from 
> > this:http://www.socialtext.net/hearplanet/index.cgi?action=display;is_inci...
>
> > Best,
> > Liam
>
> > > # Script for installing Django, PostgreSQL, and PostGIS
> > > # Run with sudo
>
> > > # Install Django:
> > > apt-get install python-django python-django-doc
>
> > > # Install PostgreSQL 8.3
> > > apt-get install postgresql-8.3 python-psycopg2 pgadmin3
>
> > > # Packages needed by GeoDjango (gdal is optional, but useful)
> > > apt-get install postgresql-8.3-postgis binutils libgdal1-1.5.0
> > > gdal-bin libgeos-3.1.0 proj libpq-dev
>
> > > # Set yourself up as a PostgreSQL superuser
> > > su - postgres
> > > createuser --createdb --superuser `whoami`
>
> > > # Create the template spatial database
> > > createdb -E UTF8 template_postgis
> > > createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
>
> > > # Allows non-superusers the ability to create from this template
> > > psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE
> > > datname='template_postgis';"
>
> > > # Load the PostGIS SQL routines
> > > psql -d template_postgis -f
> > > /usr/share/postgresql-8.3-postgis/lwpostgis.sql
> > > psql -d template_postgis -f
> > > /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
>
> > > # Enable users to alter spatial tables
> > > psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
> > > psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
> > > exit
> > turkan wrote:
> > > Hello.
>
> > > I know ... this topic was discussed quite often. But all the hints I
> > > found don't really help to setup Eclipse/Pydev under Ubuntu 9.10 for
> > > Django 1.1 (from the official Ubuntu repositories).
> > > I tried to follow this tutorial (http://solyaris.wordpress.com/
> > > 2007/05/16/how-to-djangopydev-on-feisty/), but /usr/share/python-
> > > support/python-django/ is not present anymore under Ubuntu 9.10.
> > > So I tried to add /usr/shared/pyshared/django, usr/share/python-
> > > support/, /usr/lib/python/django to the PYTHONPATH, but without any
> > > success. My projects still come up with many "undefined variable"
> > > errors. For example an error is presented for User.add_to_class.
> > > add_to_class (add_to_class is unkown), even if User seems to be known.
> > > I read that it is difficult for the IDE to recognize all variables,
> > > cause of the way some of those are generated on the fly (I am also new
> > > to Python). But is it possible to get error free projects with Django
> > > + Pydev?
> > > Why does Aptana for example does provide such a good Ruby support?
> > > Does Python/Django provide more dynamic stuff than Ruby?
>
> > > Regards,
> > > Kai
>
> > > --
>
> > > 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: Following "first app" tutorial -- admin site can't find css files

2009-12-06 Thread Waqqas Jabbar
for test server i add the following lines in settings.py

import os
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))

STATIC_DOC_ROOT = os.path.join(SITE_ROOT, 'media/')

and add the following lines in urls.py


if settings.DEBUG == True:
urlpatterns += patterns('',(r'^site_media/(?P.*)$',
'django.views.static.serve',{'document_root': settings.STATIC_DOC_ROOT}),)

and put all your media files in site_media folder


for my apache + mod_python setup i ve the following lines


PythonHandler django.core.handlers.modpython
PythonPath "['c:/site',] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE hospital.settings
SetHandler python-program



SetHandler default


alias /media/ H:/Python25/Lib/site-packages/django/contrib/admin/media/
alias /site_media/ c:/site/hospital/media/


"SetHandler default" should be after the "SetHandler python-program" in
sequences

On Mon, Dec 7, 2009 at 7:18 AM, Arthur  wrote:

> I'm using svn install.  I am using the same virtualhost for django and
> static files, with ADMIN_MEDIA_PREFIX set to '/media/', which I
> believe was the default.
>
> The admin app works fine so far, but the server gives me a 404 on the
> css files:
>
>  Using the URLconf defined in testproject.urls,
>  Django tried these URL patterns, in this order:
>  ^admin/
>  The current URL, media/css/base.css, didn't match any of these.
>
> Can anyone help me with this problem?  I really don't understand how
> the ADMIN_MEDIA_PREFIX interacts with the urlconf settings.
>
> Thank you,
> Arthur
>
>
> --
>
> 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: How to validate a form field whose value can only increase?

2009-12-06 Thread Shawn Milochik

On Dec 6, 2009, at 11:01 PM, Continuation wrote:

> What do you mean by the __init__ of the model?
> 


Every models.Model object has an __init__ function, like any Python class. You 
need to override it.

Add this into your model (in your models.py):

def __init__(self, *args, **kwargs):

#make sure you call the default __init__, or stuff breaks.
super(YourModelName, self).__init__(*args, **kwargs)

#so we can tell if the new value for the field
#is increased upon save
self.old_value = self.field_name


Then, you override the save function for the same model:

def save(self):



if self.old_value < self.fieldname:
raise ValueError('The field x can only increase.')

#go through with the standard 'save' stuff
#that is defined in models.Model class.
super(YourModelName, self).save()



This way, your model will not allow itself to be saved if that value is 
lowered. This doesn't directly answer your question, which was about form 
validation. I don't know how to do it elegantly, so I hope someone else will 
chime in. However, one thing you can do is to override the "clean" function of 
your form for that particular field so that it pulls back an instance of the 
old object and checks its own cleaned_data value against the value stored in 
the database. Something like this:

#within your forms.ModelForm for the model in question

def clean_yourfieldname(self):

yourfieldname = self.cleaned_data.get('yourfieldname', 0)
old_instance = YourModel.objects.get(pk = self.instance.pk)

if yourfieldname < old_instance.yourfieldname:
raise forms.ValidationError("The amount in field yourfieldname may 
only increase.")

return yourfieldname



To be fair, if you use this in your form validation, you don't really need the 
stuff above in your model. However, if that is your business logic, then it's a 
good idea to have it there in any case.

Shawn






--

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: settings.TIME_ZONE

2009-12-06 Thread XtraGreen
Not only do I have settings.TIME_ZONE set to 'UTC', I'm also creating
datetime objects via utcfromtimestamp() as follows:

field = datetime.datetime.utcfromtimestamp(time.time())

So I figured they would be going into the database as UTC anyway.
When I figured out that they were showing UTC-6 in the database I
changed the settings.TIME_ZONE, but that doesn't seem to change
anything for new records going into the database.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: How to validate a form field whose value can only increase?

2009-12-06 Thread Continuation
What do you mean by the __init__ of the model?

My directory structure is:

myapp/models

MyModel lives inside myapp/models.
There's an __init__.py file within myapp, but it's empty and I've
never touched it.

Can you be more specific about what to do? Thanks.

On Dec 6, 10:52 pm, Shawn Milochik  wrote:
> The easiest way I know of is this:
>
> In the __init__ of the model, create a variable:  self.old_value = 
> self.fieldname.
>
> In the save() function, you can check self.fieldname against self.old_value.
>
> Shawn

--

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: How to validate a form field whose value can only increase?

2009-12-06 Thread Shawn Milochik
The easiest way I know of is this:

In the __init__ of the model, create a variable:  self.old_value = 
self.fieldname.

In the save() function, you can check self.fieldname against self.old_value.

Shawn


--

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.




How to validate a form field whose value can only increase?

2009-12-06 Thread Continuation
I created a form class based on a model:

class MyModel(models.Model):
increasing_field = models.PositiveIntegerField()

class MyForm(forms.ModelForm):
class Meta:
model   = MyModel

I created a form to change an existing MyClass instance using POST
data to populate the form:

m = MyModel.objects.get(pk=n)
f = MyForm(request.POST, instance=m)

Every time f is being updated, f.increasing_field can only be greater
than the previous value.

How do I enforce that validation?

1 way I can think is to have clean_increasing_field take on an extra
argument that represents the previous value of  increasing_field:

def clean_increasing_field(self, previous_value)
...

This way I can just make sure the new value is greater than the
previous value. But it looks like clean_() methods cannot
take on extra arguments.

How can this validation be achieved?

--

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: settings.TIME_ZONE

2009-12-06 Thread XtraGreen


On Dec 6, 9:21 pm, Graham Dumpleton 
wrote:
> Some explanation of this issue in:
>
>  http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Timezone_and_...
>
> If using Apache/mod_wsgi, delegate Python web application instances
> with specific timezone, locale, lang requirements to a separate
> process using mod_wsgi daemon mode.
>
> Graham

In this case, I'm using Flup with one interpreter per process running
in front of lighttpd.

--

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: settings.TIME_ZONE

2009-12-06 Thread XtraGreen

On Dec 6, 8:39 pm, Brian Neal  wrote:
> What is your server setup? Apache on Linux? mod_python or mod_wsgi?
> Are you running anything else on your server like PHP apps? The
> timezone setting is process-wide, so depending on how you deployed
> your server another application could be overwriting you.
>
> BN

Using Linux, Postgresql and Lighttpd in front of Flup.  The Flup
process is just serving one site (one settings.py).

--

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

2009-12-06 Thread Graham Dumpleton


On Dec 7, 1:39 pm, Brian Neal  wrote:
> On Dec 6, 7:40 pm, XtraGreen  wrote:
>
> > I've changed settings.TIME_ZONE to 'UTC' and restarted my server but
> > when I create records (postgresql) they're not UTC, they're 'America/
> > Chicago' (-6) in the table.
>
> > Am I missing something or is settings.TIME_ZONE useless?
>
> What is your server setup? Apache on Linux? mod_python ormod_wsgi?
> Are you running anything else on your server like PHP apps? The
> timezone setting is process-wide, so depending on how you deployed
> your server another application could be overwriting you.

Some explanation of this issue in:

  
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Timezone_and_Locale_Settings

If using Apache/mod_wsgi, delegate Python web application instances
with specific timezone, locale, lang requirements to a separate
process using mod_wsgi daemon mode.

Graham

--

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

2009-12-06 Thread 一千瓦的刀狼
Hello? Anyone can help me?

On Dec 6, 9:18 am, 邓超  wrote:
> Hi all,
>   I want to change below function to use the generic view function
> update_object:
>
> @login_required
> def edit_bug_page(request, bug_id = None):
>     if bug_id == None:
>         bugInstance = Bug()
>     else:
>         bugInstance = get_object_or_404(Bug, pk = bug_id)
>         members = bugInstance.project.member.order_by('member')
>
>         if request.user not in members:
>             return HttpResponseRedirect('/bug/fail/')
>
>     if request.method == 'POST':
>         form = BugForm(request.POST, instance = bugInstance)
>
>         if form.is_valid():
>             bug = form.save()
>
>             return HttpResponseRedirect('/bug/success/')
>     else:
>         form = BugForm(instance = bugInstance)
>
>     variables = RequestContext(request, {'form': form})
>
>     return render_to_response('add_bug.html', variables)
>
> But how to use the update_object function in my views.py? Someone can help
> me? Thanks a lot!
> --
> Deng Chao

--

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: Parsing XML in the template? (New to Django and Python)

2009-12-06 Thread Sam Lai
2009/12/7 sleepjunk :
> Thanks so much for your help. I'm sorry to ask another question, but I
> am getting an error and have spent a few hours trying to figure it
> out. Googling has not helped me.
>
> Environment:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/
> Django Version: 1.1.1
> Python Version: 2.6.4
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'discvideos.videos']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
>
> Traceback:
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> site-packages/django/core/handlers/base.py" in get_response
>  92.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Users/matt/Sites/discvideos/../discvideos/videos/views.py" in
> home_page
>  21.           tree = ET.parse(feed)
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> xml/etree/ElementTree.py" in parse
>  862.     tree.parse(source, parser)
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> xml/etree/ElementTree.py" in parse
>  586.             parser.feed(data)
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> xml/etree/ElementTree.py" in feed
>  1245.         self._parser.Parse(data, 0)
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> xml/etree/ElementTree.py" in _default
>  1201.                     self._parser.ErrorColumnNumber)
>
> Exception Type: ExpatError at /
> Exception Value: undefined entity : line 198, column 55

Try adding this before line 5 in your the code you linked to:

parser = ET.XMLParser()
parser.entity['hellip'] = ""

Then change,

tree = ET.parse(feed)

to,

tree = ET.parse(feed, parser)

This will ignore all instances of the  entity that exists only
in HTML, and not XML. You can replace it with another character if you
want; just replace "" with something else.

Docs for XMLParser here -
http://effbot.org/elementtree/elementtree-xmlparser.htm

Also saw that your context doesn't include videos_context. It needs
to, otherwise all the work you just did would be inaccessible in the
template.

--

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: settings.TIME_ZONE

2009-12-06 Thread Brian Neal
On Dec 6, 7:40 pm, XtraGreen  wrote:
> I've changed settings.TIME_ZONE to 'UTC' and restarted my server but
> when I create records (postgresql) they're not UTC, they're 'America/
> Chicago' (-6) in the table.
>
> Am I missing something or is settings.TIME_ZONE useless?

What is your server setup? Apache on Linux? mod_python or mod_wsgi?
Are you running anything else on your server like PHP apps? The
timezone setting is process-wide, so depending on how you deployed
your server another application could be overwriting you.

BN

--

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.




Following "first app" tutorial -- admin site can't find css files

2009-12-06 Thread Arthur
I'm using svn install.  I am using the same virtualhost for django and
static files, with ADMIN_MEDIA_PREFIX set to '/media/', which I
believe was the default.

The admin app works fine so far, but the server gives me a 404 on the
css files:

  Using the URLconf defined in testproject.urls,
  Django tried these URL patterns, in this order:
  ^admin/
  The current URL, media/css/base.css, didn't match any of these.

Can anyone help me with this problem?  I really don't understand how
the ADMIN_MEDIA_PREFIX interacts with the urlconf settings.

Thank you,
Arthur


--

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.




PIL zip decoder error (while installed) refering to a template tag ?!

2009-12-06 Thread GoSantoni
Hi all,
What does this mean? It doesn't make sense doesn't it? Line 25 isn't
referring to the PIL...
Thanks

TemplateSyntaxError at /bookstore/
Caught an exception while rendering: decoder zip not available
Request Method: GET
Request URL:http://localhost:8000/bookstore/
Exception Type: TemplateSyntaxError
Exception Value:
Caught an exception while rendering: decoder zip not available
Exception Location: /home/mark/pinax/lib/python2.6/site-packages/
django/template/debug.py in render_node, line 81
Python Executable:  /home/mark/pinax/bin/python
Python Version: 2.6.4
Python Path:['/home/mark/pinax/mysite/apps', '/home/mark/pinax/lib/
python2.6/site-packages/pinax/apps', '/home/mark/pinax/mysite', '/home/
mark/pinax/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg', '/
home/mark/pinax/lib/python2.6/site-packages/pip-0.4.1devdev-
py2.6.egg', '/home/mark/pinax/lib/python2.6/site-packages/
python_gettext-1.0-py2.6.egg', '/home/mark/pinax/lib/python2.6', '/
home/mark/pinax/lib/python2.6/plat-linux2', '/home/mark/pinax/lib/
python2.6/lib-tk', '/home/mark/pinax/lib/python2.6/lib-old', '/home/
mark/pinax/lib/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib/
python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/home/mark/pinax/
lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages/
django_registration-0.8_alpha_1-py2.6.egg', '/usr/local/lib/python2.6/
dist-packages/django_friends-0.1.5-py2.6.egg', '/usr/local/lib/
python2.6/dist-packages/django_notification-0.1.4-py2.6.egg', '/usr/
local/lib/python2.6/dist-packages/django_photologue-2.2-py2.6.egg', '/
usr/local/lib/python2.6/dist-packages/PIL-1.1.6-py2.6-linux-i686.egg',
'/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/
dist-packages', '/usr/local/lib/python2.6/dist-packages/PIL', '/usr/
lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL',
'/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/
python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/
pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-
gtk2-unicode']
Server time:Sun, 6 Dec 2009 20:39:32 -0500
Template error

In template /home/mark/pinax/mysite/templates/bookstore/books.html,
error at line 25
Caught an exception while rendering: decoder zip not available
15  {% endifequal %}
16  {% ifequal list 'yours' %}
17  {% trans "Your Books" %}
18  {% endifequal %}
19  
20
21  
22  {% if books %}
23
24  
25  {% for book in books %}
26  
27  

**


PIL 1.1.6 BUILD SUMMARY

version   1.1.6
platform  linux2 2.6.4 (r264:75706, Nov  2 2009, 14:38:03)
  [GCC 4.4.1]

*** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not available


--

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.




settings.TIME_ZONE

2009-12-06 Thread XtraGreen
I've changed settings.TIME_ZONE to 'UTC' and restarted my server but
when I create records (postgresql) they're not UTC, they're 'America/
Chicago' (-6) in the table.

Am I missing something or is settings.TIME_ZONE useless?

--

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.




Fwd: Redundant URL during tutorial - Missing attachement here

2009-12-06 Thread f hue
here is the missing attachement.

-- Forwarded message --
From: f hue 
Date: 2009/12/7
Subject: Re: Redundant URL during tutorial
To: django-users@googlegroups.com


Yes your explanation makes sense to me.

Now the only thing that bothers me is that it doesn't match with what the
tutorial shows there :
http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-form->
pool only appears once

I join a image with the result I have on my screen, I have "pool" twice.

Maybe the image comes from an older tutorial and the URL design have been
improved...

I'll do all of it a second time to be shure.

Thanks a lot !



2009/12/7 cootetom 

Hello,
>
> The built in admin system for django names it's URL's by application
> name then model name. So if you have an application called "polls" and
> in that application you have a model called "poll" then the admin URL
> to edit those models would be admin/polls/poll
>
> amdin/polls will show all the models that you have set up in admin.py
> in your polls application.
>
> Hope that explains it!
>
>
>
>
> On Dec 6, 3:50 pm, bigshift  wrote:
> > Hello I'm just discovering Django and it was exactly the tool I was
> > looking for. This is great !
> >
> > Following the tutorial, I have an anomaly in my "pool"
> > administration :
> > the page that it supposed to be athttp://localhost:8000/admin/polls/
> > is athttp://localhost:8000/admin/polls/poll/
> >
> > Maybe I made something wrong in my model, but I don't find any
> > mistake :
> >
> > here's my models.py :
> > -
> > from django.db import models
> > import datetime
> >
> > class Poll(models.Model):
> > question = models.CharField(max_length=200)
> > pub_date = models.DateTimeField('date published')
> > def was_published_today(self):
> > return self.pub_date.date() == datetime.date.today()
> > was_published_today.short_description = 'Published today?'
> > def __unicode__(self):
> > return self.question
> >
> > class Choice(models.Model):
> > poll = models.ForeignKey(Poll)
> > choice = models.CharField(max_length=200)
> > votes = models.IntegerField()
> > def __unicode__(self):
> > return self.choice
> >
> ---
> ---
> >
> > Here's my admin.py :
> > ---
> > from myproject.polls.models import Poll
> > from myproject.polls.models import Choice
> >
> > from django.contrib import admin
> >
> > class ChoiceInline(admin.TabularInline):
> > model = Choice
> > extra = 3
> >
> > class PollAdmin(admin.ModelAdmin):
> > fieldsets = [
> > (None,   {'fields': ['question']}),
> > ('Date information', {'fields': ['pub_date'], 'classes':
> > ['collapse']}),
> > ]
> > inlines = [ChoiceInline]
> > list_display = ('question', 'pub_date', 'was_published_today')
> > list_filter = ['pub_date']
> > search_fields = ['question']
> > date_hierarchy = 'pub_date'
> >
> > admin.site.register(Poll, PollAdmin)
> >
> ---
> --
> >
> > I'm sure nothing happends without a reason but why ?
> >
> > Thanks a lot,
> >
> > bigshift
>
> --
>
> 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: Redundant URL during tutorial

2009-12-06 Thread f hue
Yes your explanation makes sense to me.

Now the only thing that bothers me is that it doesn't match with what the
tutorial shows there :
http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-form->
pool only appears once

I join a image with the result I have on my screen, I have "pool" twice.

Maybe the image comes from an older tutorial and the URL design have been
improved...

I'll do all of it a second time to be shure.

Thanks a lot !



2009/12/7 cootetom 

> Hello,
>
> The built in admin system for django names it's URL's by application
> name then model name. So if you have an application called "polls" and
> in that application you have a model called "poll" then the admin URL
> to edit those models would be admin/polls/poll
>
> amdin/polls will show all the models that you have set up in admin.py
> in your polls application.
>
> Hope that explains it!
>
>
>
>
> On Dec 6, 3:50 pm, bigshift  wrote:
> > Hello I'm just discovering Django and it was exactly the tool I was
> > looking for. This is great !
> >
> > Following the tutorial, I have an anomaly in my "pool"
> > administration :
> > the page that it supposed to be athttp://localhost:8000/admin/polls/
> > is athttp://localhost:8000/admin/polls/poll/
> >
> > Maybe I made something wrong in my model, but I don't find any
> > mistake :
> >
> > here's my models.py :
> > -
> > from django.db import models
> > import datetime
> >
> > class Poll(models.Model):
> > question = models.CharField(max_length=200)
> > pub_date = models.DateTimeField('date published')
> > def was_published_today(self):
> > return self.pub_date.date() == datetime.date.today()
> > was_published_today.short_description = 'Published today?'
> > def __unicode__(self):
> > return self.question
> >
> > class Choice(models.Model):
> > poll = models.ForeignKey(Poll)
> > choice = models.CharField(max_length=200)
> > votes = models.IntegerField()
> > def __unicode__(self):
> > return self.choice
> >
> ---
> ---
> >
> > Here's my admin.py :
> > ---
> > from myproject.polls.models import Poll
> > from myproject.polls.models import Choice
> >
> > from django.contrib import admin
> >
> > class ChoiceInline(admin.TabularInline):
> > model = Choice
> > extra = 3
> >
> > class PollAdmin(admin.ModelAdmin):
> > fieldsets = [
> > (None,   {'fields': ['question']}),
> > ('Date information', {'fields': ['pub_date'], 'classes':
> > ['collapse']}),
> > ]
> > inlines = [ChoiceInline]
> > list_display = ('question', 'pub_date', 'was_published_today')
> > list_filter = ['pub_date']
> > search_fields = ['question']
> > date_hierarchy = 'pub_date'
> >
> > admin.site.register(Poll, PollAdmin)
> >
> ---
> --
> >
> > I'm sure nothing happends without a reason but why ?
> >
> > Thanks a lot,
> >
> > bigshift
>
> --
>
> 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.




How to create a form to edit an existing object without knowing the object's id?

2009-12-06 Thread Continuation
I have:

class MyModel(models.Model):
fk= models.ForeignKey(AnotherModel)
field   = models.PositiveIntegerField()

class MyForm((forms.ModelForm):
class Meta:
model   = MyModel

Now I want to create a form to edit an existing MyModel instance. But
I don't know the pk of the instance. However I do now the value of fk
& field, which together should be enough to uniquely identify an
instance.

So I do:
z = MyModel.objects.get(fk=o, field=f)
f = MyForm(instance=z)

And the form f does have the correct data of z pre-populated.

However when I submitted the form, a new MyModel object was created
instead of just updating z.

What do I need to do to create a form that would update z?

--

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: Redundant URL during tutorial

2009-12-06 Thread cootetom
Hello,

The built in admin system for django names it's URL's by application
name then model name. So if you have an application called "polls" and
in that application you have a model called "poll" then the admin URL
to edit those models would be admin/polls/poll

amdin/polls will show all the models that you have set up in admin.py
in your polls application.

Hope that explains it!




On Dec 6, 3:50 pm, bigshift  wrote:
> Hello I'm just discovering Django and it was exactly the tool I was
> looking for. This is great !
>
> Following the tutorial, I have an anomaly in my "pool"
> administration :
> the page that it supposed to be athttp://localhost:8000/admin/polls/
> is athttp://localhost:8000/admin/polls/poll/
>
> Maybe I made something wrong in my model, but I don't find any
> mistake :
>
> here's my models.py :
> -
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>         question = models.CharField(max_length=200)
>         pub_date = models.DateTimeField('date published')
>         def was_published_today(self):
>                 return self.pub_date.date() == datetime.date.today()
>         was_published_today.short_description = 'Published today?'
>         def __unicode__(self):
>                 return self.question
>
> class Choice(models.Model):
>         poll = models.ForeignKey(Poll)
>         choice = models.CharField(max_length=200)
>         votes = models.IntegerField()
>         def __unicode__(self):
>                 return self.choice
> --- 
> ---
>
> Here's my admin.py :
> ---
> from myproject.polls.models import Poll
> from myproject.polls.models import Choice
>
> from django.contrib import admin
>
> class ChoiceInline(admin.TabularInline):
>         model = Choice
>         extra = 3
>
> class PollAdmin(admin.ModelAdmin):
>         fieldsets = [
>                 (None,               {'fields': ['question']}),
>                 ('Date information', {'fields': ['pub_date'], 'classes':
> ['collapse']}),
>         ]
>         inlines = [ChoiceInline]
>         list_display = ('question', 'pub_date', 'was_published_today')
>         list_filter = ['pub_date']
>         search_fields = ['question']
>         date_hierarchy = 'pub_date'
>
> admin.site.register(Poll, PollAdmin)
> --- 
> --
>
> I'm sure nothing happends without a reason but why ?
>
> Thanks a lot,
>
> bigshift

--

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: FlatPages return 404 when attempting to edit.

2009-12-06 Thread TheLastBookworm
Correction: I meant fork and not "port".

On Dec 6, 3:36 pm, TheLastBookworm 
wrote:
> Hi,
>
> I'm getting a error when attempting to edit a flatpage.
>
> "Http404 at /admin/flatpages/flat/
>
> App u'flatpages', model u'flat', not found. "
>
> This is the same error I get when I try to edit a non-existent
> flatpage.
>
> After some googling I discovered that site ID issues are a common
> cause of this error. I've checked my site IDs and they are correct,
> now i'm lost as to what direction to head in and google is no help.
>
> Is there some other middleware that can cause the flatpage middleware
> to fail and not return a item?  Can someone who has had the same issue
> provide an answer or point me in the right direction for debugging and
> fixing this issue?
>
> My settings file is located herehttp://dpaste.com/130113/.
>
> Note: This project is a port of 
> mingushttp://github.com/montylounge/django-mingus/tree
> . Mingus itself works fine with flatpages. Hopefully that extra
> information helps others help me.

--

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




FlatPages return 404 when attempting to edit.

2009-12-06 Thread TheLastBookworm
Hi,

I'm getting a error when attempting to edit a flatpage.

"Http404 at /admin/flatpages/flat/

App u'flatpages', model u'flat', not found. "

This is the same error I get when I try to edit a non-existent
flatpage.

After some googling I discovered that site ID issues are a common
cause of this error. I've checked my site IDs and they are correct,
now i'm lost as to what direction to head in and google is no help.

Is there some other middleware that can cause the flatpage middleware
to fail and not return a item?  Can someone who has had the same issue
provide an answer or point me in the right direction for debugging and
fixing this issue?

My settings file is located here http://dpaste.com/130113/ .


Note: This project is a port of mingus 
http://github.com/montylounge/django-mingus/tree
. Mingus itself works fine with flatpages. Hopefully that extra
information helps others help me.

--

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




No module named il8n after following up all the recommendation on djangoproject.com

2009-12-06 Thread GoSantoni
Hey all, i am new to django and started using pinax. For now i am
trying to set up il8n support using 
http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs
but it keeps on failing with a TemplateSyntaxError
'il8n' is not a valid tag library: Could not load template library
from django.templatetags.il8n, No module named il8n

What i did so far:
1) Got USE_I18N = True in my settings.py

2) succeeded with (as superuser though) django-admin.py makemessages -
l en, django-admin.py makemessages -a and django-admin.py
compilemessages

3) and did easy_install python-gettext / installed gettext

In the shell it fails too,
In [1]: import il8n
---
ImportError   Traceback (most recent call
last)
/home/mark/pinax/mysite/ in ()
ImportError: No module named il8n

What am i missing? What other modules are necessary beside python-
gettext ?

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: How to get the last item of array in a built-in template tag?

2009-12-06 Thread pjrhar...@gmail.com
Try:

{{ my_array|slice:"-1:" }}

Pete

--

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: PYTHON_EGG_CACHE, access denied error

2009-12-06 Thread Sameer Rahmani
thanks for the advice my friend i never forget that

--

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

2009-12-06 Thread Graham Dumpleton


On Dec 7, 8:47 am, Sameer Rahmani  wrote:
> it's very simple ( if you have root access to your host )  just create a
> directory with the name : ".python-eggs" in ther "/" ( root directory ) and
> change it owner to the apache user ( the user who run apache ).
> ( if you don't have root access ) change you mod_wsgi or mod_python settings
> tu use onother dir for its egg cache i thinks its settings is in apache.conf

Please don't recommend putting stuff in '/.python-eggs'. It isn't an
appropriate place for that sort of stuff unless you want to fill your
operating system install directories with cruft.

At the same time, should also point out that one should also not set
the Python egg cache to be '/tmp' or '/var/tmp' either because of
security implications due to said directories being writable by other
users.

So, create a special directory elsewhere for the egg cache, preferably
specifically for that web application installation. In other words,
try to avoid a common directory for many web applications unless that
is actually a sensible thing to do for the specific applications being
used.

For mod_wsgi you can also avoid the problem by not using embedded mode
and instead use daemon mode and set user/group to be yourself rather
than Apache user. That way it will use Python egg cache directory from
your own home directory.

Graham

--

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

2009-12-06 Thread Sameer Rahmani
it's very simple ( if you have root access to your host )  just create a
directory with the name : ".python-eggs" in ther "/" ( root directory ) and
change it owner to the apache user ( the user who run apache ).
( if you don't have root access ) change you mod_wsgi or mod_python settings
tu use onother dir for its egg cache i thinks its settings is in apache.conf

--

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.




Redundant URL during tutorial

2009-12-06 Thread bigshift
Hello I'm just discovering Django and it was exactly the tool I was
looking for. This is great !

Following the tutorial, I have an anomaly in my "pool"
administration :
the page that it supposed to be at http://localhost:8000/admin/polls/
is at http://localhost:8000/admin/polls/poll/

Maybe I made something wrong in my model, but I don't find any
mistake :

here's my models.py :
-
from django.db import models
import datetime

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
was_published_today.short_description = 'Published today?'
def __unicode__(self):
return self.question

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice
--

Here's my admin.py :
---
from myproject.polls.models import Poll
from myproject.polls.models import Choice

from django.contrib import admin

class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3

class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None,   {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes':
['collapse']}),
]
inlines = [ChoiceInline]
list_display = ('question', 'pub_date', 'was_published_today')
list_filter = ['pub_date']
search_fields = ['question']
date_hierarchy = 'pub_date'

admin.site.register(Poll, PollAdmin)
-


I'm sure nothing happends without a reason but why ?

Thanks a lot,

bigshift

--

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: PYTHON_EGG_CACHE, access denied error

2009-12-06 Thread Graham Dumpleton


On Dec 6, 11:12 pm, Oleg Oltar  wrote:
> Hi!
>
> I am deploying my django application on a server, and on last stages I am
> getting this error:
>
> ExtractionError at /admin/
>
> Can't extract file(s) to egg cache
>
> The following error occurred while trying to extract file(s) to the Python egg
> cache:
>
> [Errno 13] Permission denied: '/.python-eggs'
>
> The Python egg cache directory is currently set to:
>
> /.python-eggs
>
> Perhaps your account does not have write access to this directory?  You can
> change the cache directory by setting the PYTHON_EGG_CACHE environment
> variable to point to an accessible directory.
>
> Request Method:     GET
> Request URL:    http://go-ban.org/admin/
> Exception Type:     ExtractionError
> Exception Value:
>
> Can't extract file(s) to egg cache
>
> The following error occurred while trying to extract file(s) to the Python egg
> cache:
>
> [Errno 13] Permission denied: '/.python-eggs'
>
> The Python egg cache directory is currently set to:
>
> /.python-eggs
>
> Perhaps your account does not have write access to this directory?  You can
> change the cache directory by setting the PYTHON_EGG_CACHE environment
> variable to point to an accessible directory.
>
> Exception Location:
> /usr/lib/python2.5/site-packages/pkg_resources.py in extraction_error,
> line 887
> Python Executable:  /usr/bin/python
> Python Version:     2.5.2
> Python Path:    ['/home/oleg/sites/goban',
> '/usr/lib/python2.5/site-packages/PIL-1.1.7-py2.5-linux-i686.egg',
> '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg',
> '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
> '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
> '/usr/local/lib/python2.5/site-packages',
> '/usr/lib/python2.5/site-packages',
> '/usr/lib/python2.5/site-packages/PIL',
> '/var/lib/python-support/python2.5']
> Server time:    Sun, 6 Dec 2009 14:05:47 +0200
>
> Maybe someone come across similar issue?
>
> The strangest thing here is that I am using another django site on this host
> with no such error :(

Likely that other site has all its dependencies installed.

As to how to solve your problem, it depends on how you are hosting
Django. Are you using mod_wsgi or mod_python?

For mod_wsgi see:

  
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User

Graham

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: sorl thumbnail: messed-up thumb file path

2009-12-06 Thread omat
It is not something to do with the upload_to path.

I managed to track down the problem, I was passing the full url to the
thumbnail templatetag (i.e. "provider.logo.url") but it should be just
the relative URL (i.e. "provider.logo").

Thanks.


--
omat



On Dec 6, 9:10 pm, SmileyChris  wrote:
> upload_to should not have a trailing slash
>
> On Dec 7, 5:16 am, omat  wrote:
>
>
>
> > The model is as simple as can be:
>
> > class Provider(models.Model):
> >     name = models.CharField(max_length=100)
> >     logo = models.ImageField(upload_to='logo/',
> >                              blank=True, null=True)
>
> > Thanks.
>
> > --
> > omat
>
> > On Dec 6, 4:45 pm, Kenneth Gonsalves  wrote:
>
> > > On Sunday 06 Dec 2009 4:27:47 pm omat wrote:
>
> > > > Sorl thumbnail is creating invalid directories for thumbnails in my
> > > > development environment (mac os x, django dev server).
>
> > > do not blame Sorl thumbnail - please post that part of your model that 
> > > shows
> > > 'upload_to' setting.
> > > --
> > > regards
> > > Kenneth Gonsalves
> > > Senior Project Officer
> > > NRC-FOSShttp://nrcfosshelpline.in/web/

--

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: sorl thumbnail: messed-up thumb file path

2009-12-06 Thread SmileyChris
upload_to should not have a trailing slash

On Dec 7, 5:16 am, omat  wrote:
> The model is as simple as can be:
>
> class Provider(models.Model):
>     name = models.CharField(max_length=100)
>     logo = models.ImageField(upload_to='logo/',
>                              blank=True, null=True)
>
> Thanks.
>
> --
> omat
>
> On Dec 6, 4:45 pm, Kenneth Gonsalves  wrote:
>
>
>
> > On Sunday 06 Dec 2009 4:27:47 pm omat wrote:
>
> > > Sorl thumbnail is creating invalid directories for thumbnails in my
> > > development environment (mac os x, django dev server).
>
> > do not blame Sorl thumbnail - please post that part of your model that shows
> > 'upload_to' setting.
> > --
> > regards
> > Kenneth Gonsalves
> > Senior Project Officer
> > NRC-FOSShttp://nrcfosshelpline.in/web/

--

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: Where to store repetitive form logic?

2009-12-06 Thread jwpeddle
Sorry, the above post was meant to say I followed the idea that
Heigler presented.

On Dec 6, 1:56 pm, jwpeddle  wrote:
> I followed this type of thinking and have a result I'm happy with. I
> have a view that accepts render_to_response args as well as an
> additional forms dict. Rather than call render_to_response, I call my
> custom view, which looks for results from a number of forms, processes
> if required, then returns a response. Anything specific to the form
> itself is stored in the form, so the custom view doesn't know anything
> about the forms.
>
> http://dpaste.com/13/
>
> Thanks to everyone that pitched in. I've done a ton of useful reading
> trying to solve this.
> Also, dpaste number 13! woohoo!
>
> On Dec 4, 10:35 pm, Heigler  wrote:
>
> > Maybe this code can help you about the approach, is just an example
> > based on your previous templatetag (i haven't tested 
> > it):http://dpaste.com/129361/
>
> > The view isn't really generic, but i probablly would follow that
> > approach to solve this problem.

--

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

2009-12-06 Thread jwpeddle
I followed this type of thinking and have a result I'm happy with. I
have a view that accepts render_to_response args as well as an
additional forms dict. Rather than call render_to_response, I call my
custom view, which looks for results from a number of forms, processes
if required, then returns a response. Anything specific to the form
itself is stored in the form, so the custom view doesn't know anything
about the forms.

http://dpaste.com/13/

Thanks to everyone that pitched in. I've done a ton of useful reading
trying to solve this.
Also, dpaste number 13! woohoo!

On Dec 4, 10:35 pm, Heigler  wrote:
> Maybe this code can help you about the approach, is just an example
> based on your previous templatetag (i haven't tested 
> it):http://dpaste.com/129361/
>
> The view isn't really generic, but i probablly would follow that
> approach to solve this problem.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Parsing XML in the template? (New to Django and Python)

2009-12-06 Thread sleepjunk
Thanks so much for your help. I'm sorry to ask another question, but I
am getting an error and have spent a few hours trying to figure it
out. Googling has not helped me.

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.1.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'discvideos.videos']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django/core/handlers/base.py" in get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/matt/Sites/discvideos/../discvideos/videos/views.py" in
home_page
  21.   tree = ET.parse(feed)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
xml/etree/ElementTree.py" in parse
  862. tree.parse(source, parser)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
xml/etree/ElementTree.py" in parse
  586. parser.feed(data)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
xml/etree/ElementTree.py" in feed
  1245. self._parser.Parse(data, 0)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
xml/etree/ElementTree.py" in _default
  1201. self._parser.ErrorColumnNumber)

Exception Type: ExpatError at /
Exception Value: undefined entity : line 198, column 55


Here is my home_page: http://utilitybase.com/paste/23116

http://diveintopython3.org/xml.html seems to be explaining the problem
but I haven't gotten the code there to work for me yet. Thank you.

On Dec 5, 11:40 pm, Sam Lai  wrote:
> Inline.
>
> 2009/12/6 sleepjunk :
>
> > Thank you for the response. I don't believe I explained well enough
> > exactly what I'm trying to do.
>
> > I have table Video with a field vimeo_code. Each vimeo_code has its
> > own XML file. The XML file I used in my views.py is just a random
> > video I saw on vimeo. I need to replace the vimeo_code so the XML file
> > I'm parsing looks likehttp://vimeo.com/api/v2/video/vimeo_code.xml
>
> Ok, so just replace this line:
>
>              feed = 
> urllib.urlopen("http://vimeo.com/api/v2/video/7875440.xml;)
>
> with,
>
>              feed =
> urllib.urlopen("http://vimeo.com/api/v2/video/%s.xml; % v.vimeo_code)
>
> This replaces the code in the URL with the current vimeo_code in the loop.
>
> I think we're on the same page; give it a shot and see how it goes.
>
> > Would it be a better idea to do this as a tag filter? Any additional
> > information for me if I do it that way?
>
> I'm sure someone will have a more concrete reason for doing it one way
> or the other. Personally though, it's a matter of style. I prefer
> having it in the view function because then I can see immediately that
> extra http calls will be made when looking through my code. If I used
> a tag filter, I would have to look at the view function to find the
> template, then the template to see if custom tag filters were used,
> then the .py files for the tag filters to see what it's doing.
>
> Tag filters are pretty simple things; the Django docs link I gave
> should be easy enough. Feel free to post questions if you get stuck
> though.
>
> > Thanks again, I appreciate your help.
> > Matt
>
> > On Dec 5, 10:07 pm, Sam Lai  wrote:
> >> See inline.
>
> >> 2009/12/6 sleepjunk :
>
> >> > Hello :) I am working on a small video site that allows a user to add
> >> > a video to the site by submitting a Vimeo.com or Youtube.com URL. I'm
> >> > trying to display thumbnails without hosting them. For Vimeo videos I
> >> > need to parse an XML file to find the thumbnail location.
>
> >> > On my homepage I would like to display the 5 newest videos. As of now
> >> > I'm displaying every video in the database on the homepage. Each video
> >> > will have a different thumbnail and XML file to parse. As of right now
> >> > my "main_page" in my views.py file looks like this:
>
> >> > def home_page(request):
> >> >        template = get_template('home_page.html')
> >> >        videos = Video.objects.all()
>
> >>           videos_context = [ ]
> >>           for v in videos:>             feed = 
> >> urllib.urlopen("http://vimeo.com/api/v2/video/7875440.xml;)
> >> >             tree = ET.parse(feed)
> >> >             root = tree.getroot()
> >> >             vimeo_thumbnail = root.findtext("video/thumbnail_medium")
>
> >>                videos_context.append( { 'video' : v, 'thumbnail_url' :
> >> vimeo_thumbnail } )
>
> >> >        variables = Context({
> >> >                'videos' : videos_context,
> >> >        })
> >> >        output = 

Re: Extending result count at bottom of admin pages

2009-12-06 Thread Kaze
You can override "changelist_view" function in admin.py for that
model.
Tryn googling "def changelist_view(self, request, extra_context=None,
**kwargs):".


On Dec 6, 7:26 pm, Count László de Almásy  wrote:
> I'm new to django but working hard to come up to speed. I need to make
> a small change to the admin interface, and am hoping i could get a
> pointer on how to do this. At the bottom of an admin page, the number
> of results is displayed in a summary, along with pagination buttons.
> For example,
>
> "1 [2] 76 payments"
>
> Along with showing the number of payments at the bottom, I'd like to
> display the dollar total for them next to it. One of my columns is
> payment amount, so it should (i hope) be fairly easy to SUM the
> results of that column to get this, so it might look like this
> instead:
>
> "1 [2] 76 payments (for $1,500)"
>
> The relevant template seems to be admin/pagination.html with
> "cl.result_count" displaying the number of objects. How would i insert
> my own tag into this template to show the SUM of my payment amount
> column for said objects?

--

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: sorl thumbnail: messed-up thumb file path

2009-12-06 Thread omat
The model is as simple as can be:

class Provider(models.Model):
name = models.CharField(max_length=100)
logo = models.ImageField(upload_to='logo/',
 blank=True, null=True)


Thanks.


--
omat



On Dec 6, 4:45 pm, Kenneth Gonsalves  wrote:
> On Sunday 06 Dec 2009 4:27:47 pm omat wrote:
>
> > Sorl thumbnail is creating invalid directories for thumbnails in my
> > development environment (mac os x, django dev server).
>
> do not blame Sorl thumbnail - please post that part of your model that shows
> 'upload_to' setting.
> --
> regards
> Kenneth Gonsalves
> Senior Project Officer
> NRC-FOSShttp://nrcfosshelpline.in/web/

--

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: New to django, python, etc. - ForeignKey question

2009-12-06 Thread Guy
Thanks so much.  I figured that the problem stemmed from working
within the class rather than an instance, as you suggest.  The
suggestion to override the save fxn makes so much sense that I am now
embarrassed for asking the question in the first place.

It's amazing how much sense things make when someone else solves your
problem (*smacking forehead with hand*).

Very appreciated, thanks again.
Guy

On Dec 5, 9:56 pm, Sam Lai  wrote:
> The error is occurring here as you have mentioned -
>
> rolestartdate = models.DateField(default = \
>                                Project.objects.get
> (pk=project.id).startdate)
>
> You're right that Django creates an attribute named id for every model
> without a primary key explicitly specified, but I suspect the issue
> here is that Django is trying to resolve 'project.id' before the
> Project model has been fully initialized. Also, Django is trying to
> resolve project.id for the model class, and not a model instance which
> won't work as model classes do not contain data.
>
> I believe 'default' can only be used to specify static values, not
> values that depend on other models (there is no defined behaviour for
> that, so if it works, it's by chance and might not work later).
>
> To do what you want, I suggest you override the save method in the
> model, and add the startdate from the related Project model to the
> Role model.
>
> I'm a bit rusty on this, but something like this should work:
>
> def save(self):
>     if self.project != None:
>         self.rolestartdate = project.startdate
>
>     #don't worry about handling if self.project == None; foreign keys
> are required by default and the superclass' save method will raise an
> exception
>     super(Role, self).save()
>
> 2009/12/6 Guy :
>
>
>
> > I am using the code shown below.  The part causing the problem is the
> > Role class which describes the role a person might have on a project.
> > As part of that role, I would have an attribute that records the start
> > and end date of the person's involvement.  The problem seems to be
> > coming when I make an ill-fated attempt to define a default start date
> > as the startdate of the project to which the role is linked.
>
> > -code--
> > from django.db import models
>
> > class Project(models.Model):
> >    """class to describe the attributes that characterize a project"""
>
> >    #reference number for project
> >    referencenum = models.CharField("reference number for project",
> >                                                      max_length=20)
> >    #begin date of project
> >    startdate =  models.DateField()
>
> > class Role(models.Model):
> >    """class to describe a Person object's affiliation to a Project
> > object"""
>
> >    #project in which person is involved
> >    project =   models.ForeignKey(Project)
>
> >    #begin date of person's involvement on project; this is the
> > problem line
> >    rolestartdate = models.DateField(default = \
> >                                Project.objects.get
> > (pk=project.id).startdate)
>
> > -
> > when I run:
> >      manage.py syncdb
> > I get the following error:
>
> >   rolestartdate = models.DateField(default = Project.objects.get
> > (pk=project.id).st
> >   artdate)
> >   AttributeError: 'ForeignKey' object has no attribute 'id'
>
> > I was under the impression that django creates an attribute on every
> > model, foo.id, that serves as a primary key.
>
> > Many thanks in advance to anyone who can explain what what I not
> > grasping here.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-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: sorl thumbnail: messed-up thumb file path

2009-12-06 Thread Kenneth Gonsalves
On Sunday 06 Dec 2009 4:27:47 pm omat wrote:
> Sorl thumbnail is creating invalid directories for thumbnails in my
> development environment (mac os x, django dev server).
> 

do not blame Sorl thumbnail - please post that part of your model that shows 
'upload_to' setting.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

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: What apps do besides provide views?

2009-12-06 Thread esatterwh...@wi.rr.com
@permalink maps a model to a view function through a specific url
pattern giving you the ability to use get_absolute_url()  just by
passing parameters to the function. it will create the url for you.

to the app question. An application or an organizational and way to
focus your development. An app should have a goal, and a focus. You
should be able to sum up what your application does in 1 simple
sentence. If you can't you are probably describing something on the
scope of a project.

My app allows users to leave comments on any object from any view.
That is what it does and that is ALL that it does. DONE.
So organization and focus. For example todd, no, views do not need to
live in a file called views.py. They can live anywhere. You would just
need to remember where you are putting them all and tell your urls
that is where the view function it should use is. But this would get
very confusing to others trying to use your code. So it is a standard
practice to use a file called views.py

with an app that has a lot of views, I often times create a package
called views and segment out the views into their own files that have
a more specific focus

http://www.youtube.com/watch?v=A-S0tqpPga4

The best advice I think anyone can give you comes down to 2 options.
1. don't bring your framework's 'programming baggage' with you. Django
is not framework-X, it never will be, so trying to develop you
programs as if it were, will get you frustrated fast. Baggage all
leads to a dysfunctional relationship. in other words, trying to build
a application like you do in RoR with django is going to situations /
mailing list discussions like this one.

2.  if you really like framework X...use framework X.

On Dec 3, 2:30 pm, Todd Blanchard  wrote:
> Models?  Where do I find an example?
>
> I've got Pro Django, Definitive Guide to Django, Python Essential Reference, 
> and I've read the online django tutorial and a bunch of random docs.  I have 
> yet to see an instance of mapping a url to a model.
>
> Or, I don't know what you mean by model vs view (because when I say view - I 
> mean just a function that takes a request, returns a response, and lives in a 
> file called views.py).
>
> What am I missing?
>
> On Dec 3, 2009, at 11:58 AM, bruno desthuilliers wrote:
>
>
>
> > On 3 déc, 20:42, Todd Blanchard  wrote:
> >> On Dec 3, 2009, at 10:46 AM, Javier Guerra wrote:
>
> >>> remember that an app can do a lot more than provide views.
>
> >> Explain this one to me.  AFAICS, its just http request/response all the 
> >> way down and this is basically done by getting a request to a view that 
> >> spits out a response.  Side effects like updating the database sometimes 
> >> occur.
>
> > An app can expose views, indeed. It can also expose models - one of
> > the most important parts of an application -, templatetags, filters,
> > forms, fields, widgets etc. FWIW, the views are perhaps one of the
> > less important thing an app has to offer - and obviously the most easy
> > to factor out, cf genericviews. Models, OTHO, are really the core. If
> > you end up writing most of your code in views, then you more than
> > probably failed to identify what belongs to the model and what belongs
> > to the views. The fact that "views" are a mandatory part of the
> > request-response cycle doesn't mean they are the most important part
> > of the app.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-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: Where to store repetitive form logic?

2009-12-06 Thread esatterwh...@wi.rr.com
You can use a hidden input in the for as a way of holding the link or
id/ct of an object so you can determine where to redirect to. If the
action is repetitive and you have a pretty good idea of where you to
redirect to, I would think that is a simple solution.

This is what django's comment app does, allowing you to redirect users
where you want after you submit a comment. Maybe peek in side of that
to see how it was done?

On Dec 4, 8:29 am, jwpeddle  wrote:
> I am currently trying to write a custom generic comment app and
> growing increasingly frustrated with template tags. As far as I can
> tell, template tags are the only mechanism provided that allow pieces
> of logic to be shared across templates. Nonetheless, you cannot treat
> them like a view, and cannot do things like redirect. Someone asking
> about essentially the exact same thing two years ago 
> here:http://groups.google.ca/group/django-users/browse_thread/thread/a0603...
> and Malcolm commented that this was unusual and that isn't what
> template tags are for and the logic should go in a view.
>
> This isn't a satisfactory answer for me because the form logic in
> question is identical regardless of the view/object. Why should anyone
> be expected to duplicate form logic all over the project when it works
> perfectly in a template tag without adding any repetitive code. The
> only downside, as least in my case, is that I cannot redirect.
>
> Here's my basic tag:http://dpaste.com/128910/
>
> I'd like to know why my thinking is flawed and where I can actually
> put this logic without cluttering up every view that needs a comment
> form.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Unique model field and case sensitivity (postgres)

2009-12-06 Thread chefsmart
By the way, right now I'm using a State.objects.get(name__iexact=name)
in clean_name() method in a form subclass to prevent creation of case-
insensitive duplicates. Just wondering if there is a built-in or
better way.

On Dec 6, 2:57 pm, chefsmart  wrote:
> Reading through some discussions on this mailing list and elsewhere, I
> saw a lot of material on mysql case sensitivity and collation.
>
> Consider the following situation: -
>
> Suppose my app allows users to create the states / provinces in their
> country. Just for clarity, we are considering only ASCII characters
> here.
>
> In the US, a user could create the state called "Texas". If this app
> is being used internally, let's say the user doesn't care if it is
> spelled "texas" or "Texas"
>
> But importantly, the system should prevent creation of "texas" if
> "Texas" is already in the database.
>
> If the model is like the following:
>
> class State(models.Model):
>     name = models.CharField(max_length=50, unique=True)
>
> The uniqueness would be case-sensitive in postgres, that is, postgres
> would allow the user to create both "texas" and "Texas" as they are
> considered unique.
>
> What can be done in this situation to prevent such behavior. How does
> one go about providing case-INsenstitive uniqueness with Django and
> Postgres

--

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: PYTHON_EGG_CACHE, access denied error

2009-12-06 Thread Oleg Oltar
Hi!

I am deploying my django application on a server, and on last stages I am
getting this error:

ExtractionError at /admin/

Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

[Errno 13] Permission denied: '/.python-eggs'

The Python egg cache directory is currently set to:

/.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

Request Method: GET
Request URL:http://go-ban.org/admin/
Exception Type: ExtractionError
Exception Value:

Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

[Errno 13] Permission denied: '/.python-eggs'

The Python egg cache directory is currently set to:

/.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

Exception Location:
/usr/lib/python2.5/site-packages/pkg_resources.py in extraction_error,
line 887
Python Executable:  /usr/bin/python
Python Version: 2.5.2
Python Path:['/home/oleg/sites/goban',
'/usr/lib/python2.5/site-packages/PIL-1.1.7-py2.5-linux-i686.egg',
'/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg',
'/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages/PIL',
'/var/lib/python-support/python2.5']
Server time:Sun, 6 Dec 2009 14:05:47 +0200

Maybe someone come across similar issue?

The strangest thing here is that I am using another django site on this host
with no such error :(

--

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.




sorl thumbnail: messed-up thumb file path

2009-12-06 Thread omat
Hi All,

Sorl thumbnail is creating invalid directories for thumbnails in my
development environment (mac os x, django dev server).

In my local development settings:

MEDIA_URL = "http://localhost:8000/;

I use the "thumbnail" template filter and it generates crazy
directories under my media root as:

- "http/" (yes the directory name has a trailing slash)
- "localhost/8000" (yes, this is funny too)
- "logo" (this is the upload_to location)

and the created directory is empty, no thumbnail.

Am I missing something obvious?


Thanks,
omat

--

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.




Extending result count at bottom of admin pages

2009-12-06 Thread Count László de Almásy
I'm new to django but working hard to come up to speed. I need to make
a small change to the admin interface, and am hoping i could get a
pointer on how to do this. At the bottom of an admin page, the number
of results is displayed in a summary, along with pagination buttons.
For example,

"1 [2] 76 payments"

Along with showing the number of payments at the bottom, I'd like to
display the dollar total for them next to it. One of my columns is
payment amount, so it should (i hope) be fairly easy to SUM the
results of that column to get this, so it might look like this
instead:

"1 [2] 76 payments (for $1,500)"

The relevant template seems to be admin/pagination.html with
"cl.result_count" displaying the number of objects. How would i insert
my own tag into this template to show the SUM of my payment amount
column for said objects?

--

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.




Unique model field and case sensitivity (postgres)

2009-12-06 Thread chefsmart
Reading through some discussions on this mailing list and elsewhere, I
saw a lot of material on mysql case sensitivity and collation.

Consider the following situation: -

Suppose my app allows users to create the states / provinces in their
country. Just for clarity, we are considering only ASCII characters
here.

In the US, a user could create the state called "Texas". If this app
is being used internally, let's say the user doesn't care if it is
spelled "texas" or "Texas"

But importantly, the system should prevent creation of "texas" if
"Texas" is already in the database.

If the model is like the following:

class State(models.Model):
name = models.CharField(max_length=50, unique=True)

The uniqueness would be case-sensitive in postgres, that is, postgres
would allow the user to create both "texas" and "Texas" as they are
considered unique.

What can be done in this situation to prevent such behavior. How does
one go about providing case-INsenstitive uniqueness with Django and
Postgres



--

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: Pydev + Django + Ubuntu 9.10

2009-12-06 Thread turkan
Hello Liam,

I am sorry ... I can't access your provided link. Even after
registering there, it says "You are not authorized to view this
workspace.".
I am also not sure why you suggest me Posgresql/PostGIS. I don't have
any problems with setting up the database, just with setting up Pydev/
Eclipse correctly.
Any further suggestions?

Regards,
Kai


On Dec 6, 12:08 am, Info Cascade  wrote:
> Turkan,
>
> Perhaps this will help. I just have done this
> (PostGIS/Eclipse/Pydev/Django on Ubuntu 9.10) and it's working great!
> After having problems because I had installed Postgres 8.4, I found the
> script below, on the net somewhere.
> Modify, as appropriate, if you don't need GIS.
>
> You may also want this, for full support in pgadmin3:
> apt-get install postgresql-contrib-8.3
> cd /usr/share/postgresql/8.3/contrib
> psql -U  postgres < adminpack.sql
>
> Getting Eclipse working took some time, and I learned a lot from 
> this:http://www.socialtext.net/hearplanet/index.cgi?action=display;is_inci...
>
> Best,
> Liam
>
> > # Script for installing Django, PostgreSQL, and PostGIS
> > # Run with sudo
>
> > # Install Django:
> > apt-get install python-django python-django-doc
>
> > # Install PostgreSQL 8.3
> > apt-get install postgresql-8.3 python-psycopg2 pgadmin3
>
> > # Packages needed by GeoDjango (gdal is optional, but useful)
> > apt-get install postgresql-8.3-postgis binutils libgdal1-1.5.0
> > gdal-bin libgeos-3.1.0 proj libpq-dev
>
> > # Set yourself up as a PostgreSQL superuser
> > su - postgres
> > createuser --createdb --superuser `whoami`
>
> > # Create the template spatial database
> > createdb -E UTF8 template_postgis
> > createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
>
> > # Allows non-superusers the ability to create from this template
> > psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE
> > datname='template_postgis';"
>
> > # Load the PostGIS SQL routines
> > psql -d template_postgis -f
> > /usr/share/postgresql-8.3-postgis/lwpostgis.sql
> > psql -d template_postgis -f
> > /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
>
> > # Enable users to alter spatial tables
> > psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
> > psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
> > exit
> turkan wrote:
> > Hello.
>
> > I know ... this topic was discussed quite often. But all the hints I
> > found don't really help to setup Eclipse/Pydev under Ubuntu 9.10 for
> > Django 1.1 (from the official Ubuntu repositories).
> > I tried to follow this tutorial (http://solyaris.wordpress.com/
> > 2007/05/16/how-to-djangopydev-on-feisty/), but /usr/share/python-
> > support/python-django/ is not present anymore under Ubuntu 9.10.
> > So I tried to add /usr/shared/pyshared/django, usr/share/python-
> > support/, /usr/lib/python/django to the PYTHONPATH, but without any
> > success. My projects still come up with many "undefined variable"
> > errors. For example an error is presented for User.add_to_class.
> > add_to_class (add_to_class is unkown), even if User seems to be known.
> > I read that it is difficult for the IDE to recognize all variables,
> > cause of the way some of those are generated on the fly (I am also new
> > to Python). But is it possible to get error free projects with Django
> > + Pydev?
> > Why does Aptana for example does provide such a good Ruby support?
> > Does Python/Django provide more dynamic stuff than Ruby?
>
> > Regards,
> > Kai
>
> > --
>
> > 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: Initial values and unbound forms (apparently a bug?)

2009-12-06 Thread Manu
Hello,

I would say that the behavior you have is normal. Quoting the doc

"Using initial data with a formset:
Initial data is what drives the main usability of a formset. As shown
above you can define the number of extra forms. What this means is
that you are telling the formset how many additional forms to show
**in addition** to the number of forms it generates from the initial
data."


What I understood from the doc is that initial values are used for
existing objects or ones being built. Ie, if you provided 6 forms with
default values in a formset, you will end up with 6 new objects
created/modified. It's up to you then to really create/modfiy those
objects.

Consequently a solution for you would be to set extra=0 and set up you
inital datas as you have done but not create objects if default
values have not been changed (for instance).

Manu

--

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.




Model as database views

2009-12-06 Thread goto
Hi,

I am trying to make a django model that will show data from different
other models as a single model. Kind of like a database view to a
database table.

My idea is to make a custom field that maps to another field in some
other model

code for fields.py is as follows
---
from django.db import models
from django.db.models import get_model

class ViewField(models.Field):
def __init__(self, *args, **kwargs):
model = get_model(kwargs['app'], kwargs['model'])
if '__' in kwargs['field']:
self.var_name, self.field_name = kwargs['field'].split
('__')
else:
self.var_name = ''
self.field_name = kwargs['field']

for field in model._meta.fields:
if field.name == self.field_name:
self._field = field
break
else:
return None
del(kwargs['app'])
del(kwargs['model'])
del(kwargs['field'])
super(ViewField, self).__init__(*args, **kwargs)

def db_type(self):
return self._field.db_type()

def to_python(self, value):
return self._field.to_python(value)

def get_db_prep_value(self, value):
return self._field.get_db_prep_value(value)

def get_db_prep_lookup(self, lookup_type, value):
return self._field.get_db_prep_lookup(lookup_type, value)

def formfield(self, **kwargs):
return self._field.formfield(**kwargs)

def get_internal_type(self):
return self._field.get_internal_type()

def value_to_string(self, obj):
return self._field.value_to_string(obj)

def contribute_to_class(self, cls, name):
return self._field.contribute_to_class(cls, name)
---
I ve also made a custom manager. its code is as follows
---
from django.db.models import get_model
class ViewModelManager(models.Manager):
def __init__(self, *args, **kwargs):
self._model = get_model(kwargs['app'], kwargs['model'])
del(kwargs['app'])
del(kwargs['model'])
super(ViewModelManager, self).__init__(*args, **kwargs)

def get_query_set(self):
return self._model.objects.get_query_set()

def get_empty_query_set(self):
return self._model.objects.get_empty_query_set()

def none(self):
return self._model.objects.none()

def all(self):
return self._model.objects.all()

def count(self):
return self._model.objects.count()

def dates(self, *args, **kwargs):
return self._model.objects.dates(*args, **kwargs)

def distinct(self, *args, **kwargs):
return self._model.objects.distinct(*args, **kwargs)

def extra(self, *args, **kwargs):
return self._model.objects.extra(*args, **kwargs)

def get(self, *args, **kwargs):
return self._model.objects.get(*args, **kwargs)

def get_or_create(self, **kwargs):
return self._model.objects.get_or_create(**kwargs)

def create(self, **kwargs):
return self._model.objects.create(**kwargs)

def filter(self, *args, **kwargs):
return self._model.objects.filter(*args, **kwargs)

def aggregate(self, *args, **kwargs):
return self._model.objects.aggregate(*args, **kwargs)

def annotate(self, *args, **kwargs):
return self._model.objects.annotate(*args, **kwargs)

def complex_filter(self, *args, **kwargs):
return self._model.objects.complex_filter(*args, **kwargs)

def exclude(self, *args, **kwargs):
return self._model.objects.exclude(*args, **kwargs)

def in_bulk(self, *args, **kwargs):
return self._model.objects.in_bulk(*args, **kwargs)

def iterator(self, *args, **kwargs):
return self._model.objects.iterator(*args, **kwargs)

def latest(self, *args, **kwargs):
return self._model.objects.latest(*args, **kwargs)

def order_by(self, *args, **kwargs):
return self._model.objects.order_by(*args, **kwargs)

def select_related(self, *args, **kwargs):
return self._model.objects.select_related(*args, **kwargs)

def values(self, *args, **kwargs):
return self._model.objects.values(*args, **kwargs)

def values_list(self, *args, **kwargs):
return self._model.objects.values_list(*args, **kwargs)

def update(self, *args, **kwargs):
return self._model.objects.update(*args, **kwargs)

def reverse(self, *args, **kwargs):
return self._model.objects.reverse(*args, **kwargs)

def defer(self, *args, **kwargs):
return self._model.objects.defer(*args, **kwargs)

def only(self, *args, **kwargs):
return self._model.objects.only(*args, **kwargs)

def _insert(self, values, **kwargs):
return 

Re: Where to store repetitive form logic?

2009-12-06 Thread Manu
I got the same need and wrote up a FormView wich handles all the
repetitive process of a form.

In your case, you could build your view like this: http://dpaste.com/129827/
You will find basic example (and explanations) here:
http://www.obviews.com/form/simplest/.

Hope this helps,
Manu

--

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.