Looking for Python expert in Beijing - China

2007-12-13 Thread Ludovic - Kalibrio

Hi Guys,

Anybody knows excellent Python expert that would be interested to work
in Beijing - China on a cool Web2.0 venture? We are hiring !

Those interested can email at [EMAIL PROTECTED] for more details

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



Stupid template question

2007-12-13 Thread Steve Freitas

I have a dictionary, and I'd like to iterate over the keys, using the
keys to look up the result, like:

{% for key in myDict %}
The key is {{key}} and the value is {{myDict.key}}.
{% endfor %}

Only, it doesn't work. It seems like . lookups
require the argument to be a literal, not a variable. I'm sure there's
some easy way to do this, but I'm missing it. Any help would be
appreciated.

Thanks!

Steve


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



Re: more info when serializing

2007-12-13 Thread [EMAIL PROTECTED]

On 18 Nov, 11:25, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Sat, 2007-11-17 at 16:21 -0500, Bryan L. Fordham wrote:
> > So, say I have a model something like this:
>
> > class Bar(models.Model):
> > user = models.ForeignKey(User)
> > name = models.CharField(maxlength=50)
> > description = models.TextField()
>
> > where user is tied to a django.contrib.auth.models.User entity. When I
> > serialize this to json, I get:
> > [{"pk": "1", "model": "foo.bar", "fields": {"description": "", "user":
> > 1, "name": "Phone"}}]
>
> > Which is fine, but I need both the username and user id on the front
> > end. Is there a simple way to get this info all in one shot that I'm
> > just missing?
>
> > Ideally, it would return something like: ..."user":
> > {"username":"bfordham", "pk":1}...

Hi,

I've come up with a solution to this that is very similar to the way
Rails does it [1]. I'm also CC-ing to django-developers as it covers
ticket #4656 and feel it is wandering more into the developer realm
where a design decision is needed.

I've written a new python & json serializer for Django. An example
invocation and output for the Bar model above would look like:

>>> from django.core import serializers
>>> serializers.serialize('json',  Bar.objects.all(), 
>>> relations={'user':{'fields':('username',)}})
 [{
"pk": "1",
"model": "foo.bar",
"fields": {
"description": "",
"user": {"pk":"1", "model":"auth.user", "fields":
{"username":"bfordham"}},
"name": "Phone"
}
}]

The new serializer takes the following keyword arguments:

fields - list of fields to be serialized only.
excludes - list of fields to be excluded.
relations - list of related fields to be serialized or a
dictionary with the keys being the fields to serialize and the values
being a dictionary of arguments to pass to sub-serializer. ie. fields,
excludes, relations, methods.
methods - list of methods to include. Methods cannot take
arguments. Not yet implemented.
attributes - list of other class attributes to serialize that
aren't model fields. Not yet implemented.

At the moment with no arguments it only serializes regular model
fields that aren't ForeignKeys or ManyToManys. You have to explicitly
include related fields using the 'relations' argument. I could make
this backwards-compatible with the way the serializers work now if
needed.

>
> The serializer doesn't support this. It would take a bit of design work
> to figure out how to specify such an extension easily. You might like
> put some thought into that, though.
>
> Things that immediately spring to mind as requiring addressing:
> - what should the format look like for many-to-many objects (and
> making sure we can deserialise as well)

Here is how I do it with User model as an example:

>>> serializers.serialize('python',  User.objects.filter(username='jdoe'), 
>>> relations=('groups',))
[{
  'fields': {'date_joined': datetime.datetime(2006, 8, 14, 10, 34,
56),
 'email': u'[EMAIL PROTECTED]',
 'first_name': u'',
 'groups': [{'fields': {'name': u'group1'},
 'model': u'auth.group',
 'pk': 2},
{'fields': {'name': u'group2'},
 'model': u'auth.group',
 'pk': 1}],
 'is_active': True,
 'is_staff': True,
 'is_superuser': False,
 'last_login': datetime.datetime(2007, 9, 19, 12, 29, 2,
649167),
 'last_name': u'',
 'password': u'sha1$x',
 'username': u'jdoe'},
  'model': u'auth.user',
  'pk': 2}]

> - once you add one level of indirection, it will take
> approximately 8 seconds for somebody to want to go two levels
> and more. So it should be extensible beyond just "the immediate
> foreign key relative".

My serialiser allows for as many levels of indirection as you want as
well as specifying which fields you want included, excluded etc at
each level.

> - reverse relations

Not yet implemented.

> - deserialisation, if possible.

Not yet implemented.

> - is it easy to say "all the normal fields plus these extra
> ones".

The attributes and methods arguments are for this, though I haven't
implemented that part either and I'm thinking of merging the two
arguments into one but haven't thought of a good name. Perhaps
"extras"?

> - could passing a ValuesQuerySet to the serializer, together
> with #5768 be a solution in some fashion (as a way of specifying
> these extra fields)?
>
> I don't know how easy this would all be or how genuinely useful. Could
> be worth a bit of thinking, though.
>
> Malcolm


I wrote this because I have a need for it. I'd also like to use it
with the django_rest_interface project but that would need some
largish changes for it to work and I'm not certai

Re: newforms admin branch model update

2007-12-13 Thread djnz

Thanks for your reply. So It could be an issue of my configuration or
code. But What?
My project runs perfect on trunk. I am trying to migrate to the
newforms-admin branch, so i made the required changes in the code as
described in the documentation. I know is very strange, but yes, I
modify a record with admin and click in save and continue editing.The
changes does not display but If I look at the record with pgadmin III
or similar the changes were made.

I have to run the server on windows and linux with similar results.
.

U. I have found the problem. I have removed the
'django.middleware.cache.CacheMiddleware' and now it works. Although i
dont undestand why becouse i didn't have  any configuration of the
CACHE_MIDDLEWARE  in settings and it worked on trunk. :?

Lewis

On 14 dic, 01:51, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Dec 13, 2007 5:46 PM, djnz <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have just setup part of my project for the newforms-admin branch.
> > All seemed ok. But when i modifiy an object with the admin interface,
> > the changes do not show neither in admin nor in the public area of the
> > web. I have to restart the internal django webserver to see the
> > changes.
>
> > Any ideas?
>
> Not really.  I've been using newforms-admin for many weeks with no such
> problems.  What do you mean you've set up part of your project for
> newforms-admin?  You are either running trunk or newforms-admin, you can't
> be partly one and partly the other.  Can you be a little more specific on
> the changes you are making and where they are not being reflected?  The fact
> that restarting the development server "fixes" things makes it sound like
> you are changing code, but the rest of your description sounds like you are
> simply changing model data, and I'm baffled as to how that could not be
> reflected immediately in the admin interface where you make the change.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Backward Relationship In Template

2007-12-13 Thread pk

You mean the first one of the set?
{{ objectb.objecta_set.all.0 }}

You can also slice it, etc. But of course, you really need to define
the ordering to get to the "First" one whatever "first" means to you.

P.K.

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



Re: Error: list index out of range

2007-12-13 Thread James Bennett

On Dec 13, 2007 10:46 PM, Julien <[EMAIL PROTECTED]> wrote:
> But it still doesn't work. To make it work I have to do the whole:
> from myproject.myapp.models import Bla
>
> Not very reusable approach...

While it works well for the tutorial, where keeping all the code in
one place reduces the number of things which need to be explained,
deploying a real-world project with all of its applications and
associated code inside a single project directory is usually a bad
idea. Place the application modules directly on your Python path so
that they only need to "know" about their own names -- e.g., you can
do imports "from appname.models" instead of "from
projectname.appname.models".

That'll be pretty much necessary for django-registration, because it
assumes it's been placed directly on the Python path, and so imports
like "from registration.models import RegistrationProfile" will work.


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

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



Re: import problems

2007-12-13 Thread Eric Abrahamsen

On Dec 14, 1:21 pm, jim <[EMAIL PROTECTED]> wrote:
> what does ur urls.py look like? is everything imported correctly
> there...
>
> Jim

I think so, I don't use generic views so there's hardly anything in
there. Here's the top of the file:

from django.conf.urls.defaults import *

urlpatterns = patterns('myproject.app1.views',

url(r'^$', 'index', name="homepage"),

That ought to be enough to make it go right there...

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



Re: import problems

2007-12-13 Thread jim

what does ur urls.py look like? is everything imported correctly
there...

Jim


On Dec 14, 12:09 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> > then open an interpreter and try importing each of the modules
> > individually.
>
> > the resulting error messages should probably lead u t the solution...
>
> Nope, all that works fine. Going step by step:
>
> >>> from myproject import app1
> >>> from myproject import app2
> >>> from app1 import models as models1
> >>> from app1 import views as views1
> >>> from app2 import models as models2
> >>> from app2 import views as views2
> >>> views1.index()
>
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: index() takes exactly 1 argument (0 given)
>
> Just what you'd expect.
>
> Reaching for straws: the static media is still not functional, as I
> was leaving that for later, but I can't imagine that's relevant.
> Here's the mod_python bit of apache httpd.conf:
>
> DocumentRoot /home/me/webapps/django
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE myproject.settings
> PythonPath "['/home/me/webapps/django'] + sys.path"
> PythonDebug On
> Options FollowSymLinks
> Order allow,deny
> Allow from all
>
> Also, this directory tree is a svn checkout from a repository, don't
> know if that might have any effect.
>
> I realized I'd had the ServerName set wrong in the above apache conf,
> when I fixed it I got the same error, but a different traceback:
>
> (Thanks for your persistence with this, I hope the problem is
> interesting enough to warrant it)
>
> ==
>
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1537, in
> HandlerDispatch
>   default=default_handler, arg=req, silent=hlist.silent)
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1229, in
> _process_target
>   result = _execute_target(config, req, object, arg)
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1128, in
> _execute_target
>   result = object(arg)
> File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
> 188, in handler
>   return ModPythonHandler()(req)
> File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
> 161, in __call__
>   response = self.get_response(request)
> File "/home/me/lib/python2.5/django/core/handlers/base.py", line 131,
> in get_response
>   return callback(request, **param_dict)
> File "/home/me/lib/python2.5/django/views/defaults.py", line 90, in
> server_error
>   return http.HttpResponseServerError(t.render(Context({})))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 83,
> in render
>   return compiled_parent.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/defaulttags.py", line 29,
> in render
>   output = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 24,
> in render
>   result = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 97,
> in render
>   return self.template.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/defaulttags.py", line
> 407, in render
>   output = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/pyth

Re: import problems

2007-12-13 Thread jim

for the static media part..u probably need this added to ur config...


   SetHandler none



Jim

On Dec 14, 12:09 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> > then open an interpreter and try importing each of the modules
> > individually.
>
> > the resulting error messages should probably lead u t the solution...
>
> Nope, all that works fine. Going step by step:
>
> >>> from myproject import app1
> >>> from myproject import app2
> >>> from app1 import models as models1
> >>> from app1 import views as views1
> >>> from app2 import models as models2
> >>> from app2 import views as views2
> >>> views1.index()
>
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: index() takes exactly 1 argument (0 given)
>
> Just what you'd expect.
>
> Reaching for straws: the static media is still not functional, as I
> was leaving that for later, but I can't imagine that's relevant.
> Here's the mod_python bit of apache httpd.conf:
>
> DocumentRoot /home/me/webapps/django
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE myproject.settings
> PythonPath "['/home/me/webapps/django'] + sys.path"
> PythonDebug On
> Options FollowSymLinks
> Order allow,deny
> Allow from all
>
> Also, this directory tree is a svn checkout from a repository, don't
> know if that might have any effect.
>
> I realized I'd had the ServerName set wrong in the above apache conf,
> when I fixed it I got the same error, but a different traceback:
>
> (Thanks for your persistence with this, I hope the problem is
> interesting enough to warrant it)
>
> ==
>
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1537, in
> HandlerDispatch
>   default=default_handler, arg=req, silent=hlist.silent)
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1229, in
> _process_target
>   result = _execute_target(config, req, object, arg)
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1128, in
> _execute_target
>   result = object(arg)
> File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
> 188, in handler
>   return ModPythonHandler()(req)
> File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
> 161, in __call__
>   response = self.get_response(request)
> File "/home/me/lib/python2.5/django/core/handlers/base.py", line 131,
> in get_response
>   return callback(request, **param_dict)
> File "/home/me/lib/python2.5/django/views/defaults.py", line 90, in
> server_error
>   return http.HttpResponseServerError(t.render(Context({})))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 83,
> in render
>   return compiled_parent.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/defaulttags.py", line 29,
> in render
>   output = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 24,
> in render
>   result = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 97,
> in render
>   return self.template.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/defaulttags.py", line
> 407, in render
>   output = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File 

Re: import problems

2007-12-13 Thread Eric Abrahamsen

Here's the top section of the traceback, this could be relevant:

MOD_PYTHON ERROR

ProcessId:  4468
Interpreter:'pr.ericabrahamsen.net'

ServerName: 'pr.ericabrahamsen.net'
DocumentRoot:   '/home/me/webapps/django'

URI:'/'
Location:   '/'
Directory:  None
Filename:   '/home/me/webapps/django/'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

On Dec 14, 1:09 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> > then open an interpreter and try importing each of the modules
> > individually.
>
> > the resulting error messages should probably lead u t the solution...
>
> Nope, all that works fine. Going step by step:
>
> >>> from myproject import app1
> >>> from myproject import app2
> >>> from app1 import models as models1
> >>> from app1 import views as views1
> >>> from app2 import models as models2
> >>> from app2 import views as views2
> >>> views1.index()
>
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: index() takes exactly 1 argument (0 given)
>
> Just what you'd expect.
>
> Reaching for straws: the static media is still not functional, as I
> was leaving that for later, but I can't imagine that's relevant.
> Here's the mod_python bit of apache httpd.conf:
>
> DocumentRoot /home/me/webapps/django
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE myproject.settings
> PythonPath "['/home/me/webapps/django'] + sys.path"
> PythonDebug On
> Options FollowSymLinks
> Order allow,deny
> Allow from all
>
> Also, this directory tree is a svn checkout from a repository, don't
> know if that might have any effect.
>
> I realized I'd had the ServerName set wrong in the above apache conf,
> when I fixed it I got the same error, but a different traceback:
>
> (Thanks for your persistence with this, I hope the problem is
> interesting enough to warrant it)
>
> ==
>
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1537, in
> HandlerDispatch
>   default=default_handler, arg=req, silent=hlist.silent)
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1229, in
> _process_target
>   result = _execute_target(config, req, object, arg)
> File "/home/me/lib/python2.5/mod_python/importer.py", line 1128, in
> _execute_target
>   result = object(arg)
> File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
> 188, in handler
>   return ModPythonHandler()(req)
> File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
> 161, in __call__
>   response = self.get_response(request)
> File "/home/me/lib/python2.5/django/core/handlers/base.py", line 131,
> in get_response
>   return callback(request, **param_dict)
> File "/home/me/lib/python2.5/django/views/defaults.py", line 90, in
> server_error
>   return http.HttpResponseServerError(t.render(Context({})))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 83,
> in render
>   return compiled_parent.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/defaulttags.py", line 29,
> in render
>   output = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 24,
> in render
>   result = self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
> in render_node
>   return node.render(context)
> File "/home/me/lib/python2.5/django/template/loader_tags.py", line 97,
> in render
>   return self.template.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
> in render
>   return self.nodelist.render(context)
> File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
> in render
>   bits.append(self.render_node(node, context))
> File "/home/me/lib/python2.5/django/template/__init

