Re: superuser has no rights with newforms admin

2008-07-18 Thread joshuajenkins

Figured out what went wrong.  You now have to register your models
with the admin app, which will give you access.

If anyone else that is completely awful at Django is running into the
same problem let me know and I'll go in to more depth.

On Jul 18, 11:16 pm, joshuajenkins <[EMAIL PROTECTED]> wrote:
> Just upgraded to the new trunk which includes the newforms addition to
> the admin app, so obviously I'm very excited to play around with it.
>
> Decided to port over a very very new app, which is basically just a
> model definition at this point. However when I create my superuser and
> log in the admin site tells me I don't have permission to do anything.
>
> This is obviously extremely frustrating as there's nothing I can do
> from there, though I assume through the command line there is some way
> to enable that user as a superuser. Perhaps things are just different
> in the new admin app, but at the moment I am very stumped.
>
> Does anyone have any idea why this might be happening?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



superuser has no rights with newforms admin

2008-07-18 Thread joshuajenkins

Just upgraded to the new trunk which includes the newforms addition to
the admin app, so obviously I'm very excited to play around with it.

Decided to port over a very very new app, which is basically just a
model definition at this point. However when I create my superuser and
log in the admin site tells me I don't have permission to do anything.

This is obviously extremely frustrating as there's nothing I can do
from there, though I assume through the command line there is some way
to enable that user as a superuser. Perhaps things are just different
in the new admin app, but at the moment I am very stumped.

Does anyone have any idea why this might be happening?
--~--~-~--~~~---~--~~
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: Cookie content string error

2008-07-18 Thread 0sn

This is happening to me as well, only under modpython and not under
the test server. But it's not the session cookies, it's just cookies I
set myself.

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



problem with gettext at os x 10.4.11

2008-07-18 Thread zehi

Hey Django fellows,

Could somebody point me where is the problem. on my machine?

While I try to run:

django-admin.py makemessages -a

... I'm getting error message:

