Re: models.py

2009-10-28 Thread Vincent Jones
where would you suggest is a good basic learning site or book so i can
become proficient?

On Wed, Oct 28, 2009 at 1:05 PM, Karen Tracey  wrote:

> On Wed, Oct 28, 2009 at 12:50 PM, Vincent Jones wrote:
>
>> Thats what i don't understand.i am trying to learn django
>> using"Learning Website development with django" when i get to the step of
>> using models it gives me the second script below and says to insert the top
>> script and after i type ' python manage.py syncdb i get an *NameError :
>> name 'models' is not defined
>>
>> *
>
>
> It sounds like you've put the bookmarks block at the very top of your
> existing models.py file that had already included the Link model.  That
> won't work because the Bookmark class definition:
>
> class Bookmark(models.Model):
>
> references the models module which is not imported until further down,
> right before the Link model definition:
>
>
> from django.db import models
> class Link(models.Model):
>
> (The code you included in your first message is also entirely lacking a
> bunch of required indentation -- I presume it is really there in the file
> you are woking with?  Indentation is significant in Python so leaving it out
> when posting can cause confusion.  Leaving it out in the file you are
> working with will lead to errors.)
>
> The fix for the error message you are getting is to move the import for
> models to be above any reference to the models module.
>
> More broadly, this is basic Python knowledge.  If you are brand new to
> Python as well as Django you might want to start by working through a plain
> Python tutorial.  It's possible to learn both at the same time, but it
> really helps if you cover learning the very basics of Python first.
>
> Karen
>
> >
>

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



fabric autocompletion

2009-10-28 Thread Enrico

If anyone is interested, I've created a script for fabric
autocompletion.

http://github.com/ricobl/dotfiles/blob/master/bin/fab_bash_completion

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



Re: Error with admin site while deploying Django on Apache

2009-10-28 Thread Piotr Górski
Yes, changing directory permissions helped. Thanks.

2009/10/29 Graham Dumpleton 

>
>
>
> On Oct 29, 10:21 am, Christophe Pettus  wrote:
> > On Oct 28, 2009, at 4:01 PM, Piotr Górski wrote:
> >
> > > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File "/
> > > usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py",
> > > line 193, in execute
> > > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return
> > > Database.Cursor.execute(self, query, params)
> > > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]
> > > OperationalError: attempt to write a readonly database
> >
> > Are you sure the Apache user has write permission to the sqlite3
> > database?
>
> It also must have write permission to directory as well if it is
> sqlite. It is the directory permission which trips most people up, not
> the database file itself.
>
> Graham
> >
>

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



Re: Error with admin site while deploying Django on Apache

2009-10-28 Thread Piotr Górski
Yes, I must have overlooked that. Changing permissions helped.
I really appreciate your help. Thanks.

2009/10/29 Christophe Pettus 

>
>
> On Oct 28, 2009, at 4:01 PM, Piotr Górski wrote:
> > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File "/
> > usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py",
> > line 193, in execute
> > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return
> > Database.Cursor.execute(self, query, params)
> > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]
> > OperationalError: attempt to write a readonly database
>
> Are you sure the Apache user has write permission to the sqlite3
> database?
>
> --
> -- Christophe Pettus
>PGExperts, Inc.  http://pgexperts.com/
> x...@thebuild.com
>
>
> >
>

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



Re: Error with admin site while deploying Django on Apache

2009-10-28 Thread Graham Dumpleton



On Oct 29, 10:21 am, Christophe Pettus  wrote:
> On Oct 28, 2009, at 4:01 PM, Piotr Górski wrote:
>
> > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File "/
> > usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py",  
> > line 193, in execute
> > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]     return  
> > Database.Cursor.execute(self, query, params)
> > [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]  
> > OperationalError: attempt to write a readonly database
>
> Are you sure the Apache user has write permission to the sqlite3  
> database?

It also must have write permission to directory as well if it is
sqlite. It is the directory permission which trips most people up, not
the database file itself.

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



Re: Error with admin site while deploying Django on Apache

2009-10-28 Thread Christophe Pettus


On Oct 28, 2009, at 4:01 PM, Piotr Górski wrote:
> [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File "/ 
> usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py",  
> line 193, in execute
> [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return  
> Database.Cursor.execute(self, query, params)
> [Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]  
> OperationalError: attempt to write a readonly database

Are you sure the Apache user has write permission to the sqlite3  
database?

--
-- Christophe Pettus
PGExperts, Inc.  http://pgexperts.com/
x...@thebuild.com


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



Re: Error with admin site while deploying Django on Apache

2009-10-28 Thread Piotr Górski
On attempt to visit http://localhost/meth/admin/ I get the following in the
Apache error log:

[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] mod_wsgi
(pid=2655): Exception occurred processing WSGI script
'/var/www/meth/apache/django.wsgi'.
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] Traceback (most
recent call last):
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 245,
in __call__
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] response =
middleware_method(request, response)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/contrib/sessions/middleware.py",
line 36, in process_response
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]
request.session.save()
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py",
line 58, in save
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]
obj.save(force_insert=must_create)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/models/base.py", line 410, in
save
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]
self.save_base(force_insert=force_insert, force_update=force_update)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/models/base.py", line 495, in
save_base
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] result =
manager._insert(values, return_id=update_pk)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 177, in
_insert
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return
insert_query(self.model, values, **kwargs)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/models/query.py", line 1087, in
insert_query
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return
query.execute_sql(return_id)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/models/sql/subqueries.py", line
320, in execute_sql
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] cursor =
super(InsertQuery, self).execute_sql(None)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/models/sql/query.py", line 2369,
in execute_sql
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]
cursor.execute(sql, params)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in
execute
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return
self.cursor.execute(sql, params)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32]   File
"/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line
193, in execute
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] return
Database.Cursor.execute(self, query, params)
[Wed Oct 28 23:58:42 2009] [error] [client 85.222.111.32] OperationalError:
attempt to write a readonly database

2009/10/28 Christophe Pettus 

>
>
> On Oct 28, 2009, at 3:44 PM, Piotr Górski wrote:
> > When I try to go to admin site, I get 500 internal
> > server error (admin site works perfectly well on development server).
>
> Is there anything interesting in the Apache error log?
> --
> -- Christophe Pettus
>x...@thebuild.com
>
>
> >
>

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