Re: import problems

2007-12-13 Thread Eric Abrahamsen

> then open an interpreter and try importing each of the modules
> individually.
>
> the resulting error messages should probably lead u t the solution...

Nope, all that works fine. Going step by step:

>>> from myproject import app1
>>> from myproject import app2
>>> from app1 import models as models1
>>> from app1 import views as views1
>>> from app2 import models as models2
>>> from app2 import views as views2
>>> views1.index()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: index() takes exactly 1 argument (0 given)

Just what you'd expect.

Reaching for straws: the static media is still not functional, as I
was leaving that for later, but I can't imagine that's relevant.
Here's the mod_python bit of apache httpd.conf:

DocumentRoot /home/me/webapps/django

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonPath "['/home/me/webapps/django'] + sys.path"
PythonDebug On
Options FollowSymLinks
Order allow,deny
Allow from all

Also, this directory tree is a svn checkout from a repository, don't
know if that might have any effect.

I realized I'd had the ServerName set wrong in the above apache conf,
when I fixed it I got the same error, but a different traceback:

(Thanks for your persistence with this, I hope the problem is
interesting enough to warrant it)

==

File "/home/me/lib/python2.5/mod_python/importer.py", line 1537, in
HandlerDispatch
  default=default_handler, arg=req, silent=hlist.silent)
File "/home/me/lib/python2.5/mod_python/importer.py", line 1229, in
_process_target
  result = _execute_target(config, req, object, arg)
File "/home/me/lib/python2.5/mod_python/importer.py", line 1128, in
_execute_target
  result = object(arg)
File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
188, in handler
  return ModPythonHandler()(req)
File "/home/me/lib/python2.5/django/core/handlers/modpython.py", line
161, in __call__
  response = self.get_response(request)
File "/home/me/lib/python2.5/django/core/handlers/base.py", line 131,
in get_response
  return callback(request, **param_dict)
File "/home/me/lib/python2.5/django/views/defaults.py", line 90, in
server_error
  return http.HttpResponseServerError(t.render(Context({})))
File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
in render
  return self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
in render_node
  return node.render(context)
File "/home/me/lib/python2.5/django/template/loader_tags.py", line 83,
in render
  return compiled_parent.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
in render
  return self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
in render_node
  return node.render(context)
File "/home/me/lib/python2.5/django/template/defaulttags.py", line 29,
in render
  output = self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
in render_node
  return node.render(context)
File "/home/me/lib/python2.5/django/template/loader_tags.py", line 24,
in render
  result = self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
in render_node
  return node.render(context)
File "/home/me/lib/python2.5/django/template/loader_tags.py", line 97,
in render
  return self.template.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 176,
in render
  return self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
in render_node
  return node.render(context)
File "/home/me/lib/python2.5/django/template/defaulttags.py", line
407, in render
  output = self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/__init__.py", line 817,
in render_node
  return node.render(context)
File "/home/me/lib/python2.5/django/template/defaulttags.py", line
407, in render
  output = self.nodelist.render(context)
File "/home/me/lib/python2.5/django/template/__init__.py", line 804,
in render
  bits.append(self.render_node(node, context))
File "/home/me/lib/python2.5/django/template/

Re: import problems

2007-12-13 Thread jim

Alternatively u can do this:

python manage.py shell

this will set up a shell with the necessay variables defined...

Jim


On Dec 13, 11:38 pm, jim <[EMAIL PROTECTED]> wrote:
> set ur environment variable DJANGO_SETTINGS_MODULE to 'settings' eg.
>
> export DJANGO_SETTINGS_MODULE=.settings
>
> then open an interpreter and try importing each of the modules
> individually.
>
> the resulting error messages should probably lead u t the solution...
>
> Jim
>
> On Dec 13, 11:03 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>
> > Yup. The whole project directory tree from myproject on down is
> > exactly what it has been on my local system (with the exception of
> > settings.py), which has always worked fine using the django
> > development server. That's why this is so mysterious to me.
>
> > On Dec 14, 11:58 am, jim <[EMAIL PROTECTED]> wrote:
>
> > > do u have a __init__.py in the directory containing app1 and app2?
>
> > > Jim
>
> > > On Dec 13, 10:33 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>
> > > > I just put my local django development setup up onto my web host, and
> > > > am trying to make all the necessary adjustments. So far I haven't been
> > > > able to get the views to work. I've got:
>
> > > > myproject.app1
> > > > myproject.app2
>
> > > > The basic index view lives in myproject.app1.views. When I try to
> > > > visit the index, I get ViewDoesNotExist: Could not import
> > > > myproject.app1.views. Error was: No module named app1.models.
>
> > > > The following two lines are at the top of the myproject.app1.views
> > > > file
>
> > > > from app1.models import (some models)
> > > > from app2.models import (some other models)
>
> > > > If I change this to:
>
> > > > from myproject.app1.models import...
> > > > from myproject.app2.models import...
>
> > > > Then the error changes from 'No module named app1.models' to 'No
> > > > module named app2.models.'
>
> > > > In my development environment I never had to prepend the project name
> > > > (though obviously that's not solving the problem here, either). When
> > > > migrating to the web host I changed nothing but the settings file, and
> > > > the settings get imported correctly. I'm using 0.97-pre-SVN-6917,
> > > > python 2.5.1, and here's my traceback:
>
> > > > 
> > > > Traceback:
> > > > File "/home/me/lib/python2.5/django/core/handlers/base.py" in
> > > > get_response
> > > >   73. callback, callback_args, callback_kwargs =
> > > > resolver.resolve(request.path)
> > > > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
> > > >   233. sub_match = pattern.resolve(new_path)
> > > > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
> > > >   172. return self.callback, args, kwargs
> > > > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in
> > > > _get_callback
> > > >   181. raise ViewDoesNotExist, "Could not import %s. Error
> > > > was: %s" % (mod_name, str(e))
>
> > > > Exception Type: ViewDoesNotExist at /
> > > > Exception Value: Could not import myproject.app1.views. Error was: No
> > > > module named app2.models
> > > > 
>
> > > > Hoping someone can shed some light
>
> > > > E
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error: list index out of range

2007-12-13 Thread Julien

Hi,

I ran my code on another server and the error message was more
explicit.
The problem was in fact that in a templatetags file I was referring to
the parent's models package, and it didn't work...

Is it possible to import a model from a parent package?

Apparently in Python 2.5 you can do:
from ..models import Bla

But it still doesn't work. To make it work I have to do the whole:
from myproject.myapp.models import Bla

Not very reusable approach...

Any idea?

On Dec 14, 12:35 pm, Julien <[EMAIL PROTECTED]> wrote:
> This is in the application fromhttp://code.google.com/p/django-registration/
>
> The code is:
>
> class RegistrationProfile(models.Model):
> """
> A simple profile which stores an activation key for use during
> user account registration.
>
> Generally, you will not want to interact directly with instances
> of this model; the provided manager includes methods
> for creating and activating new accounts, as well as for cleaning
> out accounts which have never been activated.
>
> While it is possible to use this model as the value of the
> ``AUTH_PROFILE_MODULE`` setting, it's not recommended that you do
> so. This model's sole purpose is to store data temporarily during
> account registration and activation, and a mechanism for
> automatically creating an instance of a site-specific profile
> model is provided via the ``create_inactive_user`` on
> ``RegistrationManager``.
>
> """
> user = models.ForeignKey(User, unique=True,
> verbose_name=_('user'))
> activation_key = models.CharField(_('activation key'),
> max_length=40)
>
> objects = RegistrationManager()
>
> class Meta:
> verbose_name = _('registration profile')
> verbose_name_plural = _('registration profiles')
>
> class Admin:
> list_display = ('__str__', 'activation_key_expired')
> search_fields = ('user__username', 'user__first_name')
>
> def __unicode__(self):
> return u"Registration information for %s" % self.user
>
> def activation_key_expired(self):
> """
> Determines whether this ``RegistrationProfile``'s activation
> key has expired.
>
> Returns ``True`` if the key has expired, ``False`` otherwise.
>
> Key expiration is determined by the setting
> ``ACCOUNT_ACTIVATION_DAYS``, which should be the number of
> days a key should remain valid after an account is registered.
>
> """
> expiration_date =
> datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)
> return self.user.date_joined + expiration_date <=
> datetime.datetime.now()
> activation_key_expired.boolean = True
>
> On Dec 14, 12:27 pm, l5x <[EMAIL PROTECTED]> wrote:
>
> > Can you give us "class RegistrationProfile" from C:\Python25\Lib\site-
> > packages\registration\models.py ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: import problems

2007-12-13 Thread jim

set ur environment variable DJANGO_SETTINGS_MODULE to 'settings' eg.

export DJANGO_SETTINGS_MODULE=.settings

then open an interpreter and try importing each of the modules
individually.

the resulting error messages should probably lead u t the solution...

Jim