processing language ar
Error: errors happened while running xgettext on __init__.py
language `Python' unknown

I'm using Python 2.5, django from trunk, OS X 10.4.11.

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



Re: PATH problem?

2008-07-18 Thread Graham Dumpleton



On Jul 19, 7:24 am, "Álvaro J. Iradier" <[EMAIL PROTECTED]> wrote:
> Maybe this can be related:
>
> https://devel.airadier.com/default/blog/modpythonvirtualenvironments
>
> I found the same problem, modules being imported from the command line
> interpreter, but not frommod_python, and managed to workaround it as
> explained above.

FWIW, if using mod_wsgi such hacks aren't required as it
understand .pth files and virtual environments. See:

  http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

Graham


> On Wed, Jul 16, 2008 at 12:20 AM, Frantisek Malina <[EMAIL PROTECTED]> wrote:
>
> > Awesome Daniel. That was the one.
>
> > I've got the development server running on the deployment machine.
> > However, there is another PATH problem with Apache /mod_python
> > complaining about missing modules, even if those are on the spot:
>
> > ImproperlyConfigured: Error importing middleware
> > satchmo.shop.SSLMiddleware: "No module named
> > satchmo.shop.SSLMiddleware"
>
> >mod_pythontraceback:
> >http://dpaste.com/65217/
>
> > vhost.conf:
> >http://dpaste.com/65219/
>
> > Folder "httpdocs" contains a symlink "satchmo" to "/usr/lib/python2.5/
> > site-packages/satchmo"
>
> > What could be wrong here?
>
> --
> (:===:)
>  Alvaro J. Iradier Muro - [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: newforms-admin branch has been merged into trunk

2008-07-18 Thread Eric Abrahamsen

Beers all around!

On Jul 19, 2008, at 8:01 AM, Brian Rosner wrote:

>
> I have just recently merged the newforms-admin branch into trunk as of
> r7967 [1]. This is an extremely backward incompatible change. The
> entire admin application in contrib has been refactored. The newforms
> module has a few new features, but those changes are backward
> compatible. The branch also converted django.contrib.auth to use
> newforms. I have documented these changes in the usual place [2].
>
> I would like to thank Karen Tracey for her tremendous work triaging
> tickets, finding the root of problems and supplying patches where
> needed. Also, on behalf of the core developers involved with the
> branch we would like thank everyone who has tested the branch and
> reported bugs. Without your hard work and contribution we couldn't
> have made Django this much better without you! Thanks.
>
> Bugs should no longer be marked with version 'newforms-admin' as the
> branch is now closed.
>
> Onward to 1.0!
>
> [1]: http://code.djangoproject.com/changeset/7967
> [2]: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
>
>
> Brian Rosner
> http://oebfare.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: newforms-admin branch has been merged into trunk

2008-07-18 Thread Robvdl

Thanks for that, had a quick read and it looks like I don't need to
import each admin.py from all my own apps that way anymore either in
the __init__.py of each app, as autodiscover now handles all that,
nice. It bought back the Auth and Sites app too.

On Jul 19, 2:36 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Jul 18, 2008 at 10:11 PM, Robvdl <[EMAIL PROTECTED]> wrote:
>
> > Thanks very much for this
>
> > I have been running Newforms Admin for a while, so when the big
> > changeover was going to hit, I would be ready, not changing too much
> > existing code.
>
> > One thing I noticed now, running SVN 7968 vs my last checkout I did of
> > the old Newforms Admin branch (7871):
>
> >  - The Auth and Sites applications don't show in admin, like they
> > aren't registered with admin
>
> > However, these do show on the older Newforms Admin branch checkout.
>
> > Do we need to manually register these applications with admin now?? or
> > is this something that is still to be fixed?
>
> Since 7871 (in 7872, in fact) an autodiscover function was added to admin.
> You can see how it's recommended to be used if you search for autodiscover
> here:
>
> http://code.djangoproject.com/wiki/NewformsAdminBranch
>
> I'm guessing you don't call it and that is why the admin bits for those apps
> are not showing up.
>
> (But actually when I neglect to call it and then try to access the admin I
> get a Site Administration page saying I don't have permission to edit
> anything, so I can't replicate your symptoms exactly via that
> explanation...)
>
> 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
-~--~~~~--~~--~--~---



RSS feed dont work well with Internet Explorer

2008-07-18 Thread [EMAIL PROTECTED]

I use the Django syndication to generate RSS feeds for my site.

The feed is visible correctly in Firefox but Internet explorer v6x
cant really interpret this feed and tries to save it as a file.

I have tried using both - the RssFeed as well as the Atom1Feed

I noticed that the rss generated from django is missing the mime_type
= 'application/rss+xml' in the headers.

Any ideas ?

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



Re: newforms-admin branch has been merged into trunk

2008-07-18 Thread Robvdl

Thanks very much for this

I have been running Newforms Admin for a while, so when the big
changeover was going to hit, I would be ready, not changing too much
existing code.

One thing I noticed now, running SVN 7968 vs my last checkout I did of
the old Newforms Admin branch (7871):

 - The Auth and Sites applications don't show in admin, like they
aren't registered with admin

However, these do show on the older Newforms Admin branch checkout.

Do we need to manually register these applications with admin now?? or
is this something that is still to be fixed?

--~--~-~--~~~---~--~~
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 fields setting raises FieldDoesNotExist

2008-07-18 Thread Justin Myers

Ah, worked perfectly. Thanks so much!
-Justin

On Jul 18, 8:52 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> Python gothca: you've neglected to put a comma after 'slug' in 'fields':
> ('slug').  Single-element tuples need to have a comma after their one
> element to force them to be tuples.  In this case the single element is
> iterable so when code goes to iterate over every element in what it is
> expecting to be a tuple it iterates over every letter in the string.
>
> 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: Admin fields setting raises FieldDoesNotExist

2008-07-18 Thread Karen Tracey
On Fri, Jul 18, 2008 at 8:44 PM, Justin Myers <[EMAIL PROTECTED]> wrote:

>
> Hello again! Still working on the blogging app I mentioned a couple of
> days ago for my student newspaper. It's working on our production
> server right now (so some of the other editors can check it out and
> make suggestions), though I'll naturally be making some tweaks here
> and there.
>
> Right now, though, I'm having a bit of trouble with the admin
> interface. I'm trying to put the slugField into a collapsed field
> group, which we usually do to keep people from thinking they have to
> change it. For whatever reason, though, I keep getting 500s when I try
> to set it up this way. The error I'm getting (full traceback after
> this message) is "FieldDoesNotExist: Blog has no field named 's'".
>
> Here's the model:
>
> ---
>
> class Blog(models.Model):
>title = models.CharField(max_length=100)
>description = models.TextField()
>section = models.ForeignKey(Section,db_index=True)
>slug = models.SlugField(prepopulate_from=('title',),
> help_text="Used for URLs. Autogenerated from title.")
>
>def __unicode__(self):
>return self.title
>
>def get_absolute_url(self):
>return "/blogs/%s/" % self.slug
>
>class Meta:
>ordering = ['title']
>
>class Admin:
>list_display = ('title', 'section')
>fields = (
>(None, {'fields': ('title', 'description', 'section')}),
>("Don't touch unless you know what you're doing",
> {'fields': ('slug'), 'classes': 'collapse'}),
>)
>

Python gothca: you've neglected to put a comma after 'slug' in 'fields':
('slug').  Single-element tuples need to have a comma after their one
element to force them to be tuples.  In this case the single element is
iterable so when code goes to iterate over every element in what it is
expecting to be a tuple it iterates over every letter in the string.

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: newforms-admin branch has been merged into trunk

2008-07-18 Thread Chris H.

For those who aren't ready to move towards newforms-admin, Jacob has
created a notable_moments/pre-newforms-admin tag.

A BIG thanks to Brian and all those who had a hand in getting us to
this day!

Thanks!!

-C
--~--~-~--~~~---~--~~
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 fields setting raises FieldDoesNotExist

2008-07-18 Thread Justin Myers

Hello again! Still working on the blogging app I mentioned a couple of
days ago for my student newspaper. It's working on our production
server right now (so some of the other editors can check it out and
make suggestions), though I'll naturally be making some tweaks here
and there.

Right now, though, I'm having a bit of trouble with the admin
interface. I'm trying to put the slugField into a collapsed field
group, which we usually do to keep people from thinking they have to
change it. For whatever reason, though, I keep getting 500s when I try
to set it up this way. The error I'm getting (full traceback after
this message) is "FieldDoesNotExist: Blog has no field named 's'".

Here's the model:

---

class Blog(models.Model):
title = models.CharField(max_length=100)
description = models.TextField()
section = models.ForeignKey(Section,db_index=True)
slug = models.SlugField(prepopulate_from=('title',),
help_text="Used for URLs. Autogenerated from title.")

def __unicode__(self):
return self.title

def get_absolute_url(self):
return "/blogs/%s/" % self.slug

class Meta:
ordering = ['title']

class Admin:
list_display = ('title', 'section')
fields = (
(None, {'fields': ('title', 'description', 'section')}),
("Don't touch unless you know what you're doing",
{'fields': ('slug'), 'classes': 'collapse'}),
)

---

If I comment out the four lines at the end (the fields tuple),
everything works fine (except the slug field isn't collapsed), but as
soon as I uncomment them, I get the 500 I mentioned earlier. I'm
probably missing something pretty simple since I'm rather new to this,
but does anyone have any ideas what might be causing this?

Thanks!
-Justin

---

Traceback (most recent call last):

 File "/home/themaneater/lib/python2.5/django/core/handlers/base.py",
line 82, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/themaneater/lib/python2.5/django/contrib/admin/views/
decorators.py", line 62, in _checklogin
   return view_func(request, *args, **kwargs)

 File "/home/themaneater/lib/python2.5/django/views/decorators/
cache.py", line 44, in _wrapped_view_func
   response = view_func(request, *args, **kwargs)

 File "/home/themaneater/lib/python2.5/django/contrib/admin/views/
main.py", line 406, in change_stage
   return render_change_form(model, manipulator, c, change=True)

 File "/home/themaneater/lib/python2.5/django/contrib/admin/views/
main.py", line 203, in render_change_form
   field_sets = opts.admin.get_field_sets(opts)

 File "/home/themaneater/lib/python2.5/django/db/models/options.py",
line 494, in get_field_sets
   opts.get_field, fs_options['fields'], description))

 File "/home/themaneater/lib/python2.5/django/db/models/options.py",
line 505, in __init__
   self.field_lines = [AdminFieldLine(field_locator_func, line_spec)
for line_spec in line_specs]

 File "/home/themaneater/lib/python2.5/django/db/models/options.py",
line 525, in __init__
   self.fields = [field_locator_func(linespec)]

 File "/home/themaneater/lib/python2.5/django/db/models/options.py",
line 236, in get_field
   raise FieldDoesNotExist, '%s has no field named %r' %
(self.object_name, name)

FieldDoesNotExist: Blog has no field named 's'
--~--~-~--~~~---~--~~
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 + tiny_mce

2008-07-18 Thread theTrystero

I ran into problems with tinyMCE integration too... I ended up adding
the new line to urls.py in the wrong order.  D'oh.

Complete file looked like this:
from django.conf.urls.defaults import *

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

# Uncomment this for admin:
 (r'^admin/', include('django.contrib.admin.urls')),
 (r'', include('django.contrib.flatpages.urls')),
 (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
{'document_root': '/Users/userName/Development/django/sites/addin/
tinymce/jscripts'}),


)

Instead of this:
from django.conf.urls.defaults import *

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

# Uncomment this for admin:
 (r'^admin/', include('django.contrib.admin.urls')),
 (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
{'document_root': '/Users/userName/Development/django/sites/addin/
tinymce/jscripts'}),
 (r'', include('django.contrib.flatpages.urls')),

)

I initially thought the code in the book was a bit odd considering
that it's presented like this:
from django.conf.urls.defaults import *

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

# Uncomment this for admin:
 (r'^admin/', include('django.contrib.admin.urls')),
 (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
{'document_root': '/Users/userName/Development/django/sites/addin/
tinymce/jscripts'},
)

The tuple seems to be missing the closing parens, and the tuple list
isn't closed in the code.  Hope this helps someone sort things out :)
On Jul 9, 2:43 pm, LRP <[EMAIL PROTECTED]> wrote:
> Many many thanks to all who helped.
>
> Problem solved.
>
> There seem to have been two issues:
>
> 1) Mathias pointed out missing slash.
>
> 2) I'd copied only the top tiny_mce directory into my .../media/
> jscripts/tiny_mce directory.
>
> Mario, I'll definitely look at your note again when I try out django
> under Apache. But, for now, I'm still struggling with the
> fundamentals.
>
> I apologize to all for all the hassle stirred up by my clumsiness.
> This is a great list.
>
> Best wishes,
>
> Lloyd

--~--~-~--~~~---~--~~
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 has been merged into trunk

2008-07-18 Thread Ariel Mauricio Nunez Gomez
Thanks a lot!!

BTW: Bryan, you've gotta redo the commits visualization[1] for another big
explosion!!

[1] http://oebfare.com/blog/2008/jun/24/django-code_swarm/

--~--~-~--~~~---~--~~
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 has been merged into trunk

2008-07-18 Thread Frank Singleton

Brian Rosner wrote:
> I have just recently merged the newforms-admin branch into trunk as of  
> r7967 [1]. 

A BIG Thankyou to all involved !!


Cheers / Frank


--~--~-~--~~~---~--~~
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 has been merged into trunk

2008-07-18 Thread mtrier

On Jul 18, 8:01 pm, Brian Rosner <[EMAIL PROTECTED]> wrote:
> I have just recently merged the newforms-admin branch into trunk as of  
> r7967 [1]. This is an extremely backward incompatible change. The  
> entire admin application in contrib has been refactored. The newforms  
> module has a few new features, but those changes are backward  
> compatible. The branch also converted django.contrib.auth to use  
> newforms. I have documented these changes in the usual place [2].

Thank you Brian, and thank you to all the numerous contributors.  Your
work is very much appreciated.

Michael Trier
blog.michaeltrier.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
-~--~~~~--~~--~--~---



newforms-admin branch has been merged into trunk

2008-07-18 Thread Brian Rosner

I have just recently merged the newforms-admin branch into trunk as of  
r7967 [1]. This is an extremely backward incompatible change. The  
entire admin application in contrib has been refactored. The newforms  
module has a few new features, but those changes are backward  
compatible. The branch also converted django.contrib.auth to use  
newforms. I have documented these changes in the usual place [2].

I would like to thank Karen Tracey for her tremendous work triaging  
tickets, finding the root of problems and supplying patches where  
needed. Also, on behalf of the core developers involved with the  
branch we would like thank everyone who has tested the branch and  
reported bugs. Without your hard work and contribution we couldn't  
have made Django this much better without you! Thanks.

Bugs should no longer be marked with version 'newforms-admin' as the  
branch is now closed.

Onward to 1.0!

[1]: http://code.djangoproject.com/changeset/7967
[2]: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges


Brian Rosner
http://oebfare.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: Using multiple databases

2008-07-18 Thread [EMAIL PROTECTED]

Dan wrote:
>
> Most ideally we would like to have it so that the application uses DB1
> (defined in the settings.py file) as the main database, but when it's
> down to users, uses DB2.user as the users table.
> Currently we are thinking of using raw sql, but that would only be a
> last resort preferably. And at that point I'd be more scrambled on how
> to use authenticate together with it.
>
>
> If you are using MySQL, you can use the federated engine for tables 
> that are only "symlinks" to real tables in another database but will 
> act as normal tables when doing regular operations on them.
>
> It might be possible with other databases too, I don't know.
Hi Dan, thanks for the reply.
We are indeed using MySQL, and attemipting to symlink (as the mysql 
documentation at 
http://dev.mysql.com/doc/refman/5.0/en/symbolic-links-to-tables.html ) 
didn't work out ("SQL show index from `users` failed : Table 
'bingo.users' doesn't exist" is what webmin said)

If you're implying some other technique, I have no idea what you are 
talking about - could you please explain, or redirect to a page 
explaining it?

Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: inspectdb don't build model form MySQL

2008-07-18 Thread Karen Tracey
On Fri, Jul 18, 2008 at 7:42 AM, anoval <[EMAIL PROTECTED]> wrote:

>
> hi everyone,
>
> short summary says all about my problems, here is the case;
>
> --
> [snipped table definitions and basically empty models.py]
>
> did i do something wrong or it's the Django thing?
>
> oh, and yeah all tables are in the same schema...
>
> Thanks in advance,
>

Are you absolutely sure the settings.py you are using are pointing to the
database you expect?  It looks like inspectdb is finding an empty database.


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: Using multiple databases

2008-07-18 Thread Dan
> Most ideally we would like to have it so that the application uses DB1
> (defined in the settings.py file) as the main database, but when it's
> down to users, uses DB2.user as the users table.
> Currently we are thinking of using raw sql, but that would only be a
> last resort preferably. And at that point I'd be more scrambled on how
> to use authenticate together with it.
>
>
If you are using MySQL, you can use the federated engine for tables that are
only "symlinks" to real tables in another database but will act as normal
tables when doing regular operations on them.

It might be possible with other databases too, I don't know.

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



Newforms admin and custom widgets

2008-07-18 Thread Rob Hudson

Hello,

This is question my get long so I'll post the short version then the
longer more detailed version:

The short:
My goal is provide the user with an autocomplete AJAX widget to
quickly look up ISBNs. The ISBNs will end up in a text field in HTML
to be sent back to the backend where I'd like it split and save in the
ManyToMany field.

As a first deep foray into newforms I'm getting stuck at multiple
levels.

The long:

I have a Newsletter model with some basic fields.  I have a Special
model with FK to Newsletter and ManyToMany to books for book specials
to be included with the newsletter.  Since the Book model contains 16k
+ records the default admin for this takes forever to load and render
which makes it unusable.

I found a django snippet that I tried to adapt to create a
CommaSeparatedBooks(Field|Input) here:
http://www.djangosnippets.org/snippets/595/

>From there I'm trying to create a ModelForm from my Special model and
override the book field to use my custom Field.

Then I'm providing the FormSet to the StackedInline class to use.

At this point I'm getting an error when I load the admin:
Error while importing URLconf 'anglers.urls': 'ModelFormOptions'
object has no attribute 'many_to_many'.

So I've decided to come here for help and try to see where I've gone
astray.  See code below.

## admin.py

from django.contrib import admin
from django.db.models.fields.related import ManyToManyField
from django.newforms import ModelForm
from django.newforms.fields import Field
from django.newforms.models import modelformset_factory
from django.newforms.util import ValidationError
from django.newforms.widgets import Input
from anglers.book.models import Book
from anglers.newsletter.models import Newsletter, Special

# Widgets and Fields

class CommaSeparatedBooksInput(Input):
input_type = 'text'
def render(self, name, value, attrs=None):
if value is None:
value = ''
elif isinstance(value, (list, tuple)):
value = ', '.join([book.isbn for book in value])
return super(CommaSeparatedBooksInput, self).render(name,
value, attrs)

class CommaSeparatedBooksField(Field):
widget = CommaSeparatedBooksInput
def clean(self, value):
super(CommaSeparatedBooksField, self).clean(value)
if not value:
return ''
if isinstance(value, (list, tuple)):
return value
isbns = set(value.split(','))
isbns = set([isbn.strip() for isbn in isbns])
books = list(Book.objects.filter(isbn__in=isbns))
unknown_books = isbns ^ set([book.isbn_clean for book in
books])
if unknown_books:
raise ValidationError('Book ISBN values not found: %s' %
str(unknown_books))
return books

# ModelForms and FormSets

class SpecialBookForm(ModelForm):
books = CommaSeparatedBooksField()
class Meta:
model = Special

SpecialBookFormSet = modelformset_factory(SpecialBookForm)

# ModelAdmins with Inlines

class SpecialAdmin(admin.ModelAdmin):
list_display = ()
search_fields = ()
ordering = ()

class SpecialBookInline(admin.StackedInline):
model = Special
formset = SpecialBookFormSet

class NewsletterAdmin(admin.ModelAdmin):
list_display = ('start_date', 'end_date')
ordering = ('-start_date',)
inlines = (SpecialBookInline,)

admin.site.register(Newsletter, NewsletterAdmin)
admin.site.register(Special, SpecialAdmin)



## models.py

class Newsletter(models.Model):
message = models.TextField()
start_date = models.DateField(default=datetime.today)
end_date = models.DateField()

def __unicode__(self):
return u"Newsletter from %s to %s"

class Special(models.Model):
newsletter = models.ForeignKey(Newsletter)
header = models.CharField(max_length=200, core=True)
message = models.TextField()
books = models.ManyToManyField(Book)

Thanks for any guidance.

-Rob
--~--~-~--~~~---~--~~
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: Adding and removing template dirs on the fly

2008-07-18 Thread Arien

On Thu, Jul 17, 2008 at 8:04 AM, 3xM <[EMAIL PROTECTED]> wrote:
> I already tried loading templates a la
>
> '%s/name_of_template.html' % channel_template_folder
>
> but the result is that it when the template includes other templates,
> it will look for it in the same folder, not doing the fallback thing
> to the main generic template folder (as it is looking for something in
> a subfolder with the name of the value of channel_template_folder).
>
> Does it make sense?

Right, the includes will be relative to TEMPLATE_DIRS.

> I'll try to illustrate the current template structure to clarify:
>
> .../templates
>part_1.html
>part_2.html
>/channel_a
>part_1.html
>/channel_b
>part_2.html
>
> (I hope the identation in the above doesn't get ignored as whitespace)
>
> So, normally I load e.g. 'part_1.html' which, somewhere in it,
> includes 'part_2.html'. That works just fine.
>
> But for Channel A I used to load 'channel_a/part_1.html', which will
> also include 'part_2.html'. But now the template system will look for
> a file called 'channel_a/part_2.html' which doesn't exist.

The template system will only look for "part_2.html" under "channel_a"
if "channel_a" is in your TEMPLATE_DIRS.

> And for Channel B, where I only want 'part_2.html' to be different
> from the generic, I can't get it to work without adding
> 'templates/channel_b' to TEMPLATE_DIRS. A "solution" is to copy all
> templates each time I want to make differences, but that seems quite
> stupid to me.

Or you could leave TEMPLATE_DIRS alone and use this in "channel_b/part_1.html":

  {% include "channel_b/part_2.html" %}

> So what I want is to temporarily add 'templates/channel_b' to
> TEMPLATE_DIRS for requests for playlists from Channel B. Is it somehow
> possible?

But is it a good idea?

If it turns out that the only solution for your problem is to have
some fallback mechanism when including templates, you could always
write a template tag to do just that.  And maybe you can solve it
using some combination of template inheritance, inclusion and
select_template.


Arien

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



Using multiple databases

2008-07-18 Thread CPF_

Hi, I'm currently starting a project in django, and there's some data
already in another database.
We're planning to go and use that information (more specifically user
information) in the django application.

However, this forms several problems:
1) There are 2 different databases. A django settings.py file only
allows for one database (?) Is there any way to use the second
database using the database feature of django.
2) We would like to use the authenticate feature of django in the
application too. We are willing to change the users table, but we need
compatibility with other applications which use the same user
database.

Most ideally we would like to have it so that the application uses DB1
(defined in the settings.py file) as the main database, but when it's
down to users, uses DB2.user as the users table.
Currently we are thinking of using raw sql, but that would only be a
last resort preferably. And at that point I'd be more scrambled on how
to use authenticate together with it.

So, basically, preferably I would like to learn about a model method
to simply use that...

Thanks in advance!

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



ifequal with url pattern?

2008-07-18 Thread Eliza

Hi,

I'm new to Django and am working on a template, and I have the feeling
I may be approaching something the wrong way.

I have a navigation bar that is produced in the template, but needs to
look slightly different for each page, because it should have the menu
item for the current page highlighted.

My current approach is to have a series of {% ifequal ... %}
statements in the template, along these lines:
.
.
.
{% ifequal flatpage.url '/products/' %}
// draw the products menu item highlighted
{% endifequal %}
{% ifequal flatpage.url '/blog/' %}
// draw the blog menu item highlighted
{% endifequal %}

...and so on.

This works fine for now, but will break as soon as there are any sub-
pages under any of these sections. For example, I want to be able to
add a '/products/foo/' page, which contains detailed info about the
Foo product, and I want the "Products" menu bar item to remain
highlighted when this page is displayed. Since '/products/foo/' is not
equal to '/products/', the current code won't work for this.

One extremely inelegant solution would be to simply extend my list of
{% ifequal ... %}s in the template, to test for each sub-page of /
products/ separately. But the fact that this is even occurring to me
leads me to believe I'm going about this the wrong way.

Is there a better approach?

Thanks,
Eliza



--~--~-~--~~~---~--~~
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: i18n, how to denote context

2008-07-18 Thread Torsten Bronger

Hallöchen!

Ingrid Bronger writes:

> Malcolm Tredinnick writes:
>
>> [...]
>>
>> You have to make them different at the English level as well
>> then.  Gettext always merges identical source strings.
>
> Maybe Django could swallow a certain Unicode letter in
> ugettext_lazy ... then I could use it for the distinction?

I found another method, namely adding English translations, too.
Also not perfect but okay.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [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: PATH problem?

2008-07-18 Thread Álvaro J. Iradier

Maybe this can be related:

https://devel.airadier.com/default/blog/modpythonvirtualenvironments

I found the same problem, modules being imported from the command line
interpreter, but not from mod_python, and managed to workaround it as
explained above.


On Wed, Jul 16, 2008 at 12:20 AM, Frantisek Malina <[EMAIL PROTECTED]> wrote:
>
> Awesome Daniel. That was the one.
>
> I've got the development server running on the deployment machine.
> However, there is another PATH problem with Apache / mod_python
> complaining about missing modules, even if those are on the spot:
>
> ImproperlyConfigured: Error importing middleware
> satchmo.shop.SSLMiddleware: "No module named
> satchmo.shop.SSLMiddleware"
>
> mod_python traceback:
> http://dpaste.com/65217/
>
> vhost.conf:
> http://dpaste.com/65219/
>
> Folder "httpdocs" contains a symlink "satchmo" to "/usr/lib/python2.5/
> site-packages/satchmo"
>
> What could be wrong here?
> >
>



-- 
(:===:)
 Alvaro J. Iradier Muro - [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: Validation Implementation (architectural question) with newforms

2008-07-18 Thread Nash

Yesh, this looks like the fix. Thanks alot Karen!

On Jul 18, 8:01 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Jul 18, 2008 at 10:47 AM, Nash <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > There are loads of places to validate your data in django. You can do
> > it at the Model's field, at the Model.save() at the form's field level
> > clean_FIELD_NAME(), at the form level clean_data() etc.
>
> > If I have an Model with an email field, where do I write the validator
> > for it? Considering that my application would be using the ORM from
> > multiple locations and some not using the the newforms (say a XMPP
> > interface etc). It would makes sense to have the email validation at
> > the Model level.
>
> > The problem with this is that if I use newforms with the model via
> > (ModelForm), the generated form will not use my Model's email
> > validator that I have specified in my field's validator list.
>
> > What I'm looking for is a DRY method of specifying my validator for a
> > Model's field once and then have that propagated to the newforms.
> > Currently the ModelForm.is_valid() does not call the Model's
> > validator's. I can always try to catch the exception thrown when I
> > call form.save() but thats not very DRYy.
>
> > What has your experience been in this regard? And what would you
> > recommend? Thanks!
>
> Sounds like you want ticket #6845: Model validation and its propagation to
> ModelForms (http://code.djangoproject.com/ticket/6845).  You might want to
> try out the patch on that ticket.
>
> 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: i18n, how to denote context

2008-07-18 Thread Torsten Bronger

Hallöchen!

Malcolm Tredinnick writes:

> On Fri, 2008-07-18 at 22:33 +0200, Torsten Bronger wrote:
>
>> In one of my models, I have
>> 
>> from django.utils.translation import ugettext_lazy as _
>> 
>> ...
>> class Meta:
>> verbose_name = _("sample series")
>> verbose_name_plural = _("sample series")
>> 
>> However in German, both strings will be different.  How do I do
>> that?
>
> You have to make them different at the English level as well then.
> Gettext always merges identical source strings.

Maybe Django could swallow a certain Unicode letter in ugettext_lazy
... then I could use it for the distinction?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [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: i18n, how to denote context

2008-07-18 Thread Malcolm Tredinnick


On Fri, 2008-07-18 at 22:33 +0200, Torsten Bronger wrote:
> Hallöchen!
> 
> In one of my models, I have
> 
> from django.utils.translation import ugettext_lazy as _
> 
> ...
> class Meta:
> verbose_name = _("sample series")
> verbose_name_plural = _("sample series")
> 
> However in German, both strings will be different.  How do I do
> that?
> 

You have to make them different at the English level as well then.
Gettext always merges identical source strings.

Regards,
Malcolm



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



i18n, how to denote context

2008-07-18 Thread Torsten Bronger

Hallöchen!

In one of my models, I have

from django.utils.translation import ugettext_lazy as _

...
class Meta:
verbose_name = _("sample series")
verbose_name_plural = _("sample series")

However in German, both strings will be different.  How do I do
that?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [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: request getlist() in order?

2008-07-18 Thread Rob Hudson

Thanks Arien!
--~--~-~--~~~---~--~~
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: Nested for loops in template

2008-07-18 Thread brianmac44

That worked. I just updated my entries model to include comments =
generic.GenericRelation(FreeThreadedComment)

Thanks.

-Brian

On Jul 18, 12:30 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Brian, I think the solution is to add a GenericRelation to your entries
> model; 
> seehttp://www.djangoproject.com/documentation/contenttypes/#reverse-gene...
> an explanation.  I think that after doing this you'll be able to
> access
> p.comments.count (assuming that the generic relation is named "comments").
> I haven't used the contenttypes framework yet, but from the looks of it I
> believe that will work.
>
>   -- Scott
>
>
>
> On Fri, Jul 18, 2008 at 12:21 PM, brianmac44 <[EMAIL PROTECTED]> wrote:
>
> > Hi Scott,
> > Thanks for your help, but I'm still having trouble.
> > I using django-threadedcomments
> >http://code.google.com/p/django-threadedcomments/
> > so its a little confusing.
>
> > Here are my models
> >http://dpaste.com/65848/
>
> > -Brian
>
> > On Jul 18, 12:01 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> > > Brian, without knowing exactly how your models are configured, you can do
> > > something like this:
>
> > > {{ p.comment_set.count }}
>
> > > If you use it in more than one place (e.g., as {% if p.comment_set.count
> > %}
> > > ... {{ p.comment_set.count }} ...), you will want to optimize things so
> > that
> > > the SQL "COUNT()" query is executed only once:
>
> > > {% with p.comment_set.count as comment_count %}
> > >   {% if comment_count %} . . . {{ comment_count }} . . . {% endif %}
> > > {% endwith %}
>
> > > If you have any trouble getting this working, please let us have a look
> > at
> > > your entry and comment models (use dpaste.com) and we can help you
> > figure
> > > out exactly what to write.
>
> > >   -- Scott
>
> > > On Fri, Jul 18, 2008 at 11:47 AM, brianmac44 <[EMAIL PROTECTED]> wrote:
>
> > > > I have two tables, one is entries and the other is comments.
>
> > > > In the template I would like display how many comments for each entry
> > > > and some other entry data.
> > > > So far I have...
>
> > > > view:
> > > > entries_list = entries.objects.filter( ...)
>
> > > > template:
> > > > {% for p in object_list %}
> > > > 
> > > >        
> > > >                {{ p.name }}
> > > >        
> > > >         
> > > >                ...
> > > >        
> > > > 
> > > > {% endfor %}
>
> > > > How is this done? Should I use select_related in the view?
> > > > Thanks in advance.
>
> > > --http://scott.andstuff.org/|http://truthadorned.org/
>
> --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
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: Nested for loops in template

2008-07-18 Thread Scott Moonen
Brian, without knowing exactly how your models are configured, you can do
something like this:

{{ p.comment_set.count }}

If you use it in more than one place (e.g., as {% if p.comment_set.count %}
... {{ p.comment_set.count }} ...), you will want to optimize things so that
the SQL "COUNT()" query is executed only once:

{% with p.comment_set.count as comment_count %}
  {% if comment_count %} . . . {{ comment_count }} . . . {% endif %}
{% endwith %}

If you have any trouble getting this working, please let us have a look at
your entry and comment models (use dpaste.com) and we can help you figure
out exactly what to write.

  -- Scott

On Fri, Jul 18, 2008 at 11:47 AM, brianmac44 <[EMAIL PROTECTED]> wrote:

>
> I have two tables, one is entries and the other is comments.
>
> In the template I would like display how many comments for each entry
> and some other entry data.
> So far I have...
>
> view:
> entries_list = entries.objects.filter( ...)
>
> template:
> {% for p in object_list %}
> 
>
>{{ p.name }}
>
> 
>...
>
> 
> {% endfor %}
>
> How is this done? Should I use select_related in the view?
> Thanks in advance.
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

--~--~-~--~~~---~--~~
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 Pickling Querysets

2008-07-18 Thread Ed Menendez

Ticket #7813. Let me know if I messed up the ticket report!! :-)

Thanks,

- Ed


On Jul 18, 11:43 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-07-18 at 09:34 -0700, Ed Menendez wrote:
> > I saw a previously closed ticket 7506 for a related (no pun intended)
> > problem. It seems like when we use select_related suddenly the
> > queryset can't be pickled. This used to work back in May sometime.
> > Currently using SVN 7944.
>
> Pickling should always work, so this is a bug. Can you open a ticket
> containing a small example showing the problem so we don't lose it,
> please?
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems Pickling Querysets

2008-07-18 Thread Malcolm Tredinnick


On Fri, 2008-07-18 at 09:34 -0700, Ed Menendez wrote:
> I saw a previously closed ticket 7506 for a related (no pun intended)
> problem. It seems like when we use select_related suddenly the
> queryset can't be pickled. This used to work back in May sometime.
> Currently using SVN 7944.

Pickling should always work, so this is a bug. Can you open a ticket
containing a small example showing the problem so we don't lose it,
please?

Regards,
Malcolm



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



Multiple host for one single django project

2008-07-18 Thread Leon Yeh | New Avenue.net

Hi,

I have been using one domain name for my django project. 
http://www.example.com.


Now I need to add new domain name http://blog.example.com. In the new 
domain name, all the pattern should be same the main host(www) with one 
different pattern. For blog site, for ^$ pattern go to a different view.

I tried to look into multihost middleware and site middleware, and I 
think those approach is a bit overkill for my problem.

Is there anyway to have urlpattern to look into the host name portion of 
the url? I was hoping to do all of this into urls.py.

Thanks in advance
Leon Yeh


--~--~-~--~~~---~--~~
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: Nested for loops in template

2008-07-18 Thread Scott Moonen
Brian, I think the solution is to add a GenericRelation to your entries
model; see
http://www.djangoproject.com/documentation/contenttypes/#reverse-generic-relationsfor
an explanation.  I think that after doing this you'll be able to
access
p.comments.count (assuming that the generic relation is named "comments").
I haven't used the contenttypes framework yet, but from the looks of it I
believe that will work.

  -- Scott

On Fri, Jul 18, 2008 at 12:21 PM, brianmac44 <[EMAIL PROTECTED]> wrote:

>
> Hi Scott,
> Thanks for your help, but I'm still having trouble.
> I using django-threadedcomments
> http://code.google.com/p/django-threadedcomments/
> so its a little confusing.
>
> Here are my models
> http://dpaste.com/65848/
>
> -Brian
>
> On Jul 18, 12:01 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> > Brian, without knowing exactly how your models are configured, you can do
> > something like this:
> >
> > {{ p.comment_set.count }}
> >
> > If you use it in more than one place (e.g., as {% if p.comment_set.count
> %}
> > ... {{ p.comment_set.count }} ...), you will want to optimize things so
> that
> > the SQL "COUNT()" query is executed only once:
> >
> > {% with p.comment_set.count as comment_count %}
> >   {% if comment_count %} . . . {{ comment_count }} . . . {% endif %}
> > {% endwith %}
> >
> > If you have any trouble getting this working, please let us have a look
> at
> > your entry and comment models (use dpaste.com) and we can help you
> figure
> > out exactly what to write.
> >
> >   -- Scott
> >
> >
> >
> > On Fri, Jul 18, 2008 at 11:47 AM, brianmac44 <[EMAIL PROTECTED]> wrote:
> >
> > > I have two tables, one is entries and the other is comments.
> >
> > > In the template I would like display how many comments for each entry
> > > and some other entry data.
> > > So far I have...
> >
> > > view:
> > > entries_list = entries.objects.filter( ...)
> >
> > > template:
> > > {% for p in object_list %}
> > > 
> > >
> > >{{ p.name }}
> > >
> > > 
> > >...
> > >
> > > 
> > > {% endfor %}
> >
> > > How is this done? Should I use select_related in the view?
> > > Thanks in advance.
> >
> > --http://scott.andstuff.org/|http://truthadorned.org/
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

--~--~-~--~~~---~--~~
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: Heavy database query (max 32 tables problem)

2008-07-18 Thread Scott Moonen
Norman, unfortunately I think he's asking for the mutual intersection of the
users' courses, not the union.

  -- Scott

On Fri, Jul 18, 2008 at 11:49 AM, Norman Harman <[EMAIL PROTECTED]>
wrote:

>
> Deniz Dogan wrote:
> > Hey.
> >
> > I have a model Course and then I have django.contrib.auth.models.User.
> > Users and courses are related through M2M, so a user can register for
> > many courses and a course can register multiple users. Now, given a
> > potentially very long list of users, I want to retrieve all the
> > courses for which all of those users have registered. Currently I have
> > implemented it in this manner:
> >
> > courses = Course.objects.all()
> > for user in users:
> >   courses = courses.filter(users=user)
> > courses = courses.distinct()
> >
> > As you might expect, I get the "maximum 32 tables in a join" error
> > when having a very long list of users. How would I go about doing what
> > I want here?
>
> http://www.djangoproject.com/documentation/db-api/#in
>
> user_ids = [u.id for u in users]
> # or user_ids = User.objects.values_list("id", flat=true)
> courses = Course.objects.filter(users__id__in=user_ids)
>
> I've used 'in' with a many hundreds ids.  Have no idea how performant it
> is compared to other solutions.
>
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> You've got fun!  Check out Austin360.com for all the entertainment
> info you need to live it up in the big city!
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

--~--~-~--~~~---~--~~
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 Pickling Querysets

2008-07-18 Thread Ed Menendez

I saw a previously closed ticket 7506 for a related (no pun intended)
problem. It seems like when we use select_related suddenly the
queryset can't be pickled. This used to work back in May sometime.
Currently using SVN 7944.

Here's the model:

class LeagueSeason(models.Model):
is_conference_used  = models.BooleanField(default=False)
is_division_used= models.BooleanField(default=False)

class LeagueConference(models.Model):
league_season   = models.ForeignKey(LeagueSeason)
name= models.CharField(max_length=50)
# slug is not unique by itself.
slug= models.CharField(max_length=50,
prepopulate_from=('name',), db_index=True)
sort_order  = models.SmallIntegerField(default=1)

class LeagueDivision(models.Model):
league_conference   = models.ForeignKey(LeagueConference)
name= models.CharField(max_length=50)
# slug is not unique by itself.
slug= models.CharField(max_length=50,
prepopulate_from=('name',), db_index=True)
sort_order  = models.SmallIntegerField(default=1)


# This works
ld = LeagueDivision.objects.all()
cache.set('test2', ld)

# This doesn't work
ld = LeagueDivision.objects.select_related('league_conference').all()
cache.set('test2', ld)

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\django\core\cache\backends
\memcached.py", line 35, in set
self._cache.set(smart_str(key), value, timeout or
self.default_timeout)
  File "C:\Projects\pyapps\memcache.py", line 437, in set
return self._set("set", key, val, time, min_compress_len)
  File "C:\Projects\pyapps\memcache.py", line 609, in _set
store_info = self._val_to_store_info(val, min_compress_len, key)
  File "C:\Projects\pyapps\memcache.py", line 581, in
_val_to_store_info
pickler.dump(val)
  File "C:\Python25\lib\copy_reg.py", line 71, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects

Is this supposed to be supported? Did we just get lucky when it used
to work in a previous version? Let me know if you need more info!

- Ed

--~--~-~--~~~---~--~~
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: Heavy database query (max 32 tables problem)

2008-07-18 Thread Norman Harman

Deniz Dogan wrote:
> Hey.
> 
> I have a model Course and then I have django.contrib.auth.models.User.
> Users and courses are related through M2M, so a user can register for
> many courses and a course can register multiple users. Now, given a
> potentially very long list of users, I want to retrieve all the
> courses for which all of those users have registered. Currently I have
> implemented it in this manner:
> 
> courses = Course.objects.all()
> for user in users:
>   courses = courses.filter(users=user)
> courses = courses.distinct()
> 
> As you might expect, I get the "maximum 32 tables in a join" error
> when having a very long list of users. How would I go about doing what
> I want here?

http://www.djangoproject.com/documentation/db-api/#in

user_ids = [u.id for u in users]
# or user_ids = User.objects.values_list("id", flat=true)
courses = Course.objects.filter(users__id__in=user_ids)

I've used 'in' with a many hundreds ids.  Have no idea how performant it 
is compared to other solutions.


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

--~--~-~--~~~---~--~~
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: Nested for loops in template

2008-07-18 Thread brianmac44

Hi Scott,
Thanks for your help, but I'm still having trouble.
I using django-threadedcomments 
http://code.google.com/p/django-threadedcomments/
so its a little confusing.

Here are my models
http://dpaste.com/65848/

-Brian

On Jul 18, 12:01 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Brian, without knowing exactly how your models are configured, you can do
> something like this:
>
> {{ p.comment_set.count }}
>
> If you use it in more than one place (e.g., as {% if p.comment_set.count %}
> ... {{ p.comment_set.count }} ...), you will want to optimize things so that
> the SQL "COUNT()" query is executed only once:
>
> {% with p.comment_set.count as comment_count %}
>   {% if comment_count %} . . . {{ comment_count }} . . . {% endif %}
> {% endwith %}
>
> If you have any trouble getting this working, please let us have a look at
> your entry and comment models (use dpaste.com) and we can help you figure
> out exactly what to write.
>
>   -- Scott
>
>
>
> On Fri, Jul 18, 2008 at 11:47 AM, brianmac44 <[EMAIL PROTECTED]> wrote:
>
> > I have two tables, one is entries and the other is comments.
>
> > In the template I would like display how many comments for each entry
> > and some other entry data.
> > So far I have...
>
> > view:
> > entries_list = entries.objects.filter( ...)
>
> > template:
> > {% for p in object_list %}
> > 
> >        
> >                {{ p.name }}
> >        
> >         
> >                ...
> >        
> > 
> > {% endfor %}
>
> > How is this done? Should I use select_related in the view?
> > Thanks in advance.
>
> --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Standard documentation method.

2008-07-18 Thread Chris

hello,
Does django have a preferred method of commenting on code in
docstrings? I notice that there is some specific ways that some
applications write documentation in their code but didn't know if
django had some kind of preferred method. I would like to be able to
parse in my code documentation on the backend using docutils but I
noticed that I get errors b/c my strings are not formatted a specific
way.
--~--~-~--~~~---~--~~
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: Heavy database query (max 32 tables problem)

2008-07-18 Thread [EMAIL PROTECTED]

Theres no need for that list comprehension, you can just do

Course.objects.filter(users__in=users)

On Jul 18, 10:49 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Deniz Dogan wrote:
> > Hey.
>
> > I have a model Course and then I have django.contrib.auth.models.User.
> > Users and courses are related through M2M, so a user can register for
> > many courses and a course can register multiple users. Now, given a
> > potentially very long list of users, I want to retrieve all the
> > courses for which all of those users have registered. Currently I have
> > implemented it in this manner:
>
> > courses = Course.objects.all()
> > for user in users:
> >   courses = courses.filter(users=user)
> > courses = courses.distinct()
>
> > As you might expect, I get the "maximum 32 tables in a join" error
> > when having a very long list of users. How would I go about doing what
> > I want here?
>
> http://www.djangoproject.com/documentation/db-api/#in
>
> user_ids = [u.id for u in users]
> # or user_ids = User.objects.values_list("id", flat=true)
> courses = Course.objects.filter(users__id__in=user_ids)
>
> I've used 'in' with a many hundreds ids.  Have no idea how performant it
> is compared to other solutions.
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> You've got fun!  Check out Austin360.com for all the entertainment
> info you need to live it up in the big city!
--~--~-~--~~~---~--~~
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: Changing the value of the primary key

2008-07-18 Thread J Meier



On Jul 18, 7:41 am, Torsten Bronger <[EMAIL PROTECTED]>
wrote:
> > Can I ask why you would need to change PKs?
>
> Yes.  We are a scientific institution, and I create a samples
> database.  Frequently a sample gets a new name, however, the old
> name(s) must be kept as aliases.
>
> For the aliases, I probably will use a second table with many-to-one
> relationship.
>
> I wanted to keep the (current) sample name the primary key because I
> think that this accelerates lookup, but if all else fails, I must
> use a surrogate key.

Clearly, a growing set of names is not a sufficiently unique and
immutable primary key for your data. I'd suggest something like a
composite key made of date/time, sample no.,  and fk to experiment
(whatever an experiment's pk is), but django doesn't support composite
keys. So a "surrogate" is a good compromise here. As for names, since
each sample can have multiple names, it should be a separate table
with a foreign key to the samples table.

class Experiment(models.Model):
date = ...
etc 

class Sample(models.Model):
experiment = models.ForeignKey(Experiment)
date = models.DateTimeField()
sampleno = models.PositiveIntegerField()
... data ...
   class Meta:
   unique_together = (('experiment', 'date', 'sampleno'),)

class SampleName(models.Model):
sample = models.ForeignKey(Sample)
name = models.CharField(max_length = 60)
named = models.DateTimeField()

Primary keys never change over time.

-Jim
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Nested for loops in template

2008-07-18 Thread brianmac44

I have two tables, one is entries and the other is comments.

In the template I would like display how many comments for each entry
and some other entry data.
So far I have...

view:
entries_list = entries.objects.filter( ...)

template:
{% for p in object_list %}


{{ p.name }}

 
...


{% endfor %}

How is this done? Should I use select_related in the view?
Thanks in advance.

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



Re: Changing the value of the primary key

2008-07-18 Thread Torsten Bronger

Hallöchen!

Dan writes:

> [...]
>
> I don't think it's best practice to give meaningful names to
> primary key field in Django, you should probably have field name
> and let Django auto-create a id field.

You're right.  I now also think that Django's abstraction layer for
the RDBMS -- albeit thin -- means that you're better off with
unique=True fields in all cases.  The common advantages of primary
keys are mimicked by Django very well.

I only hope that InnoDB's lookup works for unique=True fields as
fast as for primary_key=True fields ...  ;-)

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [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: newforms-admin weird error ( 'str' object has no attribute '_default_manager' )

2008-07-18 Thread Karen Tracey
On Fri, Jul 18, 2008 at 10:57 AM, Bram de Jong <[EMAIL PROTECTED]>
wrote:

>
> Hello all,
>
> just updated to latest newforms-admin (r7947) and
>

Do you know what level you updated from?  That's always handy to know when
trying to pinpoint when a problem was introduced.


> This is the admin for one of my (rather large) models:
>
> class Sound(SocialModel): # SocialModel is a model that defines some
> GenericRelation
>user = models.ForeignKey(User)
># snip
>license = models.ForeignKey(License)
>geotag = models.ForeignKey(GeoTag, null=True, blank=True, default=None)
>#snip
>sources = models.ManyToManyField('self', symmetrical=False,
> related_name='remixes', blank=True)
>pack = models.ForeignKey('Pack', null=True, blank=True, default=None)
>#snip
>type = models.CharField(db_index=True, max_length=4,
> choices=SOUND_TYPE_CHOICES)
>#
>
> class SoundAdmin(admin.ModelAdmin):
>raw_id_fields = ('user', 'pack', 'sources', 'geotag')
>list_display = ('id', 'user', 'original_filename', 'license')
>list_filter = ('processing_state', 'moderation_state', 'license')
>fieldsets = (
> (None, {'fields': ('user', 'created', 'modified')}),
> ('Filenames', {'fields': ('original_path', 'base_filename_slug')}),
> ('User defined fields', {'fields': ('description', 'license',
> 'geotag', 'original_filename', 'sources', 'pack')}),
> ('File properties', {'fields': ('md5', 'type', 'duration',
> 'bitrate', 'bitdepth', 'samplerate', 'filesize', 'channels')}),
> ('Moderation', {'fields': ('moderation_state',
> 'moderation_date', 'moderation_bad_description')}),
> ('Processing', {'fields': ('processing_state',
> 'processing_date', 'processing_log')}),
> )
> admin.site.register(Sound, SoundAdmin)
>
>
> And this is the error I get when validating:
>

So it's got something to do with validation.  Do you know if it worked at
all after validation of ModelAdmin was added (r7929) and has broken
subsequently, or if it broke as soon as ModelAdmin validation was added?


> [snip Traceback start]
>  184. def fields_for_model(model, fields=None, exclude=None,
> formfield_callback=lambda f: f.formfield()):
> File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/fields/related.py"
> in formfield
>  685. defaults = {'form_class': forms.ModelChoiceField,
> 'queryset':
> self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)}
>
> Exception Type: AttributeError at /account/upload/
> Exception Value: 'str' object has no attribute '_default_manager'
>
>
> The error goes away when I remove the fieldsets definition.
>

Determining which part of the fieldsets definition generates the error would
be helpful.  You might be able to determine it by looking at the local vars
in the debug page.  Alternatively you could experiment with removing pieces
of it to see which field is causing the error.  Basic fieldsets validation
works (I'm sure it's got tests and I have models that use it and still work
on current newforms-admin), so it's something specific to your model.  If
you could strip your models down to a reasonably simple testcase that
displays the error it would be helpful.

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: How to switch/force a language from inside a usual view function?

2008-07-18 Thread Valery Khamenya

Hi Malcolm,

it worked out, many thanks for the great help!

best regards
--
Valery

--~--~-~--~~~---~--~~
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: similar method for get_or_create()

2008-07-18 Thread Malcolm Tredinnick


On Fri, 2008-07-18 at 02:57 -0700, leppy wrote:
> hi everyone,
> 
> Can anyone tell me a method similar to django model's get_or_create
> for updating an object with a particular id only when it exists, or
> else to create a new object.

That's exactly what the save() method on a model does.

Perhaps you should explain the problem you're really trying to solve
here if calling save() doesn't do what you are looking for.

Regards,
Malcolm



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



Re: Validation Implementation (architectural question) with newforms

2008-07-18 Thread Karen Tracey
On Fri, Jul 18, 2008 at 10:47 AM, Nash <[EMAIL PROTECTED]> wrote:

>
> Hi all,
>
> There are loads of places to validate your data in django. You can do
> it at the Model's field, at the Model.save() at the form's field level
> clean_FIELD_NAME(), at the form level clean_data() etc.
>
> If I have an Model with an email field, where do I write the validator
> for it? Considering that my application would be using the ORM from
> multiple locations and some not using the the newforms (say a XMPP
> interface etc). It would makes sense to have the email validation at
> the Model level.
>
> The problem with this is that if I use newforms with the model via
> (ModelForm), the generated form will not use my Model's email
> validator that I have specified in my field's validator list.
>
> What I'm looking for is a DRY method of specifying my validator for a
> Model's field once and then have that propagated to the newforms.
> Currently the ModelForm.is_valid() does not call the Model's
> validator's. I can always try to catch the exception thrown when I
> call form.save() but thats not very DRYy.
>
> What has your experience been in this regard? And what would you
> recommend? Thanks!
>

Sounds like you want ticket #6845: Model validation and its propagation to
ModelForms (http://code.djangoproject.com/ticket/6845).  You might want to
try out the patch on that ticket.

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
-~--~~~~--~~--~--~---



newforms-admin weird error ( 'str' object has no attribute '_default_manager' )

2008-07-18 Thread Bram de Jong

Hello all,

just updated to latest newforms-admin (r7947) and


This is the admin for one of my (rather large) models:

class Sound(SocialModel): # SocialModel is a model that defines some
GenericRelation
user = models.ForeignKey(User)
# snip
license = models.ForeignKey(License)
geotag = models.ForeignKey(GeoTag, null=True, blank=True, default=None)
#snip
sources = models.ManyToManyField('self', symmetrical=False,
related_name='remixes', blank=True)
pack = models.ForeignKey('Pack', null=True, blank=True, default=None)
#snip
type = models.CharField(db_index=True, max_length=4,
choices=SOUND_TYPE_CHOICES)
#

class SoundAdmin(admin.ModelAdmin):
raw_id_fields = ('user', 'pack', 'sources', 'geotag')
list_display = ('id', 'user', 'original_filename', 'license')
list_filter = ('processing_state', 'moderation_state', 'license')
fieldsets = (
 (None, {'fields': ('user', 'created', 'modified')}),
 ('Filenames', {'fields': ('original_path', 'base_filename_slug')}),
 ('User defined fields', {'fields': ('description', 'license',
'geotag', 'original_filename', 'sources', 'pack')}),
 ('File properties', {'fields': ('md5', 'type', 'duration',
'bitrate', 'bitdepth', 'samplerate', 'filesize', 'channels')}),
 ('Moderation', {'fields': ('moderation_state',
'moderation_date', 'moderation_bad_description')}),
 ('Processing', {'fields': ('processing_state',
'processing_date', 'processing_log')}),
 )
admin.site.register(Sound, SoundAdmin)


And this is the error I get when validating:

Traceback:
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  85. response = callback(request, *callback_args,
**callback_kwargs)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/decorators.py"
in __call__
  66. if self.test_func(request.user):
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/middleware.py"
in __get__
  5. request._cached_user = get_user(request)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/__init__.py"
in get_user
  80. user_id = request.session[SESSION_KEY]
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/sessions/backends/base.py"
in __getitem__
  33. return self._session[key]
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/sessions/backends/base.py"
in _get_session
  147. self._session_cache = self.load()
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/sessions/backends/db.py"
in load
  20. expire_date__gt=datetime.datetime.now()
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/manager.py"
in get
  82. return self.get_query_set().get(*args, **kwargs)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py"
in get
  296. clone = self.filter(*args, **kwargs)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py"
in filter
  479. return self._filter_or_exclude(False, *args, **kwargs)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py"
in _filter_or_exclude
  497. clone.query.add_q(Q(*args, **kwargs))
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py"
in add_q
  1159. can_reuse=used_aliases)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py"
in add_filter
  1037. alias, True, allow_many, can_reuse=can_reuse)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py"
in setup_joins
  1197. field, model, direct, m2m = opts.get_field_by_name(name)
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in get_field_by_name
  274. cache = self.init_name_map()
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in init_name_map
  300. for f, model in self.get_all_related_m2m_objects_with_model():
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in get_all_related_m2m_objects_with_model
  377. cache = self._fill_related_many_to_many_cache()
File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/

Heavy database query (max 32 tables problem)

2008-07-18 Thread Deniz Dogan

Hey.

I have a model Course and then I have django.contrib.auth.models.User.
Users and courses are related through M2M, so a user can register for
many courses and a course can register multiple users. Now, given a
potentially very long list of users, I want to retrieve all the
courses for which all of those users have registered. Currently I have
implemented it in this manner:

courses = Course.objects.all()
for user in users:
  courses = courses.filter(users=user)
courses = courses.distinct()

As you might expect, I get the "maximum 32 tables in a join" error
when having a very long list of users. How would I go about doing what
I want here?

Deniz

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Validation Implementation (architectural question) with newforms

2008-07-18 Thread Nash

Hi all,

There are loads of places to validate your data in django. You can do
it at the Model's field, at the Model.save() at the form's field level
clean_FIELD_NAME(), at the form level clean_data() etc.

If I have an Model with an email field, where do I write the validator
for it? Considering that my application would be using the ORM from
multiple locations and some not using the the newforms (say a XMPP
interface etc). It would makes sense to have the email validation at
the Model level.

The problem with this is that if I use newforms with the model via
(ModelForm), the generated form will not use my Model's email
validator that I have specified in my field's validator list.

What I'm looking for is a DRY method of specifying my validator for a
Model's field once and then have that propagated to the newforms.
Currently the ModelForm.is_valid() does not call the Model's
validator's. I can always try to catch the exception thrown when I
call form.save() but thats not very DRYy.

What has your experience been in this regard? And what would you
recommend? 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: SVN checkout for users without access to SVN

2008-07-18 Thread warsng

without all the SVN cruft 


http://warsng.googlepages.com/django-trunk.7z



On Jul 18, 12:35 pm, warsng <[EMAIL PROTECTED]> wrote:
> Thanks, much appreciated guys.
>
> On Jul 18, 11:48 am, Phillip Parrin <[EMAIL PROTECTED]> wrote:
>
> > there ya go,http://silver.parrin.nl/~phillip/django.tgz
>
> > On Jul 18, 12:39 pm, warsng <[EMAIL PROTECTED]> wrote:
>
> > > I cannot install SVN on the machine i am currently accessing the
> > > internet through, is it possible for someone to provide me with a
> > > tarball/zip of the latest SVN co? Or is this hidden somewhere on the
> > > django site?
--~--~-~--~~~---~--~~
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: Changing the value of the primary key

2008-07-18 Thread Dan
>
>
> Are you saying that Django adds the "ON UPDATE CASCADE" to the database
> definition? I've never noticed it doing this (unless you're using a
> patch that I submitted that does this for Foreign Keys where tell it to
> do so).
>
> Or, are you saying that Django emulates this behavior? I don't think
> that's correct either (see the URL I reference below).
>

I was under the assumption it was doing this as it was creating foreign key
constraints, I might be wrong.

> Yes.  We are a scientific institution, and I create a samples
> database.  Frequently a sample gets a new name, however, the old
> name(s) must be kept as aliases.

> For the aliases, I probably will use a second table with many-to-one
> relationship.

I don't think it's best practice to give meaningful names to primary key
field in Django, you should probably have field name and let Django
auto-create a id field. The relationship table is a good idea but if you
want to alias different models, you could take a look at generic
relationship and "tag" your samples with the old names.

--~--~-~--~~~---~--~~
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: similar method for get_or_create()

2008-07-18 Thread R. Gorman

Why do you need a method other than get_or_create?  Could you not try
to retrieve the object using get_or_create and then update the object
if retrieved?

R.

On Jul 18, 5:57 am, leppy <[EMAIL PROTECTED]> wrote:
> hi everyone,
>
> Can anyone tell me a method similar to django model's get_or_create
> for updating an object with a particular id only when it exists, or
> else to create a new object.
>
> Thanks in advance.
> leppy.
--~--~-~--~~~---~--~~
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: Changing the value of the primary key

2008-07-18 Thread Michael Glassford

Torsten Bronger wrote:
> Hallöchen!
> 
> Dan writes:
> 
>> Django sets this for you if your database supports it (ie: you are
>> using postgres or mysql with innodb tables). >If you are using
>> mysql, check that tables aren't MyISAM.

Are you saying that Django adds the "ON UPDATE CASCADE" to the database 
definition? I've never noticed it doing this (unless you're using a 
patch that I submitted that does this for Foreign Keys where tell it to 
do so).

Or, are you saying that Django emulates this behavior? I don't think 
that's correct either (see the URL I reference below).

Maybe I misunderstood you?

> Okay, I have InnoDB.
> 
>> If you want to do this inside Django, more complex because if you
>> change an object's primary key, Django concludes that you want to
>> work with another row altogether and doesn't modify your original
>> row.
> 
> So what happens when I say
> 
> my_db_object.its_primary_key = new_value
> my_db_object.save()
> 
> ?  Is a new object created or the row changed?  

A new row is created--unless you change it to a value of an 
already-existing row. See 
http://www.djangoproject.com/documentation/db-api/#how-django-knows-to-update-vs-insert.

 > If the first, how do
> I change the value at all?
> 
>> Can I ask why you would need to change PKs?
> 
> Yes.  We are a scientific institution, and I create a samples
> database.  Frequently a sample gets a new name, however, the old
> name(s) must be kept as aliases.
> 
> For the aliases, I probably will use a second table with many-to-one
> relationship.
> 
> I wanted to keep the (current) sample name the primary key because I
> think that this accelerates lookup, but if all else fails, I must
> use a surrogate key.
> 
> Tschö,
> Torsten.
> 
> 
> On Fri, Jul 18, 2008 at 7:58 AM, Torsten Bronger <[EMAIL PROTECTED]> wrote:
> 
> 
> Hallöchen!
> 
> When I change the value of a primary key field (assuming that it is
> still unique), are depending tables also updated?  I found on the
> net that "ON UPDATE CASCADE" has to be set for the child tables, but
> I didn't find anything Django-related.
> 
> Tschö,
> Torsten.
> 
> --
> Torsten Bronger, aquisgrana, europa vetus
>   Jabber ID: [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
-~--~~~~--~~--~--~---



parent query for child

2008-07-18 Thread Casey Deccio

Hi,

I'm looking for a good way to filter a query of a parent class for
specific children.  For example, given the model:

from django.contrib.auth.models import Group

class Team(Group):
pass

I want to find out which teams a user is a member of:

>>> g = Group.objects.create(name='group1')
>>> t = Team.objects.create(name='team1')
>>> u = User.objects.create(username='val')
>>> u.groups = (g,t)
>>> u.groups.filter(team__isnull=False)
[]

However, instead this returns:

>>> u.groups.filter(team__isnull=False)
[, ]

Up until a few weeks ago (not sure which changeset), this worked:
>>> u.groups.filter(team__pk__isnull=False)
[]

but it no longer works.  Perhaps the join between the child and parent
has been optimized out?  I've also tried each of the following, none
of which works:

>>> u.groups.select_related(depth=1).filter(team__pk__isnull=False)
[, ]
>>> u.groups.select_related(depth=1).filter(team__isnull=False)
[, ]

One thing does work is filtering by a field in the parent model
because it forces the join between the parent and child.  But it seems
like a kludge:

>>> Group.objects.filter(team__name__isnull=False)
[]

Any other ideas?

Thanks,
Casey

--~--~-~--~~~---~--~~
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 and commit=False

2008-07-18 Thread Rajesh Dhawan

Hi,

> > Take a look at how Form Preview works. You should be able to adapt
> > that to your above workflow:
> >http://www.djangoproject.com/documentation/form_preview/
>
> Thanks , that looks exactly like what I need!
> I do not think however it is possible to use it with uploads as
> django/contrib/formtools/preview.py does not seem to bind the upload
> file to the form :

Right and for a good reason. The second stage of the preview form
renders all of the submitted form fields as hidden fields. To render a
large file upload field like that would cause problems in the user's
browser (that hidden field could potentially have a very very large
base64 encoded string etc.)

>
> def preview_post(self, request):
> "Validates the POST data. If valid, displays the preview page.
> Else, redisplays form."
> f = self.form(request.POST, auto_id=AUTO_ID)
>
> so validation always fails.
> There is also a warning in this file that preview_post is a METHOD
> SUBCLASSES SHOULDN'T OVERRIDE.
> Any idea why not and what to watch out for if I do

I am not sure but may be that method name is not guaranteed to remain
the same?

You might want to consider just creating a copy of the form preview
application for your custom use. Here's one way to handle file
uploads. When the file is upload in the first stage, save it in a
temporary location (the new Upload File handlers let you do this quite
easily.) Incorporate the filename and filesize into your custom hash
and render the filename in a hidden field (instead of the file's
contents.) The rest should follow from that.

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

2008-07-18 Thread Torsten Bronger

Hallöchen!

Dan writes:

> Django sets this for you if your database supports it (ie: you are
> using postgres or mysql with innodb tables). If you are using
> mysql, check that tables aren't MyISAM.

Okay, I have InnoDB.

> If you want to do this inside Django, more complex because if you
> change an object's primary key, Django concludes that you want to
> work with another row altogether and doesn't modify your original
> row.

So what happens when I say

my_db_object.its_primary_key = new_value
my_db_object.save()

?  Is a new object created or the row changed?  If the first, how do
I change the value at all?

> Can I ask why you would need to change PKs?

Yes.  We are a scientific institution, and I create a samples
database.  Frequently a sample gets a new name, however, the old
name(s) must be kept as aliases.

For the aliases, I probably will use a second table with many-to-one
relationship.

I wanted to keep the (current) sample name the primary key because I
think that this accelerates lookup, but if all else fails, I must
use a surrogate key.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [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: 64 bit integer field

2008-07-18 Thread Karen Tracey
On Fri, Jul 18, 2008 at 12:30 AM, simon <[EMAIL PROTECTED]> wrote:

>
> How do i create a long long integer field in my model ? Do I use
> decimal ? (worried about performance of the decimal field). I am using
> the mysql backend.
>
>
There's a very old ticket that has not yet been closed for adding a big
integer field to Django:

http://code.djangoproject.com/ticket/399

Since that ticket was opened it has become much easier to add your own
custom field types, one of the more recent comments in that ticket has a
snippet of code for defining your own new type that may work for you (I have
not tested it myself).

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: Changing the value of the primary key

2008-07-18 Thread Dan
Django sets this for you if your database supports it (ie: you are using
postgres or mysql with innodb tables). If you are using mysql, check that
tables aren't MyISAM. If you want to do this inside Django, more complex
because if you change an object's primary key, Django concludes that you
want to work with another row altogether and doesn't modify your original
row.

Can I ask why you would need to change PKs?

On Fri, Jul 18, 2008 at 7:58 AM, Torsten Bronger <
[EMAIL PROTECTED]> wrote:

>
> Hallöchen!
>
> When I change the value of a primary key field (assuming that it is
> still unique), are depending tables also updated?  I found on the
> net that "ON UPDATE CASCADE" has to be set for the child tables, but
> I didn't find anything Django-related.
>
> Tschö,
> Torsten.
>
> --
> Torsten Bronger, aquisgrana, europa vetus
>   Jabber ID: [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: Field representation in n-f-admin

2008-07-18 Thread Jeff FW

If you just want to apply the formatting in the change_list view, then
define a method in the class in question that returns the formatted
string you want.  Then, in the corresponding Admin class, put the name
of that function in list_display, and that's it.

If you're talking about modifying it in the change view, then you
might need something like (but not exactly) this:
http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIchangetheattributesforawidgetonasinglefieldinmymodel.

-Jeff

On Jul 17, 4:51 am, "Alex Rades" <[EMAIL PROTECTED]> wrote:
> Hi,
> I have a field (a XMLField) which I'd like to format somehow before
> presenting it into the admin change_list page.
> How do i alter the string representation of a field in django?
>
> 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: i18n: How to the language on per-user basis

2008-07-18 Thread yml

Hello,

Sometimes ago I try to solve a similar problem, it seems to me that
the solution to your problem is to write a middleware.
You will find an example there : 
http://yml-blog.blogspot.com/search/label/Django

---8<
from django.utils.cache import patch_vary_headers
from django.utils import translation

class MultilingualURLMiddleware:
def get_language_from_request (self,request):
# This is the place where you should write
# the logic to find the right language
lang =  user.language  # <= May be something like
return lang
def process_request(self, request):
from django.conf import settings
language = self.get_language_from_request(request)
if language is None:
language = settings.LANGUAGE_CODE[:2]
translation.activate(language)
request.LANGUAGE_CODE = translation.get_language()
def process_response(self, request, response):
patch_vary_headers(response, ("Accept-Language",))
translation.deactivate()
return response
--8<--
I hope that help.
--yml


On Jul 18, 2:01 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
> You could use "user profiles" which will allow you to store various user
> specific preferences. See [1] to learn how to do this.
>
> I am currently using profiles to identify users by the department they work
> in and the last time they edited a form (this is different from last login).
>
> Best,
>
> R
>
> [1] -http://www.djangoproject.com/documentation/authentication/#storing-ad...
>
> On Thu, Jul 17, 2008 at 6:32 PM, Torsten Bronger <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hallöchen!
>
> > In my Web application, every user has to log in.  In an additional
> > user database table, the prefered language of each user is given.
> > But how do I activate it?
>
> > I use django.contrib.auth.views.login for the login.  However, as
> > far as I can see, I have to copy-and-paste this function and add a
> > line to it which stors the language in the current session.  Am I
> > right?
>
> > Tschö,
> > Torsten.
>
> > --
> > Torsten Bronger, aquisgrana, europa vetus
> >                   Jabber ID: [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: i18n: How to the language on per-user basis

2008-07-18 Thread Rishabh Manocha
You could use "user profiles" which will allow you to store various user
specific preferences. See [1] to learn how to do this.

I am currently using profiles to identify users by the department they work
in and the last time they edited a form (this is different from last login).

Best,

R

[1] -
http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users

On Thu, Jul 17, 2008 at 6:32 PM, Torsten Bronger <
[EMAIL PROTECTED]> wrote:

>
> Hallöchen!
>
> In my Web application, every user has to log in.  In an additional
> user database table, the prefered language of each user is given.
> But how do I activate it?
>
> I use django.contrib.auth.views.login for the login.  However, as
> far as I can see, I have to copy-and-paste this function and add a
> line to it which stors the language in the current session.  Am I
> right?
>
> Tschö,
> Torsten.
>
> --
> Torsten Bronger, aquisgrana, europa vetus
>   Jabber ID: [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
-~--~~~~--~~--~--~---



inspectdb don't build model form MySQL

2008-07-18 Thread anoval

hi everyone,

short summary says all about my problems, here is the case;

--

DROP TABLE IF EXISTS LANGUAGE;
CREATE TABLE LANGUAGE (
  LANGUAGE_ID   INT NOT NULLPRIMARY
KEY AUTO_INCREMENT
, LANGUAGE_TITLECHAR(100)   NOT NULL
) TYPE = INNODB;

DROP TABLE IF EXISTS QUESTION_ACTION;
CREATE TABLE QUESTION_ACTION (
  QUESTION_ID   INT NOT NULLPRIMARY
KEY AUTO_INCREMENT
, LANGUAGE_ID   INT NOT NULL
, ACTION_ID INT NOT NULL
, MULTI_CHOICE  CHAR(1) NOT NULL
, SORTNRSMALLINTNOT NULL
, SHOW_TYPE CHAR(10)NOT NULL
, QUESTION  TEXTNOT NULL

, FOREIGN KEY   (LANGUAGE_ID)   REFERENCES
LANGUAGE(LANGUAGE_ID)
, FOREIGN KEY   (ACTION_ID) REFERENCES
ACTION(ACTION_ID)
) TYPE = INNODB;

Ok this is not the whole sql there are many more tables, but the
principle is the same everywhere.
So when i put python manage.py inspectdb > models.py, it successfully
finish it but the result is


# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or
field names.
#
# Also note: You'll have to insert the output of 'django-admin.py
sqlcustom [appname]'
# into your database.

from django.db import models

---

did i do something wrong or it's the Django thing?

oh, and yeah all tables are in the same schema...

Thanks in advance,
Alen

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Changing the value of the primary key

2008-07-18 Thread Torsten Bronger

Hallöchen!

When I change the value of a primary key field (assuming that it is
still unique), are depending tables also updated?  I found on the
net that "ON UPDATE CASCADE" has to be set for the child tables, but
I didn't find anything Django-related.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: [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: Model Inheritance in new-forms admin

2008-07-18 Thread Russell Keith-Magee

On Fri, Jul 18, 2008 at 7:41 PM, cschand <[EMAIL PROTECTED]> wrote:
>
> Hi Russ
>The problem is not solved in the ticket

No - that's because it's a bug report. When the bug is fixed, the
ticket will be closed.

Yours,
Russ Magee %-)

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



Re: "ColorField"?

2008-07-18 Thread [EMAIL PROTECTED]

Leaf,

You *have* checked Django Pluggables and Django snippets already,
haven't you? :-) Great places to start!

http://djangoplugables.com/
http://www.djangosnippets.org/

HTH,
Carlos

On Jul 8, 4:49 pm, "Peter Herndon" <[EMAIL PROTECTED]> wrote:
> You'll want to check out django.db.models.fields,
> django.db.models.fields.subclassing, and django.core.validators as
> starting points for creating a new Field type with a custom validator.
>  In addition, there's a js attribute for class Admin you can use to
> bring in the necessary JavaScript into admin
> (http://www.djangoproject.com/documentation/model-api/#js), or you can
> look into newforms-admin branch (soon to be trunk) for more options on
> custom admin pages.
>
> On Mon, Jul 7, 2008 at 11:28 PM, Leaf <[EMAIL PROTECTED]> wrote:
>
> > Also note - when I say this, I'm talking about something that can plug
> > in to the admin interface. Just clearing that up.
>
> > Regards,
> > Leaf
--~--~-~--~~~---~--~~
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: Model Inheritance in new-forms admin

2008-07-18 Thread cschand

Hi Russ
The problem is not solved in the ticket

Satheesh

On Jul 18, 4:13 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Fri, Jul 18, 2008 at 7:00 PM, cschand <[EMAIL PROTECTED]> wrote:
>
> > When I tried model inheritance in new-forms admin, I faced some
> > problems
> ...
> > What is wrong with me?
>
> You haven't checked the tickets:http://code.djangoproject.com/ticket/6755
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: SVN checkout for users without access to SVN

2008-07-18 Thread warsng

Thanks, much appreciated guys.

On Jul 18, 11:48 am, Phillip Parrin <[EMAIL PROTECTED]> wrote:
> there ya go,http://silver.parrin.nl/~phillip/django.tgz
>
> On Jul 18, 12:39 pm, warsng <[EMAIL PROTECTED]> wrote:
>
> > I cannot install SVN on the machine i am currently accessing the
> > internet through, is it possible for someone to provide me with a
> > tarball/zip of the latest SVN co? Or is this hidden somewhere on the
> > django site?
--~--~-~--~~~---~--~~
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: Model Inheritance in new-forms admin

2008-07-18 Thread Andre Meyer
hi

i had (and still have) the same
problem
.

really hope this gets fixed (be)for(e) 1.0; patches seem to be available, so
it can't be long... ;-)

xing fingers



On Fri, Jul 18, 2008 at 1:13 PM, Russell Keith-Magee <[EMAIL PROTECTED]>
wrote:

>
> On Fri, Jul 18, 2008 at 7:00 PM, cschand <[EMAIL PROTECTED]> wrote:
> >
> > When I tried model inheritance in new-forms admin, I faced some
> > problems
> ...
> > What is wrong with me?
>
> You haven't checked the tickets: http://code.djangoproject.com/ticket/6755
>
> Yours,
> Russ Magee %-)
>
> >
>

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



Re: Model Inheritance in new-forms admin

2008-07-18 Thread Russell Keith-Magee

On Fri, Jul 18, 2008 at 7:00 PM, cschand <[EMAIL PROTECTED]> wrote:
>
> When I tried model inheritance in new-forms admin, I faced some
> problems
...
> What is wrong with me?

You haven't checked the tickets: http://code.djangoproject.com/ticket/6755

Yours,
Russ Magee %-)

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



Model Inheritance in new-forms admin

2008-07-18 Thread cschand

When I tried model inheritance in new-forms admin, I faced some
problems
The below is the code i tried

class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.EmailField()

def __str__(self):
return u"%s %s" % (self.first_name, self.last_name)

class ReporterChild(Reporter):
location = models.CharField(max_length=100)

def __str__(self):
return "%s" % self.location

ReporterChild._meta.get_field('reporter_ptr').blank = True

Here I can't saved the data and it throws the Value Error exception
with "Cannot assign None: "ReporterChild.reporter_ptr" does not allow
null values." error message

So I set this field to Null by adding
ReporterChild._meta.get_field('reporter_ptr').null = True

So its adds fine and working. But when I tried to delete a data. It is
throws IntegrityError exception with "datatype mismatch" message.

It can delete only commenting the added code.

What is wrong with me?

Satheesh
--~--~-~--~~~---~--~~
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: SVN checkout for users without access to SVN

2008-07-18 Thread Ramiro Morales

On Fri, Jul 18, 2008 at 7:39 AM, warsng <[EMAIL PROTECTED]> wrote:
>
> I cannot install SVN on the machine i am currently accessing the
> internet through, is it possible for someone to provide me with a
> tarball/zip of the latest SVN co?

You can use the web interfaces of the distributed version control mirrors of
Django's SVN repo (Git, Mercurial, Bazaar), the URLs are published at:

http://code.djangoproject.com/wiki/DjangoBranches#Distributedversioncontrolmirrors

some of these provide tarballs with snapshots of the tree.

HTH,

-- 
 Ramiro Morales

--~--~-~--~~~---~--~~
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: SVN checkout for users without access to SVN

2008-07-18 Thread Phillip Parrin

there ya go, http://silver.parrin.nl/~phillip/django.tgz

On Jul 18, 12:39 pm, warsng <[EMAIL PROTECTED]> wrote:
> I cannot install SVN on the machine i am currently accessing the
> internet through, is it possible for someone to provide me with a
> tarball/zip of the latest SVN co? Or is this hidden somewhere on the
> django site?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



SVN checkout for users without access to SVN

2008-07-18 Thread warsng

I cannot install SVN on the machine i am currently accessing the
internet through, is it possible for someone to provide me with a
tarball/zip of the latest SVN co? Or is this hidden somewhere on the
django site?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



similar method for get_or_create()

2008-07-18 Thread leppy

hi everyone,

Can anyone tell me a method similar to django model's get_or_create
for updating an object with a particular id only when it exists, or
else to create a new object.

Thanks in advance.
leppy.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Glamour models & Fasion designing New look watch my profile http://www.geocities.com/cathrina39

2008-07-18 Thread hot rathi

Glamour models & Fasion designing
New look

watch my profile


http://www.geocities.com/cathrina39

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



Re: How to deal with two distinct UserProfile model ?

2008-07-18 Thread [EMAIL PROTECTED]

If you're using the SVN version you can bypass the profile system and
give both of them a OneToOne field. Instead of doing
user.get_profile(), you would do user.client_profile, where
client_profile is whatever your related_name happens to be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URL encoding problem

2008-07-18 Thread [EMAIL PROTECTED]

Hi!
Thanks for your help..
more informations :
I have downloaded the latest trunk this morning (0.97-pre-SVN-7947),
but nothing  changed...
I run django on ubuntu server, python 2.5.1 and mysql 5 (apache +
mod_python).

I have copied the wrong urlPattern, this is the right one:

(r'(?P[^/]+)/(?P\d+)/$',
'views.box_detail'),

called by:

(r'^dossiers/', include('jungle.dossiers.urls')),

this is the url..

http://elvis.sinedita.it/dossiers/Comunità/1/



I'm sure that last week, before I downloaded a new trunk all works
well...

Now, that's my models and views:

  sections/models.py
from django.db import models
from django.contrib.sites.models import Site

class Section(models.Model):
id_site = models.ForeignKey(Site,verbose_name="Sito")
section_name = models.CharField(max_length=100,core=True,
verbose_name="Nome")
template_name = models.CharField(max_length=100,verbose_name="Nome
template",blank=True,null=True)
section_father = models.ForeignKey('self',blank=True,null=True,
verbose_name="Sezione superiore")


  dossiers/models.py
class Dossier(models.Model):
title = models.TextField(verbose_name =
"titolo" ,max_length=200,core=True)
abstract = models.TextField('sommario',max_length=400,core=True)
section =
models.ManyToManyField(Section,verbose_name="Sezione",filter_interface=models.HORIZONTAL,
null = False)
site = models.ManyToManyField(Site,verbose_name="Sito",
filter_interface=models.HORIZONTAL)

--- dossiers/views.py
def box_detail(request, section_name,boxdossier_id):
my_section =
Section.objects.get(section_name=section_name,id_site=Site.objects.get_current().id)


Thanks Davide


--~--~-~--~~~---~--~~
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 site settings in templates

2008-07-18 Thread Ross Riley

On 7/16/08, Jon Brisbin <[EMAIL PROTECTED]> wrote:
>
> I can't find a good answer to this in the Django docs: is there a good
> way to access site-specific settings from your templates without
> having to put them in context variables? I've got my media served by
> Apache and everything else by Django. In my templates, I've got an
> ugly hack to check for the existence of a "site_base_url" variable or
> default to localhost. This is a mess because I can't test it from my
> iPod without using a hostname, but I can't get context variables to
> the views I don't have control over (like login/logout, etc...), so my
> templates don't have the "site_base_url" for everything.
>
> Do I have to write some custom middleware that will add my global
> application settings to every request, then reference them through the
> RequestContext I'm passing in to render_to_response? Or is there some
> other feature of views I'm missing (I've read so much on Django
> lately, I'm starting to forget what I've read and what I haven't)?
>
> Thanks!
>
> Jon Brisibn
> http://jbrisbin.com
>
>
> >
>

-- 
Sent from Google Mail for mobile | mobile.google.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: How to deal with two distinct UserProfile model ?

2008-07-18 Thread Hades_L

I figured out a solution for now, not the best imho but it does the
job. I use the method is_staff to check if the user is part of the
team. If True, then it's an employee, then it's a client. Based on
that answer, I wrote a little helper method wich take a User in
parameter, and return the correct Profile for him.

But your solution seems better. However, I don't really understand how
to use 'related_name' and OneToOneField. In my models, I defined the
link to the User model like this :
user = models.ForeignKey(User, unique=True)

So I suppose I should modify like this :
for Employee :
user = models.ForeignKey(User, unique=True, related_name='employee')
for Client
user = models.ForeignKey(User, unique=True, related_name='client')

and now, what should i do ? ^^

Thanks for your help.



On Jul 18, 8:21 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> If you're using the SVN version you can bypass the profile system and
> give both of them a OneToOne field. Instead of doing
> user.get_profile(), you would do user.client_profile, where
> client_profile is whatever your related_name happens to be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-18 Thread Andre Meyer
hi Rajesh

so, implemented it as you told and it works very well.

thanks for your patience and all the explanations.

cheers
André


On Thu, Jul 17, 2008 at 7:22 PM, Rajesh Dhawan <[EMAIL PROTECTED]>
wrote:

>
>
> > > > still, it's not exactly clear to me why the admin does not work the
> same
> > > as
> > > > other templates.
> >
> > > The Admin is not a template. So, I don't know what you mean by that.
> >
> > admin is not using templates? well, i did not check the implementation.
>
> Sorry, if I wasn't clear. The admin does use templates but it's much
> more than that (that's why I said that the Admin is not a template).
> Moreover, the Admin change-list and all its other templates have to be
> dynamic because they don't know beforehand what fields each model is
> going to have and which of those are going to be displayed via
> list_display.
>
> So, as I explained above, there's no way for the admin to guess what
> you want it to do with related many-valued fields like Post.comments
> in your case. So, it chokes when you try to do such a thing.
>
> >
> > The whole point is that in your own template, you decide whether you
> >
> > > want to display the count of comments or a list of comments or the
> > > names of the commenters, and so on. How would the Admin know what you
> > > want if you were allowed to put "comments" in the list_display? One
> > > user may want the count, another may want something else. That's why
> > > the Admin supports calling methods in your model class. And through
> > > such methods you are able to display your comments field exactly the
> > > way you want.
> >
> > agree, though it would make sense to me to return the RelatedManager
> > instance, just like in the templates.
>
> What would that give you? In the change list you would just see the
> class name of the RelatedManager. Is that what you mean?
>
> Remember that in your own templates, you don't just say:
>
> {{ post.comments }}
>
> Instead you either loop over comments or do a length filter on them,
> etc. In other words, you are actively making the decision on what you
> want to do with that related manager instance.
>
> Also, there's one other important difference: when you loop over
> post.comments in your template, you are causing a DB query that brings
> in the comments of that single  post instance. If an Admin were to do
> that, it would have to issue an extra query for each row it is going
> to display in the change-list screen.
>
> All this is documented in the second bullet here:
>
> http://www.djangoproject.com/documentation/model-api/#list-display
>
> -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
-~--~~~~--~~--~--~---