Re: Error with admin site while deploying Django on Apache

2009-10-28 Thread Christophe Pettus


On Oct 28, 2009, at 3:44 PM, Piotr Górski wrote:
> When I try to go to admin site, I get 500 internal
> server error (admin site works perfectly well on development server).

Is there anything interesting in the Apache error log?
--
-- Christophe Pettus
x...@thebuild.com


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



Re: I got stuck when modelling.

2009-10-28 Thread Javier Guerra

On Wed, Oct 28, 2009 at 5:19 PM, Wim De Hul  wrote:
>
> Hi all,
>
> I'm trying to build a web application to keep track of my firewall
> requests.
> I want to keep track of hosts and hostgroups, but I got stuck in
> creating the model. The problem is the following:
> ...snip...
> Now, a hostgroup contains one or more hosts, but it can also contain one
> or more hostgroups.

if a host can only belong to a single hostgroup:

Host:
id (Primary key)
hostgroup (foreing key)
name
ipaddress
netmask
creation_date

HostGroup:
id (primary key)
parent (foreign key to 'self')
name
creation_date

if a host can belong to several hostgroups simply change the foreign
key from host to hostgroup to a ManyToManyKey.

make sure that the 'parent' field in hostgroup is null'able, to
account for 'main' groups



-- 
Javier

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



Error with admin site while deploying Django on Apache

2009-10-28 Thread Piotr Górski

I have a small Django website which I am trying to run on an Apache
2.2 HTTP-Server. The application is running fine using "python
manage.py runserver". It is also running fine on Apache, except for
the admin site. When I try to go to admin site, I get 500 internal
server error (admin site works perfectly well on development server).

My urls.py file:

from django.conf.urls.defaults import *
from meth.views import *
from settings import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^meth/', include('meth.foo.urls')),

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

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

# Site urls
(r'^$', main),
(r'^prot-desc/(Y[A-Z]{2}\d{3}[A-Z])/$', protein_description),
(r'^about/$', about),
(r'^links/$', links),
(r'^contact/$', contact),
)
# end of urls.py


My httpd.conf file (the end of it):

Alias /meth/media /var/www/meth/media/


Order deny,allow
Allow from all


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


Order deny,allow
Allow from all

# end of httpd.conf

What's wrong with it?
I was googling for a few hours, bud didn't find anything helpful.
I will be grateful for any suggestions.

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



need help with saving/updating model record via admin interface

2009-10-28 Thread Andrew

Hello,

I am pretty new to django and python and stuck with admin interface
functionality.

I have a model which represents a product, and I want to have
functionality to add product via admin interface with picture and
later to have possibility to update it using the same admin
interface.

The problem is then I am updating the product data, if no file has
been uploaded, then file field becomes empty!

How do I rewrite save() method to stop it reseting image field, but
update it only when it is uploaded?

My current Product model:
---
class Product(db.Model):
  title = db.StringProperty(required=True)
  description = db.StringProperty()
  price = db.FloatProperty()
  image = db.BlobProperty()
  created = db.DateTimeProperty(auto_now_add = True)
  lastmodified = db.DateTimeProperty(auto_now = True)

  def save(self):
if getattr(self, 'image'):
  img = getattr(self, 'image')
  print "String length: " + len(img)
  image = images.resize(getattr(self, 'image'), settings.THW2,
settings.THT2)
  setattr(self, 'image', image)
super(Product, self).save()


I have tried to apply some changes on save method and update seems to
be working as expected and not able to creat new products anymore:


class Product(db.Model):
  title = db.StringProperty(required=True)
  description = db.StringProperty()
  price = db.FloatProperty()
  image = db.BlobProperty()
  created = db.DateTimeProperty(auto_now_add = True)
  lastmodified = db.DateTimeProperty(auto_now = True)

  def save(self):

Product.title = getattr(self, 'title')
Product.description = getattr(self, 'description')
Product.price = getattr(self, 'price')

if getattr(self, 'image'):
  Product.image = images.resize(getattr(self, 'image'),
settings.THW2, settings.THT2)

#strange, why does it update record without calling save() ???
#super(Product, self).save()
-

Woud be grateful for your help!

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



I got stuck when modelling.

2009-10-28 Thread Wim De Hul

Hi all,

I'm trying to build a web application to keep track of my firewall
requests.
I want to keep track of hosts and hostgroups, but I got stuck in
creating the model. The problem is the following:

I have 3 tables:

Host
--
id (Primary key)
name
ipaddress
netmask
creation_date

Hostgroup
---
id (primary key)
name
creation_date

HostgroupMembers
-
id (foreign key to Hostgroup.id)
host_id (foreign key to Host.id)
hostgroup_id (???)

Now, a hostgroup contains one or more hosts, but it can also contain one
or more hostgroups.
For each hostgroup, I have inlines where I can add host(groups) to a hostgroup.
Somehow, I have to create a second foreign key in the HostgroupMembers
table to the Hostgroup table, but I think that's not the way.
If possible, I would like to have the hosts and hostgroups in the same dropdown 
box
on the admin portal.

I hope I made myself clear. FYI, I use sqlite3 for development, but I'm
going to use Postgresql in production.

Does anyone know how to do this in Django?
I don't prefer writing custom SQL.


-- 
 Wim

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



Re: Replicating Google Groups in Django

2009-10-28 Thread Kai

Hi Julien and all,

Better integration of mailing lists with Django has also been on my
mind, and seeing this thread prompted two points:

1) The Satchmo app for Django has Mailman 2 integration already, here:
http://bitbucket.org/chris1610/satchmo/src/tip/satchmo/apps/satchmo_ext/newsletter/mailman.py

2) Has anyone looked at Mailman 3 code and tying that in with Django?
https://launchpad.net/mailman

Given how important email is for retaining site users, it's surprising
there doesn't seem to be a lot of interest in this area. An email-list
of 1000 opt-in users is arguably more valuable than a site with 1000
registered users.  So if anyone is interested in looking further into
Mailman 3 integration, give a shout,

Kai