On Dec 13, 11:03 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> Yup. The whole project directory tree from myproject on down is
> exactly what it has been on my local system (with the exception of
> settings.py), which has always worked fine using the django
> development server. That's why this is so mysterious to me.
>
> On Dec 14, 11:58 am, jim <[EMAIL PROTECTED]> wrote:
>
> > do u have a __init__.py in the directory containing app1 and app2?
>
> > Jim
>
> > On Dec 13, 10:33 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>
> > > I just put my local django development setup up onto my web host, and
> > > am trying to make all the necessary adjustments. So far I haven't been
> > > able to get the views to work. I've got:
>
> > > myproject.app1
> > > myproject.app2
>
> > > The basic index view lives in myproject.app1.views. When I try to
> > > visit the index, I get ViewDoesNotExist: Could not import
> > > myproject.app1.views. Error was: No module named app1.models.
>
> > > The following two lines are at the top of the myproject.app1.views
> > > file
>
> > > from app1.models import (some models)
> > > from app2.models import (some other models)
>
> > > If I change this to:
>
> > > from myproject.app1.models import...
> > > from myproject.app2.models import...
>
> > > Then the error changes from 'No module named app1.models' to 'No
> > > module named app2.models.'
>
> > > In my development environment I never had to prepend the project name
> > > (though obviously that's not solving the problem here, either). When
> > > migrating to the web host I changed nothing but the settings file, and
> > > the settings get imported correctly. I'm using 0.97-pre-SVN-6917,
> > > python 2.5.1, and here's my traceback:
>
> > > 
> > > Traceback:
> > > File "/home/me/lib/python2.5/django/core/handlers/base.py" in
> > > get_response
> > >   73. callback, callback_args, callback_kwargs =
> > > resolver.resolve(request.path)
> > > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
> > >   233. sub_match = pattern.resolve(new_path)
> > > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
> > >   172. return self.callback, args, kwargs
> > > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in
> > > _get_callback
> > >   181. raise ViewDoesNotExist, "Could not import %s. Error
> > > was: %s" % (mod_name, str(e))
>
> > > Exception Type: ViewDoesNotExist at /
> > > Exception Value: Could not import myproject.app1.views. Error was: No
> > > module named app2.models
> > > 
>
> > > Hoping someone can shed some light
>
> > > E
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Development Server question - not "refreshing data"

2007-12-13 Thread James Bennett

On Dec 13, 2007 10:04 PM, subgiambi <[EMAIL PROTECTED]> wrote:
> and I can access my site at http://127.0.0.1:8000/ fine.  However when
> I, for example, use the website interface to change a user's profile
> by altering the user's "City" - even if I refresh the new City is not
> displayed on the user's profile.  I must stop and then start the
> server again for the changes to be realized on the profile.

I'm going to bet money that you're running into the sort of error
described in the section "Be careful with module globals" here:

http://www.b-list.org/weblog/2007/nov/06/urlconf/


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

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



Django Development Server question - not "refreshing data"

2007-12-13 Thread subgiambi

I start my development server with:
python manage.py runserver

and I can access my site at http://127.0.0.1:8000/ fine.  However when
I, for example, use the website interface to change a user's profile
by altering the user's "City" - even if I refresh the new City is not
displayed on the user's profile.  I must stop and then start the
server again for the changes to be realized on the profile.  Is this
normal?  Is there some kind of a "force-check-data-from-database"
switch for runserver?  This makes it difficult to test things out, as
I have to stop and start the server each time I change something.

Any help would be appreciated!  Hopefully I'm overlooking something
silly.
-Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: import problems

2007-12-13 Thread Eric Abrahamsen

Yup. The whole project directory tree from myproject on down is
exactly what it has been on my local system (with the exception of
settings.py), which has always worked fine using the django
development server. That's why this is so mysterious to me.


On Dec 14, 11:58 am, jim <[EMAIL PROTECTED]> wrote:
> do u have a __init__.py in the directory containing app1 and app2?
>
> Jim
>
> On Dec 13, 10:33 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>
> > I just put my local django development setup up onto my web host, and
> > am trying to make all the necessary adjustments. So far I haven't been
> > able to get the views to work. I've got:
>
> > myproject.app1
> > myproject.app2
>
> > The basic index view lives in myproject.app1.views. When I try to
> > visit the index, I get ViewDoesNotExist: Could not import
> > myproject.app1.views. Error was: No module named app1.models.
>
> > The following two lines are at the top of the myproject.app1.views
> > file
>
> > from app1.models import (some models)
> > from app2.models import (some other models)
>
> > If I change this to:
>
> > from myproject.app1.models import...
> > from myproject.app2.models import...
>
> > Then the error changes from 'No module named app1.models' to 'No
> > module named app2.models.'
>
> > In my development environment I never had to prepend the project name
> > (though obviously that's not solving the problem here, either). When
> > migrating to the web host I changed nothing but the settings file, and
> > the settings get imported correctly. I'm using 0.97-pre-SVN-6917,
> > python 2.5.1, and here's my traceback:
>
> > 
> > Traceback:
> > File "/home/me/lib/python2.5/django/core/handlers/base.py" in
> > get_response
> >   73. callback, callback_args, callback_kwargs =
> > resolver.resolve(request.path)
> > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
> >   233. sub_match = pattern.resolve(new_path)
> > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
> >   172. return self.callback, args, kwargs
> > File "/home/me/lib/python2.5/django/core/urlresolvers.py" in
> > _get_callback
> >   181. raise ViewDoesNotExist, "Could not import %s. Error
> > was: %s" % (mod_name, str(e))
>
> > Exception Type: ViewDoesNotExist at /
> > Exception Value: Could not import myproject.app1.views. Error was: No
> > module named app2.models
> > 
>
> > Hoping someone can shed some light
>
> > E
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: import problems

2007-12-13 Thread jim

do u have a __init__.py in the directory containing app1 and app2?

Jim


On Dec 13, 10:33 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> I just put my local django development setup up onto my web host, and
> am trying to make all the necessary adjustments. So far I haven't been
> able to get the views to work. I've got:
>
> myproject.app1
> myproject.app2
>
> The basic index view lives in myproject.app1.views. When I try to
> visit the index, I get ViewDoesNotExist: Could not import
> myproject.app1.views. Error was: No module named app1.models.
>
> The following two lines are at the top of the myproject.app1.views
> file
>
> from app1.models import (some models)
> from app2.models import (some other models)
>
> If I change this to:
>
> from myproject.app1.models import...
> from myproject.app2.models import...
>
> Then the error changes from 'No module named app1.models' to 'No
> module named app2.models.'
>
> In my development environment I never had to prepend the project name
> (though obviously that's not solving the problem here, either). When
> migrating to the web host I changed nothing but the settings file, and
> the settings get imported correctly. I'm using 0.97-pre-SVN-6917,
> python 2.5.1, and here's my traceback:
>
> 
> Traceback:
> File "/home/me/lib/python2.5/django/core/handlers/base.py" in
> get_response
>   73. callback, callback_args, callback_kwargs =
> resolver.resolve(request.path)
> File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
>   233. sub_match = pattern.resolve(new_path)
> File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
>   172. return self.callback, args, kwargs
> File "/home/me/lib/python2.5/django/core/urlresolvers.py" in
> _get_callback
>   181. raise ViewDoesNotExist, "Could not import %s. Error
> was: %s" % (mod_name, str(e))
>
> Exception Type: ViewDoesNotExist at /
> Exception Value: Could not import myproject.app1.views. Error was: No
> module named app2.models
> 
>
> Hoping someone can shed some light
>
> E
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



import problems

2007-12-13 Thread Eric Abrahamsen

I just put my local django development setup up onto my web host, and
am trying to make all the necessary adjustments. So far I haven't been
able to get the views to work. I've got:

myproject.app1
myproject.app2

The basic index view lives in myproject.app1.views. When I try to
visit the index, I get ViewDoesNotExist: Could not import
myproject.app1.views. Error was: No module named app1.models.

The following two lines are at the top of the myproject.app1.views
file

from app1.models import (some models)
from app2.models import (some other models)

If I change this to:

from myproject.app1.models import...
from myproject.app2.models import...

Then the error changes from 'No module named app1.models' to 'No
module named app2.models.'

In my development environment I never had to prepend the project name
(though obviously that's not solving the problem here, either). When
migrating to the web host I changed nothing but the settings file, and
the settings get imported correctly. I'm using 0.97-pre-SVN-6917,
python 2.5.1, and here's my traceback:


Traceback:
File "/home/me/lib/python2.5/django/core/handlers/base.py" in
get_response
  73. callback, callback_args, callback_kwargs =
resolver.resolve(request.path)
File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
  233. sub_match = pattern.resolve(new_path)
File "/home/me/lib/python2.5/django/core/urlresolvers.py" in resolve
  172. return self.callback, args, kwargs
File "/home/me/lib/python2.5/django/core/urlresolvers.py" in
_get_callback
  181. raise ViewDoesNotExist, "Could not import %s. Error
was: %s" % (mod_name, str(e))

Exception Type: ViewDoesNotExist at /
Exception Value: Could not import myproject.app1.views. Error was: No
module named app2.models


Hoping someone can shed some light

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



Re: Automatically create a UserProfile object when a User is created

2007-12-13 Thread Josh

Fantastic!!  Thanks for this information.  It's exactly what I've been
looking for!

On Dec 8, 6:39 am, Julien <[EMAIL PROTECTED]> wrote:
> Oh, just a precision for those who are interested. I put Alex's code
> in the __init__.py file of my profile app.
>
> On Dec 9, 12:37 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > Fantastic! It works beautifully. Very neat and powerful.
>
> > Thanks for your help guys!
>
> > On Dec 9, 12:02 am, Thomas <[EMAIL PROTECTED]> wrote:
>
> > > Very good idea.
>
> > > T.
>
> > > On Dec 8, 1:44 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > > > Use django signals infrastructure. Handle post_save and post_delete
> > > > signal and add or delete profile. Example of creation:
>
> > > > from django.contrib.auth.models import User
> > > > from django.db.models import signals
> > > > from django.dispatch import dispatcher
>
> > > > def create_profile_for_user(sender, instance, signal, *args,
> > > > **kwargs):
> > > > from myapp.models import Profile
> > > > try:
> > > > Profile.objects.get( user = instance )
> > > > except ( Profile.DoesNotExist, AssertionError ):
> > > > profile = Profile( user = instance )
> > > > profile.save()
>
> > > > dispatcher.connect(create_profile_for_user, signal=signals.post_save,
> > > > sender=User)
>
> > > > On 8 дек, 15:41, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > Thanks for the link Thomas. In fact I had already stumbled on django-
> > > > > profiles before. But I don't think this quite solve my problem.
>
> > > > > I'd like the profile to be automatically created when a new user is
> > > > > created, even when creating a user through the admin interface or
> > > > > through the shell for example.
>
> > > > > If the User class was a custom class of mine, I'd simply override the
> > > > >save() and delete() methods. But since the User class is built in
> > > > > Django, I don't know how to do to.
>
> > > > > Any idea how to solve this?
>
> > > > > Cheers!
>
> > > > > Julien
>
> > > > > On Dec 8, 10:52 pm, Thomas <[EMAIL PROTECTED]> wrote:
>
> > > > > > Julien,
>
> > > > > > have a look here:
>
> > > > > >http://www.b-list.org/weblog/2007/nov/24/profiles/
>
> > > > > > Thomas
>
> > > > > > On Dec 8, 12:20 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > > > > > > Hi all,
>
> > > > > > > I feel like my question must have been asked before, but I 
> > > > > > > couldn't
> > > > > > > find any help on this group or through regular googling.
>
> > > > > > > All I'm trying to do is that whenever a new user is created 
> > > > > > > (either
> > > > > > > through the admin interface, or with django-registration), an 
> > > > > > > instance
> > > > > > > of the associated profile class (AUTH_PROFILE_MODULE) is created 
> > > > > > > too.
>
> > > > > > > I guess I'd need to put ahookon the User.save() and delete()
> > > > > > > methods, am I right? How could I do that?
>
> > > > > > > Thanks a lot!
>
> > > > > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error: list index out of range

2007-12-13 Thread l5x

Can you give us "class RegistrationProfile" from C:\Python25\Lib\site-
packages\registration\models.py ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error: list index out of range

2007-12-13 Thread Julien

This is in the application from http://code.google.com/p/django-registration/

The code is:

class RegistrationProfile(models.Model):
"""
A simple profile which stores an activation key for use during
user account registration.

Generally, you will not want to interact directly with instances
of this model; the provided manager includes methods
for creating and activating new accounts, as well as for cleaning
out accounts which have never been activated.

While it is possible to use this model as the value of the
``AUTH_PROFILE_MODULE`` setting, it's not recommended that you do
so. This model's sole purpose is to store data temporarily during
account registration and activation, and a mechanism for
automatically creating an instance of a site-specific profile
model is provided via the ``create_inactive_user`` on
``RegistrationManager``.

"""
user = models.ForeignKey(User, unique=True,
verbose_name=_('user'))
activation_key = models.CharField(_('activation key'),
max_length=40)

objects = RegistrationManager()

class Meta:
verbose_name = _('registration profile')
verbose_name_plural = _('registration profiles')

class Admin:
list_display = ('__str__', 'activation_key_expired')
search_fields = ('user__username', 'user__first_name')

def __unicode__(self):
return u"Registration information for %s" % self.user

def activation_key_expired(self):
"""
Determines whether this ``RegistrationProfile``'s activation
key has expired.

Returns ``True`` if the key has expired, ``False`` otherwise.

Key expiration is determined by the setting
``ACCOUNT_ACTIVATION_DAYS``, which should be the number of
days a key should remain valid after an account is registered.

"""
expiration_date =
datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)
return self.user.date_joined + expiration_date <=
datetime.datetime.now()
activation_key_expired.boolean = True


On Dec 14, 12:27 pm, l5x <[EMAIL PROTECTED]> wrote:
> Can you give us "class RegistrationProfile" from C:\Python25\Lib\site-
> packages\registration\models.py ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error: list index out of range

2007-12-13 Thread Julien

Hi,

There's no template variable, at least for the frontpage.
Here's the traceback:
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 0.97-pre-SVN-6917
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'registration',
 'apps.frontpage',
 'apps.profiles',
 'apps.projects']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.locale.LocaleMiddleware')


Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "E:\Software\workspace\bigproject\trunk\apps\frontpage\views.py"
in frontpage
  6. return render_to_response('frontpage.html')
File "C:\Python25\Lib\site-packages\django\shortcuts\__init__.py" in
render_to_response
  18. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "C:\Python25\Lib\site-packages\django\template\loader.py" in
render_to_string
  106. return t.render(context_instance)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  176. return self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  804. bits.append(self.render_node(node, context))
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render_node
  817. return node.render(context)
File "C:\Python25\Lib\site-packages\django\template\loader_tags.py" in
render
  64. compiled_parent = self.get_parent(context)
File "C:\Python25\Lib\site-packages\django\template\loader_tags.py" in
get_parent
  61. return get_template_from_string(source, origin,
parent)
File "C:\Python25\Lib\site-packages\django\template\loader.py" in
get_template_from_string
  88. return Template(source, origin, name)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
__init__
  166. self.nodelist = compile_string(template_string, origin)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
compile_string
  182. return parser.parse()
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
parse
  290. compiled_result = compile_func(self, token)
File "C:\Python25\Lib\site-packages\django\template\defaulttags.py" in
load
  855. lib = get_library("django.templatetags.%s" %
taglib)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
get_library
  1004. mod = __import__(module_name, {}, {}, [''])
File "E:\Software\workspace\bigproject\trunk\apps\projects\templatetags
\project_tags.py" in 
  5. from models import Project
File "C:\Python25\Lib\site-packages\registration\models.py" in

  169. class RegistrationProfile(models.Model):
File "C:\Python25\Lib\site-packages\django\db\models\base.py" in
__new__
  53. new_class._meta.app_label =
model_module.__name__.split('.')[-2]

Exception Type: IndexError at /
Exception Value: list index out of range


On Dec 14, 11:37 am, l5x <[EMAIL PROTECTED]> wrote:
> Traceback? Template variables?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Backward Relationship In Template

2007-12-13 Thread [EMAIL PROTECTED]

Oops..sorry my dog jumped on keyboard and posted that in the middle of
typing

So in template I'd have:

{% for obj in objecttypebs %}
  {{ obj.someproperty }}

  # this would loop through all of them
  {% for obj objecttypebs.objecttypea_set.all %}
  {% endfor %}

  # what would just give me the first one?

{% endfor %}

On Dec 13, 4:28 pm, jim <[EMAIL PROTECTED]> wrote:
> what is the type of someobject? is it a dictionary?...in that case you
> can do:
>
> {% for object in someobject.items() %}
>
> Jim
>
> On Dec 13, 4:21 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Maybe someone could refresh my memory on this... I could swear I've
> > done this before ... but cannot find my code.. or anything online
> > about it.
>
> > I know to access all items for a relationship in the templates.. I can
> > do:
>
> > {% for object in someobject.relationname_set.all %}
>
> > How do I just access the first one though?  It's been one of those
> > weeks.. so I figured I'd just bite the bullet and ask on here.
>
> > Thanks for any info.
> > Carole
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Backward Relationship In Template

2007-12-13 Thread [EMAIL PROTECTED]

No..that's not it... it's the backward relations in the models...

So I have one class where

class ObjectTypeB(models.Model):

object_typeb_id = models.AutoField(primary_key=True)
some_property =
some_other_property =

class ObjectTypeA(models.Model):

object_typea_id = models.AutoField(primary_key=True)
object_typeb = models.ForeignKey(ObjectTypeB)


So I can have multiple ObjectTypeA's related to ObjectTypeB  ... and
in my view I do
   bojects = ObjectTypeB.objects.all()
   
   pass it to my template as 'objecttypebs'

Then in my template instead of:

On Dec 13, 4:28 pm, jim <[EMAIL PROTECTED]> wrote:
> what is the type of someobject? is it a dictionary?...in that case you
> can do:
>
> {% for object in someobject.items() %}
>
> Jim
>
> On Dec 13, 4:21 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Maybe someone could refresh my memory on this... I could swear I've
> > done this before ... but cannot find my code.. or anything online
> > about it.
>
> > I know to access all items for a relationship in the templates.. I can
> > do:
>
> > {% for object in someobject.relationname_set.all %}
>
> > How do I just access the first one though?  It's been one of those
> > weeks.. so I figured I'd just bite the bullet and ask on here.
>
> > Thanks for any info.
> > Carole
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms admin branch model update

2007-12-13 Thread Karen Tracey
On Dec 13, 2007 5:46 PM, djnz <[EMAIL PROTECTED]> wrote:

>
> I have just setup part of my project for the newforms-admin branch.
> All seemed ok. But when i modifiy an object with the admin interface,
> the changes do not show neither in admin nor in the public area of the
> web. I have to restart the internal django webserver to see the
> changes.
>
> Any ideas?
>

Not really.  I've been using newforms-admin for many weeks with no such
problems.  What do you mean you've set up part of your project for
newforms-admin?  You are either running trunk or newforms-admin, you can't
be partly one and partly the other.  Can you be a little more specific on
the changes you are making and where they are not being reflected?  The fact
that restarting the development server "fixes" things makes it sound like
you are changing code, but the rest of your description sounds like you are
simply changing model data, and I'm baffled as to how that could not be
reflected immediately in the admin interface where you make the change.

Karen

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



Re: Error: list index out of range

2007-12-13 Thread l5x

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



Error: list index out of range

2007-12-13 Thread Julien

Hi there,

I have rearranged the structure of my project and made some minor
changes in the code, and suddenly nothing works at all. Every page of
the site fails and give the error "list index out of range".

In fact, the error is generated each time I do a return
render_to_response("my_template.html) in any view.

Django can find the templates folder, so the templates are apparently
not the cause.

Do you know how I can fix this?

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



newforms admin branch model update

2007-12-13 Thread djnz

I have just setup part of my project for the newforms-admin branch.
All seemed ok. But when i modifiy an object with the admin interface,
the changes do not show neither in admin nor in the public area of the
web. I have to restart the internal django webserver to see the
changes.

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



Re: about tagging app and tags cloud

2007-12-13 Thread Kellen

The font_size shouldn't be 0, ever. Make sure you've restarted your
web server. The font_size is set with this snippet:
tag.font_size = i + 1
Where i is the index in a list. So it _can't_ ever be 0 if the code is
properly executing.

My font sizing is done like this:
style="font-size: {{ tag.font_size|sub:1|mult:25|add:100 }}%"
with some reasonable default font-size.

Kellen


On Dec 12, 3:36 pm, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> ok, it fix the problem of the font_size attr but the distribution of
> values is too spaced. For example, if I got two tags: politics, linux.
> the count for those tags are:
> politics: 6
> linux: 4
>
> when it generate the font_size attr, for "politics" the size is 6 and
> for "linux" the size is 0. It can't be posible.
>
> On Dec 11, 2007 8:48 PM, Kellen <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > There's a bug:
> >http://code.google.com/p/django-tagging/issues/detail?id=54
>
> > For which there is a patch, which changes in tagging/utils.py:
> > -thresholds = [math.pow(max_weight - min_weight + 1,
> > float(i) / float(steps)) \
> > +thresholds = [min_weight + math.pow(max_weight -
> > min_weight, float(i) / float(steps)) \
>
> > On Dec 11, 10:00 pm, "Lic. José M. Rodriguez Bacallao"
> > <[EMAIL PROTECTED]> wrote:
> > > I'm controling the font size with CSS, that is not the problem, the
> > > problem is with the code for tags cloud that it doesn't generate the
> > > font_size attr for some tags.
>
> > > On Dec 11, 2007 3:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > > Just control the default font size with a little CSS? (presuming
> > > > you're using this for [X]HTML output)
>
> > > > On Dec 11, 8:26 pm, "Lic. José M. Rodriguez Bacallao"
>
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > hi folks, I need to generate a tags cloud for a model and I'm using
> > > > > the tagging app from google code. I do something like this:
>
> > > > > cloud = Tag.objects.cloud_for_model(NewsEntry, 6)
>
> > > > > and generate the html cloud based in the "font_size" attr from the
> > > > > tags list "cloud". The problem come when I realize that some of the
> > > > > tags in that list (cloud) doesn't contain a "font_size" attr> I was
> > > > > looking inside the code of the tagging app and I saw that when the
> > > > > "count" attr of the tag is less than any of the values of threshold
> > > > > list it doesn't add the "font_size" attr, so, how can I generate the
> > > > > tags cloud?
>
> > > > > --
> > > > > Lic. José M. Rodriguez Bacallao
> > > > > Cupet
> > > > > -
> > > > > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos 
> > > > > lo mismo.
>
> > > > > Recuerda: El arca de Noe fue construida por aficionados, el titanic
> > > > > por profesionales
> > > > > -
>
> > > --
> > > Lic. José M. Rodriguez Bacallao
> > > Cupet
> > > -
> > > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
> > > mismo.
>
> > > Recuerda: El arca de Noe fue construida por aficionados, el titanic
> > > por profesionales
> > > -
>
> --
> Lic. José M. Rodriguez Bacallao
> Cupet
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Negation in queries

2007-12-13 Thread Kent Johnson

Jan Rademaker wrote:

> There is an undocumented class called QNot which resides in
> django.db.models.query.

That is just what I was looking for. Thanks!

Kent


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



Re: Backward Relationship In Template

2007-12-13 Thread jim

what is the type of someobject? is it a dictionary?...in that case you
can do:

{% for object in someobject.items() %}

Jim


On Dec 13, 4:21 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Maybe someone could refresh my memory on this... I could swear I've
> done this before ... but cannot find my code.. or anything online
> about it.
>
> I know to access all items for a relationship in the templates.. I can
> do:
>
> {% for object in someobject.relationname_set.all %}
>
> How do I just access the first one though?  It's been one of those
> weeks.. so I figured I'd just bite the bullet and ask on here.
>
> Thanks for any info.
> Carole
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Backward Relationship In Template

2007-12-13 Thread [EMAIL PROTECTED]

Maybe someone could refresh my memory on this... I could swear I've
done this before ... but cannot find my code.. or anything online
about it.

I know to access all items for a relationship in the templates.. I can
do:

{% for object in someobject.relationname_set.all %}

How do I just access the first one though?  It's been one of those
weeks.. so I figured I'd just bite the bullet and ask on here.

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



Re: Negation in queries

2007-12-13 Thread Jan Rademaker



On Dec 13, 5:18 pm, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Is there a way to express != in a database query?
>



> or mayby
>filter(s1=1, !Q(s2=1))
> but I don't see any way to do this in the docs. Hopefully I am just
> overlooking something!

There is an undocumented class called QNot which resides in
django.db.models.query. It takes a Q object as a parameter. Using QNot
your example would look like this:

Foo.objects.filter(Q(s1=1) | QNot(Q(s2=1))

The sql produced looks like:

... WHERE (("s1" = 1 OR (NOT ("s2" = 1

I'm not sure if this is exactly the same as 's2 <> 1', though. Any
ideas?

Regards,

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



Re: Need help with book tutorial

2007-12-13 Thread jim

Even if your simple app dosen't do anything with the database, django
still needs those values populated in the settings.py file as the
applications inside the INSTALLED_APPS requires it.

e.g. by default your settings.py will contain:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
)


python goes and builds tables for these e.g. it will create a table
called django_session.

Jim




On Dec 13, 3:39 pm, intercoder <[EMAIL PROTECTED]> wrote:
> I would like a little help in trying to figure out why my /now/ web
> page
> is not working.  I am running Django 0.96
>
> I followed all the instructions from the beginning of the book to the
> letter as far as I can tell. I have all the files that are required
> according to Chapter 2, Starting a project.  See below:
> __init__.py
> manage.py
> settings.py
> urls.py
>
> I made the /now/ program in Idle and saved it in the directory
> 'mysite'.
>
> I started up the django server and tried to run the page. This is the
> error message I got:
>
>  Traceback (most recent call last):
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/core/servers/
> basehttp.py",
> line 272, in run> self.result = application(self.environ, 
> self.start_response)
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/core/servers/
> basehttp.py",
> line 614, in __call__> return self.application(environ, start_response)
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/core/handlers/wsgi.py",
> line 189, in __call__> response = self.get_response(request)
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/core/handlers/base.py",
> line 115, in get_response> receivers = 
> dispatcher.send(signal=signals.got_request_exception)
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/dispatch/dispatcher.py",
> line 358, in send> sender=sender,
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/dispatch/robustapply.py",
> line 47, in robustApply> return receiver(*arguments, **named)
>
> >   File "/usr/pkg/lib/python2.4/site-packages/django/db/__init__.py",
>
> line 47, in _rollback_on_exception> transaction.rollback_unless_managed()
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/db/transaction.py", line
> 145, in rollback_unless_managed> connection._rollback()
>
> >   File
>
> "/usr/pkg/lib/python2.4/site-packages/django/db/backends/dummy/
> base.py",
> line 13, in complain
>
> > raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE
> setting yet."
>
> > ImproperlyConfigured: You haven't set the DATABASE_ENGINE setting yet.
>
> I see that it says I haven't set the Database engine yet. According to
> '
> Your first view: Dynamic content' The second paragraph says:
>
> This simple example doesn't involve a database or any sort of user
> input
> -- just the output of your server's internal clock.
>
> I assumed that I wouldn't have to have the database engine set up yet.
> Was I wrong in that assumption? Could there be something else I have
> done wrong?
>
> I would appreciate any input.
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pickling and unpickling a model field

2007-12-13 Thread [EMAIL PROTECTED]

OK, you're spot on there. That'll teach me to evan glance at my own
code before posting my cries for help! (And thanks for the tip about
get_internal_type)

Anyway, now I think I have what is needed, but now I get the following
traceback:-

Traceback (most recent call last):
  File "", line 1, in 
  File "/Django Source/django/db/models/query.py", line 108, in
__repr__
return repr(self._get_data())
  File "/Django Source/django/db/models/query.py", line 483, in
_get_data
self._result_cache = list(self.iterator())
  File "/Django Source/django/db/models/query.py", line 189, in
iterator
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "")
+ ",".join(select) + sql, params)
  File "/Django Source/django/db/backends/util.py", line 21, in
execute
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
  File "/Django Source/django/db/backends/__init__.py", line 150, in
last_executed_query
return smart_unicode(sql) % u_params
TypeError: not all arguments converted during string formatting

Ideas?

On Dec 13, 8:31 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Dec 13, 2007 3:11 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Heh, I just picked this up, too! I got the field working almost
> > straight away after your kind help (all apart from queries, which I
> > haven't fixed yet as I've been traveling up until this evening)
>
> Glad to hear you're making progress!
>
> > Anyway, what I have ishttp://dpaste.com/27955/which seems to work
> > fine, all apart from the issue I detail in
> >http://groups.google.com/group/django-users/browse_frm/thread/dc8aaf4...
>
> A couple of comments that might help you out:
>
> 1.) Using db_type() makes me cringe, especially the way you're using
> it. Try this instead.
>
> def get_internal_type(self):
> return "TextField"
>
> No importing of database backends. Much nicer.
>
> 2.) I can't say for certain about your query problem without trying
> out the code myself, but it doesn't look like your
> get_db_prep_lookup() is doing what you want it to do. You're storing
> the entire value (dictionary, perhaps?) as a single pickled string,
> but you're looking up based on a list of pickled dictionary keys
> instead.
>
> Basically, I don't think "the ORM" is iterating over your dictionary.
> You are. Try using something like [pickle.dumps(values)] if you want
> it to match the dictionary exactly. But I'm not sure exactly how you
> want it to behave, so I can't be of much more help in this area.
>
> -Gul
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MultiWidget, value_from_datadict, SplitDateWidget

2007-12-13 Thread [EMAIL PROTECTED]

I do, sorry!

On Dec 13, 8:33 pm, l5x <[EMAIL PROTECTED]> wrote:
> > Doesn't Django have something very similar inbuilt to newforms?
>
> You mean: SplitDateTimeWidget
> But there is no custom 'value_from_datadict'
> See:http://code.djangoproject.com/browser/django/trunk/django/newforms/wi...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with initial data

2007-12-13 Thread jim

I think you need to be using 'fixtures' for this purpose.

http://www.djangoproject.com/documentation/models/fixtures/

e.g. I have an application called common, so I created a xml file
called 'initial_data.xml' in the directory:

apps\common\fixtures

the initial_data.xml looks like:




yada yada yada


...




Then when you do python manage.py syncdb, it automatically loads this
data...

Jim




On Dec 13, 3:14 pm, "Tane Piper" <[EMAIL PROTECTED]>
wrote:
> Ok, I've modified this slightly, however still cannot get this to
> work.  To test it, I put a print statement at the top of the function
> and called syncdb, and sure enough the function was being called 8
> times!
>
> So, I modified it so each import is a function, and each has it's own
> dispatcher with a sender (being IssueType, IssueSeverity and
> IssueStatus) - however when the models are created they don't get
> called.  Take the sender away and each function gets called 8 times -
> very strange.
>
> Can anyone help?
>
> On 13/12/2007, Tane Piper <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi folks,
>
> > In our app, we're building a simple Issue list app, and within the app
> > we want to add some basic entries for issue type, issue status and
> > issue severity.  Within our /issue directory, I have created a
> > management.py file and added this:
>
> > from django.dispatch import dispatcher
> > from django.db.models import signals
>
> > from hgfront.issue.models import *
>
> > def init_issues_database():
> > """This injects the database with default values for issues"""
> > issue_types = (
> > ('Bug', 0),
> > ('Enhancment', 1),
> > ('Feature Request', 2),
> > ('Typo', 3)
> > )
> > for issue in issue_types:
> > p = IssueType(title = issue[0], order=issue[1])
> > p.save()
>
> > sev_types = (
> > ('Minor', 0),
> > ('Medium', 1),
> > ('Major', 2),
> > ('Critical', 3),
> > ('Blocker', 4)
> > )
> > for sev in sev_types:
> > s = IssueSeverity(title = sev[0], order=sev[1])
> > s.save()
>
> > status_types = (
> > ('Raised', 0),
> > ('Accepted', 1),
> > ('Not Accepted', 2),
> > ('Fixed', 3),
> > ('Works For Me', 4)
> > )
> > for status in status_types:
> > t = IssueStatus(title = status[0], order=status[1])
> > t.save()
>
> > dispatcher.connect(init_issues_database, signal=signals.post_syncdb)
>
> > The problem is, when I do syncdb, the items do get added to the
> > database, but for issue_types instead of just 4 entries, 36 entries go
> > in.  For sev_types and status_types 40 entries go in each instead of
> > 5.  From what I can work out, it seems to be looping and adding a full
> > entry for each item within the tuples.
>
> > Cannot work this one out at all so either - a) it's a bug or b) we're
> > using management.py wrong, and if so can anyone please point us in the
> > right direction and I can't find any docs on it.
>
> > --
> > Tane Piper
> > Blog -http://digitalspaghetti.me.uk
> > AJAX Pastebin -http://pastemonkey.org
>
> > This email is: [ ] blogable [ x ] ask first [ ] private
>
> --
> Tane Piper
> Blog -http://digitalspaghetti.me.uk
> AJAX Pastebin -http://pastemonkey.org
>
> This email is: [ ] blogable [ x ] ask first [ ] private
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Need help with book tutorial

2007-12-13 Thread intercoder

I would like a little help in trying to figure out why my /now/ web
page
is not working.  I am running Django 0.96

I followed all the instructions from the beginning of the book to the
letter as far as I can tell. I have all the files that are required
according to Chapter 2, Starting a project.  See below:
__init__.py
manage.py
settings.py
urls.py

I made the /now/ program in Idle and saved it in the directory
'mysite'.

I started up the django server and tried to run the page. This is the
error message I got:

 Traceback (most recent call last):
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/core/servers/
basehttp.py",
line 272, in run
> self.result = application(self.environ, self.start_response)
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/core/servers/
basehttp.py",
line 614, in __call__
> return self.application(environ, start_response)
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/core/handlers/wsgi.py",
line 189, in __call__
> response = self.get_response(request)
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/core/handlers/base.py",
line 115, in get_response
> receivers = dispatcher.send(signal=signals.got_request_exception)
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/dispatch/dispatcher.py",
line 358, in send
> sender=sender,
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/dispatch/robustapply.py",
line 47, in robustApply
> return receiver(*arguments, **named)
>
>   File "/usr/pkg/lib/python2.4/site-packages/django/db/__init__.py",
line 47, in _rollback_on_exception
> transaction.rollback_unless_managed()
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/db/transaction.py", line
145, in rollback_unless_managed
> connection._rollback()
>
>   File
"/usr/pkg/lib/python2.4/site-packages/django/db/backends/dummy/
base.py",
line 13, in complain
> raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE
setting yet."
>
> ImproperlyConfigured: You haven't set the DATABASE_ENGINE setting yet.


I see that it says I haven't set the Database engine yet. According to
'
Your first view: Dynamic content' The second paragraph says:

This simple example doesn't involve a database or any sort of user
input
-- just the output of your server's internal clock.

I assumed that I wouldn't have to have the database engine set up yet.
Was I wrong in that assumption? Could there be something else I have
done wrong?

I would appreciate any input.

Thanks.






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



Re: Problems with initial data

2007-12-13 Thread James Bennett

On Dec 13, 2007 2:14 PM, Tane Piper <[EMAIL PROTECTED]> wrote:
> So, I modified it so each import is a function, and each has it's own
> dispatcher with a sender (being IssueType, IssueSeverity and
> IssueStatus) - however when the models are created they don't get
> called.  Take the sender away and each function gets called 8 times -
> very strange.
>
> Can anyone help?

Yes.

Go actually look at django/contrib/sites/management.py and look at
what it uses as the "sender" argument.


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

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



Re: MultiWidget, value_from_datadict, SplitDateWidget

2007-12-13 Thread l5x

> Doesn't Django have something very similar inbuilt to newforms?

You mean: SplitDateTimeWidget
But there is no custom 'value_from_datadict'
See: 
http://code.djangoproject.com/browser/django/trunk/django/newforms/widgets.py#L459
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pickling and unpickling a model field

2007-12-13 Thread Marty Alchin

On Dec 13, 2007 3:11 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Heh, I just picked this up, too! I got the field working almost
> straight away after your kind help (all apart from queries, which I
> haven't fixed yet as I've been traveling up until this evening)

Glad to hear you're making progress!

> Anyway, what I have is http://dpaste.com/27955/ which seems to work
> fine, all apart from the issue I detail in
> http://groups.google.com/group/django-users/browse_frm/thread/dc8aaf47a79cd31c#6f4fffeca4c5c6dc

A couple of comments that might help you out:

1.) Using db_type() makes me cringe, especially the way you're using
it. Try this instead.

def get_internal_type(self):
return "TextField"

No importing of database backends. Much nicer.

2.) I can't say for certain about your query problem without trying
out the code myself, but it doesn't look like your
get_db_prep_lookup() is doing what you want it to do. You're storing
the entire value (dictionary, perhaps?) as a single pickled string,
but you're looking up based on a list of pickled dictionary keys
instead.

Basically, I don't think "the ORM" is iterating over your dictionary.
You are. Try using something like [pickle.dumps(values)] if you want
it to match the dictionary exactly. But I'm not sure exactly how you
want it to behave, so I can't be of much more help in this area.

-Gul

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



Passing a dictionary as a query argument?

2007-12-13 Thread [EMAIL PROTECTED]

Hey All,

I've just written a custom model field for storing anything which is
pickle-able (generally this will be used for storing dictionaries). It
all works great, apart from when I want to perform a query on objects
using the field as an argument. When doing something like:

SomeModel.objects.filter(my_field={'foo': 'bar', 'bar': 'baz'})

However, it seems to reduce my dictionary to an iterable containing
just the dictionary keys (so, in this case ['foo', 'bar']). I presume
Django is doing this by iterating over the dictionary, but obviously
this doesn't work for my field. Is there any way to stop Django from
doing this, away from overriding query methods in the manager to
convert the dictionary to something non-iterable?

Any help much appreciated!

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



Re: Negation in queries

2007-12-13 Thread [EMAIL PROTECTED]

I think you need to use Q objects, which can be OR'd together
http://www.djangoproject.com/documentation/db-api/#complex-lookups-with-q-objects

Or you could just write your own SQL (http://www.djangoproject.com/
documentation/db-api/#falling-back-to-raw-sql)

On Dec 13, 6:00 pm, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Doug B wrote:
> > I think you want filter's evil twin exclude:
>
> I know about exclude() but I don't see how to use it here.
>
> I want s1==1 OR s2!=1, so for example records (s1=1, s2=1) and (s1=2,
> s2=2) would be accepted.
>
> filter(s1=1).exclude(s2=1) is s1==1 AND s2!=1; it will not retrieve
> either of the above examples.
>
> Kent
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MultiWidget, value_from_datadict, SplitDateWidget

2007-12-13 Thread [EMAIL PROTECTED]

Doesn't Django have something very similar inbuilt to newforms?

l5x wrote:
> Hello,
>
> Based on this thread: 
> http://groups.google.com/group/django-users/browse_thread/thread/fd450734295e450f/68d466b0d6b24eb7
>
> I have the following code for the SplitDateWidget:
>
> class SplitDateWidget(forms.MultiWidget):
> def __init__(self, attrs=None):
> widgets = (Select(attrs=attrs, choices=DAY_LIST),
> Select(attrs=attrs, choices=MONTH_LIST), Select(attrs=attrs,
> choices=YEAR_LIST))
> super(SplitDateWidget, self).__init__(widgets, attrs)
>
> def value_from_datadict(self, data, files, name):
> return [widget.value_from_datadict(data, files, name + '_
> %s' % i) for i, widget in enumerate(self.widgets)]
>
> def decompress(self, value):
> if value:
> print 'value: ', value
> value=unicode(value).split('-')
> return [value[2],value[1],value[0]]
> return None
>
> And I don't know what do I need to change in value_from_datadict to
> get this work after request.POST. As for now I get error: "Ensure this
> value has at most 3 characters (it has 22)."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pickling and unpickling a model field

2007-12-13 Thread [EMAIL PROTECTED]

Oh, I also tried using __setattr__ and __getattribute__ to solve this,
but the problem is that Django's ORM will just (unintentionally) call
__getattribute__ when generating the SQL, thereby unpickling the
object again, which will of course raise a SQL error and defeat the
entire purpose.

To see what I mean, try doing something like what I had at 
http://dpaste.com/27956/

On Dec 13, 8:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Heh, I just picked this up, too! I got the field working almost
> straight away after your kind help (all apart from queries, which I
> haven't fixed yet as I've been traveling up until this evening)
>
> Anyway, what I have ishttp://dpaste.com/27955/which seems to work
> fine, all apart from the issue I detail 
> inhttp://groups.google.com/group/django-users/browse_frm/thread/dc8aaf4...
>
> Hope this helps, let me know how you get on. As soon as I get queries
> working, I will post the full code to Django Snippets.
>
> Happy Djangoing!
>
> On Dec 13, 6:48 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
>
> > Ken,
>
> > There was someone else working on this recently as well, so you might
> > take a look at the conversation,[1] the beginnings of the code,[2] and
> > probably contact the author directly to see if you two can't share
> > ideas. It'd be a shame to duplicate effort. It'd be a great candidate
> > for a snippet.[3]
>
> > -Gul
>
> > [1]http://groups.google.com/group/django-users/browse_thread/thread/988d...
> > [2]http://dpaste.com/hold/27712/
> > [3]http://www.djangosnippets.org/
>
> > On Dec 13, 2007 12:59 PM, Ken <[EMAIL PROTECTED]> wrote:
>
> > > Does anyone have an example on how to sub-class a model field so that
> > > setattr pickles the field and getattr unpickles it?  I want to shuffle
> > > a query back and forth between the app and the rendered pages.  I
> > > could urlencode the query but the URL could get potentially rather
> > > long so I thought I'd shuffle just a key to an entry in a table.  The
> > > value part of the entry would be the pickled dict for the query.
>
> > >http://mydjangoapps.mydomain/appname/?srchid=23
>
> > > instead of
>
> > >http://mydjangoapps.mydomain/appname/?this=xxx&that=yyy∧=so&on=and
> > > ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with initial data

2007-12-13 Thread Tane Piper

Ok, I've modified this slightly, however still cannot get this to
work.  To test it, I put a print statement at the top of the function
and called syncdb, and sure enough the function was being called 8
times!

So, I modified it so each import is a function, and each has it's own
dispatcher with a sender (being IssueType, IssueSeverity and
IssueStatus) - however when the models are created they don't get
called.  Take the sender away and each function gets called 8 times -
very strange.

Can anyone help?


On 13/12/2007, Tane Piper <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> In our app, we're building a simple Issue list app, and within the app
> we want to add some basic entries for issue type, issue status and
> issue severity.  Within our /issue directory, I have created a
> management.py file and added this:
>
> from django.dispatch import dispatcher
> from django.db.models import signals
>
> from hgfront.issue.models import *
>
> def init_issues_database():
> """This injects the database with default values for issues"""
> issue_types = (
> ('Bug', 0),
> ('Enhancment', 1),
> ('Feature Request', 2),
> ('Typo', 3)
> )
> for issue in issue_types:
> p = IssueType(title = issue[0], order=issue[1])
> p.save()
>
> sev_types = (
> ('Minor', 0),
> ('Medium', 1),
> ('Major', 2),
> ('Critical', 3),
> ('Blocker', 4)
> )
> for sev in sev_types:
> s = IssueSeverity(title = sev[0], order=sev[1])
> s.save()
>
> status_types = (
> ('Raised', 0),
> ('Accepted', 1),
> ('Not Accepted', 2),
> ('Fixed', 3),
> ('Works For Me', 4)
> )
> for status in status_types:
> t = IssueStatus(title = status[0], order=status[1])
> t.save()
>
> dispatcher.connect(init_issues_database, signal=signals.post_syncdb)
>
> The problem is, when I do syncdb, the items do get added to the
> database, but for issue_types instead of just 4 entries, 36 entries go
> in.  For sev_types and status_types 40 entries go in each instead of
> 5.  From what I can work out, it seems to be looping and adding a full
> entry for each item within the tuples.
>
> Cannot work this one out at all so either - a) it's a bug or b) we're
> using management.py wrong, and if so can anyone please point us in the
> right direction and I can't find any docs on it.
>
> --
> Tane Piper
> Blog - http://digitalspaghetti.me.uk
> AJAX Pastebin - http://pastemonkey.org
>
> This email is: [ ] blogable [ x ] ask first [ ] private
>


-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
AJAX Pastebin - http://pastemonkey.org

This email is: [ ] blogable [ x ] ask first [ ] private

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



Re: pickling and unpickling a model field

2007-12-13 Thread [EMAIL PROTECTED]

Heh, I just picked this up, too! I got the field working almost
straight away after your kind help (all apart from queries, which I
haven't fixed yet as I've been traveling up until this evening)

Anyway, what I have is http://dpaste.com/27955/ which seems to work
fine, all apart from the issue I detail in
http://groups.google.com/group/django-users/browse_frm/thread/dc8aaf47a79cd31c#6f4fffeca4c5c6dc

Hope this helps, let me know how you get on. As soon as I get queries
working, I will post the full code to Django Snippets.

Happy Djangoing!

On Dec 13, 6:48 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> Ken,
>
> There was someone else working on this recently as well, so you might
> take a look at the conversation,[1] the beginnings of the code,[2] and
> probably contact the author directly to see if you two can't share
> ideas. It'd be a shame to duplicate effort. It'd be a great candidate
> for a snippet.[3]
>
> -Gul
>
> [1]http://groups.google.com/group/django-users/browse_thread/thread/988d...
> [2]http://dpaste.com/hold/27712/
> [3]http://www.djangosnippets.org/
>
> On Dec 13, 2007 12:59 PM, Ken <[EMAIL PROTECTED]> wrote:
>
>
>
> > Does anyone have an example on how to sub-class a model field so that
> > setattr pickles the field and getattr unpickles it?  I want to shuffle
> > a query back and forth between the app and the rendered pages.  I
> > could urlencode the query but the URL could get potentially rather
> > long so I thought I'd shuffle just a key to an entry in a table.  The
> > value part of the entry would be the pickled dict for the query.
>
> >http://mydjangoapps.mydomain/appname/?srchid=23
>
> > instead of
>
> >http://mydjangoapps.mydomain/appname/?this=xxx&that=yyy∧=so&on=and
> > ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pickling and unpickling a model field

2007-12-13 Thread Marty Alchin

Ken,

There was someone else working on this recently as well, so you might
take a look at the conversation,[1] the beginnings of the code,[2] and
probably contact the author directly to see if you two can't share
ideas. It'd be a shame to duplicate effort. It'd be a great candidate
for a snippet.[3]

-Gul

[1] 
http://groups.google.com/group/django-users/browse_thread/thread/988dcb5f4914c1c1/
[2] http://dpaste.com/hold/27712/
[3] http://www.djangosnippets.org/

On Dec 13, 2007 12:59 PM, Ken <[EMAIL PROTECTED]> wrote:
>
> Does anyone have an example on how to sub-class a model field so that
> setattr pickles the field and getattr unpickles it?  I want to shuffle
> a query back and forth between the app and the rendered pages.  I
> could urlencode the query but the URL could get potentially rather
> long so I thought I'd shuffle just a key to an entry in a table.  The
> value part of the entry would be the pickled dict for the query.
>
> http://mydjangoapps.mydomain/appname/?srchid=23
>
> instead of
>
> http://mydjangoapps.mydomain/appname/?this=xxx&that=yyy&and=so&on=and
> ...
>
>
> >
>

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



Re: Accessing Multiple Databases

2007-12-13 Thread birkin

Derek,

> ...If not, what should I be doing?

For one of my projects I import data from a non-django-controlled
database using the MySQLdb python library, populate a django model
object and save it (to my app's django-controlled database table).
Works smoothly.

http://sourceforge.net/projects/mysql-python

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65235

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



Re: Negation in queries

2007-12-13 Thread Kent Johnson

Doug B wrote:
> I think you want filter's evil twin exclude:

I know about exclude() but I don't see how to use it here.

I want s1==1 OR s2!=1, so for example records (s1=1, s2=1) and (s1=2, 
s2=2) would be accepted.

filter(s1=1).exclude(s2=1) is s1==1 AND s2!=1; it will not retrieve 
either of the above examples.

Kent


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



Re: Problems with initial data

2007-12-13 Thread James Bennett

On Dec 13, 2007 10:36 AM, Tane Piper <[EMAIL PROTECTED]> wrote:
> dispatcher.connect(init_issues_database, signal=signals.post_syncdb)

This will set up the code to run every single time an application is
installed. Not just the application it resides in, but *every*
application. You want to look up the "sender" argument to
dispatcher.connect() to see how to set it up to only run once, when
its own application is being installed (django.contrib.auth and
django.contrib.sites both provide examples of this, by creating the
superuser account and the default Site object).


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

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



Re: Tableless models?

2007-12-13 Thread Nathan Fiedler

Hi Ned,

Thanks for the response. I have found so far that I can create a
simple "model" that has no fields and this seems to be alright during
runtime, I don't need to set up a database. But, to run the tests at
all, I have to set up a database. Thankfully, I can define "sqlite3"
with an arbitrary database name and it will be alright.

I guess what I'm looking for is a recipe for how this should be done
in Django. Like I said in an earlier reply, doing this in Rails is
simple. I can have a model that, for all intents and purposes, is
identical to a model backed by a database, but in actuality it is a
resource accessed via HTTP. For instance, I have a Rails RESTful web
service that wraps a revision control system. The usefulness of this
is that there are plugins that leverage the model API to perform tasks
like pagination and searching. If I just write a "Ruby class", I will
not have these features.

So, if I am to do the same thing with Django, it would be good to know
if I'm on the right track or not. So far I'm making it work, but it's
probably poorly done.

n


On Dec 13, 2007 3:55 AM, Ned Batchelder <[EMAIL PROTECTED]> wrote:
> You should explain more about what you are trying to do, and where the
> difficulties are.  Ticket #419 is about abstract base classes for
> table-based models.  It sounds like you want a model class that has
> nothing to do with tables ever.  If the latter is the case, then simply
> create a Python class and do whatever you want with it.
>
> For example, you can write a view function that pulls data from wherever
> you want (an RSS feed, a file on disk, a random number generator), then
> formats it as HTML and returns it to the browser.  There's no need for a
> database to be involved.

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



pickling and unpickling a model field

2007-12-13 Thread Ken

Does anyone have an example on how to sub-class a model field so that
setattr pickles the field and getattr unpickles it?  I want to shuffle
a query back and forth between the app and the rendered pages.  I
could urlencode the query but the URL could get potentially rather
long so I thought I'd shuffle just a key to an entry in a table.  The
value part of the entry would be the pickled dict for the query.

http://mydjangoapps.mydomain/appname/?srchid=23

instead of

http://mydjangoapps.mydomain/appname/?this=xxx&that=yyy&and=so&on=and
...


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



Re: Negation in queries

2007-12-13 Thread Doug B

I think you want filter's evil twin exclude:

http://www.djangoproject.com/documentation/0.96/db-api/#exclude-kwargs

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



UK DJANGO/Python Developer positions (Contract/Permanent)

2007-12-13 Thread James

Hi There,

I hope this is Ok to post this to this group - I've seen other job ads
here so I'm assuming it is.


DJANGO/Python Developer position (Contract/Permanent)
Oxford, UK (potential to do some telecommuting)

We are currently expanding our in-house team to take forward the
development of an exciting Web 2.0 business networking platform and
have both permanent and contract opportunities for django developers.

We are a small team which is working on a functionally complex Web 2.0
networking platform and are looking for talented developers to play an
important role in this innovative project.

The people we're looking for will have experience in requirements
analysis, design, coding and unit testing of scalable, distributed,
fault-tolerant applications in Web environments.

You will also need the following:

- Development experience using Python or DJANGO
- Experience of at least one other OO language such as Java or C++
- Hands-on knowledge of relational databases (preferably PostgreSQL)
- Basic LINUX system administration skills
- Experience of working with Subversion or other source control
systems

If you are interested in this challenging project then please give me
(James) a ring on 01865 339395 (I don't check my googlemail very
often)

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



MultiWidget, value_from_datadict, SplitDateWidget

2007-12-13 Thread l5x

Hello,

Based on this thread: 
http://groups.google.com/group/django-users/browse_thread/thread/fd450734295e450f/68d466b0d6b24eb7

I have the following code for the SplitDateWidget:

class SplitDateWidget(forms.MultiWidget):
def __init__(self, attrs=None):
widgets = (Select(attrs=attrs, choices=DAY_LIST),
Select(attrs=attrs, choices=MONTH_LIST), Select(attrs=attrs,
choices=YEAR_LIST))
super(SplitDateWidget, self).__init__(widgets, attrs)

def value_from_datadict(self, data, files, name):
return [widget.value_from_datadict(data, files, name + '_
%s' % i) for i, widget in enumerate(self.widgets)]

def decompress(self, value):
if value:
print 'value: ', value
value=unicode(value).split('-')
return [value[2],value[1],value[0]]
return None

And I don't know what do I need to change in value_from_datadict to
get this work after request.POST. As for now I get error: "Ensure this
value has at most 3 characters (it has 22)."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django using AJP with apache2 and mod_jk leads to HTTP 500 errors

2007-12-13 Thread Roman Zechner

Hey Giorgi!


Thanks for your fast help!

I tried your 1st tips with setting other Location directives and all
the combinations but it didn't work.
I checked out ajp-wsgi but it's currently only available for BSD, Mac
OS X and Gentoo. I will just stick with mod_python and maybe give it a
try another time. But thanks anyway, I didn't know that there's sth
newer to `flup`.


Cheers, Roman


On 13 Dez., 15:27, iGL <[EMAIL PROTECTED]> wrote:
> Hi Ramon,
> As far as I understood the apache jakarta docs, the problem you
> describe might be caused by using sethandlers.
> Therefore, if you have time for further experiments, you might want to
> do either
> - set up another virtual host for the static files
> (e.g.,media.mysite.com) and avoid using SetHandler None
> or
> - Instead of invoking Jkmount, do something like this
>  #or  - I am not sure which one is
> correct
> SetHandler jakarta-servlet
> SetEnv JK_WORKER_NAME mysite-worker
>   
> 
> SetHandler none
> 
>
> 
> SetHandler none
> 
> Hope that helps.
> Greetings,
> Giorgi
> P.S. I believe usinghttp://www.saddi.com/software/ajp-wsgi/instead
> of flup-ajp leads to an improvement in performance.
>
> On 13 Dez., 16:30, Roman Zechner <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > I want to use django with AJP. Inspired 
> > byhttp://blog.webpragmatix.info/category/python-programming-language/dj...
> > andhttp://john.calixto.net/django_benchmarks.htmlandthe thought of
> > having two completely separated systems that can run under different
> > uid's made me courious.
>
> > Problem: I get HTTP 500 errors.
>
> > What I use:
>
> > + debian (on a virtual server if that matters)
> > + apache2
> > + mod_jk
> > + django-trunk (fresh and tasty from svn)
> > + flup
> > + mysql
>
> > What I did:
>
> > 1. I set up apache2.conf like this
>
> > 
> > ServerNamewww.mysite.com
> > ServerAlias mysite.com
> > DocumentRoot /var/www/mysite.com
>
> > # Possible values include: debug, info, notice, warn, error,
> > crit, alert, emerg.
> > LogLevel warn
> > CustomLog /var/log/apache2/mysite.com_access.log combined
> > ErrorLog /var/log/apache2/mysite.com_error.log
>
> > JkMount  /* mysite-worker
>
> > #
> > # Theme files are static and not done by django
> > #
> > 
> > SetHandler none
> > 
>
> > 
> > SetHandler none
> > 
>
> > 
>
> > 2. included jk.conf
> > # The list of Tomcat workers
> > #
> > worker.list=mysite-worker
>
> > worker.mysite-worker.port=8666
> > worker.mysite-worker.host=localhost
> > worker.mysite-worker.type=ajp13
> > #
> > # Specify the size of the open connection cache.
> > worker.mysite-worker.cachesize=10
> > #
> > # Specifies the load balance factor when used with
> > # a load balancing worker.
> > # Note:
> > #  > lbfactor must be > 0
> > #  > Low lbfactor means less work done by the worker.
> > #worker.mysite-worker.lbfactor=1
>
> > 3. started django using ajp
>
> > [EMAIL PROTECTED]:# cd /usr/local/django-apps/mysite/
> > [EMAIL PROTECTED]:# sudo -u www-data ./manage.py runfcgi protocol=ajp
> > method=threaded host=127.0.0.1 port=8666 --settings=mysite.settings
>
> > What am I doing wrong here?
>
> > In the beginning I thought this would be some user access problem
> > where apache2 can't connect to django, but using `sudo` it can't be
> > that.
> > mod_jk is working with tomcat. I also checked several log files, but
> > couldn't find any information except in the acces-log of apache2.
>
> > There seem to be pretty few people around using django with ajp, but
> > never give up hope :-)
>
> > If anybody of the django-documenteers read this, maybe you want to add
> > examples tohttp://www.djangoproject.com/documentation/fastcgi/onhow
> > to use django with AJP. You should also hint that you have to include
> > the settings file with --settings=mysite.settings. And if I may add,
> > the django docs are really great - I never felt so comfortably to
> > browse a doc, very thoughtful implemented.
>
> > Looking forward for your answers - you other 2 AJP users out there.
>
> > Cheers, Roman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Negation in queries

2007-12-13 Thread Kent Johnson

Is there a way to express != in a database query?

Suppose I have a field 'status' that can take the values 1, 2 or 3. If I 
want to select status!=2 I can use exclude(status=2). But for more 
complicated conditions this is harder to do. What if I have two status 
fields, s1, s2 and I want to select on
   s1==1 or s2!=1
?

One way would be
   filter(s1=1, (Q(s2=2) | Q(s2=3)))

Is there any way to do this without enumerating the possible values of 
s2? I would like something like
   filter(s1=1, s2__exact__not=1)
or mayby
   filter(s1=1, !Q(s2=1))
but I don't see any way to do this in the docs. Hopefully I am just 
overlooking something!

I'm using Django 0.96 if it matters...

Thanks,
Kent


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



Re: Problems with initial data

2007-12-13 Thread Rajesh Dhawan

Hi,

>
> from django.dispatch import dispatcher
> from django.db.models import signals
>
> from hgfront.issue.models import *
>
> def init_issues_database():
> """This injects the database with default values for issues"""
> issue_types = (
> ('Bug', 0),
> ('Enhancment', 1),
> ('Feature Request', 2),
> ('Typo', 3)
> )
> for issue in issue_types:
> p = IssueType(title = issue[0], order=issue[1])
> p.save()

Replace those 2 statements with this:

IssueType.objects.get_or_create(title=issue[0],
defaults={'order':issue[1]})

This will ensure that an IssueType gets created only if that title
doesn't already exist.

> for sev in sev_types:
> s = IssueSeverity(title = sev[0], order=sev[1])
> s.save()

Repeat the above pattern for IssueSeverity here.

> for status in status_types:
> t = IssueStatus(title = status[0], order=status[1])
> t.save()

Repeat here too.

> The problem is, when I do syncdb, the items do get added to the
> database, but for issue_types instead of just 4 entries, 36 entries go
> in.  For sev_types and status_types 40 entries go in each instead of
> 5.  From what I can work out, it seems to be looping and adding a full
> entry for each item within the tuples.

That's because your management.py can get invoked more than once. So,
you do want to defend your code against that with the "get_or_create"
method.

-Rajesh

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



Problems with initial data

2007-12-13 Thread Tane Piper

Hi folks,

In our app, we're building a simple Issue list app, and within the app
we want to add some basic entries for issue type, issue status and
issue severity.  Within our /issue directory, I have created a
management.py file and added this:

from django.dispatch import dispatcher
from django.db.models import signals

from hgfront.issue.models import *

def init_issues_database():
"""This injects the database with default values for issues"""
issue_types = (
('Bug', 0),
('Enhancment', 1),
('Feature Request', 2),
('Typo', 3)
)
for issue in issue_types:
p = IssueType(title = issue[0], order=issue[1])
p.save()

sev_types = (
('Minor', 0),
('Medium', 1),
('Major', 2),
('Critical', 3),
('Blocker', 4)
)
for sev in sev_types:
s = IssueSeverity(title = sev[0], order=sev[1])
s.save()

status_types = (
('Raised', 0),
('Accepted', 1),
('Not Accepted', 2),
('Fixed', 3),
('Works For Me', 4)
)
for status in status_types:
t = IssueStatus(title = status[0], order=status[1])
t.save()

dispatcher.connect(init_issues_database, signal=signals.post_syncdb)

The problem is, when I do syncdb, the items do get added to the
database, but for issue_types instead of just 4 entries, 36 entries go
in.  For sev_types and status_types 40 entries go in each instead of
5.  From what I can work out, it seems to be looping and adding a full
entry for each item within the tuples.

Cannot work this one out at all so either - a) it's a bug or b) we're
using management.py wrong, and if so can anyone please point us in the
right direction and I can't find any docs on it.

-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
AJAX Pastebin - http://pastemonkey.org

This email is: [ ] blogable [ x ] ask first [ ] private

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



Re: GeoDjango: Invalid spatial reference pointer returned from "OGR_L_GetSpatialRef"

2007-12-13 Thread Joe

On Dec 12, 2007 10:12 PM, Justin Bronn <[EMAIL PROTECTED]> wrote:
>
> > Should the example still work with the latest svn revision of
> > GeoDjango? The IPython session is pasted below.
>
> Yes, it should work.  You found a bug -- I just fixed it in r6916.

The example works perfectly now. Thanks very much!

> There have been some significant changes to GeoDjango since FOSS4G
> (e.g., GEOS & GDAL refactors, distance queries, additional spatial
> backends).  However, substantively, everything should still work as
> shown.  This particular bug is an artifact of the GDAL library
> refactoring: the census shapefiles do not explicitly give a spatial
> reference, which is NAD83, and the `srs` property should be None
> instead of raising an exception.  One thing that has explicitly
> changed is that `models.GeoMixin` is no longer required for geographic
> models.

I appreciate your taking the time to explain the issue. It's very
helpful for someone just starting out with GeoDjango.

Thanks,
Joe

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



Re: URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread sector119

Thank you! I miss "url" at the beginning of all patterns :)

On 13 Грд, 17:14, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Dec 13, 2007 9:58 AM, sector119 <[EMAIL PROTECTED]> wrote:
>
> > urlpatterns = patterns('django.views.generic',
> > (r'^location/$', 'list_detail.object_list', location_list_info,
> > name='locations-location_list'),
> > )
>
> In order to name your URLpatterns, you'll need to use the url() function.
>
> urlpatterns = patterns('django.views.generic',
> url(r'^location/$', 'list_detail.object_list', location_list_info,
> name='locations-location_list'),
> )
>
> Notice "url" at the beginning of the pattern. That's key.
>
> -Gul
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread Marty Alchin

On Dec 13, 2007 9:58 AM, sector119 <[EMAIL PROTECTED]> wrote:
> urlpatterns = patterns('django.views.generic',
> (r'^location/$', 'list_detail.object_list', location_list_info,
> name='locations-location_list'),
> )

In order to name your URLpatterns, you'll need to use the url() function.

urlpatterns = patterns('django.views.generic',
url(r'^location/$', 'list_detail.object_list', location_list_info,
name='locations-location_list'),
)

Notice "url" at the beginning of the pattern. That's key.

-Gul

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



Re: URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread yml

Hello,
I don't know what line is 13 but it seems to me that for the second
urlpatterns should be:
"""
urlpatterns += patterns(
"""
Let me know if this help.

On 13 déc, 15:58, sector119 <[EMAIL PROTECTED]> wrote:
> Hi all!
>
> When I try to use Naming URL patterns I get error:
> Exception Type: ImproperlyConfigured
> Exception Value:Error while importing URLconf 'locations.urls':
> invalid syntax (urls.py, line 13)
> Exception Location: /home/sector119/devel/django_src/django/core/
> urlresolvers.py in _get_urlconf_module, line 255
>
> When I remove name='locations-location_list' from my URLconf
> everything is OK, but why? Why Django can't resolve that name?
>
> root URLconf: % cat urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> (r'^admin/', include('django.contrib.admin.urls')),
> (r'^locations/', include('locations.urls')),
> )
>
> locations URLconf: % cat apps/locations/urls.py
> from django.conf.urls.defaults import *
>
> # generic views
>
> from locations.models import Location
>
> location_list_info = {
> 'queryset' :   Location.objects.all(),
> 'paginate_by': 10,
>
> }
>
> urlpatterns = patterns('django.views.generic',
> (r'^location/$', 'list_detail.object_list', location_list_info,
> name='locations-location_list'),
> )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin interface broken

2007-12-13 Thread Julian

this one solved it:

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



Re: URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread sector119

I use django current trunk, if this info is needed.

On 13 Грд, 16:58, sector119 <[EMAIL PROTECTED]> wrote:
> Hi all!
>
> When I try to use Naming URL patterns I get error:
> Exception Type: ImproperlyConfigured
> Exception Value:Error while importing URLconf 'locations.urls':
> invalid syntax (urls.py, line 13)
> Exception Location: /home/sector119/devel/django_src/django/core/
> urlresolvers.py in _get_urlconf_module, line 255
>
> When I remove name='locations-location_list' from my URLconf
> everything is OK, but why? Why Django can't resolve that name?
>
> root URLconf: % cat urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> (r'^admin/', include('django.contrib.admin.urls')),
> (r'^locations/', include('locations.urls')),
> )
>
> locations URLconf: % cat apps/locations/urls.py
> from django.conf.urls.defaults import *
>
> # generic views
>
> from locations.models import Location
>
> location_list_info = {
> 'queryset' :   Location.objects.all(),
> 'paginate_by': 10,
>
> }
>
> urlpatterns = patterns('django.views.generic',
> (r'^location/$', 'list_detail.object_list', location_list_info,
> name='locations-location_list'),
> )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread sector119

Hi all!

When I try to use Naming URL patterns I get error:
Exception Type: ImproperlyConfigured
Exception Value:Error while importing URLconf 'locations.urls':
invalid syntax (urls.py, line 13)
Exception Location: /home/sector119/devel/django_src/django/core/
urlresolvers.py in _get_urlconf_module, line 255

When I remove name='locations-location_list' from my URLconf
everything is OK, but why? Why Django can't resolve that name?


root URLconf: % cat urls.py
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
(r'^locations/', include('locations.urls')),
)

locations URLconf: % cat apps/locations/urls.py
from django.conf.urls.defaults import *

# generic views

from locations.models import Location

location_list_info = {
'queryset' :   Location.objects.all(),
'paginate_by': 10,
}

urlpatterns = patterns('django.views.generic',
(r'^location/$', 'list_detail.object_list', location_list_info,
name='locations-location_list'),
)

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



Re: Burning question about forums .. and I guess this applies to gmail as well

2007-12-13 Thread Jonathan Buchanan

On Dec 13, 2007 8:59 AM, Roboto <[EMAIL PROTECTED]> wrote:
>
> How do forums ie PHPBB and gmail know if I've viewed a topic or not?
>
> I can think of only 2 methods - 1 is session, and the second is
> database.  However, if I change computers and therefore changing my
> session it's still able to ensure track what I've viewed.  It
> therefore leads me to believe that they are tracking via database
>
> If that is the case?  What would be the logic to set this up??

I would imagine there's something stored in a database to track when
you last read a topic/mail, yes :)

Here's a pared-down snippet of how I do it in my forum application [1]
by way of example:

# models.py

class TopicTracker(models.Model):
"""
Tracks the last time a User read a particular Topic.
"""
user  = models.ForeignKey(User, related_name='topic_trackers')
topic = models.ForeignKey(Topic, related_name='trackers')
last_read = models.DateTimeField()

def update_last_read(self, last_read):
"""
Updates this TopicTracker's ``last_read``.
"""
self.last_read = last_read
model_utils.update(self, 'last_read')

update_last_read.alters_data = True

# views.py

def topic_detail(request, topic_id):
topic = get_object_or_404(Topic, pk=topic_id)
if request.user.is_authenticated():
last_read = datetime.datetime.now()
tracker, created = \
TopicTracker.objects.get_or_create(user=request.user, topic=topic,
   defaults={'last_read':
last_read})
if not created:
tracker.update_last_read(last_read)
transaction.commit()
# ...

Regards,
Jonathan.

[1] http://www.jonathanbuchanan.plus.com/repos/forum/

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



Re: django using AJP with apache2 and mod_jk leads to HTTP 500 errors

2007-12-13 Thread iGL

Hi Ramon,
As far as I understood the apache jakarta docs, the problem you
describe might be caused by using sethandlers.
Therefore, if you have time for further experiments, you might want to
do either
- set up another virtual host for the static files
(e.g.,media.mysite.com) and avoid using SetHandler None
or
- Instead of invoking Jkmount, do something like this
 #or  - I am not sure which one is
correct
SetHandler jakarta-servlet
SetEnv JK_WORKER_NAME mysite-worker
  

SetHandler none



SetHandler none

Hope that helps.
Greetings,
Giorgi
P.S. I believe using http://www.saddi.com/software/ajp-wsgi/ instead
of flup-ajp leads to an improvement in performance.

On 13 Dez., 16:30, Roman Zechner <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I want to use django with AJP. Inspired 
> byhttp://blog.webpragmatix.info/category/python-programming-language/dj...
> andhttp://john.calixto.net/django_benchmarks.htmland the thought of
> having two completely separated systems that can run under different
> uid's made me courious.
>
> Problem: I get HTTP 500 errors.
>
> What I use:
>
> + debian (on a virtual server if that matters)
> + apache2
> + mod_jk
> + django-trunk (fresh and tasty from svn)
> + flup
> + mysql
>
> What I did:
>
> 1. I set up apache2.conf like this
>
> 
> ServerNamewww.mysite.com
> ServerAlias mysite.com
> DocumentRoot /var/www/mysite.com
>
> # Possible values include: debug, info, notice, warn, error,
> crit, alert, emerg.
> LogLevel warn
> CustomLog /var/log/apache2/mysite.com_access.log combined
> ErrorLog /var/log/apache2/mysite.com_error.log
>
> JkMount  /* mysite-worker
>
> #
> # Theme files are static and not done by django
> #
> 
> SetHandler none
> 
>
> 
> SetHandler none
> 
>
> 
>
> 2. included jk.conf
> # The list of Tomcat workers
> #
> worker.list=mysite-worker
>
> worker.mysite-worker.port=8666
> worker.mysite-worker.host=localhost
> worker.mysite-worker.type=ajp13
> #
> # Specify the size of the open connection cache.
> worker.mysite-worker.cachesize=10
> #
> # Specifies the load balance factor when used with
> # a load balancing worker.
> # Note:
> #  > lbfactor must be > 0
> #  > Low lbfactor means less work done by the worker.
> #worker.mysite-worker.lbfactor=1
>
> 3. started django using ajp
>
> [EMAIL PROTECTED]:# cd /usr/local/django-apps/mysite/
> [EMAIL PROTECTED]:# sudo -u www-data ./manage.py runfcgi protocol=ajp
> method=threaded host=127.0.0.1 port=8666 --settings=mysite.settings
>
> What am I doing wrong here?
>
> In the beginning I thought this would be some user access problem
> where apache2 can't connect to django, but using `sudo` it can't be
> that.
> mod_jk is working with tomcat. I also checked several log files, but
> couldn't find any information except in the acces-log of apache2.
>
> There seem to be pretty few people around using django with ajp, but
> never give up hope :-)
>
> If anybody of the django-documenteers read this, maybe you want to add
> examples tohttp://www.djangoproject.com/documentation/fastcgi/on how
> to use django with AJP. You should also hint that you have to include
> the settings file with --settings=mysite.settings. And if I may add,
> the django docs are really great - I never felt so comfortably to
> browse a doc, very thoughtful implemented.
>
> Looking forward for your answers - you other 2 AJP users out there.
>
> Cheers, Roman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Burning question about forums .. and I guess this applies to gmail as well

2007-12-13 Thread Roboto

How do forums ie PHPBB and gmail know if I've viewed a topic or not?

I can think of only 2 methods - 1 is session, and the second is
database.  However, if I change computers and therefore changing my
session it's still able to ensure track what I've viewed.  It
therefore leads me to believe that they are tracking via database

If that is the case?  What would be the logic to set this up??

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



django using AJP with apache2 and mod_jk leads to HTTP 500 errors

2007-12-13 Thread Roman Zechner

Hi!


I want to use django with AJP. Inspired by
http://blog.webpragmatix.info/category/python-programming-language/django-web-framework/
and http://john.calixto.net/django_benchmarks.html and the thought of
having two completely separated systems that can run under different
uid's made me courious.

Problem: I get HTTP 500 errors.


What I use:

+ debian (on a virtual server if that matters)
+ apache2
+ mod_jk
+ django-trunk (fresh and tasty from svn)
+ flup
+ mysql



What I did:

1. I set up apache2.conf like this



ServerName www.mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/mysite.com

# Possible values include: debug, info, notice, warn, error,
crit, alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/mysite.com_access.log combined
ErrorLog /var/log/apache2/mysite.com_error.log

JkMount  /* mysite-worker

#
# Theme files are static and not done by django
#

SetHandler none



SetHandler none





2. included jk.conf
# The list of Tomcat workers
#
worker.list=mysite-worker


worker.mysite-worker.port=8666
worker.mysite-worker.host=localhost
worker.mysite-worker.type=ajp13
#
# Specify the size of the open connection cache.
worker.mysite-worker.cachesize=10
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  > lbfactor must be > 0
#  > Low lbfactor means less work done by the worker.
#worker.mysite-worker.lbfactor=1

3. started django using ajp

[EMAIL PROTECTED]:# cd /usr/local/django-apps/mysite/
[EMAIL PROTECTED]:# sudo -u www-data ./manage.py runfcgi protocol=ajp
method=threaded host=127.0.0.1 port=8666 --settings=mysite.settings


What am I doing wrong here?


In the beginning I thought this would be some user access problem
where apache2 can't connect to django, but using `sudo` it can't be
that.
mod_jk is working with tomcat. I also checked several log files, but
couldn't find any information except in the acces-log of apache2.

There seem to be pretty few people around using django with ajp, but
never give up hope :-)

If anybody of the django-documenteers read this, maybe you want to add
examples to http://www.djangoproject.com/documentation/fastcgi/ on how
to use django with AJP. You should also hint that you have to include
the settings file with --settings=mysite.settings. And if I may add,
the django docs are really great - I never felt so comfortably to
browse a doc, very thoughtful implemented.

Looking forward for your answers - you other 2 AJP users out there.

Cheers, Roman



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



admin interface broken

2007-12-13 Thread Julian

Hi there,

i haven't been developing my django project for some weeks and so i
continued my work today.

there are three links on the right upper corner of the admin interface
(documentation, change password, logout) but all of them point to
"http://127.0.0.1:8000/admin/"; and nothing happens if i click them.

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



Re: Tableless models?

2007-12-13 Thread Ned Batchelder

You should explain more about what you are trying to do, and where the 
difficulties are.  Ticket #419 is about abstract base classes for 
table-based models.  It sounds like you want a model class that has 
nothing to do with tables ever.  If the latter is the case, then simply 
create a Python class and do whatever you want with it.

For example, you can write a view function that pulls data from wherever 
you want (an RSS feed, a file on disk, a random number generator), then 
formats it as HTML and returns it to the browser.  There's no need for a 
database to be involved.

--Ned.
http://nedbatchelder.com

Nathan Fiedler wrote:
> This topic has come up once or twice before, but it doesn't seem like
> a solution exists. Basically I'm looking for a recommended pattern for
> creating Django models that have no association with a database (i.e.
> "tableless").
>
> Curiously, ticket #419 has to do with enabling tableless models, but
> it was resolved as "duplicate", with no reference to any other ticket.
> Has this really been resolved, and if so, what happened?
>
> Thanks
>
> n
>
> >
>
>   

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



Would you stop for a moment?!

2007-12-13 Thread عاصم عبد اللطيف

Excuse me!!
Would you stop for a moment?!
O...man...Haven't you thought-one day- about yourself ?
Who has made it?
Have you seen a design which hasn't a designer ?!
Have you seen a wonderful,delicate work without a worker ?!
It's you and the whole universe!..
Who has made them all ?!!
You know who ?.. It's "ALLAH",prise be to him.
Just think for a moment.
How are you going to be after death ?!
Can you believe that this exact system of the universe and all of
these great creation will end in in nothing...just after death!
Have you thought, for a second, How to save your soul from Allah's
punishment?!
Haven't you thought about what is the right religion?!
Read ... and think deeply before you answer..
It is religion of Islam.
It is the religion that Mohammad-peace upon him- the last prophet, had
been sent by.
It is the religion that the right Bible- which is not distorted-has
preached.
Just have a look at The Bible of (Bernaba).
Don't be emstional.
Be rational and judge..
Just look..listen...compare..and then judge and say your word.
We advise you visiting :
http://www.islam-guide.com/
http://www.thetruereligion.org/
http://www.it-is-truth.org/
http://www.beconvinced.com/
http://www.plaintruth.org/
http://english.islamway.com/
http://www.todayislam.com/
http://www.prophetmuhammed.org/
http://www.islamtoday.net/english/
http://www.islamunveiled.org/
http://www.islamic-knowledge.com/

We willingly recive any inquries at the e-mail :

[EMAIL PROTECTED]

 http://www.islam-qa.com

 Or

http://www.islam-online.net/

 Or

http://www.al-islam.com/

Or

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



Re: ManyToManyField problem?

2007-12-13 Thread Marcin Mierzejewski


Sorry, it should be:

def Tags(self):
return self.tags.all()


On Dec 13, 10:02 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> Is this code work?
>
> The class can not return. I think only function can return something.
>
> Can you clear the code to prevent ambiguity
>
> On Dec 13, 2007 5:45 PM, Marcin Mierzejewski <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > It should work.
>
> > On Dec 13, 9:32 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> > > Ye. It works.
>
> > > But when I work with generic view such as update insert, how can I work
> > with
> > > this code?
>
> > > On Dec 13, 2007 5:04 PM, Marcin Mierzejewski <
> > [EMAIL PROTECTED]>
> > > wrote:
>
> > > > Hi,
>
> > > > Try this:
>
> > > > class Entry(models.Model):
> > > >  ...
> > > >  tags = models.ManyToManyField( Tag )
>
> > > >  class Tags(self):
> > > >return self.tags.all()
>
> > > > class Tag(models.Model):
> > > >  ...
>
> > > > And now, Entry.Targs() returns all Tags related to the blog entry.
>
> > > > Regards,
> > > > Marcin
>
> > > > On Dec 13, 8:54 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> > > > > class Entry(models.Model):
> > > > > blog = models.ForeignKey(Blog,related_name='entries')
> > > > > Title = models.CharField(maxlength=250, blank=False, null=False)
> > > > > Slug = models.SlugField(maxlength=250, blank=False, null=False,
> > > > > prepopulate_from=('Title',))
> > > > > Content = models.TextField(blank=False, null=False)
> > > > > Post_Date = models.DateTimeField(auto_now_add=True)
> > > > > tags = blog.select_relates().tags # models.ManyToManyField
> > ('Tag',
> > > > > blank=True, related_name='entries')
> > > > > Pictures = models.ForeignKey('Picture', blank=True, null=True,
> > > > > related_name='entries')
> > > > > Files = models.ForeignKey('File', blank=True, null=True,
> > > > > related_name='entries')
> > > > > # comments = models.ForeignKey(Comment, blank=True, null=True,
> > > > > related_name='entries')
> > > > > Is_Draft = models.BooleanField(default=False, help_text="Draft
> > > > entries
> > > > > are visible only to the author and admins")
> > > > > Comments_Allowed = models.BooleanField(default=True)
> > > > > Trackbacks_Allowed = models.BooleanField(default=False)
>
> > > > > class Tag(models.Model):
> > > > > blog = models.ForeignKey(Blog,related_name='tags')
> > > > > Name = models.CharField(maxlength=250)
> > > > > Slug = models.SlugField(maxlength=250,
> > prepopulate_from=('Name',))
> > > > > Total_ref = models.IntegerField(blank=True, default=0)
> > > > > Font_size = models.IntegerField(blank=True, default=0)
>
> > > > > This is the two table that I'm using.
>
> > > > > What I want to do is in this models that I want to refer the Tag
> > list by
> > > > not
> > > > > all tag list but Blog.tag list
>
> > > > > When I execute this code in the web, I can see the whole tag list.
> > > > > But I want to see the tag list belonged to blog's user
>
> > > > > If I can solve this problem in the template code, but I want to
> > solve
> > > > this
> > > > > problem in terms of models.
> > > > > Because this solution could be more neat.
>
> > > > > Give me a clue
>
> > > > > Thanks, always
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Tableless models?

2007-12-13 Thread David Reynolds


On 12 Dec 2007, at 6:52 pm, Nathan Fiedler wrote:

> This topic has come up once or twice before, but it doesn't seem like
> a solution exists. Basically I'm looking for a recommended pattern for
> creating Django models that have no association with a database (i.e.
> "tableless").

This may be a silly point and may not do what you want, but a form  
(using newforms) is kind of like a model without a database table.

-- 
David Reynolds
[EMAIL PROTECTED]



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



Re: ManyToManyField problem?

2007-12-13 Thread Young Gyu Park
Is this code work?

The class can not return. I think only function can return something.

Can you clear the code to prevent ambiguity

On Dec 13, 2007 5:45 PM, Marcin Mierzejewski <[EMAIL PROTECTED]>
wrote:

>
>
> It should work.
>
> On Dec 13, 9:32 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> > Ye. It works.
> >
> > But when I work with generic view such as update insert, how can I work
> with
> > this code?
> >
> > On Dec 13, 2007 5:04 PM, Marcin Mierzejewski <
> [EMAIL PROTECTED]>
> > wrote:
> >
> >
> >
> > > Hi,
> >
> > > Try this:
> >
> > > class Entry(models.Model):
> > >  ...
> > >  tags = models.ManyToManyField( Tag )
> >
> > >  class Tags(self):
> > >return self.tags.all()
> >
> > > class Tag(models.Model):
> > >  ...
> >
> > > And now, Entry.Targs() returns all Tags related to the blog entry.
> >
> > > Regards,
> > > Marcin
> >
> > > On Dec 13, 8:54 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> > > > class Entry(models.Model):
> > > > blog = models.ForeignKey(Blog,related_name='entries')
> > > > Title = models.CharField(maxlength=250, blank=False, null=False)
> > > > Slug = models.SlugField(maxlength=250, blank=False, null=False,
> > > > prepopulate_from=('Title',))
> > > > Content = models.TextField(blank=False, null=False)
> > > > Post_Date = models.DateTimeField(auto_now_add=True)
> > > > tags = blog.select_relates().tags # models.ManyToManyField
> ('Tag',
> > > > blank=True, related_name='entries')
> > > > Pictures = models.ForeignKey('Picture', blank=True, null=True,
> > > > related_name='entries')
> > > > Files = models.ForeignKey('File', blank=True, null=True,
> > > > related_name='entries')
> > > > # comments = models.ForeignKey(Comment, blank=True, null=True,
> > > > related_name='entries')
> > > > Is_Draft = models.BooleanField(default=False, help_text="Draft
> > > entries
> > > > are visible only to the author and admins")
> > > > Comments_Allowed = models.BooleanField(default=True)
> > > > Trackbacks_Allowed = models.BooleanField(default=False)
> >
> > > > class Tag(models.Model):
> > > > blog = models.ForeignKey(Blog,related_name='tags')
> > > > Name = models.CharField(maxlength=250)
> > > > Slug = models.SlugField(maxlength=250,
> prepopulate_from=('Name',))
> > > > Total_ref = models.IntegerField(blank=True, default=0)
> > > > Font_size = models.IntegerField(blank=True, default=0)
> >
> > > > This is the two table that I'm using.
> >
> > > > What I want to do is in this models that I want to refer the Tag
> list by
> > > not
> > > > all tag list but Blog.tag list
> >
> > > > When I execute this code in the web, I can see the whole tag list.
> > > > But I want to see the tag list belonged to blog's user
> >
> > > > If I can solve this problem in the template code, but I want to
> solve
> > > this
> > > > problem in terms of models.
> > > > Because this solution could be more neat.
> >
> > > > Give me a clue
> >
> > > > Thanks, always
> >
>

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



Re: __init__() got an unexpected keyword argument 'max_length'

2007-12-13 Thread DjangoFett

Found the problem. There was another copy of django in the python
framework directory (this was all in OS X). I deleted it and 'ln'd my
trunk directory in its place. Everything seems to work well now.
Thanks to Magus on #django.

Randall

On Dec 13, 2:27 am, DjangoFett <[EMAIL PROTECTED]> wrote:
> I get the above error when running an application via apache2. not
> when i use the built in 'python mange.py runserver' command.
>
> I've done a svn update with the current trunk both directly into my
> site-packages directory and to another directory with an 'ln' link
> inside the site-packages directory. i have another server that
> currently uses the 'max_length' directive without problem. i have
> copied that directory into the proper local directory as well with no
> help either. this error is greatly stifling my development of a
> current project and i need any information that could help. please
> help! :-)
>
> Randall Prince
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToManyField problem?

2007-12-13 Thread Marcin Mierzejewski


It should work.

On Dec 13, 9:32 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> Ye. It works.
>
> But when I work with generic view such as update insert, how can I work with
> this code?
>
> On Dec 13, 2007 5:04 PM, Marcin Mierzejewski <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Hi,
>
> > Try this:
>
> > class Entry(models.Model):
> >  ...
> >  tags = models.ManyToManyField( Tag )
>
> >  class Tags(self):
> >return self.tags.all()
>
> > class Tag(models.Model):
> >  ...
>
> > And now, Entry.Targs() returns all Tags related to the blog entry.
>
> > Regards,
> > Marcin
>
> > On Dec 13, 8:54 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> > > class Entry(models.Model):
> > > blog = models.ForeignKey(Blog,related_name='entries')
> > > Title = models.CharField(maxlength=250, blank=False, null=False)
> > > Slug = models.SlugField(maxlength=250, blank=False, null=False,
> > > prepopulate_from=('Title',))
> > > Content = models.TextField(blank=False, null=False)
> > > Post_Date = models.DateTimeField(auto_now_add=True)
> > > tags = blog.select_relates().tags # models.ManyToManyField('Tag',
> > > blank=True, related_name='entries')
> > > Pictures = models.ForeignKey('Picture', blank=True, null=True,
> > > related_name='entries')
> > > Files = models.ForeignKey('File', blank=True, null=True,
> > > related_name='entries')
> > > # comments = models.ForeignKey(Comment, blank=True, null=True,
> > > related_name='entries')
> > > Is_Draft = models.BooleanField(default=False, help_text="Draft
> > entries
> > > are visible only to the author and admins")
> > > Comments_Allowed = models.BooleanField(default=True)
> > > Trackbacks_Allowed = models.BooleanField(default=False)
>
> > > class Tag(models.Model):
> > > blog = models.ForeignKey(Blog,related_name='tags')
> > > Name = models.CharField(maxlength=250)
> > > Slug = models.SlugField(maxlength=250, prepopulate_from=('Name',))
> > > Total_ref = models.IntegerField(blank=True, default=0)
> > > Font_size = models.IntegerField(blank=True, default=0)
>
> > > This is the two table that I'm using.
>
> > > What I want to do is in this models that I want to refer the Tag list by
> > not
> > > all tag list but Blog.tag list
>
> > > When I execute this code in the web, I can see the whole tag list.
> > > But I want to see the tag list belonged to blog's user
>
> > > If I can solve this problem in the template code, but I want to solve
> > this
> > > problem in terms of models.
> > > Because this solution could be more neat.
>
> > > Give me a clue
>
> > > Thanks, always
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToManyField problem?

2007-12-13 Thread Young Gyu Park
Ye. It works.

But when I work with generic view such as update insert, how can I work with
this code?



On Dec 13, 2007 5:04 PM, Marcin Mierzejewski <[EMAIL PROTECTED]>
wrote:

>
> Hi,
>
> Try this:
>
> class Entry(models.Model):
>  ...
>  tags = models.ManyToManyField( Tag )
>
>  class Tags(self):
>return self.tags.all()
>
> class Tag(models.Model):
>  ...
>
> And now, Entry.Targs() returns all Tags related to the blog entry.
>
> Regards,
> Marcin
>
> On Dec 13, 8:54 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> > class Entry(models.Model):
> > blog = models.ForeignKey(Blog,related_name='entries')
> > Title = models.CharField(maxlength=250, blank=False, null=False)
> > Slug = models.SlugField(maxlength=250, blank=False, null=False,
> > prepopulate_from=('Title',))
> > Content = models.TextField(blank=False, null=False)
> > Post_Date = models.DateTimeField(auto_now_add=True)
> > tags = blog.select_relates().tags # models.ManyToManyField('Tag',
> > blank=True, related_name='entries')
> > Pictures = models.ForeignKey('Picture', blank=True, null=True,
> > related_name='entries')
> > Files = models.ForeignKey('File', blank=True, null=True,
> > related_name='entries')
> > # comments = models.ForeignKey(Comment, blank=True, null=True,
> > related_name='entries')
> > Is_Draft = models.BooleanField(default=False, help_text="Draft
> entries
> > are visible only to the author and admins")
> > Comments_Allowed = models.BooleanField(default=True)
> > Trackbacks_Allowed = models.BooleanField(default=False)
> >
> > class Tag(models.Model):
> > blog = models.ForeignKey(Blog,related_name='tags')
> > Name = models.CharField(maxlength=250)
> > Slug = models.SlugField(maxlength=250, prepopulate_from=('Name',))
> > Total_ref = models.IntegerField(blank=True, default=0)
> > Font_size = models.IntegerField(blank=True, default=0)
> >
> > This is the two table that I'm using.
> >
> > What I want to do is in this models that I want to refer the Tag list by
> not
> > all tag list but Blog.tag list
> >
> > When I execute this code in the web, I can see the whole tag list.
> > But I want to see the tag list belonged to blog's user
> >
> > If I can solve this problem in the template code, but I want to solve
> this
> > problem in terms of models.
> > Because this solution could be more neat.
> >
> > Give me a clue
> >
> > Thanks, always
> >
>

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



Re: Tableless models?

2007-12-13 Thread Nathan Fiedler

What do you mean by "backend"? I just started learning Python two
months ago, and Django a couple of weeks later, so I am unfamiliar
with many of the related terms.

So far, I have found that I have to use sqlite3 just to be able to run
the tests. Annoying, but as long as no real database is involved, it's
workable.

Anyway, I asked this question because with Rails, this sort of thing
is pretty well understood and easy to set up. But with Django, it
seems no one knows the answer.

Thanks

n


On Dec 12, 2007 3:52 PM, Empty <[EMAIL PROTECTED]> wrote:
> Wouldn't it just involve creating a backend that has nothing to do
> with a database?  Seems pretty straightforward to me.

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



Re: ManyToManyField problem?

2007-12-13 Thread Marcin Mierzejewski

Hi,

Try this:

class Entry(models.Model):
  ...
  tags = models.ManyToManyField( Tag )

  class Tags(self):
return self.tags.all()

class Tag(models.Model):
  ...

And now, Entry.Targs() returns all Tags related to the blog entry.

Regards,
Marcin

On Dec 13, 8:54 am, "Young Gyu Park" <[EMAIL PROTECTED]> wrote:
> class Entry(models.Model):
> blog = models.ForeignKey(Blog,related_name='entries')
> Title = models.CharField(maxlength=250, blank=False, null=False)
> Slug = models.SlugField(maxlength=250, blank=False, null=False,
> prepopulate_from=('Title',))
> Content = models.TextField(blank=False, null=False)
> Post_Date = models.DateTimeField(auto_now_add=True)
> tags = blog.select_relates().tags # models.ManyToManyField('Tag',
> blank=True, related_name='entries')
> Pictures = models.ForeignKey('Picture', blank=True, null=True,
> related_name='entries')
> Files = models.ForeignKey('File', blank=True, null=True,
> related_name='entries')
> # comments = models.ForeignKey(Comment, blank=True, null=True,
> related_name='entries')
> Is_Draft = models.BooleanField(default=False, help_text="Draft entries
> are visible only to the author and admins")
> Comments_Allowed = models.BooleanField(default=True)
> Trackbacks_Allowed = models.BooleanField(default=False)
>
> class Tag(models.Model):
> blog = models.ForeignKey(Blog,related_name='tags')
> Name = models.CharField(maxlength=250)
> Slug = models.SlugField(maxlength=250, prepopulate_from=('Name',))
> Total_ref = models.IntegerField(blank=True, default=0)
> Font_size = models.IntegerField(blank=True, default=0)
>
> This is the two table that I'm using.
>
> What I want to do is in this models that I want to refer the Tag list by not
> all tag list but Blog.tag list
>
> When I execute this code in the web, I can see the whole tag list.
> But I want to see the tag list belonged to blog's user
>
> If I can solve this problem in the template code, but I want to solve this
> problem in terms of models.
> Because this solution could be more neat.
>
> Give me a clue
>
> Thanks, always
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---