On Oct 23, 9:06 am, Julien Phalip  wrote:
> Hi,
>
> On one site I'm considering the possibility of replicating the (basic)
> functionality of Google Groups in Django. The idea is:
>
> - There would be 5 different mailing lists. Users can subscribe to one
> or more lists.
> - People can purely use emails to access the lists.
> - All the emails can then also be seen via a web interface.
>
> I've been thinking of using Mailman to leverage all the email
> management part. But now I'm not sure how to reliably sync the Mailman
> subscription system with django.contrib.auth.
>
> I don't think there's any straight forward to do this. Would you have
> any advice to get me started?
>
> Thanks!
>
> Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {% url in templates

2009-10-28 Thread Umapathy S
On Wed, Oct 28, 2009 at 8:03 PM, Gabriel .  wrote:

>
> On Wed, Oct 28, 2009 at 4:16 PM, Umapathy S  wrote:
> > view_xyz is the view function.  No arguments.
> >
> > exps is the application.  pams is project.
> >
> > pams/urls.py
> >
> > urlpatterns = patterns('',
> > # Example:
> > # (r'^pams/', include('pams.foo.urls')),
> > (r'pams/', include('pams.exps.urls')),
> >
> >
> > pams/exps.urls.py
> >
> > from django.conf.urls.defaults import *
> > from django.views.generic import list_detail
> > from pams.exps.models import *
> >
> > urlpatterns = patterns('pams.exps.views',
> > (r'exps/xyz/$', 'view_xyz'),
> >
>
> Try with {% url exps.views.view_xyz 
>
> or "pams.exps.views.view_xyz"
>
> {%
>

Thanks.

 {% url exps.views.view_xyz %} worked.

Is it possible to do this for generic views?


Thanks

Umapathy

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



Re: {% url in templates

2009-10-28 Thread Gabriel .

On Wed, Oct 28, 2009 at 4:16 PM, Umapathy S  wrote:
> view_xyz is the view function.  No arguments.
>
> exps is the application.  pams is project.
>
> pams/urls.py
>
> urlpatterns = patterns('',
>     # Example:
>     # (r'^pams/', include('pams.foo.urls')),
>     (r'pams/', include('pams.exps.urls')),
>
>
> pams/exps.urls.py
>
> from django.conf.urls.defaults import *
> from django.views.generic import list_detail
> from pams.exps.models import *
>
> urlpatterns = patterns('pams.exps.views',
>     (r'exps/xyz/$', 'view_xyz'),
>

Try with {% url exps.views.view_xyz 

or "pams.exps.views.view_xyz"

{%



-- 
Kind Regards

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



Re: {% url in templates

2009-10-28 Thread Umapathy S
view_xyz is the view function.  No arguments.

exps is the application.  pams is project.

pams/urls.py

urlpatterns = patterns('',
# Example:
# (r'^pams/', include('pams.foo.urls')),
(r'pams/', include('pams.exps.urls')),


pams/exps.urls.py

from django.conf.urls.defaults import *
from django.views.generic import list_detail
from pams.exps.models import *

urlpatterns = patterns('pams.exps.views',
(r'exps/xyz/$', 'view_xyz'),


view_xyz is defined in pams/exps/views.py.  Its just a dummy function which
gets some data through POST and prints out a table.

Thanks

Umapathy


On Wed, Oct 28, 2009 at 7:05 PM, Gabriel .  wrote:

>
> On Wed, Oct 28, 2009 at 3:55 PM, Umapathy S  wrote:
> >
> > Hello there,
> >
> > I am developing a page which has a left side menu.  This menu is a
> seperate html and gets includes in the base.html template.
> >
> > To make it less vulnerable to url changes, I am trying to implement the
> {% url %}
> >
> > in lhsmenu.html
> >
> > 
> > 
> > view
> > 
> > {% url exps.view_xyz as viewxyzurl %}
> > xyz
> > 
> > 
> > 
> >
> > I tried
> >
> > xyz
> >
> >
> > Exception Type: TemplateSyntaxError
> > Exception Value:
> >
> > Caught an exception while rendering: Reverse for 'exps.view_xyz' with
> arguments '()' and keyword arguments '{}' not found.
> >
> > What could be the issue.  Any help much appreciated.
> >
> > Thanks
> >
>
> Is your view called exps.view_xyz or view_xyz? Would be usefull if you
> paste your urls.py conf.
>
> --
> Kind Regards
>
> >
>

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



Re: {% url in templates

2009-10-28 Thread Gabriel .

On Wed, Oct 28, 2009 at 3:55 PM, Umapathy S  wrote:
>
> Hello there,
>
> I am developing a page which has a left side menu.  This menu is a seperate 
> html and gets includes in the base.html template.
>
> To make it less vulnerable to url changes, I am trying to implement the {% 
> url %}
>
> in lhsmenu.html
>
> 
> 
>     view
>     
>     {% url exps.view_xyz as viewxyzurl %}
>     xyz
>     
> 
> 
>
> I tried
>
>     xyz
>
>
> Exception Type: TemplateSyntaxError
> Exception Value:
>
> Caught an exception while rendering: Reverse for 'exps.view_xyz' with 
> arguments '()' and keyword arguments '{}' not found.
>
> What could be the issue.  Any help much appreciated.
>
> Thanks
>

Is your view called exps.view_xyz or view_xyz? Would be usefull if you
paste your urls.py conf.

--
Kind Regards

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



Re: {% url in templates

2009-10-28 Thread David Zhou
What's your 'view_xyz'?

Are you sure that view_xyz is accessible through an URL without any
arguments?

-- dz


On Wed, Oct 28, 2009 at 2:55 PM, Umapathy S  wrote:

> Hello there,
>
> I am developing a page which has a left side menu.  This menu is a seperate
> html and gets includes in the base.html template.
>
> To make it less vulnerable to url changes, I am trying to implement the {%
> url %}
>
> in lhsmenu.html
>
> 
> 
> view
> 
> {% url exps.view_xyz as viewxyzurl %}
> xyz
> 
> 
> 
>
> I tried
>
> xyz
>
>
> Exception Type: TemplateSyntaxError  Exception Value:
>
> Caught an exception while rendering: Reverse for 'exps.view_xyz' with 
> arguments '()' and keyword arguments '{}' not found.
>
>
>
> What could be the issue.  Any help much appreciated.
>
> Thanks
>
>
>
> >
>

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



{% url in templates

2009-10-28 Thread Umapathy S
Hello there,

I am developing a page which has a left side menu.  This menu is a seperate
html and gets includes in the base.html template.

To make it less vulnerable to url changes, I am trying to implement the {%
url %}

in lhsmenu.html



view

{% url exps.view_xyz as viewxyzurl %}
xyz




I tried

xyz


Exception Type: TemplateSyntaxError  Exception Value:

Caught an exception while rendering: Reverse for 'exps.view_xyz' with
arguments '()' and keyword arguments '{}' not found.



What could be the issue.  Any help much appreciated.

Thanks

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



Re: Starting a daemon thread from Django view

2009-10-28 Thread Jumpfroggy

I'm in the same boat here.  My plan is similar.

>From views.py, record the job in the DB.
Start the daemon thread.
Return a "Processing..." response to the browser.
When the daemon thread is done, it records it in the DB.
The browser page uses AJAX to query the DB and update the status.
When the DB changes, the browser page then shows "Done." and the
results.

One unanswered question is whether updating the DB with the models is
thread safe.  I realize that Django itself is not guaranteed to be
thread safe, but I don't yet see that there would be any problems
inserting & updating models (db rows) so far.  I know I'll have to
worry about things like race conditions, but I suspect that actual
operation of updating a model would not be affected.  Hopefully that's
true and I don't run into crazy threading bugs.

Your method will be safer, since calling a web service to signal the
end of the job is concurrency, but avoids the threading problem.  It's
no different than multiple users calling the server at once.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



poll question

2009-10-28 Thread Ross

I've gone through and successfully made the poll application and I've
begun to play around and tried to change a few things. The first thing
I would like to do is have the poll such that the index view still
displays the name of all the different polls, but the detail view
displays a field where users can submit their own unique answer
instead of voting on particular answers. I realize this involves
changing the Choice model, but after this, I'm unsure of what to do
with the detail template to get this form displayed. Also, would I
need to change the vote view since a different type of data is being
submitted so that the results tempate renders correctly?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: models.py

2009-10-28 Thread Karen Tracey
On Wed, Oct 28, 2009 at 12:50 PM, Vincent Jones  wrote:

> Thats what i don't understand.i am trying to learn django
> using"Learning Website development with django" when i get to the step of
> using models it gives me the second script below and says to insert the top
> script and after i type ' python manage.py syncdb i get an *NameError :
> name 'models' is not defined
>
> *


It sounds like you've put the bookmarks block at the very top of your
existing models.py file that had already included the Link model.  That
won't work because the Bookmark class definition:

class Bookmark(models.Model):

references the models module which is not imported until further down, right
before the Link model definition:

from django.db import models
class Link(models.Model):

(The code you included in your first message is also entirely lacking a
bunch of required indentation -- I presume it is really there in the file
you are woking with?  Indentation is significant in Python so leaving it out
when posting can cause confusion.  Leaving it out in the file you are
working with will lead to errors.)

The fix for the error message you are getting is to move the import for
models to be above any reference to the models module.

More broadly, this is basic Python knowledge.  If you are brand new to
Python as well as Django you might want to start by working through a plain
Python tutorial.  It's possible to learn both at the same time, but it
really helps if you cover learning the very basics of Python first.

Karen

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



Re: models.py

2009-10-28 Thread Vincent Jones
Thats what i don't understand.i am trying to learn django using"Learning
Website development with django" when i get to the step of using models it
gives me the second script below and says to insert the top script and after
i type ' python manage.py syncdb i get an *NameError : name 'models' is not
defined

I am supposed to get:

*CREATE TABLE "bookmarks_bookmark" (
"id" integer NOT NULL PRIMARY KEY,
"title" varchar(200) NOT NULL,
"user_id" integer NOT NULL REFERENCES
"auth_user" ("id"),
"link_id" integer NOT NULL REFERENCES
"bookmarks_link" ("id"),
);
CREATE TABLE "bookmarks_link" (
"id" integer NOT NULL PRIMARY KEY,
"url" varchar(200) NOT NULL UNIQUE
);
COMMIT;*

After i type: python mange.py sql bookmarks


*
On Wed, Oct 28, 2009 at 4:31 AM, David  wrote:

>
> can you explain a bit better? where do you want to insert?
>
> On 28 Okt., 00:46, Vman  wrote:
> > how do i insert this:
> >
> > from django.contrib.auth.models import User
> > class Bookmark(models.Model):
> > title = models.CharField(maxlength=200)
> > user = models.ForeignKey(User)
> > link = models.ForeignKey(Link)
> >
> > into this?
> >
> > from django.db import models
> > class Link(models.Model):
> > url = models.URLField(unique=True)
> >
> > I am getting this error:
> >
> > NameError: name 'models' is not defined
> >
> > Thanks...
> >
>

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



Re: inspectdb Oracle

2009-10-28 Thread gillengam

Thank you very much.

On 26 Ott, 15:03, "Mark (Nosrednakram)" 
wrote:
> On Oct 26, 4:43 am, gillengam  wrote:
>
> > Hi, I must develop an application that use Oracle database. The Oracle
> > connection user is the owner of some tables, but he can only read two
> > views (he is not the owner). I used command "python manage.py
> >inspectdb> models.py", but I got only user's tables and  I need
> > also the two views. How can I do? Is it possible?
>
> > Thanks
>
> I usually create a table using something similar to:
>
> create table temp_member_view as select * from member_view where
> rownum < 2;
>
> Where member_view would be the original view name.  I then use theinspectdbto 
> create the model for the new table and then drop the
> table it should create a better model than I do usually when I try to
> do it manually.    If your view doesn't have an obvious single column
> primary key you may want to look at my notes on this subject:
>
> http://projects.django-development.info/trac/dd_dd/wiki/Creating_Djan...
>
> Great call on overriding save/delete I'll add to my notes and start
> doing that as well since I wasn't.
>
> Mark

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



Re: FF3 src error in django admin calendar

2009-10-28 Thread Dan Ward

I've had the issue myself, and noticed a bug has been reported on the
part of Django's DateTimeShortcuts.js script relying on the DOM to
fetch the admin_media_prefix. A milestone of 1.2 has also been set by
Jacob on the ticket, so fingers-crossed, other than the patch, an
upcoming update will resolve the issue.

The ticket information can be found here for anybody interested:
http://code.djangoproject.com/ticket/11967

Thanks,
Daniel Ward (http://danward.tel)

On Sep 30, 10:08 am, Daniel Roseman  wrote:
>
> I've got some time this week so I might try and work up a patch: I
> think it would be best to set an admin_media_path variable in the
> admin base template, which all the JS files can use, although I
> suspect this might run into 'design decision needed' territory.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Versionable Models?

2009-10-28 Thread hcarvalhoalves

On Oct 27, 4:54 pm, Todd Blanchard  wrote:
> Total django noob here.  Rails/PHP/WebObjects refugee here.
>
> I'm starting a project where some models need to be fully versioned.
>
> IOW, record update is forbidden - every save to a changed model should  
> result in a new record with a new version number or timestamp along  
> with identity pulled from the current authenticated user's session.  
> Queries/relationships should be specified as "fetch newest" or "fetch  
> history".  IOW sometimes I want to traverse a relationship and just  
> get the "current" record.  Sometimes I want to get the history of that  
> relationship.
>
> Anybody done this?  Got any tips?
>
> Thanks,
> -Todd Blanchard

You can do all that without much magic.


class MyVersionedModel(models.Model):
user = models.ForeignKey('User', editable=False)
timestamp = models.DateTimeField(auto_now_add=True,
editable=False)

class Meta:
ordering = ['-timestamp']
get_latest_by = 'timestamp'
abstract = True

def save(self, *args, **kwargs):
self.pk = None # Forces insert
return super(MyVersionedObject, self).save(*args, **kwargs)


Now you just need to inherit this mixin on all models you want
versioned.


class MyVersionedPony(MyVersionedObject):
... # Whatever other fields


In your views you can:


def my_pony_view(request):
...
my_pony.user = request.user
my_pony.save() # Always inserts instead of updating

current_pony = MyVersionedPony.objects.latest()  # Last pony
all_ponies = MyVersionedPony.objects.all() # Ordered descending


If you need to encapsulate logic for more complex queries, you can
create a model manager. [1]

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



Re: Haystack/Whoosh problem

2009-10-28 Thread nausikaa

Ok, looks like I found a solution:

svn co http://svn.whoosh.ca/projects/whoosh/trunk/ whoosh
cd whoosh
sudo python setup.py install

The site here suggests a patch but I think it's not up to date
anymore:
http://haystacksearch.org/docs/installing_engines.html



On Oct 28, 4:10 pm, nausikaa  wrote:
> Hi there
>
> I've been trying to use haystack with the whoosh backend in my django
> app.
> I've installed whoosh and haystack using
> pip install Whoosh
> pip install django-haystack
>
> Then I added 'haystack' to my INSTALLED_APPS in settings.py and when
> trying to run
> python manage.py runserver it would say
>
> ...
>   File "/Library/Python/2.6/site-packages/haystack/backends/
> whoosh_backend.py", line 27, in 
>     raise MissingDependency("The 'whoosh' backend requires the
> installation of 'Whoosh'. Please refer to the documentation.")
> haystack.exceptions.MissingDependency: The 'whoosh' backend requires
> the installation of 'Whoosh'. Please refer to the documentation.
>
> Then I removed 'haystack' from setttings.py and did
> python manage.py shell>>> for p in sys.path: print p
>
> ...
> /Library/Python/2.6/site-packages/Whoosh-0.1.4-py2.6.egg
> ...
>
> So, whoosh seems to be on the path, even tho haystack complains.
> I've googled for this, but it looks as if I'm the only one having this
> problem, therefore I assume
> I am missing something obvious.
> Can anyone help me please?
> I'm using Django 1.1, Python 2.6 on a Mac OS 10.6.1,
> Thanks for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



My CKEditor Integration Pattern

2009-10-28 Thread Johan

I've outlined how I am currently integrating CKEditor into my admin
site (http://tinyurl.com/ylfjumo) . This way obviously work very
nicely for me.
Is there any reason to go the more advanced route of creating a custom
widget?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Haystack/Whoosh problem

2009-10-28 Thread nausikaa

Hi there

I've been trying to use haystack with the whoosh backend in my django
app.
I've installed whoosh and haystack using
pip install Whoosh
pip install django-haystack

Then I added 'haystack' to my INSTALLED_APPS in settings.py and when
trying to run
python manage.py runserver it would say

...
  File "/Library/Python/2.6/site-packages/haystack/backends/
whoosh_backend.py", line 27, in 
raise MissingDependency("The 'whoosh' backend requires the
installation of 'Whoosh'. Please refer to the documentation.")
haystack.exceptions.MissingDependency: The 'whoosh' backend requires
the installation of 'Whoosh'. Please refer to the documentation.

Then I removed 'haystack' from setttings.py and did
python manage.py shell
>>> for p in sys.path: print p
...
/Library/Python/2.6/site-packages/Whoosh-0.1.4-py2.6.egg
...


So, whoosh seems to be on the path, even tho haystack complains.
I've googled for this, but it looks as if I'm the only one having this
problem, therefore I assume
I am missing something obvious.
Can anyone help me please?
I'm using Django 1.1, Python 2.6 on a Mac OS 10.6.1,
Thanks for any help!


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



My CKEditor Integration Pattern

2009-10-28 Thread Johan

I've outlined how I am currently integrating CKEditor into my admin
site (http://johansdevblog.blogspot.com/2009/10/adding-ckeditor-to-
django-admin.html ) . This way obviously work very nicely for me.
Isthere any reason to go the more advanced route of creating a custom
widget?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



My CKEditor Integration Pattern

2009-10-28 Thread Johan

I've outlined how I am currently integrating CKEditor into my admin
site (http://johansdevblog.blogspot.com/2009/10/adding-ckeditor-to-
django-admin.html) . This way obviously work very nicely for me. Is
there any reason to go the more advanced route of creating a custom
widget?

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



Re: manage.py syncdb over web?

2009-10-28 Thread zayatzz

Can i also somehow capture the output, so i could see what actually
was done?

Alan.

On Oct 28, 11:39 am, Daniel Roseman  wrote:
> On Oct 28, 8:45 am, zayatzz  wrote:
>
> > Hi.
>
> > I have a problem with django project that is beeing hosting in a
> > server where i have no shell access... so how can i do syncdb there.
> > doing mysql dumps in development db and updating hosting mysql is
> > kinda slow..
>
> > Is it possible do this run syncdb script over web?
>
> > Alan
>
> You could have a view that does django.core.management.call_command
> ('syncdb'). Make sure you've got proper authentication on it though.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Filtering on model methods

2009-10-28 Thread Mikhail Korobov

I think if your methods are really complex then the best you can do is
to denormalise your DB.

Make your calculated fields real fields in a table and update them in
model's save method or using signals.
Another way is to make them calculated by DB using triggers or DB
views but I would prefer denormalisation in this case.

If your methods are not that complex then it may be better to write
manager's methods and put query constructing there.

There are several django apps that can help with denormalisation
(http://bitbucket.org/daevaorn/django-composition/src/,
http://github.com/initcrash/django-denorm).

On 28 окт, 19:29, pbzRPA  wrote:
> I think my problem is both 1 and 2. What happens when you want to use
> python modules to analyse the extra field?
>
> For Example:
>
> Database table History:
>     id       |  Ordered | Delivered | Invoiced |
>     1              10           15           5
>     2               5            5            3
>
> class History(models.Model):
>     ordered = models.IntegerField()
>     delivered = models.IntegerField()
>     Invoiced = models.IntegerField()
>
>     def compute_problem(self):
>          'here will be code that analyses the above data'
>          if self.ordered > self.delivered:
>              return self.ordered - self.delivered
>          if self.invoiced < self.delivered:
>              return self.delivered - self.invoiced
>          return 0
>
> Ideally I would like to create the virtual scenario:
>
>     id       |  Ordered | Delivered | Invoiced | compute_problem
>     1              10           15           5               -5
>     2               5            5            3               -2
>
> in the view I would like to do the following. Please note that my
> compute_problem is a real basic example and I am sure that the above
> example I could do in SQL but my methods become a lot more
> complicated.
>
> queryset = History.objects.filter().exclude(compute_problem = 0)
>
> I can not modify the database as I am writing add-ons and not creating
> the database myself.
>
> I hope this makes a bit more sense. :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why does Django think my browser doesn't except cookies?

2009-10-28 Thread philip.bar...@impaerospace.com

Starting with that premise, I looked into what circumstances lead to
IE rejecting cookies unread. As it turned out, the VM System clock was
six weeks behind the times and IE was throwing out what appeared to be
six week old cookies.

After adjusting the VM system clock the problem went away.

Thanks for your help Grant,

Philip

On Oct 27, 4:40 pm, Grant Livingston  wrote:
> I wouldn't be surprised if this is a bug in IE =/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Filtering on model methods

2009-10-28 Thread pbzRPA

I think my problem is both 1 and 2. What happens when you want to use
python modules to analyse the extra field?

For Example:

Database table History:
id   |  Ordered | Delivered | Invoiced |
1  10   15   5
2   553

class History(models.Model):
ordered = models.IntegerField()
delivered = models.IntegerField()
Invoiced = models.IntegerField()

def compute_problem(self):
 'here will be code that analyses the above data'
 if self.ordered > self.delivered:
 return self.ordered - self.delivered
 if self.invoiced < self.delivered:
 return self.delivered - self.invoiced
 return 0

Ideally I would like to create the virtual scenario:

id   |  Ordered | Delivered | Invoiced | compute_problem
1  10   15   5   -5
2   553   -2


in the view I would like to do the following. Please note that my
compute_problem is a real basic example and I am sure that the above
example I could do in SQL but my methods become a lot more
complicated.

queryset = History.objects.filter().exclude(compute_problem = 0)

I can not modify the database as I am writing add-ons and not creating
the database myself.

I hope this makes a bit more sense. :)



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



Re: upload problems

2009-10-28 Thread bax...@gretschpages.com

Thanks Karen. It was the path inconsistency. They were uploading, just
not where I was expecting them to be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: upload problems

2009-10-28 Thread Karen Tracey
On Wed, Oct 28, 2009 at 9:03 AM, bax...@gretschpages.com <
mail.bax...@gmail.com> wrote:

>
> No, it's not that I can't see them on the site. They're not in the
> filesystem. They're not there, anywhere, as far as I can see.
>
>
I'm pretty sure you'd get an error in the admin if it had any trouble saving
the uploaded file.  Probably the easiest way to verify the full path that is
being used when saving is to put:

import pdb; pdb.set_trace()

at the beginning of the _save() function in django/core/files/storage.py and
step through the save code.   For example:

> /home/kmt/django/trunk/django/core/files/storage.py(139)_save()
-> full_path = self.path(name)
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(141)_save()
-> directory = os.path.dirname(full_path)
(Pdb) full_path
'/home/kmt/software/web/playground/file_thing_files/1.txt'
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(142)_save()
-> if not os.path.exists(directory):
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(143)_save()
-> os.makedirs(directory)
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(153)_save()
-> while True:
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(154)_save()
-> try:
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(156)_save()
-> if hasattr(content, 'temporary_file_path'):
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(164)_save()
-> fd = os.open(full_path, os.O_WRONLY | os.O_CREAT | os.O_EXCL |
getattr(os, 'O_BINARY', 0))
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(165)_save()
-> try:
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(166)_save()
-> locks.lock(fd, locks.LOCK_EX)
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(167)_save()
-> for chunk in content.chunks():
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(168)_save()
-> os.write(fd, chunk)
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(167)_save()
-> for chunk in content.chunks():
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(170)_save()
-> locks.unlock(fd)
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(171)_save()
-> os.close(fd)
(Pdb) n
> /home/kmt/django/trunk/django/core/files/storage.py(181)_save()
-> break

shows this uploaded file was saved to:
'/home/kmt/software/web/playground/file_thing_files/1.txt'

If you do that and still can't see the files on disk after uploading that
will be very curious.

I do see some inconsistencies in the settings you mention:

MEDIA_ROOT = '/Users//Sites/django-media/'

doesn't quite match:

  {'document_root': '/Users/tbaxter/Sites/django-media/ink/',

I assume  is tbaxter but what's the 'ink' on the end?  You also
mention:

> If I back up to the /media/img/ directory, nothing.

Are 'img' and 'ink' supposed to be the same thing?

But these inconsistencies would just affect being able to see the uploaded
files via the browser, they wouldn't have any impact on seeing the files
directly in '/Users//Sites/django-media/' after uploading.

Karen

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



Re: Filtering on model methods

2009-10-28 Thread Mikhail Korobov

Maybe I wrote a reply without undersanding what you need.

You have 2 separate issues:

1. Want to sort and filter by calculated field
2. Want to create calculated field that is calculated in python

Am I correct?

1) can be acheived using ".extra" method or aggregations

http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none
http://docs.djangoproject.com/en/dev/topics/db/aggregation/#order-by

q = Entry.objects.extra(select={'is_recent': "pub_date >
'2006-01-01'"})
q = q.extra(order_by = ['-is_recent'])

Book.objects.annotate(num_authors=Count('authors')).order_by
('num_authors')

2) is not directly possible because there is no support for this on DB
level. Maybe if you provide exact python code you want it becomes
clear how to solve this.


On 28 окт, 15:39, pbzRPA  wrote:
> Thanks for you reply Mikhail,
>
> I do use model managers but more often to get a certain defined
> queryset back. Could you maybe show me a simple example of how to
> implement your suggestion?
>
> I imagine it looking something like this.
>
> class PersonManager(models.Manager):
>      def get_query_set(self):
>           ??? x = 1
>           return super(type(self), self).get_query_set()
>
> class Person(models.Model):
>     name = models.CharField(...)
>
>     objects = models.Manager()
>     compare_to_other = PersonManager()
>
> Now without pulling the value out of the SQL database how do I add a
> value?
>
> The ?? is where I am not sure of how to define a variable per sql
> line.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: If your on Dreamhost, vote for Django support

2009-10-28 Thread Mark Stahler

Good Luck. I have a Dreamhost account for my blog (Tried a dreamhost
vps for a week and a half) and now I have a Linode slice for my Django/
Rails stuff. Quasi-democratic system as in you have the illusion of
some kind of voice.

On Oct 28, 1:17 am, Richard Jeong  wrote:
> Thanks to Daniels help, I'm likely going to get my Dreamhost VPS server
> installed inspite of the problems I had during my attempt at installation.
> I would like to adovcate that for anyone else who is still on Dreamhost and
> on this list, vote for Full Django
> supporton
> the suggestion panel.  It's about time they really supported, and as
> they
> are quasi-democratic about how they improve then we should leverage it.
>
> Also worth voting for is
> mod_pythonand
> mod_wsgias
> they are obviously useful in Django support.
>
> Thanks again to the list and Daniel for making Django work for me.
> Rich
> 
> rje...@spamcop.net
> skype: rjeong
> blog: blog.wonderfullyrich.nethttp://imgs.xkcd.com/comics/beliefs.jpg
>
> Sent from Kampala, Uganda
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: upload problems

2009-10-28 Thread bax...@gretschpages.com



On Oct 27, 8:39 pm, Karen Tracey  wrote:
> On Tue, Oct 27, 2009 at 5:57 PM, bax...@gretschpages.com <
>
>
>
>
>
> mail.bax...@gmail.com> wrote:
>
> > Not sure what's going on, but my images aren't uploading.
>
>
> Have you changed ADMIN_MEDIA_PREFIX 
> (http://docs.djangoproject.com/en/dev/ref/settings/#admin-media-prefix) from
> its default of the same thing?
>
ADMIN_MEDIA is set to "admin_media", because I like the regular media
to be at /media.

>
>
> For now, while it's just in test, I have this in URLS.py:
>
> >    (r'^media/(?P.*)$', 'django.views.static.serve',
> >        {'document_root': '/Users/tbaxter/Sites/django-media/ink/',
> > 'show_indexes': True}),
>
> This won't have any effect if ADMIN_MEDIA_PREFIX is also /media/.  The
> development server special-cases requests for admin media (that is, any path
> that starts with ADMIN_MEDIA_PREFIX) and they don't go through normal url
> resolution.

But it's not

>
> It sounds like your images are uploading, you just can't see them on the
> site after you've uploaded them because your requests for them are being
> routed to the admin media server, which can't find them where it looks (in
> the Django source tree).

No, it's not that I can't see them on the site. They're not in the
filesystem. They're not there, anywhere, as far as I can see.

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



inline model admin with generic relation (not exactly)

2009-10-28 Thread Viktor

hi,

I have three models

Blog:
author

Post:
blog = foreignKey

Attachments:
content_type
object_id

Clearly, an Attachment might be related to a Post.

Now I would like to have an admin page for Blog with Posts inlined,
but allowing an easy editing of the attachments. It's important that
the page should be for Blog, not for Post, thus
generic.GenericTabularInline [1] is not a solution.

My idea would be to simply list the related Posts for a Blog, and
provide an "edit in new window" link, where the Post's admin page is
shown that can already contain the Attachment as a
GenericTabularInline.

Is there an already available solution for this?

Thanks, Viktor

[1]: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#using-generic-relations-as-an-inline
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Versionable Models?

2009-10-28 Thread David De La Harpe Golden

Tim Chase wrote:


> Back to the topic on hand, there are several ways to do 
> model-versioning.  I'm partial to having a FooHistory table that 
> mirrors the parent table's fields but has a timestamp associated 
> with it.  The most recent one is always the Foo object, but 
> before a Foo is saved, the current state is archived off to the 
> FooHistory table with the archiving timestamp. 


Yeah, I for one was put off django-reversion and other similar systems
by their use of serialization/pickling and django generic relations,
which mean they don't generate histories that are particularly easily
queried later at the pure SQL/relational level (which is important for
me, anyway) (django-reversion looks like it'd do what it says on the
tin, don't get me wrong...)

So just maintaining a history table was easiest for me. I confess I've
been violating DRY to make them too - really I should consider making a
Model subclass that inspects a main model and derives a reasonable
history model definition for it, or something.

Related, there's a book on approaches to dealing with time varying data
in relational (or at least SQL) databases here:
http://www.cs.arizona.edu/people/rts/tdbbook.pdf



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



navigation

2009-10-28 Thread elminio

Hi,

I use generic view on updating objects. How to create button with
cancel that will always redirect me to the previous page ?

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



Re: Filtering on model methods

2009-10-28 Thread pbzRPA

Thanks for you reply Mikhail,

I do use model managers but more often to get a certain defined
queryset back. Could you maybe show me a simple example of how to
implement your suggestion?

I imagine it looking something like this.

class PersonManager(models.Manager):
 def get_query_set(self):
  ??? x = 1
  return super(type(self), self).get_query_set()

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

objects = models.Manager()
compare_to_other = PersonManager()

Now without pulling the value out of the SQL database how do I add a
value?

The ?? is where I am not sure of how to define a variable per sql
line.

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



Re: manage.py syncdb over web?

2009-10-28 Thread Daniel Roseman

On Oct 28, 8:45 am, zayatzz  wrote:
> Hi.
>
> I have a problem with django project that is beeing hosting in a
> server where i have no shell access... so how can i do syncdb there.
> doing mysql dumps in development db and updating hosting mysql is
> kinda slow..
>
> Is it possible do this run syncdb script over web?
>
> Alan

You could have a view that does django.core.management.call_command
('syncdb'). Make sure you've got proper authentication on it though.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



manage.py syncdb over web?

2009-10-28 Thread zayatzz

Hi.

I have a problem with django project that is beeing hosting in a
server where i have no shell access... so how can i do syncdb there.
doing mysql dumps in development db and updating hosting mysql is
kinda slow..

Is it possible do this run syncdb script over web?

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



Re: models.py

2009-10-28 Thread David

can you explain a bit better? where do you want to insert?

On 28 Okt., 00:46, Vman  wrote:
> how do i insert this:
>
> from django.contrib.auth.models import User
> class Bookmark(models.Model):
> title = models.CharField(maxlength=200)
> user = models.ForeignKey(User)
> link = models.ForeignKey(Link)
>
> into this?
>
> from django.db import models
> class Link(models.Model):
> url = models.URLField(unique=True)
>
> I am getting this error:
>
> NameError: name 'models' is not defined
>
> Thanks...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANNOUNCE:- ibm_db_django-0.1.4 IBM Dataservers backend support for Django 1.1 Released

2009-10-28 Thread Tarun Pasrija

Mistakably I have missed the What's New section so here is goes:-

What's New??
-

This version has added support for the following-

- ZOS support included
- ibm_db google code issue no - 25 Implementation change for
sequence_reset_sql
   in operations.py.

Thanks and Regards
Tarun Pasrija
Open Source Application Development
IBM India Software Labs

On Oct 22, 9:50 am, Tarun Pasrija  wrote:
> IBM_DB_DJANGO-0.1.4
> ---IBM_DB_DJANGOadaptor enables access to IBM 
> databases from Django
> applicationshttp://www.djangoproject.com/. The adaptor is developed
> and maintained by IBM.
>
> What's New?
> 
> We are pleased to announce the release ofibm_db_django-0.1.4 to
> support Django 1.1 and 1.0.x. We have kept the backward compatibility
> so that users who have not migrated from 1.0.x to 1.1 can still use
> the same adaptor.
>
> Note:- Updation from fromibm_db_django-0.1.0 toibm_db_django-0.1.4
> ---
> --
> The name of the adaptor (in Django terminology, the DATABASE_ENGINE)
> has been changed to 'ibm_db_django' from this version onwards (in
> earlier versions it was 'db2'). For your existing apps please
> remember
> to change this once you upgrade toibm_db_django-0.1.4
> The 'DATABASE_ENGINE' field in settings.py should as below when 
> usingibm_db_django-0.1.2
>    DATABASE_ENGINE    = 'ibm_db_django'
> (In version 0.1.0, it is "DATABASE_ENGINE    = 'db2' " )
>
> SVN access to the source
> ---http://code.google.com/p/ibm-db/source/browse/trunk/IBM_DB/ibm_db_dja...
>
> Installation
> 
> $ easy_installibm_db_django
>
> Feedback/Suggestions/Issues
> 
> You can provide us feedback/suggestions, or report a bug/defect, or
> ask for help by using any of the following channels:
> 1. Mailing us at open...@us.ibm.com
> 2. Opening a new issue athttp://code.google.com/p/ibm-db/issues/list.
> 3. By opening new discussion athttp://groups.google.co.in/group/ibm_db.
> For prerequisites, installation steps and help details, visit 
> -http://code.google.com/p/ibm-db/wiki/ibm_db_django_README
> Try this out and let us know you valuable feedback. Have fun.
>
> Cheers,
> Tarun Pasrija
> Open Source Application Development
> IBM India Software Labs
>
> DB2 Cobra is now available. Download Express-C for free, go to:
> ---
> -https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=swg-...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Versionable Models?

2009-10-28 Thread David

Is there a big advantage of MartyAlchin Historization over the django-
reversion project?
Has anybody compared the two approaches in detail.
>From what i could understood on the django-revsion site it seems to me
more complete, as it inclueds i.e. file-reversion.
Plus it is easier to use as it is maintained and delivered as an app.
Any expert's opinions?

david

On 28 Okt., 01:15, Mike Dewhirst  wrote:
> Todd Blanchard wrote:
> > Total django noob here.  Rails/PHP/WebObjects refugee here.
>
> > I'm starting a project where some models need to be fully versioned.
>
> > IOW, record update is forbidden - every save to a changed model should  
> > result in a new record with a new version number or timestamp along  
> > with identity pulled from the current authenticated user's session.  
> > Queries/relationships should be specified as "fetch newest" or "fetch  
> > history".  IOW sometimes I want to traverse a relationship and just  
> > get the "current" record.  Sometimes I want to get the history of that  
> > relationship.
>
> > Anybody done this?  Got any tips?
>
> Marty Allchin has documented this very precisely and eloquently in
> chapter 11 of his Pro Django published recently by Apress.
>
> Highly recommended :)
>
> Cheers
>
> Mike
>
>
>
> > Thanks,
> > -Todd Blanchard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---