Re: In admin, unable to save many-to-many relation objects with intermediate table

2008-07-08 Thread Karen Tracey
On Wed, Jul 9, 2008 at 12:57 AM, ristretto.rb <[EMAIL PROTECTED]>
wrote:

> I'm using the svn version.  I updated this morning.  I can't remember
> if I was getting the error before I updated, or not.
>

That ticket I pointed to identifies r7710 as a revision where this problem
did not exist.  With your models (much simpler than the ones in that ticket)
I was able to recreate the problem on r7871. Binary search shows that the
problem was introduced in r7790:

http://code.djangoproject.com/changeset/7790

The change message says it was to "Make sure we only create the minimum
number of table indexes for MySQL" but I don't believe this problem has
anything to do with creating table indexes.  (I did not recreate the tables
when recreating the problem, just attempted to "save and continue editing" a
problematic entry.)

I have spent the day tracking this down (it's taken me all day because
> I don't know Django or Python very well, and I haven't been able to
> find a comprehensive IDE that is worth much more then just an editor.
> Argh.)
>

Well you picked some hairy code to start with.  FWIW I use Eclipse with
PyDev which is good enough for stepping through code, setting breakpoints,
and examining variables, though it can run into problems with side-effects
of the variable display.  For getting some clue about what code path is
running it's usually OK enough.

In any case, here's what I'm up to
>
> In django-trunk/django/oldforms/__init__.py line around 68, I have put
> some logging output.  field.get_validation_errors(new_data) is coming
> back as a oldforms.HiddenField when it generated the following error.
>
> 2008-07-09 04:03:08,227 DEBUG 
> 2008-07-09 04:03:08,227 DEBUG {'jointable.0.id': [u'Join table with
> this ID already exists.']}
>
> I don't know why the admin system needs to put this following hidden
> in the html
>
>name="jointtable.0.id" value="38" />
>

That's the primary key value of the inline-edited object.  When the admin
code needs to update any of the visible fields, it needs to pull the primary
key value out of the hidden field in order to know the correct record to
update.


> Now, I've traced this down to line 474, roughly of django-trunk/django/
> oldforms/__init__.py where a the HiddenField class is defined.  A
> validator is passed in called "_curried".  I have no idea what that
> is.  Going to stop here.
>

Yeah, the problem is that validator.  Prior to r7790, these hidden fields
did not have any validators attached to them.  Now they have the
manipulator_validator_unique validator that is run.  Problem is this
validator doesn't seem to be appropriate for this case.  Tracing through it
it is looking up the inline edited object's primary key value in the parent
object's table and if it exists comparing it to the parent object's original
primary key value, so you get an error if the primary key value for the
inline edited object exists in the parent object's table and differs from
the parent primary key value.  I don't believe that validator is supposed to
be associated with the hidden input field for the primary key of an
inline-edited object.

It's being added here:

(
http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/__init__.py#L329
)

if self.unique or (self.primary_key and not rel):

params['validator_list'].append(curry(manipulator_validator_unique, self,
opts, manipulator))

which points to the changes associated with setting unique in r7790 as what
has introduced the problem.  I don't understand exactly what that change was
supposed to be doing, so I'm not sure what the right fix is.  I'll update
#7682 with what I've figured out and hopefully someone who knows the code
can fix it.  In the meantime if you drop back to r7789 I think you will find
the problem goes away.

Karen


>
> On Jul 9, 2:47 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Tue, Jul 8, 2008 at 9:57 PM, ristretto.rb <[EMAIL PROTECTED]>
> wrote:
> >
> > > More details.  I'm using MySQL at the moment (but with a plan to move
> > > to Postgresql.)  The association table has a number of rows loaded
> > > through these models, but not through my Django app directly.  I used
> > > the Model classes in a script to pre load a bunch of data.  Could this
> > > be the problem?
> >
> > > On Jul 9, 1:28 pm, ristretto.rb <[EMAIL PROTECTED]> wrote:
> > > > OK, I took core=True off, and added it to the reference_no field.
>  The
> > > > problem seems to go away for the case when no there are no
> > > > pre-existing joins.   Clearly, I don't understand what core is for.
> > > > I'll read the docs again, and see if it makes sense.
> >
> > > > However, it still errors with
> >
> > > > {'jointable.0.id': [u'Join Table record with this ID already
> exists.']}
> >
> > > > when I tried to save a LeftSide records with existing associations.
> >
> > > > thanks for any and all help.
> >
> > I have no idea what is going on, but a ticket was recently (4 hours ago)
> > opened reporting t

how to log in automaticly

2008-07-08 Thread [EMAIL PROTECTED]

i am using registration module from google, does anyone know how to
log in automatically after a new user registered?

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



Black Box Testing Framework for Django

2008-07-08 Thread Pepsi330ml

Hi All,

I am reading up on how to use external testing framework on Django Web
Application.
Particularly, Black Box Testing.
Anybody using any particular framework on Django? Please kindly
advise.

Currently, i am looking into using HttpUnit on Django.

Thank you.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: What is the fastest way to come up to speed with Django?

2008-07-08 Thread ristretto.rb

Hi Malcolm,  Thanks for the reply.

I just spent the day banging through the admin code down to the
oldform fields to track down a problem I was having.  It took a very
long time because I don't know Django under the hood, and I only have
just started to learn Python.

I can think of some features in an IDE that would make this much
easier for me, and no doubt other noobs like myself.  I'll list them
out here in hopes that someone that creates IDE's reads it.  :)

*  go to last edit position (line/file), and keep going back through
history.  Komodo doesn't do this.
*  code completion and inspection in django templates and python
code.  Komodo does this a bit, but it's limited.
*  show """ doc for a object, if available
*  integrated debugger
*  Fast open - type file name to open it


On Jul 9, 2:20 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-08 at 19:08 -0700, ristretto.rb wrote:
> > I leading a project based on Django, and I come from 12 years of Java,
> > and 0 years of Python.  
>
> You won't get any crap from me, at least. The more languages people
> know, the better.
>
> > I'm currently digging into the django-trunk on many an occasion,
> > trying to explain things that I can't find in the docs.  Because I
> > don't understand how Django was designed, and can't guess too easily,
> > I find that really slow.
>
> > I'm wondering if getting the KomodoIDE editor with a debugger would
> > make learning Django faster.  Or would WingIDE be a better bet?  Or
> > Eclipse with pyDev.  In theory, I could see stepping through code to
> > learn how it all fits.  But, does this work well in practice?
>
> Personally I have no experience with any of those, so I'm not going to
> give advice.
>
> The one cavaet I'll point out is that *running* pretty much anything in
> Django requires a settings file, since there are a few places where code
> is executed conditionally based on settings. Most files can now be
> imported without a settings file being present (allowing you to import
> things and then manually configure settings in advanced cases), but
> there might be some deep internals where that isn't possible. All this
> means is that you *might* need to have DJANGO_SETTINGS_MODULE set and
> pointing to some reasonably simple settings file (specify a template
> loader and a database engine).
>
> > Any other tips to getting up to speed fast?
>
> With the internal code? I wish there was some silver bullet like that.
>
> When you are poking around the internals, things are generally grouped
> fairly logically. Although, like any piece of software with five or six
> years of development behind it, there are some historical oddities as
> well. But, by and large, you'll find like grouped with like. For
> example,
>
>         django/templates:
>                 all the template loading and rendering code
>         django/core/handlers:
>                 the stuff that is the outer layer of request/response
>                 handling.
>         django/db/models/fields/
>                 all the model field code
>         django/db/models/sql
>                 SQL statement creation
>         django/db/models/*
>                 all the other model stuff
>         django/db/backends/
>                 the individual database backends and common wrapping
>                 code for them.
>         django/utils/translation/
>                 i18n/l10n support
>
> django/utils is a bit of a grab bag of internal common stuff that is
> used in multiple places. Django/core is stuff that didn't sit anywhere
> else but was important.
>
> In something as modular and wide-ranging as Django there isn't really an
> obvious way to read it from beginning to end. However, if you really
> want to understand what's going on you could start with the lifecycle of
> an HTTP request (django/core/handlers/wsgi.py, say), which leads to URL
> resolving, following through to the middleware, view calling, middleware
> again and response dispatching. Orthogonal to that is model handling,
> database interaction (triggered by the model code) and various view
> support stuff like generic views.
>
> 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: "ImportError No module named django"

2008-07-08 Thread Julien Phalip

Apparently Django is not present in the PYTHONPATH and therefore not
reachable by Python.
I'm not a Mac user, but some help can be found on google.

Try there for example:
http://antoniocangiano.com/2007/12/22/how-to-install-django-with-mysql-on-mac-os-x/
http://www.rhonabwy.com/wp/2006/07/20/installing-django-on-macos-x-development-version/

In the first link, the section "Telling Python where Django is" looks
like what you're after.

Cheers,

Julien

On Jul 9, 12:34 pm, MadMax007 <[EMAIL PROTECTED]> wrote:
> Ok, for the PYTHONPATH I got:
>
> >>> import sys
> >>> print sys.path
>
> ['', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python25.zip', '/System/Library/Frameworks/Python.framework/Versions/
> 2.5/lib/python2.5', '/System/Library/Frameworks/Python.framework/
> Versions/2.5/lib/python2.5/plat-darwin', '/System/Library/Frameworks/
> Python.framework/Versions/2.5/lib/python2.5/plat-mac', '/System/
> Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-
> mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/
> Versions/2.5/Extras/lib/python', '/System/Library/Frameworks/
> Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/System/Library/
> Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload', '/
> Library/Python/2.5/site-packages', '/System/Library/Frameworks/
> Python.framework/Versions/2.5/Extras/lib/python/PyObjC']
>
>
>
> Hope this tells you something, I relatively new to Apple computers so
> I feel a bit lost, and to top things off, I'm new to Python as well :
> (
>
> On Jul 8, 5:42 pm, Julien Phalip <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > This means that Django is not in the PYTHONPATH. To check what's in
> > that path, run the following in Python:
>
> > >>> import sys
> > >>> print sys.path
>
> > On Jul 9, 9:35 am, Juanjo Conti <[EMAIL PROTECTED]> wrote:
>
> > > How did you exactly install it?
> > > Which folders are in your PYTHONPATH?
>
> > > Juanjo
> > > --
> > > mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
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: In admin, unable to save many-to-many relation objects with intermediate table

2008-07-08 Thread ristretto.rb

I'm using the svn version.  I updated this morning.  I can't remember
if I was getting the error before I updated, or not.

I have spent the day tracking this down (it's taken me all day because
I don't know Django or Python very well, and I haven't been able to
find a comprehensive IDE that is worth much more then just an editor.
Argh.)

In any case, here's what I'm up to

In django-trunk/django/oldforms/__init__.py line around 68, I have put
some logging output.  field.get_validation_errors(new_data) is coming
back as a oldforms.HiddenField when it generated the following error.

2008-07-09 04:03:08,227 DEBUG 
2008-07-09 04:03:08,227 DEBUG {'jointable.0.id': [u'Join table with
this ID already exists.']}

I don't know why the admin system needs to put this following hidden
in the html

   

Now, I've traced this down to line 474, roughly of django-trunk/django/
oldforms/__init__.py where a the HiddenField class is defined.  A
validator is passed in called "_curried".  I have no idea what that
is.  Going to stop here.

thanks!



On Jul 9, 2:47 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 8, 2008 at 9:57 PM, ristretto.rb <[EMAIL PROTECTED]> wrote:
>
> > More details.  I'm using MySQL at the moment (but with a plan to move
> > to Postgresql.)  The association table has a number of rows loaded
> > through these models, but not through my Django app directly.  I used
> > the Model classes in a script to pre load a bunch of data.  Could this
> > be the problem?
>
> > On Jul 9, 1:28 pm, ristretto.rb <[EMAIL PROTECTED]> wrote:
> > > OK, I took core=True off, and added it to the reference_no field.  The
> > > problem seems to go away for the case when no there are no
> > > pre-existing joins.   Clearly, I don't understand what core is for.
> > > I'll read the docs again, and see if it makes sense.
>
> > > However, it still errors with
>
> > > {'jointable.0.id': [u'Join Table record with this ID already exists.']}
>
> > > when I tried to save a LeftSide records with existing associations.
>
> > > thanks for any and all help.
>
> I have no idea what is going on, but a ticket was recently (4 hours ago)
> opened reporting the same error message for inline-edited objects:
>
> http://code.djangoproject.com/ticket/7682
>
> It seems like some code is thinking records are supposed to be new and
> checking for primary key uniqueness when in fact it is existing records that
> are being updated.  This might be a recently introduced bug, it's a little
> curious to have two people reporting the same (not common) error message
> suddenly so close together.
>
> What version are you running?
>
> Karen
>
>
>
> > > On Wed, Jul 9, 2008 at 1:09 PM, ristretto. rb <[EMAIL PROTECTED]>
> > wrote:
> > > > Hello, I'm stuck.  Any help will be much appreciated.
>
> > > > I followed
> > > >http://www.djangoproject.com/documentation/models/m2m_intermediary/to...
> > > > a
> > > > Many-to-many relationship via an intermediary table.
>
> > > > class LeftSide(models.Model):
> > > > :
>
> > > > class RightSide(models.Model):
> > > > :
>
> > > > class JoinTable(models.Model):
> > > >     leftSide = models.ForeignKey(LeftSide,
> > > >                 edit_inline=models.TABULAR,
> > > >                 num_in_admin=3, core=True)
> > > >     rightSide = models.ForeignKey(RightSide,
> > > >                 edit_inline=models.TABULAR,
> > > >                 num_in_admin=3,core=True)
> > > >     reference_no = models.CharField(max_length=10, null=True,
> > blank=True)
>
> > > > I can load the LeftSide in the admin, and choose to Change a record.  I
> > get
> > > > 3 RightSide menu groups at the bottom.  I can choose a RightSide to set
> > as a
> > > > join.  When I choose Save (any of the 3 save variations on the page)
> > nothing
> > > > is saved.
>
> > > > There are two cases.
>
> > > > 1)  If the are already records in the join table for that LeftSide,
> > then I
> > > > get an error when I save.  {'jointable.0.id': [u'Join Table record
> > with this
> > > > ID already exists.']}  I didn't actually make any changes to that
> > > > association, so I don't know why it would complain.
>
> > > > 2)  If there are no join table records associated with the LeftSide,
> > then
> > > > there is no error, but nothing is saved.
>
> > > > Am I doing something totally wrong here?  Or is this a bug in the Admin
> > > > system?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



memcached

2008-07-08 Thread gt7658b

Hello, I tried to use memcached as follow. BTW, memcached is running
as seen from top command on server.

CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
# CACHE_BACKEND = 'dummy:///'
CACHE_MIDDLEWARE_SECONDS = 60*30
CACHE_MIDDLEWARE_KEY_PREFIX =''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

However, I got 500 error. If I switch to CACHE_BACKEND = 'dummy:///',
our web site worked just fine.

I wonder if anyone has any clues about this issue.

Thanks,
Harry
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



memcached

2008-07-08 Thread gt7658b

Hello, I tried to use memcached as follow. BTW, memcached is running
as seen from top command on server.

CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
# CACHE_BACKEND = 'dummy:///'
CACHE_MIDDLEWARE_SECONDS = 60*30
CACHE_MIDDLEWARE_KEY_PREFIX =''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

However, I got 500 error. If I switch to CACHE_BACKEND = 'dummy:///',
our web site worked just fine.

I wonder if anyone has any clues about this issue.

Thanks,
Harry
--~--~-~--~~~---~--~~
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: root() takes exactly 3 arguments (2 given)

2008-07-08 Thread furby

hmm...seems obvious now that you mention it =).  Thanks for the help
guys.


On Jul 7, 9:25 pm, Juanjo Conti <[EMAIL PROTECTED]> wrote:
> furby escribió:
> [...]
>
> > admin.site.root() takes3arguments: self, request, url.  There is no
> > way to specifyargumentsin urls.py, so I have no idea how to fix
> > this.  Any help would be appreciated.  Thanks.
>
> Yes there is. You can use regex groups:
>
> (r'^admin/(.*)', site1.root),
>
> The string that matches .* will be passed as an extra arg.
>
> Or named groups:
>
> (r'^admin/(?P.*)', site1.root),
>
> Additionaly, you can pass extra 
> args:http://www.djangoproject.com/documentation/url_dispatch/#passing-extr...
>
> Juanjo
> --
> mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Import issues since newforms-admin

2008-07-08 Thread Julien Phalip

Ok, I've just opened a ticket and posted some code illustrating the
issue:
http://code.djangoproject.com/ticket/7684

Thanks,

Julien

On Jul 9, 2:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-08 at 21:10 -0700, Julien Phalip wrote:
> > Thanks for the tip Malcolm.
>
> > I've prepared some very simple code to illustrate the problem. I can't
> > find a way to attach files in this mailing list. Should I open a
> > ticket and post it there?
>
> Yes. Trac is the only place where things will not be forgotten.
>
> 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: Import issues since newforms-admin

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 21:10 -0700, Julien Phalip wrote:
> Thanks for the tip Malcolm.
> 
> I've prepared some very simple code to illustrate the problem. I can't
> find a way to attach files in this mailing list. Should I open a
> ticket and post it there?

Yes. Trac is the only place where things will not be forgotten.

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: Import issues since newforms-admin

2008-07-08 Thread Julien Phalip

Thanks for the tip Malcolm.

I've prepared some very simple code to illustrate the problem. I can't
find a way to attach files in this mailing list. Should I open a
ticket and post it there?

Thanks,

Julien

On Jul 9, 9:50 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-08 at 16:20 -0700, Julien Phalip wrote:
> > Hi,
>
> > There's an issue that arose as I upgraded an external app of mine to
> > newforms-admin.
>
> > I created the conventional admin.py, which does all the registration
> > business, and did "import admin" in the module's __init__.py
>
> > After I did that, I got some import errors at compilation time (or
> > say, project's launching time):
>
> > "ImportError: cannot import name MenuItem"
>
> > "MenuItem" is in the external app (freshly upgraded to nfa), and the
> > import that raises the error is made in the project's app.
>
> It's a bit (for me, at least) to keep track of what structure you're
> describing here. You are using the word "project" to mean something that
> isn't clear. Could you give a small layout of the directory structure
> please.
>
> It's not impossible to imagine something like the problem you're
> describing happening depending upon import paths. Remember that when you
> do "from foo import models", Python first has to parse and execute the
> code in "foo/__init__.py", so things might not be fully constructed.
> But, again, it's hard to tell without concrete code. If you can
> construct a very small example that demonstrates the problem (like,
> literally, as few lines as possible. To the point that if you remove any
> more lines, the problem goes away) then you've got something you can put
> in a bug report because then other people can try to repeat the problem
> and diagnose it.
>
> I'm not intimately familiar with how newforms is doing imports or
> recommended practices over there, but if this type of problem is
> cropping up, it's worth knowing about it so that we can either document
> "don't do that" or get things fixed if possible.
>
> Again, I'm not saying that what you're seeing is a bug or necessarily a
> problem in Django. I don't understand the problem you're describing from
> the English-language version. Code speaks more clearly here, I think.
>
> 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: Django, Apache, and CSS

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 9:47 PM, foo <[EMAIL PROTECTED]> wrote:
>
> First, I want to thank you for your reply Milan!  I just recently
> joined the group and I'm impressed at how active the group is and how
> helpful all of the advice I've found here has been.
>
> I've made the changes that you suggested and unfortunately, I'm still
> seeing the same behavior.  What I did was:
>

What happens when you try to access http://yourserver/media/style.css ?
If you get a 404 then something is not setup right, it could be some
other directive is overriding your media settings.  If you get the
style sheet as expected then we're looking at template glitch, sounds
like a combo. ;)  Just wondering exactly what "seeing same behavior"
means and tackling one thing at a time ...

--
Milan

--~--~-~--~~~---~--~~
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, Apache, and CSS

2008-07-08 Thread Colin Bean

The blank page seems suspicious, as usually you'd be getting an error
message if something was wrong with your configuration.  What do you
see if you view the source of that page?  Perhaps there's an error in
your HTML, like forgetting to close a  tag.  It's impossible to
tell without seeing at the source of your base.html, but I'd start
there.

Colin

On Tue, Jul 8, 2008 at 7:47 PM, foo <[EMAIL PROTECTED]> wrote:
>
> First, I want to thank you for your reply Milan!  I just recently
> joined the group and I'm impressed at how active the group is and how
> helpful all of the advice I've found here has been.
>
> I've made the changes that you suggested and unfortunately, I'm still
> seeing the same behavior.  What I did was:
>
> Created the alias in my apache2.conf file...that file now looks as
> such:
>
> # Django initialization
> LoadModule python_module modules/mod_python.so
>
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
>
> 
>SetHandler None
> 
>
> Alias /media/ /opt/python/django-apps/foo/templates/media/
>
> I changed MEDIA_URL to only be '/media/'
>
> And I changed base.html template to use /media/style.css instead of
> media/style.css
>
> (I appreciate your comment about the location of my media
> directory...I'll be sure to change it as soon as I have all of this
> working!)
>
> DEBUG was already set to true in my settings.py file and per your
> advice, I checked the apache logs to see if there was anything odd in
> there and there wasn't anything useful.  Is there another log to check
> besides /var/log/apache2/error.log?
>
> Any other ideas?
>
> On Jul 8, 9:22 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>> On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote:
>>
>> > OK, I know this has been posted in the forums before, but for some
>> > reason, I'm still struggling to get my CSS stylesheet applied to my
>> > django templates.  I'm hoping that if I post my configuration, someone
>> > can point out what I'm missing.
>>
>> > I have my django project at:  /opt/python/django-apps/foo/
>> > In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
>> > apps/foo/templates/media/ and MEDIA_URL set tohttp://localhost/media
>>
>> > In my apache2.conf file, I have the following:
>>
>> > # Django configuration
>> > LoadModule python_module modules/mod_python.so
>>
>> > 
>> >SetHandler python-program
>> >PythonHandler django.core.handlers.modpython
>> >SetEnv DJANGO_SETTINGS_MODULE foo.settings
>> >PythonDebug On
>> >PythonPath "['/opt/python/django-apps/'] + sys.path"
>> > 
>> > 
>> >SetHandler python-program
>> >PythonHandler django.core.handlers.modpython
>> >SetEnv DJANGO_SETTINGS_MODULE foo.settings
>> >PythonDebug On
>> >PythonPath "['/opt/python/django-apps/'] + sys.path"
>> > 
>>
>> > 
>> >SetHandler None
>> > 
>>
>> An alias directive to tell apache where to find your media is probably
>> all you need. Assuming your apache's DocumentRoot is something other
>> than your templates dir.
>>
>> 
>>SetHandler None
>> 
>> Alias /media/ /opt/python/django-apps/foo/templates/media/
>>
>> Also putting your media dir in your templates dir is kind of odd.
>> Usually it's at the top of the project directory.
>>
>> Then set MEDIA_URL='/media/' you don't need 'http://localhost'.
>>
>> > In my base.html file, I reference the stylesheet as > > rel="stylesheet" type="text/css" href="media/style.css"
>> > media="screen" />
>>
>> Finally in your templates use '/media/foo' not 'media/foo', that way
>> it doesn't matter what location you are serving from, /media/ will
>> work.
>>
>>
>>
>> > When I point my browser athttp://localhost/contact, all I get is a
>> > blank page... no style and no text.  The contact.html template is
>> > below:
>>
>> > {% extends "base.html" %}
>>
>> > {% block title %}
>> >- Contact Us
>> > {% endblock %}
>>
>> > {% block content %}
>> >some content...please show up
>> > {% endblock %}
>>
>> > I'm not sure if there not being any text is related to the CSS problem
>> > or not.  I haven't spent any time troubleshooting that just yet, but I
>> > thought I'd throw it in for good measure.
>>
>> > Any help that anyone can give is greatly appreciated!
>>
>> Also don't forget to set DEBUG=True in your settings.py and check your
>> error log for more info.
>>
>> --
>> Milan
> >
>

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

Re: In admin, unable to save many-to-many relation objects with intermediate table

2008-07-08 Thread Karen Tracey
On Tue, Jul 8, 2008 at 9:57 PM, ristretto.rb <[EMAIL PROTECTED]> wrote:

>
> More details.  I'm using MySQL at the moment (but with a plan to move
> to Postgresql.)  The association table has a number of rows loaded
> through these models, but not through my Django app directly.  I used
> the Model classes in a script to pre load a bunch of data.  Could this
> be the problem?
>
> On Jul 9, 1:28 pm, ristretto.rb <[EMAIL PROTECTED]> wrote:
> > OK, I took core=True off, and added it to the reference_no field.  The
> > problem seems to go away for the case when no there are no
> > pre-existing joins.   Clearly, I don't understand what core is for.
> > I'll read the docs again, and see if it makes sense.
> >
> > However, it still errors with
> >
> > {'jointable.0.id': [u'Join Table record with this ID already exists.']}
> >
> > when I tried to save a LeftSide records with existing associations.
> >
> > thanks for any and all help.
> >
>

I have no idea what is going on, but a ticket was recently (4 hours ago)
opened reporting the same error message for inline-edited objects:

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

It seems like some code is thinking records are supposed to be new and
checking for primary key uniqueness when in fact it is existing records that
are being updated.  This might be a recently introduced bug, it's a little
curious to have two people reporting the same (not common) error message
suddenly so close together.

What version are you running?

Karen

>
> >
> > On Wed, Jul 9, 2008 at 1:09 PM, ristretto. rb <[EMAIL PROTECTED]>
> wrote:
> > > Hello, I'm stuck.  Any help will be much appreciated.
> >
> > > I followed
> > >http://www.djangoproject.com/documentation/models/m2m_intermediary/tomake
> > > a
> > > Many-to-many relationship via an intermediary table.
> >
> > > class LeftSide(models.Model):
> > > :
> >
> > > class RightSide(models.Model):
> > > :
> >
> > > class JoinTable(models.Model):
> > > leftSide = models.ForeignKey(LeftSide,
> > > edit_inline=models.TABULAR,
> > > num_in_admin=3, core=True)
> > > rightSide = models.ForeignKey(RightSide,
> > > edit_inline=models.TABULAR,
> > > num_in_admin=3,core=True)
> > > reference_no = models.CharField(max_length=10, null=True,
> blank=True)
> >
> > > I can load the LeftSide in the admin, and choose to Change a record.  I
> get
> > > 3 RightSide menu groups at the bottom.  I can choose a RightSide to set
> as a
> > > join.  When I choose Save (any of the 3 save variations on the page)
> nothing
> > > is saved.
> >
> > > There are two cases.
> >
> > > 1)  If the are already records in the join table for that LeftSide,
> then I
> > > get an error when I save.  {'jointable.0.id': [u'Join Table record
> with this
> > > ID already exists.']}  I didn't actually make any changes to that
> > > association, so I don't know why it would complain.
> >
> > > 2)  If there are no join table records associated with the LeftSide,
> then
> > > there is no error, but nothing is saved.
> >
> > > Am I doing something totally wrong here?  Or is this a bug in the Admin
> > > system?
> >
>

--~--~-~--~~~---~--~~
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, Apache, and CSS

2008-07-08 Thread foo

First, I want to thank you for your reply Milan!  I just recently
joined the group and I'm impressed at how active the group is and how
helpful all of the advice I've found here has been.

I've made the changes that you suggested and unfortunately, I'm still
seeing the same behavior.  What I did was:

Created the alias in my apache2.conf file...that file now looks as
such:

# Django initialization
LoadModule python_module modules/mod_python.so


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE foo.settings
PythonDebug On
PythonPath "['/opt/python/django-apps/'] + sys.path"


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE foo.settings
PythonDebug On
PythonPath "['/opt/python/django-apps/'] + sys.path"



SetHandler None


Alias /media/ /opt/python/django-apps/foo/templates/media/

I changed MEDIA_URL to only be '/media/'

And I changed base.html template to use /media/style.css instead of
media/style.css

(I appreciate your comment about the location of my media
directory...I'll be sure to change it as soon as I have all of this
working!)

DEBUG was already set to true in my settings.py file and per your
advice, I checked the apache logs to see if there was anything odd in
there and there wasn't anything useful.  Is there another log to check
besides /var/log/apache2/error.log?

Any other ideas?

On Jul 8, 9:22 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote:
>
> > OK, I know this has been posted in the forums before, but for some
> > reason, I'm still struggling to get my CSS stylesheet applied to my
> > django templates.  I'm hoping that if I post my configuration, someone
> > can point out what I'm missing.
>
> > I have my django project at:  /opt/python/django-apps/foo/
> > In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
> > apps/foo/templates/media/ and MEDIA_URL set tohttp://localhost/media
>
> > In my apache2.conf file, I have the following:
>
> > # Django configuration
> > LoadModule python_module modules/mod_python.so
>
> > 
> >        SetHandler python-program
> >        PythonHandler django.core.handlers.modpython
> >        SetEnv DJANGO_SETTINGS_MODULE foo.settings
> >        PythonDebug On
> >        PythonPath "['/opt/python/django-apps/'] + sys.path"
> > 
> > 
> >        SetHandler python-program
> >        PythonHandler django.core.handlers.modpython
> >        SetEnv DJANGO_SETTINGS_MODULE foo.settings
> >        PythonDebug On
> >        PythonPath "['/opt/python/django-apps/'] + sys.path"
> > 
>
> > 
> >        SetHandler None
> > 
>
> An alias directive to tell apache where to find your media is probably
> all you need. Assuming your apache's DocumentRoot is something other
> than your templates dir.
>
> 
>        SetHandler None
> 
> Alias /media/ /opt/python/django-apps/foo/templates/media/
>
> Also putting your media dir in your templates dir is kind of odd.
> Usually it's at the top of the project directory.
>
> Then set MEDIA_URL='/media/' you don't need 'http://localhost'.
>
> > In my base.html file, I reference the stylesheet as  > rel="stylesheet" type="text/css" href="media/style.css"
> > media="screen" />
>
> Finally in your templates use '/media/foo' not 'media/foo', that way
> it doesn't matter what location you are serving from, /media/ will
> work.
>
>
>
> > When I point my browser athttp://localhost/contact, all I get is a
> > blank page... no style and no text.  The contact.html template is
> > below:
>
> > {% extends "base.html" %}
>
> > {% block title %}
> >        - Contact Us
> > {% endblock %}
>
> > {% block content %}
> >        some content...please show up
> > {% endblock %}
>
> > I'm not sure if there not being any text is related to the CSS problem
> > or not.  I haven't spent any time troubleshooting that just yet, but I
> > thought I'd throw it in for good measure.
>
> > Any help that anyone can give is greatly appreciated!
>
> Also don't forget to set DEBUG=True in your settings.py and check your
> error log for more info.
>
> --
> Milan
--~--~-~--~~~---~--~~
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, Apache, and CSS

2008-07-08 Thread foo

First, I want to say thank you for your reply Milan!  I just recently
joined the group and I'm impressed at how active the group and how
helpful all of the advice I've found here has been.

I've made the changes that you suggested and unfortunately, I'm still
seeing the same behavior.  What I did was:

Created the alias in my apache2.conf file...that file now looks as
such:

# Django initialization
LoadModule python_module modules/mod_python.so


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE fourthbear.settings
PythonDebug On
PythonPath "['/opt/python/django-apps/'] + sys.path"


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE fourthbear.settings
PythonDebug On
PythonPath "['/opt/python/django-apps/'] + sys.path"



SetHandler None


Alias /media/ /opt/python/django-apps/foo/templates/media/

I changed MEDIA_URL to only be '/media/'

And I changed base.html template to use /media/style.css instead of
media/style.css

(I appreciate your comment about the location of my media
directory...I'll be sure to change it as soon as I have all of this
working!)

DEBUG was already set to true in my settings.py file and per your
advice, I checked the apache logs to see if there was anything odd in
there and there wasn't anything useful.  Is there another log to check
besides /var/log/apache2/error.log?

Any other ideas?


On Jul 8, 9:22 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote:
>
> > OK, I know this has been posted in the forums before, but for some
> > reason, I'm still struggling to get my CSS stylesheet applied to my
> > django templates.  I'm hoping that if I post my configuration, someone
> > can point out what I'm missing.
>
> > I have my django project at:  /opt/python/django-apps/foo/
> > In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
> > apps/foo/templates/media/ and MEDIA_URL set tohttp://localhost/media
>
> > In my apache2.conf file, I have the following:
>
> > # Django configuration
> > LoadModule python_module modules/mod_python.so
>
> > 
> >        SetHandler python-program
> >        PythonHandler django.core.handlers.modpython
> >        SetEnv DJANGO_SETTINGS_MODULE foo.settings
> >        PythonDebug On
> >        PythonPath "['/opt/python/django-apps/'] + sys.path"
> > 
> > 
> >        SetHandler python-program
> >        PythonHandler django.core.handlers.modpython
> >        SetEnv DJANGO_SETTINGS_MODULE foo.settings
> >        PythonDebug On
> >        PythonPath "['/opt/python/django-apps/'] + sys.path"
> > 
>
> > 
> >        SetHandler None
> > 
>
> An alias directive to tell apache where to find your media is probably
> all you need. Assuming your apache's DocumentRoot is something other
> than your templates dir.
>
> 
>        SetHandler None
> 
> Alias /media/ /opt/python/django-apps/foo/templates/media/
>
> Also putting your media dir in your templates dir is kind of odd.
> Usually it's at the top of the project directory.
>
> Then set MEDIA_URL='/media/' you don't need 'http://localhost'.
>
> > In my base.html file, I reference the stylesheet as  > rel="stylesheet" type="text/css" href="media/style.css"
> > media="screen" />
>
> Finally in your templates use '/media/foo' not 'media/foo', that way
> it doesn't matter what location you are serving from, /media/ will
> work.
>
>
>
> > When I point my browser athttp://localhost/contact, all I get is a
> > blank page... no style and no text.  The contact.html template is
> > below:
>
> > {% extends "base.html" %}
>
> > {% block title %}
> >        - Contact Us
> > {% endblock %}
>
> > {% block content %}
> >        some content...please show up
> > {% endblock %}
>
> > I'm not sure if there not being any text is related to the CSS problem
> > or not.  I haven't spent any time troubleshooting that just yet, but I
> > thought I'd throw it in for good measure.
>
> > Any help that anyone can give is greatly appreciated!
>
> Also don't forget to set DEBUG=True in your settings.py and check your
> error log for more info.
>
> --
> Milan
--~--~-~--~~~---~--~~
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: "ImportError No module named django"

2008-07-08 Thread MadMax007

Ok, for the PYTHONPATH I got:

>>> import sys
>>> print sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python25.zip', '/System/Library/Frameworks/Python.framework/Versions/
2.5/lib/python2.5', '/System/Library/Frameworks/Python.framework/
Versions/2.5/lib/python2.5/plat-darwin', '/System/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/plat-mac', '/System/
Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-
mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/
Versions/2.5/Extras/lib/python', '/System/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/System/Library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload', '/
Library/Python/2.5/site-packages', '/System/Library/Frameworks/
Python.framework/Versions/2.5/Extras/lib/python/PyObjC']
>>>

Hope this tells you something, I relatively new to Apple computers so
I feel a bit lost, and to top things off, I'm new to Python as well :
(

On Jul 8, 5:42 pm, Julien Phalip <[EMAIL PROTECTED]> wrote:
> Hi,
>
> This means that Django is not in the PYTHONPATH. To check what's in
> that path, run the following in Python:
>
> >>> import sys
> >>> print sys.path
>
> On Jul 9, 9:35 am, Juanjo Conti <[EMAIL PROTECTED]> wrote:
>
> > How did you exactly install it?
> > Which folders are in your PYTHONPATH?
>
> > Juanjo
> > --
> > mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
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: What is the fastest way to come up to speed with Django?

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 19:08 -0700, ristretto.rb wrote:
> I leading a project based on Django, and I come from 12 years of Java,
> and 0 years of Python.  

You won't get any crap from me, at least. The more languages people
know, the better.

> I'm currently digging into the django-trunk on many an occasion,
> trying to explain things that I can't find in the docs.  Because I
> don't understand how Django was designed, and can't guess too easily,
> I find that really slow.
> 
> I'm wondering if getting the KomodoIDE editor with a debugger would
> make learning Django faster.  Or would WingIDE be a better bet?  Or
> Eclipse with pyDev.  In theory, I could see stepping through code to
> learn how it all fits.  But, does this work well in practice?

Personally I have no experience with any of those, so I'm not going to
give advice.

The one cavaet I'll point out is that *running* pretty much anything in
Django requires a settings file, since there are a few places where code
is executed conditionally based on settings. Most files can now be
imported without a settings file being present (allowing you to import
things and then manually configure settings in advanced cases), but
there might be some deep internals where that isn't possible. All this
means is that you *might* need to have DJANGO_SETTINGS_MODULE set and
pointing to some reasonably simple settings file (specify a template
loader and a database engine).

> Any other tips to getting up to speed fast? 

With the internal code? I wish there was some silver bullet like that.

When you are poking around the internals, things are generally grouped
fairly logically. Although, like any piece of software with five or six
years of development behind it, there are some historical oddities as
well. But, by and large, you'll find like grouped with like. For
example,

django/templates:
all the template loading and rendering code
django/core/handlers:
the stuff that is the outer layer of request/response
handling.
django/db/models/fields/
all the model field code
django/db/models/sql
SQL statement creation
django/db/models/*
all the other model stuff
django/db/backends/
the individual database backends and common wrapping
code for them.
django/utils/translation/
i18n/l10n support

django/utils is a bit of a grab bag of internal common stuff that is
used in multiple places. Django/core is stuff that didn't sit anywhere
else but was important.

In something as modular and wide-ranging as Django there isn't really an
obvious way to read it from beginning to end. However, if you really
want to understand what's going on you could start with the lifecycle of
an HTTP request (django/core/handlers/wsgi.py, say), which leads to URL
resolving, following through to the middleware, view calling, middleware
again and response dispatching. Orthogonal to that is model handling,
database interaction (triggered by the model code) and various view
support stuff like generic views.

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



Generic delete view.

2008-07-08 Thread William

Hi, I'm having a bit of trouble using the delete generic view in
Django SVN. I have the following entry in my urlpatterns:
from django.views.generic.create_update import *
urlpatterns = patterns('',
...
(r'^calendar/delete/(?P\d+)/$','delete_object',
{'model':Event,'post_delete_redirect':'/calendar/'}),
...
)

And in a template, I have the following hyperlink:
Delete Event

When I click on the link in the above template, I get the following:
TypeError at /calendar/delete/1/
'str' object is not callable
/usr/lib/python2.5/site-packages/django/core/handlers/base.py in
get_response, line 86

I've tried various different ways of calling this generic view, but
none seem to work.
As a side note, is it worth using generic views such as create and
update since they still use oldforms?

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



What is the fastest way to come up to speed with Django?

2008-07-08 Thread ristretto.rb

I leading a project based on Django, and I come from 12 years of Java,
and 0 years of Python.  

I'm currently digging into the django-trunk on many an occasion,
trying to explain things that I can't find in the docs.  Because I
don't understand how Django was designed, and can't guess too easily,
I find that really slow.

I'm wondering if getting the KomodoIDE editor with a debugger would
make learning Django faster.  Or would WingIDE be a better bet?  Or
Eclipse with pyDev.  In theory, I could see stepping through code to
learn how it all fits.  But, does this work well in practice?

Any other tips to getting up to speed fast?  I have both Django books,
2 python references and the python cookbook, and I'm working hard to
get up to speed.

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: Issue with django-tagging 0.3 (svn) with models definition

2008-07-08 Thread Peter Herndon

For a more immediate answer, ask on #django on IRC.  Mailing list may
not answer as quickly as you'd prefer. Or at all, if nobody has the
time to answer.

You should look at the model documentation for specifics, but you
likely need null=True as a param in your tags=Tagfield() declaration.

---Pete r Herndon


On 7/8/08, Nicolas Steinmetz <[EMAIL PROTECTED]> wrote:
>
> Nicolas Steinmetz wrote:
>
>>
>> Hello,
>>
>> Despite I read a lot of time the overview.txt on the django tagging svn
>> repository, I still can't stand how to use it at my model's level. I'm
>> quite new to python and may miss some elements.
>>
>> When diving into the register part, it says it requiers a field for tag
>> which is supposed to be "tags". But what kind of type is this tag supposed
>> to be ? a TagField() ?
>>
>> I came down to this kind of things which looks not the optimum for me (at
>> least at validate & runserver step, it stops shouting...):
>>
>> from django.db import models
>> import tagging
>> from tagging.models import Tag
>> from tagging.fields import TagField
>>
>> # Create your models here.
>> class Links(models.Model):
>> title = models.CharField(max_length=80)
>> description = models.TextField()
>> url = models.URLField()
>> tags = TagField()
>>
>> class Admin:
>> list_display = ('title', 'description', 'url', 'tags',)
>> list_filter = ['title', 'tags']
>> search_fields = ['title','tags',]
>>
>> class Meta:
>> verbose_name = "Lien"
>> verbose_name_plural = "Liens"
>>
>> tagging.register(Links)
>>
>> But when I try to save a link, I got :
>>
>> IntegrityError at /admin/links/links/add/
>> tagging_taggeditem.object_id may not be NULL
>>
>> What did I miss ?
>>
>> Regards,
>> Nicolas
>>
>
> Nobody is in a similar case than mine ?
> --
> Nicolas Steinmetz
> http://www.steinmetz.fr/
> http://www.unelectronlibre.info/
>
>
> >
>

--~--~-~--~~~---~--~~
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: connection.queries - show improper SQL?

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 17:43 -0700, Peter wrote:
[...]

> Is this Django-MySQL 5.x specific?  Is this a full-on django bug?

Neither. Any quoting and escaping of parameters in the query is done by
the Python database wrapper. The DB API does not expose any public
function to access how each individual backend does that quoting, so we
can only show you the values prior to escaping occurring (for all
backends). It's a good approximation, but it's not always perfect for
cut-and-paste use. Pretty easy to modify when you need it, though.

If you want to see the exact query that is being passed through to
cursor.execute() and you're using trunk, have a look at

my_queryset.query.as_sql()

That will return the string (with "%s" where parameters go) and a tuple
of the parameters that are being substituted. That is *exactly* what is
passed to the DB wrapper (MySQLdb, pyscopg2, pysqlite2, etc).

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: In admin, unable to save many-to-many relation objects with intermediate table

2008-07-08 Thread ristretto.rb

More details.  I'm using MySQL at the moment (but with a plan to move
to Postgresql.)  The association table has a number of rows loaded
through these models, but not through my Django app directly.  I used
the Model classes in a script to pre load a bunch of data.  Could this
be the problem?

On Jul 9, 1:28 pm, ristretto.rb <[EMAIL PROTECTED]> wrote:
> OK, I took core=True off, and added it to the reference_no field.  The
> problem seems to go away for the case when no there are no
> pre-existing joins.   Clearly, I don't understand what core is for.
> I'll read the docs again, and see if it makes sense.
>
> However, it still errors with
>
> {'jointable.0.id': [u'Join Table record with this ID already exists.']}
>
> when I tried to save a LeftSide records with existing associations.
>
> thanks for any and all help.
>
>
>
> On Wed, Jul 9, 2008 at 1:09 PM, ristretto. rb <[EMAIL PROTECTED]> wrote:
> > Hello, I'm stuck.  Any help will be much appreciated.
>
> > I followed
> >http://www.djangoproject.com/documentation/models/m2m_intermediary/to make
> > a
> > Many-to-many relationship via an intermediary table.
>
> > class LeftSide(models.Model):
> > :
>
> > class RightSide(models.Model):
> > :
>
> > class JoinTable(models.Model):
> >     leftSide = models.ForeignKey(LeftSide,
> >                 edit_inline=models.TABULAR,
> >                 num_in_admin=3, core=True)
> >     rightSide = models.ForeignKey(RightSide,
> >                 edit_inline=models.TABULAR,
> >                 num_in_admin=3,core=True)
> >     reference_no = models.CharField(max_length=10, null=True, blank=True)
>
> > I can load the LeftSide in the admin, and choose to Change a record.  I get
> > 3 RightSide menu groups at the bottom.  I can choose a RightSide to set as a
> > join.  When I choose Save (any of the 3 save variations on the page) nothing
> > is saved.
>
> > There are two cases.
>
> > 1)  If the are already records in the join table for that LeftSide, then I
> > get an error when I save.  {'jointable.0.id': [u'Join Table record with this
> > ID already exists.']}  I didn't actually make any changes to that
> > association, so I don't know why it would complain.
>
> > 2)  If there are no join table records associated with the LeftSide, then
> > there is no error, but nothing is saved.
>
> > Am I doing something totally wrong here?  Or is this a bug in the Admin
> > system?
--~--~-~--~~~---~--~~
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 using custom sql in manager

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 17:17 -0700, AJ wrote:
> Thanks for your quick reply.  I have been searching for a long time
> for good documentation on using IN and paramaters with no luck.  When
> it worked with a list I assumed that was correct.  Could you clarify
> an example of transforming a list of items into something mysqldb
> would accept then executing it?  I think you are saying that if I have
> 2 items in the list I need to manually specify:
> 
> zips = ['7', '55544']
> sql = """
> SELECT id
> FROM Event
> WHERE zip_code IN %s, %s"""
> cursor.execute(sql, (zips[0], zips[1]))

That's not valid SQL. The "IN" operator requires something in
parentheses. Normal SQL rules apply. Yes, it's possibly an error or an
oversight that all this isn't handled automatically in some fashion, but
it's really hard, since some databases allow array-like operations and
there's all sort of edge-cases. I can't blame Python's DB-API for
pushings things back to the client code here.

Here's how Django constructs the SQL piece for "IN" operators:
http://code.djangoproject.com/browser/django/trunk/django/db/models/sql/where.py#L151
 (that line number is only valid until the next time that file is changed, but 
it's the right file, so you can always just search for the word "IN").

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: does django cache models.py?

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 6:12 PM, Daehee <[EMAIL PROTECTED]> wrote:
>
> i'm trying it figure out why django is not recognizing a new models.py
> file for my app. even when i completely butcher the code in models.py
> or change the filename and run "manage.py sqlreset" or "manage.py
> syndb," it still generates the old model. any thoughts??

Are you sure that app is in INSTALLED_APPS in settings.py?  Otherwise
django and hence runserver ignore it.  Not sure if I'm following
exactly.  If you can post a bit more information like your
directory/file structure and your settings.py that would help
diagnosis.

--
Milan

--~--~-~--~~~---~--~~
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: elusive Post error

2008-07-08 Thread Jeff FW

Are you getting a particular error code, like 501 (not implemented)?
I would check Apache's error logs, as the issue might be happening
before Django ever gets the request.  If nothing useful shows up in
those logs, try increasing the logging level.

Oh, just a note--you may want to strip secret data out of your config
files before posting them.  In fact, I'd suggest changing those
passwords quickly, just in case.

-Jeff

On Jul 8, 11:45 am, Adam Fraser <[EMAIL PROTECTED]> wrote:
> I was wondering if anyone else has ever run into this problem...
>
> When filling out a form, I click submit and get a POST error claiming
> that the page does not support POST.  However, if I refresh the error
> page, the request goes through, and all is happy.
>
> I don't have much experience with web applications, so I'm not sure
> where to start here.  We're running on Apache and using SSL for
> authentication, but I disabled SSL and the problem persists.
>
> Here's my settings file anyway... any ideas?
>
> -Adam
>
> # Django settings for ProjectProfiler project.
>
> import posix  # for getuid
> import pwd    # for getpwuid
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
>     # ('Your Name', '[EMAIL PROTECTED]'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'mysql'                    # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>
> # Check whether to use the test or production version of the DB
> if (pwd.getpwuid(posix.getuid())[0] == "imageweb") :
>     DATABASE_NAME = 'projectprofiler'        # Or path to database
> file if using sqlite3.
> else :
>     DATABASE_NAME = 'projectprofilertest'    # Or path to database
> file if using sqlite3.
>
> DATABASE_USER = 'cpuser'                     # Not used with sqlite3.
> DATABASE_PASSWORD = 'cPus3r'                 # Not used with sqlite3.
> DATABASE_HOST = 'imgdb01.broad.mit.edu'      # Set to empty string for
> localhost. Not used with sqlite3.
> DATABASE_PORT = ''                           # Set to empty string for
> default. Not used with sqlite3.
>
> TIME_ZONE = 'America/New_York'
> LANGUAGE_CODE = 'en-us'
> SITE_ID = 1
> USE_I18N = True
> MEDIA_ROOT = '/home/radon01/afraser/projectprofiler/trunk/
> projectprofiler/media/'
> MEDIA_URL = 'http://127.0.0.1:8000/projectprofiler/media/'
> ADMIN_MEDIA_PREFIX = '/projectprofiler/media/admin/'
> SECRET_KEY = '&[EMAIL PROTECTED]&a886+2(2w9fu$6=-'
>
> TEMPLATE_LOADERS = (
>     'django.template.loaders.filesystem.load_template_source',
>     'django.template.loaders.app_directories.load_template_source',
> #     'django.template.loaders.eggs.load_template_source',
> )
>
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
> #    'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'projectprofiler.sslauth.middleware.SSLAuthMiddleware',
>     'django.middleware.doc.XViewMiddleware',
>     'projectprofiler.middleware.threadlocals.ThreadLocals',
> )
>
> ROOT_URLCONF = 'projectprofiler.urls'
>
> TEMPLATE_DIRS = (
>     '/home/radon01/afraser/projectprofiler/trunk/projectprofiler/
> templates',
>     '/imaging/analysis/People/imageweb/projectprofiler/trunk/
> projectprofiler/templates',
>     '/Users/ljosa/research/projectprofiler/projectprofiler/trunk/
> projectprofiler/templates',
> )
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
> #    'django.contrib.sites',
>     'projectprofiler.sslauth',
>     'projectprofiler.projects',
>     'django.contrib.admin',
> )
>
> AUTHENTICATION_BACKENDS = (
>     'projectprofiler.sslauth.backends.SSLAuthBackend',
> #    'django.contrib.auth.backends.ModelBackend',
> )
>
> def myusernamegen(ssl_info):
>     import re
>     return re.sub('[EMAIL PROTECTED]', '', ssl_info.subject_email)
>
> SSLAUTH_CREATE_USER_CALLBACK = myusernamegen
> SSLAUTH_CREATE_USER = True
--~--~-~--~~~---~--~~
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: In admin, unable to save many-to-many relation objects with intermediate table

2008-07-08 Thread ristretto . rb

OK, I took core=True off, and added it to the reference_no field.  The
problem seems to go away for the case when no there are no
pre-existing joins.   Clearly, I don't understand what core is for.
I'll read the docs again, and see if it makes sense.

However, it still errors with

{'jointable.0.id': [u'Join Table record with this ID already exists.']}

when I tried to save a LeftSide records with existing associations.

thanks for any and all help.




On Wed, Jul 9, 2008 at 1:09 PM, ristretto. rb <[EMAIL PROTECTED]> wrote:
> Hello, I'm stuck.  Any help will be much appreciated.
>
> I followed
> http://www.djangoproject.com/documentation/models/m2m_intermediary/ to make
> a
> Many-to-many relationship via an intermediary table.
>
> class LeftSide(models.Model):
> :
>
> class RightSide(models.Model):
> :
>
> class JoinTable(models.Model):
> leftSide = models.ForeignKey(LeftSide,
> edit_inline=models.TABULAR,
> num_in_admin=3, core=True)
> rightSide = models.ForeignKey(RightSide,
> edit_inline=models.TABULAR,
> num_in_admin=3,core=True)
> reference_no = models.CharField(max_length=10, null=True, blank=True)
>
> I can load the LeftSide in the admin, and choose to Change a record.  I get
> 3 RightSide menu groups at the bottom.  I can choose a RightSide to set as a
> join.  When I choose Save (any of the 3 save variations on the page) nothing
> is saved.
>
> There are two cases.
>
> 1)  If the are already records in the join table for that LeftSide, then I
> get an error when I save.  {'jointable.0.id': [u'Join Table record with this
> ID already exists.']}  I didn't actually make any changes to that
> association, so I don't know why it would complain.
>
> 2)  If there are no join table records associated with the LeftSide, then
> there is no error, but nothing is saved.
>
> Am I doing something totally wrong here?  Or is this a bug in the Admin
> system?
>
>
>



-- 
Picante Solutions Limited
e: [EMAIL PROTECTED]
w: 06 757 9488

--~--~-~--~~~---~--~~
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, Apache, and CSS

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote:
>
> OK, I know this has been posted in the forums before, but for some
> reason, I'm still struggling to get my CSS stylesheet applied to my
> django templates.  I'm hoping that if I post my configuration, someone
> can point out what I'm missing.
>
> I have my django project at:  /opt/python/django-apps/foo/
> In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
> apps/foo/templates/media/ and MEDIA_URL set to http://localhost/media
>
> In my apache2.conf file, I have the following:
>
> # Django configuration
> LoadModule python_module modules/mod_python.so
>
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
>
> 
>SetHandler None
> 
>

An alias directive to tell apache where to find your media is probably
all you need. Assuming your apache's DocumentRoot is something other
than your templates dir.


   SetHandler None

Alias /media/ /opt/python/django-apps/foo/templates/media/

Also putting your media dir in your templates dir is kind of odd.
Usually it's at the top of the project directory.

Then set MEDIA_URL='/media/' you don't need 'http://localhost'.

> In my base.html file, I reference the stylesheet as  rel="stylesheet" type="text/css" href="media/style.css"
> media="screen" />

Finally in your templates use '/media/foo' not 'media/foo', that way
it doesn't matter what location you are serving from, /media/ will
work.

> When I point my browser at http://localhost/contact, all I get is a
> blank page... no style and no text.  The contact.html template is
> below:
>
> {% extends "base.html" %}
>
> {% block title %}
>- Contact Us
> {% endblock %}
>
> {% block content %}
>some content...please show up
> {% endblock %}
>
> I'm not sure if there not being any text is related to the CSS problem
> or not.  I haven't spent any time troubleshooting that just yet, but I
> thought I'd throw it in for good measure.
>
> Any help that anyone can give is greatly appreciated!
>

Also don't forget to set DEBUG=True in your settings.py and check your
error log for more info.

--
Milan

--~--~-~--~~~---~--~~
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-08 Thread Mario

Lloyd,

There's more than one way to skin a cat. It does not matter if you are
using development server or apache. I have been using Tiny MCE for
about a year now and I am happy with the setup.

For flatpages, if you have admin rights to the server, you need to
edit your flatpages model located in the /usr/lib/python2.5/site-
packages/django/contrib/flatpages directory. Make sure make a copy of
the model prior to making any changes.

Check out Bill DeOra write about Tiny_MCE. It was written in 2006. The
URL is http://dehora.net/journal/2006/05/

Gracias,

-Mario

On Jul 8, 8:01 pm, LRP <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thanks to all for responses, but puzzle persists...
>
> Mathias, I added the slash. Still can't see the tiny_mce edit bar.
> But it does provide a clue: Output of runserver now looks like:
>
> [08/Jul/2008 19:37:17] "GET /admin/ HTTP/1.1" 200 4851
> [08/Jul/2008 19:37:20] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200
> 2817
> [08/Jul/2008 19:37:23] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200
> 5187
> [08/Jul/2008 19:37:23] "GET /admin/jsi18n/ HTTP/1.1" 200 803
> [08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771
> [08/Jul/2008 19:37:24] "GET /tiny_mce/themes/simple/editor_template.js
> HTTP/1.1" 404 1834
>
> If I enterhttp://192.168.1.4:8000/tiny_mce/tiny_mce.js, I still see:
> var tinymce={majorVersion:'3',minorVersion:'0.8'...
>
> Mario,
>
> I'm serving through the development server , runserver, not Apache.
> Also, the model is buried in django.contrib.flatpages somewhere. I
> would think that James Bennett would have mentioned something about
> adding to the model if it were required. I'll keep you idea in mind,
> however.
>
> Thanks again to all,
>
> 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
-~--~~~~--~~--~--~---



In admin, unable to save many-to-many relation objects with intermediate table

2008-07-08 Thread ristretto . rb
 Hello, I'm stuck.  Any help will be much appreciated.

I followed
http://www.djangoproject.com/documentation/models/m2m_intermediary/ to make
a
Many-to-many relationship via an intermediary table.

class LeftSide(models.Model):
:

class RightSide(models.Model):
:

class JoinTable(models.Model):
leftSide = models.ForeignKey(LeftSide,
edit_inline=models.TABULAR,
num_in_admin=3, core=True)
rightSide = models.ForeignKey(RightSide,
edit_inline=models.TABULAR,
num_in_admin=3,core=True)
reference_no = models.CharField(max_length=10, null=True, blank=True)

I can load the LeftSide in the admin, and choose to Change a record.  I get
3 RightSide menu groups at the bottom.  I can choose a RightSide to set as a
join.  When I choose Save (any of the 3 save variations on the page) nothing
is saved.

There are two cases.

1)  If the are already records in the join table for that LeftSide, then I
get an error when I save.  {'jointable.0.id': [u'Join Table record with this
ID already exists.']}  I didn't actually make any changes to that
association, so I don't know why it would complain.

2)  If there are no join table records associated with the LeftSide, then
there is no error, but nothing is saved.

Am I doing something totally wrong here?  Or is this a bug in the Admin
system?

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



In admin, unable to save many-to-many relation objects with intermidiate table

2008-07-08 Thread ristretto.rb

Hello, I'm stuck.  Any help will be much appreciated.

I followed 
http://www.djangoproject.com/documentation/models/m2m_intermediary/ to 
make a
Many-to-many relationship via an intermediary table.

class LeftSide(models.Model):
:

class RightSide(models.Model):
:

class JoinTable(models.Model):
leftSide = models.ForeignKey(LeftSide,
edit_inline=models.TABULAR,
num_in_admin=3, core=True)
rightSide = models.ForeignKey(RightSide,
edit_inline=models.TABULAR,
num_in_admin=3,core=True)
reference_no = models.CharField(max_length=10, null=True, blank=True)

I can load the LeftSide in the admin, and choose to Change a record.  I 
get 3 RightSide menu groups at the bottom.  I can choose a RightSide to 
set as a join.  When I choose Save (any of the 3 save variations on the 
page) nothing is saved.

There are two cases. 

1)  If the are already records in the join table for that LeftSide, then 
I get an error when I save.  {'jointable.0.id': [u'Join Table record 
with this ID already exists.']}  I didn't actually make any changes to 
that association, so I don't know why it would complain.

2)  If there are no join table records associated with the LeftSide, 
then there is no error, but nothing is saved, either.

Am I doing something totally wrong here?  Or is this a bug in the Admin 
system?



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



Django, Apache, and CSS

2008-07-08 Thread foo

OK, I know this has been posted in the forums before, but for some
reason, I'm still struggling to get my CSS stylesheet applied to my
django templates.  I'm hoping that if I post my configuration, someone
can point out what I'm missing.

I have my django project at:  /opt/python/django-apps/foo/
In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
apps/foo/templates/media/ and MEDIA_URL set to http://localhost/media

In my apache2.conf file, I have the following:

# Django configuration
LoadModule python_module modules/mod_python.so


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE foo.settings
PythonDebug On
PythonPath "['/opt/python/django-apps/'] + sys.path"


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE foo.settings
PythonDebug On
PythonPath "['/opt/python/django-apps/'] + sys.path"



SetHandler None


In my base.html file, I reference the stylesheet as 

When I point my browser at http://localhost/contact, all I get is a
blank page... no style and no text.  The contact.html template is
below:

{% extends "base.html" %}

{% block title %}
- Contact Us
{% endblock %}

{% block content %}
some content...please show up
{% endblock %}

I'm not sure if there not being any text is related to the CSS problem
or not.  I haven't spent any time troubleshooting that just yet, but I
thought I'd throw it in for good measure.

Any help that anyone can give is greatly appreciated!

--~--~-~--~~~---~--~~
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-08 Thread Chatchai Neanudorn
Ok, Got you. Where is retrun code for
/tiny_mce/tiny_mce.jsitself,
Did you mean all js under /tiny_mce cannot be loadded by django?
What is environment you are working on?

2008/7/9 Chatchai Neanudorn <[EMAIL PROTECTED]>:

> http://192.168.1.4:8000/tiny_mce/tiny_mce.js vs [08/Jul/2008 19:37:23]
> "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771
>
> What is "lang" at the right side?
>
> Chatchai
>
> 2008/7/9 LRP <[EMAIL PROTECTED]>:
>
>
>> Hi,
>>
>> Thanks to all for responses, but puzzle persists...
>>
>> Mathias, I added the slash. Still can't see the tiny_mce edit bar.
>> But it does provide a clue: Output of runserver now looks like:
>>
>> [08/Jul/2008 19:37:17] "GET /admin/ HTTP/1.1" 200 4851
>> [08/Jul/2008 19:37:20] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200
>> 2817
>> [08/Jul/2008 19:37:23] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200
>> 5187
>> [08/Jul/2008 19:37:23] "GET /admin/jsi18n/ HTTP/1.1" 200 803
>> [08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771
>> [08/Jul/2008 19:37:24] "GET /tiny_mce/themes/simple/editor_template.js
>> HTTP/1.1" 404 1834
>>
>> If I enter http://192.168.1.4:8000/tiny_mce/tiny_mce.js, I still see:
>> var tinymce={majorVersion:'3',minorVersion:'0.8'...
>>
>> Mario,
>>
>> I'm serving through the development server , runserver, not Apache.
>> Also, the model is buried in django.contrib.flatpages somewhere. I
>> would think that James Bennett would have mentioned something about
>> adding to the model if it were required. I'll keep you idea in mind,
>> however.
>>
>> Thanks again to all,
>>
>> 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
-~--~~~~--~~--~--~---



connection.queries - show improper SQL?

2008-07-08 Thread Peter

When I look at generated sql from connection.queries, it doesn't show
any quotes around strings.

For example:
>>> from django.db import connection
>>> from django.contrib.auth.models import User
>>> User.objects.filter(username="bob")
[]
>>> connection.queries[-1]
{'time': '0.000', 'sql': u'SELECT `auth_user`.`id`,
`auth_user`.`username`, `auth_user`.`first_name`,
`auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`,
`auth_user`.`is_staff`, `auth_user`.`is_active`,
`auth_user`.`is_superuser`, `auth_user`.`last_login`,
`auth_user`.`date_joined` FROM `auth_user` WHERE
`auth_user`.`username` = bob  ORDER BY `auth_user`.`username` ASC'}
>>>

As one would imagine, when I execute:

mysql> SELECT `auth_user`.`id`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`,
`auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
`auth_user`.`is_active`, `auth_user`.`is_superuser`,
`auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
WHERE `auth_user`.`username` = bob  ORDER BY `auth_user`.`username`
ASC;

It complains with "Unknown column 'bob' in 'where clause'".

It's obvious how I would change that code to execute properly, but I'd
like to know exactly what query django is building.
(for example you can get away with passing a number into a query
against a varchar, and that can affect the efficiency of complex
queries)

Is this Django-MySQL 5.x specific?  Is this a full-on django bug?

Regards.
Peter
--~--~-~--~~~---~--~~
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-08 Thread Chatchai Neanudorn
http://192.168.1.4:8000/tiny_mce/tiny_mce.js vs [08/Jul/2008 19:37:23] "GET
/tiny_mce/langs/en.js HTTP/1.1" 404 1771

What is "lang" at the right side?

Chatchai

2008/7/9 LRP <[EMAIL PROTECTED]>:

>
> Hi,
>
> Thanks to all for responses, but puzzle persists...
>
> Mathias, I added the slash. Still can't see the tiny_mce edit bar.
> But it does provide a clue: Output of runserver now looks like:
>
> [08/Jul/2008 19:37:17] "GET /admin/ HTTP/1.1" 200 4851
> [08/Jul/2008 19:37:20] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200
> 2817
> [08/Jul/2008 19:37:23] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200
> 5187
> [08/Jul/2008 19:37:23] "GET /admin/jsi18n/ HTTP/1.1" 200 803
> [08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771
> [08/Jul/2008 19:37:24] "GET /tiny_mce/themes/simple/editor_template.js
> HTTP/1.1" 404 1834
>
> If I enter http://192.168.1.4:8000/tiny_mce/tiny_mce.js, I still see:
> var tinymce={majorVersion:'3',minorVersion:'0.8'...
>
> Mario,
>
> I'm serving through the development server , runserver, not Apache.
> Also, the model is buried in django.contrib.flatpages somewhere. I
> would think that James Bennett would have mentioned something about
> adding to the model if it were required. I'll keep you idea in mind,
> however.
>
> Thanks again to all,
>
> 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: Problems using custom sql in manager

2008-07-08 Thread AJ

Thanks for your quick reply.  I have been searching for a long time
for good documentation on using IN and paramaters with no luck.  When
it worked with a list I assumed that was correct.  Could you clarify
an example of transforming a list of items into something mysqldb
would accept then executing it?  I think you are saying that if I have
2 items in the list I need to manually specify:

zips = ['7', '55544']
sql = """
SELECT id
FROM Event
WHERE zip_code IN %s, %s"""
cursor.execute(sql, (zips[0], zips[1]))

and do you need to specify the parens around the params?  I tried
passing in a string like '("3", "33344")' and it didn't error, but
it didn't return any results either.

On Jul 8, 8:00 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-08 at 16:56 -0700, AJ wrote:
> > I've run into an issue using a manager for a model to run some custom
> > sql.
> > A dumbed down version of the code looks something like this:
> > 
> > cursor = connection.cursor()
> > # Get list of zipcodes
> > zips = [zip.zipcode for zip in
> > Zip_Code.objects.filter(lat__range=(min_lat, max_lat),
> > lon__range=(min_lon, max_lon))]
>
> > sql = """
> > SELECT id
> > FROM Event
> > WHERE zip_code IN %s"""
> > cursor.execute(sql, (zips,))
>
> > 
> > The Zipcode field is a VARCHAR(10) in the database, so the zipcodes in
> > the list are unicode strings.  If I run the query this way, I get 0
> > results.  Although If I copy the sql it generates and run it I get
> > several results.
>
> > The interesting this is if I cast the zipcode to an integer then the
> > query works.  I also tried casting each zipcode to a regular string
> > but it also returns 0 results.  So it looks like in order for the IN
> > function to work for the MySQLdb backend it must be a list of
> > integers.  This doesn't work so well for zipcodes that begin with 0's
> > like Burlington VT which is "05401".
>
> > Is there some trick I am missing, or is this a genuine bug in the
> > python MySQLdb module?
>
> You're making the assumption that you can pass a list or a tuple as a
> parameter to the query and that the DB wrapper will magically turn it
> into the right thing. This isn't correct (it happens to work by accident
> in some cases, like integers where str(some_list) is valid SQL).
>
> You need to be passing in N parameters with something like
>
>         ', '.join(["%s"] * len(params))
>
> used to construct the placeholders.
>
> 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: Django + tiny_mce

2008-07-08 Thread LRP

Hi,

Thanks to all for responses, but puzzle persists...

Mathias, I added the slash. Still can't see the tiny_mce edit bar.
But it does provide a clue: Output of runserver now looks like:

[08/Jul/2008 19:37:17] "GET /admin/ HTTP/1.1" 200 4851
[08/Jul/2008 19:37:20] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200
2817
[08/Jul/2008 19:37:23] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200
5187
[08/Jul/2008 19:37:23] "GET /admin/jsi18n/ HTTP/1.1" 200 803
[08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771
[08/Jul/2008 19:37:24] "GET /tiny_mce/themes/simple/editor_template.js
HTTP/1.1" 404 1834

If I enter http://192.168.1.4:8000/tiny_mce/tiny_mce.js, I still see:
var tinymce={majorVersion:'3',minorVersion:'0.8'...

Mario,

I'm serving through the development server , runserver, not Apache.
Also, the model is buried in django.contrib.flatpages somewhere. I
would think that James Bennett would have mentioned something about
adding to the model if it were required. I'll keep you idea in mind,
however.

Thanks again to all,

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: Problems using custom sql in manager

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 16:56 -0700, AJ wrote:
> I've run into an issue using a manager for a model to run some custom
> sql.
> A dumbed down version of the code looks something like this:
> 
> cursor = connection.cursor()
> # Get list of zipcodes
> zips = [zip.zipcode for zip in
> Zip_Code.objects.filter(lat__range=(min_lat, max_lat),
> lon__range=(min_lon, max_lon))]
> 
> sql = """
> SELECT id
> FROM Event
> WHERE zip_code IN %s"""
> cursor.execute(sql, (zips,))
> 
> 
> The Zipcode field is a VARCHAR(10) in the database, so the zipcodes in
> the list are unicode strings.  If I run the query this way, I get 0
> results.  Although If I copy the sql it generates and run it I get
> several results.
> 
> The interesting this is if I cast the zipcode to an integer then the
> query works.  I also tried casting each zipcode to a regular string
> but it also returns 0 results.  So it looks like in order for the IN
> function to work for the MySQLdb backend it must be a list of
> integers.  This doesn't work so well for zipcodes that begin with 0's
> like Burlington VT which is "05401".
> 
> Is there some trick I am missing, or is this a genuine bug in the
> python MySQLdb module?

You're making the assumption that you can pass a list or a tuple as a
parameter to the query and that the DB wrapper will magically turn it
into the right thing. This isn't correct (it happens to work by accident
in some cases, like integers where str(some_list) is valid SQL).

You need to be passing in N parameters with something like 

', '.join(["%s"] * len(params))

used to construct the placeholders.

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



Problems using custom sql in manager

2008-07-08 Thread AJ

I've run into an issue using a manager for a model to run some custom
sql.
A dumbed down version of the code looks something like this:

cursor = connection.cursor()
# Get list of zipcodes
zips = [zip.zipcode for zip in
Zip_Code.objects.filter(lat__range=(min_lat, max_lat),
lon__range=(min_lon, max_lon))]

sql = """
SELECT id
FROM Event
WHERE zip_code IN %s"""
cursor.execute(sql, (zips,))


The Zipcode field is a VARCHAR(10) in the database, so the zipcodes in
the list are unicode strings.  If I run the query this way, I get 0
results.  Although If I copy the sql it generates and run it I get
several results.

The interesting this is if I cast the zipcode to an integer then the
query works.  I also tried casting each zipcode to a regular string
but it also returns 0 results.  So it looks like in order for the IN
function to work for the MySQLdb backend it must be a list of
integers.  This doesn't work so well for zipcodes that begin with 0's
like Burlington VT which is "05401".

Is there some trick I am missing, or is this a genuine bug in the
python MySQLdb module?

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: Import issues since newforms-admin

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 16:20 -0700, Julien Phalip wrote:
> Hi,
> 
> There's an issue that arose as I upgraded an external app of mine to
> newforms-admin.
> 
> I created the conventional admin.py, which does all the registration
> business, and did "import admin" in the module's __init__.py
> 
> After I did that, I got some import errors at compilation time (or
> say, project's launching time):
> 
> "ImportError: cannot import name MenuItem"
> 
> "MenuItem" is in the external app (freshly upgraded to nfa), and the
> import that raises the error is made in the project's app.

It's a bit (for me, at least) to keep track of what structure you're
describing here. You are using the word "project" to mean something that
isn't clear. Could you give a small layout of the directory structure
please.

It's not impossible to imagine something like the problem you're
describing happening depending upon import paths. Remember that when you
do "from foo import models", Python first has to parse and execute the
code in "foo/__init__.py", so things might not be fully constructed.
But, again, it's hard to tell without concrete code. If you can
construct a very small example that demonstrates the problem (like,
literally, as few lines as possible. To the point that if you remove any
more lines, the problem goes away) then you've got something you can put
in a bug report because then other people can try to repeat the problem
and diagnose it.

I'm not intimately familiar with how newforms is doing imports or
recommended practices over there, but if this type of problem is
cropping up, it's worth knowing about it so that we can either document
"don't do that" or get things fixed if possible.

Again, I'm not saying that what you're seeing is a bug or necessarily a
problem in Django. I don't understand the problem you're describing from
the English-language version. Code speaks more clearly here, I think.

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: streaming output

2008-07-08 Thread Joshua Jonah

Not that i know of, but you'd be surprised how easy it is to write a 
socket server in Python:

http://www.amk.ca/python/howto/sockets/

Brogli wrote:
> Hi,
> Is there an easy way to get a handle to the output file stream in a
> Django application?  Instead of building an entire response in memory
> then sending it out, I'd like to send the response in pieces.
>
> thanks,
>   Dave
>
> >
>
>   


--~--~-~--~~~---~--~~
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: streaming output

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 13:31 -0700, Brogli wrote:
> Hi,
> Is there an easy way to get a handle to the output file stream in a
> Django application?  Instead of building an entire response in memory
> then sending it out, I'd like to send the response in pieces.

Not really (in a reliable way). One constraint is that Django is
designed to operate seamlessly as a WSGI application and the WSGI
specification does not permit responses to be streamed in pieces
("chunked transfer encoding" in the HTTP 1.1 parlance) from an
application.

Yes, it's theoretically possible to pass a generator to the
HttpResponse, but there are lots of technical problems that can arise.
Some of which are being worked out on the dev list at the moment, some
of which are just technically impossible (like the WSGI constraint).

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: "ImportError No module named django"

2008-07-08 Thread Julien Phalip

Hi,

This means that Django is not in the PYTHONPATH. To check what's in
that path, run the following in Python:

>>> import sys
>>> print sys.path


On Jul 9, 9:35 am, Juanjo Conti <[EMAIL PROTECTED]> wrote:
> How did you exactly install it?
> Which folders are in your PYTHONPATH?
>
> Juanjo
> --
> mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
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: "ImportError No module named django"

2008-07-08 Thread Juanjo Conti

How did you exactly install it?
Which folders are in your PYTHONPATH?

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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 use combined indices (esp. in fulltext queries)?

2008-07-08 Thread Malcolm Tredinnick


On Tue, 2008-07-08 at 08:13 -0700, ToSH wrote:
> Hi,
> 
> I would need to do a query like
> SELECT * FROM mytable WHERE match (a) against("+AAA" in boolean mode)
> and match (b against("+BBB" in boolean mode)
> and match (a,b) against("+AAA +BBB" in boolean mode)
> 
> If I would omit the last line (which seems to be redundant) I could do
> this easily with the Django framework by
> s.filter(a__search='AAA', b__search='BBB')
> 
> However it turned out that doing the query with the last line is far
> more efficient for MySQL. By querying (a,b) it can query a combined
> index which returns only very few rows which then are combined with
> the other two AND statements. If I omit the combined index, the temp
> table (for doing the AND statement) is far bigger. The speed gain is
> about factor 100 - sometimes even more (yes: my tables are quiet large
> and it is noticeable)
> 
> How would I do this in Django?

cursor.execute(my_custom_sql)

Seriously! Django is designed to cover maybe 80% of what SQL does. The
common stuff. And it provides you with access the the database cursor so
that you can do raw queries when you need to. Django isn't a replacement
for SQL, it's an adjunct. Particularly if you want to take advantages of
things that are very specific to one or other backend (esp. MySQL with
all the myriad of storage engine options), talking to the database is
the right idea.

You might be able to pull of something with the extra(where=) method
on a queryset, too, although that can become a bit fragile in complex
situations.

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



"ImportError No module named django"

2008-07-08 Thread MadMax007

I installed Django on my iMac running Lepoard. I installed the
official release and followed the instructions, but when I try to
import Django to Python I get the following message:

 "ImportError No module named django" on top of this, I now have 2
Python folders version 2.5.

Has anyone come up with a fix for this?

--~--~-~--~~~---~--~~
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-08 Thread Mario

Easy fix. Open your models.py and in the Class Admin section of the
model insert js = ['tiny_mce/tiny_mce.js', 'js/textareas.js'].

For example:

class Admin:
list_display = ('headline', 'author', 'pub_date', 'publish')
list_filter = ['pub_date']
save_as = True
js = ['tiny_mce/tiny_mce.js', 'js/textareas.js']

Save the model.
Stop and restart you apache server.
Login the Admin and verify the changes.

-Mario


On Jul 6, 11:56 am, [EMAIL PROTECTED] wrote:
> Hello,
>
> I'm working through James Bennett's Practical Django Projects. Have brought 
> up the cms; would like to add Rich Text Editing, but the instructions in 
> Bennet's book don't seem to work for me.
>
> Googling around, I find a number of recipes for adding RTE. Thought I try the 
> approach suggested by the Django 
> project:http://code.djangoproject.com/wiki/AddWYSIWYGEditor.
>
> But this doesn't work for me either.
>
> Here's my config:
>
> 1) tiny_mce.js is in: /usr/share/tinymce/www
> 2) TEMPLATE_DIRS in settings.py is set to:
>
> TEMPLATE_DIRS = (
> '/home/lloyd/django/templates/cms/',
>  )
>
> 3) my template is in: ~/django/templates/cms/flatpages
> 4) I've copied change_form.html, the admin template, into: 
> ~/django/templates/admin_copies
>
> 5) the admin template extension, change_forms.html, is in: 
> ~/django/templates/admin/flatpages/flatpage
>
> ...and reads:
>
> {% extends "admin_copies/change_form.html" %}
> {% block extrahead %}{{ block.super }}
>  src="/usr/share/tinymce/www/tiny_mce.js">
>  src="/usr/share/tinymce/www/textareas.js"
> {% endblock %}
>
> With this configuration, everything works fine, except the tiny_mce editor 
> fails to show on the admin page.
>
> Questions:
>
> 1) Am I missing or misunderstanding  a step?
> 2) Is there an effective debugging method that I can use in a case like this?
>
> Many thanks,
>
> Lloyd R. Prentice
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Import issues since newforms-admin

2008-07-08 Thread Julien Phalip

Hi,

There's an issue that arose as I upgraded an external app of mine to
newforms-admin.

I created the conventional admin.py, which does all the registration
business, and did "import admin" in the module's __init__.py

After I did that, I got some import errors at compilation time (or
say, project's launching time):

"ImportError: cannot import name MenuItem"

"MenuItem" is in the external app (freshly upgraded to nfa), and the
import that raises the error is made in the project's app.

The external app was included at the top of the INSTALLED_APPS
setting. Putting it at the end of INSTALLED_APPS solved the issue.

I thought that the order didn't matter in INSTALLED_APPS. Have I
missed something or have I possibly misconfigured my external app or
my project's apps?

Is that a known issue (and if so, what's the proper way around it?),
or is that worth filing a ticket?

Thanks!

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



does django cache models.py?

2008-07-08 Thread Daehee

i'm trying it figure out why django is not recognizing a new models.py
file for my app. even when i completely butcher the code in models.py
or change the filename and run "manage.py sqlreset" or "manage.py
syndb," it still generates the old model. any thoughts??
--~--~-~--~~~---~--~~
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: how to make input widgets smaller

2008-07-08 Thread Torsten Bronger

Hallöchen!

Torsten Bronger writes:

> I use newforms.ModelForm to get a form from one of my models.
> However, the HTML  fields are all too wide.  Okay, I could
> re-define all fields that need narrower s like
>
> class SixChamberChannelForm(ModelForm):
> gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
> diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
> class Meta:
> model = models.SixChamberChannel
>
> however, then I lose the information contained in max_length and
> help_text in the model.  How can I just put a "size" attribute to
> the fields?

Okay, after some introspection (__dict__ rules) I found this
solution:

class SixChamberChannelForm(ModelForm):
def __init__(self, **keyw):
super(SixChamberLayerForm, self).__init__(**keyw)
self.fields["gas"].widget = forms.TextInput(attrs={"size": "10"})
self.fields["diluted_in"].widget = forms.TextInput(attrs={"size": "10"})
class Meta:
model = models.SixChamberChannel

I nobody sees possible unfortunate side effects here, I think that's
it.

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: Trying to understand project structure w/apps

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 3:53 PM, eddie <[EMAIL PROTECTED]> wrote:
>
> Hi guys+gals,
>
> I'm new to django, and I'm trying to wrap my head around a project
> structure.  I have a simple case that I'm thinking about, but can't
> put together a reasonable mental model for it.
>
> I've got a site that has a schedule component (events), and a news
> component (news items).  So I can easily create two apps, one for
> events, and the other for news, and I can create varying ways to
> display these components.  My problem is that when I start thinking
> about the homepage... where I'd like to display both some events, and
> some news items.  I can't figure out how I would use templates to do
> such a thing... place both on the same page.  Ideally, I would like to
> have a template that displays an event, and one that displays a news
> item.  But I'm not sure how that would work, with both of them
> extending the same base template.
>
> I could, of course, create one app which has all of these models
> internal, which would let me easily pull them into a single template,
> but I would really rather not couple the two distinct models together
> in both the view and the templates.
>

Another option is to skip writing a view and just use a generic view
which you can do with a urls.py file and a template.  We just had a
couple people asking similar question:

http://groups.google.com/group/django-users/browse_thread/thread/d2524403e13fcd22/4fe607f6d9487ee9#4fe607f6d9487ee9

But there is nothing wrong and it's quite easy to just create a
frontpage app with just a view that returns the correct objects to a
template.

--
Milan

--~--~-~--~~~---~--~~
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: running development server

2008-07-08 Thread Karen Tracey
Just use 0.0.0.0 and the dev server will listen on all interfaces.

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: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-07-08 Thread Milan Andric



On Jun 30, 3:01 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> I've been wresting with this one for a couple hours now trying to
> track it down, but no luck.  I'm recently updated to django trunk and
> getting very odd reponses.  I could take the same page and refresh it
> several times in succession and eventually get the page, but usually
> get 500 errors.  What would cause that?
>
> http://multimedia.journalism.berkeley.edu/training/projects/
>
> I also restarted/stop/started and removed all .pyc files from my
> project, installed apps and django just for good measure.
>
>  I managed to get the traceback while in debug mode that raises a
> FieldError:http://dpaste.com/5/
>
> Here's the wrapped generic view that is being called:http://dpaste.com/60002/
>
> Here's the model:http://dpaste.com/60005/
>

Does anyone have comments on the above model?  I'm wresting with a
FieldError during a loop in the template and having a hell of a time
tracking down the problem.

The relevant part of the template is:

{% for m in p.members.all %}
{{m.get_profile.get_display_name}}{% if not forloop.last %},
{% endif %}
{% endfor %}


When I do the same loop in the shell I don't get any exceptions.  Any
help is greatly appreciated, this is on trunk.
The code seems to choke on specifically one project (id 51) but I've
traced all the relations in the db that I could think of and don't see
any inconsistencies.  But the template error is not consistent meaning
sometimes i get the exception and sometimes I don't so just trying to
clean things up where I can, starting with the model.

--
Milan
--~--~-~--~~~---~--~~
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: Trying to understand project structure w/apps

2008-07-08 Thread Norman Harman

eddie wrote:
> Hi guys+gals,
> 
> I'm new to django, and I'm trying to wrap my head around a project
> structure.  I have a simple case that I'm thinking about, but can't
> put together a reasonable mental model for it.
> 
> I've got a site that has a schedule component (events), and a news
> component (news items).  So I can easily create two apps, one for
> events, and the other for news, and I can create varying ways to
> display these components.  My problem is that when I start thinking
> about the homepage... where I'd like to display both some events, and
> some news items.  I can't figure out how I would use templates to do
> such a thing... place both on the same page.  Ideally, I would like to
> have a template that displays an event, and one that displays a news
> item.  But I'm not sure how that would work, with both of them
> extending the same base template.

Typically templates are so site specific that is doesn't make sense to 
have templates in "apps".  Templatetags can be handy.

> I could, of course, create one app which has all of these models
> internal, which would let me easily pull them into a single template,
> but I would really rather not couple the two distinct models together
> in both the view and the templates.

I think you have a false idea that templates are tied to models somehow. 
  This is not the case.

I often create an app called "main" that includes stuff like index about 
other "site" pages.  The main index page often includes data from many 
models. in main/views.py

from app import ModelOne
from app import ModelTwo

def index(request):
 context = dict()
 context["ones"] = ModelOne.objects.all()
 context["twos"] = ModelTwo.objects.filter(somekey=somevalue)
 render_to_response("main/index.html", context)


> If someone could give me a few pointers in a direction they'd approach
> this problem, it would be greatly appreciated.

http://www.pointy-stick.com/blog/2007/11/09/django-tip-developing-without-projects/


-- 
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: Calculating on generic view

2008-07-08 Thread rocco_s

Hey,
it helps :-)

but i have a little problem now. I try to add an attribute to each
element.
In the CLI ist works:

>>> from mysite.myapp.models import Mymodel
>>> list = Mymodel.objects.all()
>>> for elem in list:
...   elem.kmph = elem.distance/elem.time
>>> list[0].kmph
45

But when i put this in a view, it don't work:

def myview(request):
list = Mymodel.objects.all()
for elem in list:
   elem.kmph = elem.distance/elem.time
return object_list(request, queryset=list)

In the template i have a part something like this:

[...]
{% for elem in object_list %}

{{elem.distance}}
{{elem.time}}
{{elem.kmph}}

{% endfor %}
[...]

but the "kmph" is allways empty.

Any idea?

thanks so far...
--~--~-~--~~~---~--~~
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: Calculating on generic view

2008-07-08 Thread rocco_s

Hey,
it helps :-)

but i have a little problem now. I try to add an attribute to each
element.
In the CLI ist works:

>>> from mysite.myapp.models import Mymodel
>>> list = Mymodel.objects.all()
>>> for elem in list:
...   elem.kmph = elem.distance/elem.time
>>> list[0].kmph
45

But when i put this in a view, it don't work:

def myview(request):
list = Mymodel.objects.all()
for elem in list:
   elem.kmph = elem.distance/elem.time
return object_list(request, queryset=list)

In the template i have a part something like this:

[...]
{% for elem in object_list %}

{{elem.distance}}
{{elem.time}}
{{elem.kmph}}

{% endfor %}
[...]

but the "kmph" is allways empty.

Any idea?

thanks so far...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



streaming output

2008-07-08 Thread Brogli

Hi,
Is there an easy way to get a handle to the output file stream in a
Django application?  Instead of building an entire response in memory
then sending it out, I'd like to send the response in pieces.

thanks,
  Dave

--~--~-~--~~~---~--~~
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: Calculating on generic view

2008-07-08 Thread rocco_s

Hey,
it helps :-)

but i have a little problem now. I try to add an attribute to each
element.
In the CLI ist works:

>>> from mysite.myapp.models import Mymodel
>>> list = Mymodel.objects.all()
>>> for elem in list:
...   elem.kmph = elem.distance/elem.time
>>> list[0].kmph
45

But when i put this in a view, it don't work:

def myview(request):
list = Mymodel.objects.all()
for elem in list:
   elem.kmph = elem.distance/elem.time
return object_list(request, queryset=list)

In the template i have a part something like this:

[...]
{% for elem in object_list %}

{{elem.distance}}
{{elem.time}}
{{elem.kmph}}

{% endfor %}
[...]

but the "kmph" is allways empty.

Any idea?

thanks so far...
--~--~-~--~~~---~--~~
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: AutoImageField From Custom upload and filters

2008-07-08 Thread moos3

any takers on this ?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Trying to understand project structure w/apps

2008-07-08 Thread eddie

Hi guys+gals,

I'm new to django, and I'm trying to wrap my head around a project
structure.  I have a simple case that I'm thinking about, but can't
put together a reasonable mental model for it.

I've got a site that has a schedule component (events), and a news
component (news items).  So I can easily create two apps, one for
events, and the other for news, and I can create varying ways to
display these components.  My problem is that when I start thinking
about the homepage... where I'd like to display both some events, and
some news items.  I can't figure out how I would use templates to do
such a thing... place both on the same page.  Ideally, I would like to
have a template that displays an event, and one that displays a news
item.  But I'm not sure how that would work, with both of them
extending the same base template.

I could, of course, create one app which has all of these models
internal, which would let me easily pull them into a single template,
but I would really rather not couple the two distinct models together
in both the view and the templates.

If someone could give me a few pointers in a direction they'd approach
this problem, it would be greatly appreciated.
--~--~-~--~~~---~--~~
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: connection.queries - show improper SQL?

2008-07-08 Thread Adam V.

>From the source for QuerySet.__str__:

Returns the query as a string of SQL with the parameter values
substituted in.
Parameter values won't necessarily be quoted correctly, since that is
done by the database interface at execution time.


The __str__ method just does a naive Python % operation, and doesn't
try to quote the results.
(And in fact, the different ORM backends take the query and parameters
as separate arguments and do their own thing, such as substituting
literal 'NULL' for None paramters and things like 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: newforms: how to make input widgets smaller

2008-07-08 Thread Torsten Bronger

Hallöchen!

bruno desthuilliers writes:

> On 8 juil, 21:06, Torsten Bronger <[EMAIL PROTECTED]>
> wrote:
>
>> I use newforms.ModelForm to get a form from one of my models.
>> However, the HTML  fields are all too wide.  Okay, I could
>> re-define all fields that need narrower s like
>>
>> class SixChamberChannelForm(ModelForm):
>> gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
>> diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
>> class Meta:
>> model = models.SixChamberChannel
>>
>> however, then I lose the information contained in max_length and
>> help_text in the model.  How can I just put a "size" attribute to
>> the fields?
>
> What about using css ?

I had tried and failed.  At least Firefox ignores style="width: 3em"
attributes.

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: Django + tiny_mce

2008-07-08 Thread Matthias Kestenholz

2008/7/8 LRP <[EMAIL PROTECTED]>:
>
> 
>

Add a slash here:


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

2008-07-08 Thread bruno desthuilliers

On 8 juil, 21:06, Torsten Bronger <[EMAIL PROTECTED]>
wrote:
> Hallöchen!
>
> I use newforms.ModelForm to get a form from one of my models.
> However, the HTML  fields are all too wide.  Okay, I could
> re-define all fields that need narrower s like
>
> class SixChamberChannelForm(ModelForm):
> gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
> diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
> class Meta:
> model = models.SixChamberChannel
>
> however, then I lose the information contained in max_length and
> help_text in the model.  How can I just put a "size" attribute to
> the fields?

What about using css ?
--~--~-~--~~~---~--~~
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: running development server

2008-07-08 Thread bruno desthuilliers

On 8 juil, 20:37, [EMAIL PROTECTED] wrote:
> thnx, i got that, but the IP is that my machine's IP on the network,
> or the network's IP?

Should be your machine's IP address, of course.

> i tried it with mine, made sure the port 8000 was open and did python
> manage.py runserver IP:8000 and got the server to initially start, but
> immediately after it displays the "Quit the server with CTRL-BREAK"
> line I get "Error: (10049, "Can't assign requested address")" error.

Chances are another service is already listening on that ip+port on
your machine. Try with a couple other ports and see what happens.


--~--~-~--~~~---~--~~
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-08 Thread LRP

Thanks Chatchai.

Unfortunately, integration of tiny_mce still eludes me. It seems that
django is not looking in the proper directory for tiny_mce.js. But I
can't see why, despite generous off-list help from kind-soul Peter.

1) I've reviewed and documented my configuration below and would be
truly grateful if someone could point out the error or my way.

2) Also, at one point I though the problem might be due to improper
file permissions. So I've opened tiny_mce.js and change_form.html wide
open. Didn't help, but I suspect it may have created a security
problem. Can anyone tell me how to set the permissions correctly?

Lloyd

Review of tiny_mce  configuration:

1) Bennett:p23

"In urls.py, add a new line..."

 my urls.py *

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': '/home/lloyd/
django/media/jscripts/tiny_mce' }),
(r'', include('django.contrib.flatpages.urls')),
)

**

2) Bennett:p24

"Replace the /path-to-tiny_mce/..."

See above.

2a) Confirm path to tiny_mce

Entered in browser: http://192.168.1.4:8000/tiny_mce/tiny_mce.js

Browser returned: var tinymce={majorVersion:'3',minorVersion:'0.8',...

3) Bennett:p25

"So inside your templates directory, create an admin directory. Then
create a flatpages directory inside of admin and a flatpage
subdirectory inside of flatpages. Finally copy the change_form
template..."

[EMAIL PROTECTED]:~/django/templates/admin/flatpages/flatpage$ ls -l
total 4
-rwxrwxrwx 1 lloyd lloyd 3493 2008-07-08 02:16 change_form.html

4) Bennett:p25

"Now you can open up the change_form.html template in your template
directory and edit it..."

{% extends "admin/base_site.html" %}
{% load i18n admin_modify adminmedia %}
{% block extrahead %}{{ block.super }}



tinyMCE.init({
mode: "textareas",
theme: "simple"
});


5) Test

Enter in browser: 192.168.1.4:8000/admin/ and advance to change form.

Output of runserver:

[08/Jul/2008 15:37:57] "GET /admin/ HTTP/1.1" 200 4851
[08/Jul/2008 15:38:00] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200
2817
[08/Jul/2008 15:38:06] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200
5186
[08/Jul/2008 15:38:07] "GET /admin/jsi18n/ HTTP/1.1" 200 803
[08/Jul/2008 15:38:07] "GET /admin/flatpages/flatpage/2/tiny_mce/
tiny_mce.js HTTP/1.1" 404 1780

Clearly django is looking for tiny_mce.js in wrong place.

6) Confirm location of tiny_mce:

[EMAIL PROTECTED]:~/django/media/jscripts/tiny_mce$ ls -l
total 424
-rw-r--r-- 1 lloyd lloyd453 2008-07-07 16:12 example.html
-rw-r--r-- 1 lloyd lloyd   1617 2008-07-07 16:12 textareas.js
-rwxrwxrwx 1 lloyd lloyd 153025 2008-07-07 16:12 tiny_mce.js
-rw-r--r-- 1 lloyd lloyd   7145 2008-07-07 16:12 tiny_mce_popup.js
-rw-r--r-- 1 lloyd lloyd 251714 2008-07-07 16:12 tiny_mce_src.js

7) Let's look at settings.py:

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/home/lloyd/django/templates',

8) QUESTION?

Why is django looking for tiny_mce in .../admin/flatpages/flatpage ?






--~--~-~--~~~---~--~~
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: Markup languages vs HTML

2008-07-08 Thread bruno desthuilliers



On 8 juil, 18:02, "Matic Žgur" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm working on some project, a part of which is a small blog app. All
> the blog posts are saved as HTML (using TinyMCE in admin). I was
> wondering, after reading some stuff about Markdown, what are pros and
> cons of each method, ie. saving posts with some markup language vs.
> html.

Err... HTML actually *is* a markup language, you 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
-~--~~~~--~~--~--~---



Re: running development server

2008-07-08 Thread jorgehugoma
Chris,

Are you using the IP address of your network interface?

 
Jorge Hugo Murillo





- Original Message 
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: Django users 
Sent: Tuesday, July 8, 2008 2:37:02 PM
Subject: Re: running development server


thnx, i got that, but the IP is that my machine's IP on the network,
or the network's IP?

i tried it with mine, made sure the port 8000 was open and did python
manage.py runserver IP:8000 and got the server to initially start, but
immediately after it displays the "Quit the server with CTRL-BREAK"
line I get "Error: (10049, "Can't assign requested address")" error.

if anyone has had this error, please let me know and i can work with
our network admin to fix it. the server runs fine when it's just on my
machine at 127.0.0.1:8000.

chris

On Jul 8, 2:33 pm, moos3 <[EMAIL PROTECTED]> wrote:
> Also you could use mod_python or fastcgi so you can see how its going
> to act when deployed.
>
> On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote:
>
> > hey all,
>
> > i'm trying to open up my development server to a couple of our other
> > staff members to help me start testing next week. to open up the
> > development server to others on our network, do i set runserver to my
> > IP or the network's IP?
>
> > chris


  
--~--~-~--~~~---~--~~
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: running development server

2008-07-08 Thread jorgehugoma
Chris,

Are you using the IP address of your network interface?

 
Jorge Hugo Murillo





- Original Message 
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: Django users 
Sent: Tuesday, July 8, 2008 2:37:02 PM
Subject: Re: running development server


thnx, i got that, but the IP is that my machine's IP on the network,
or the network's IP?

i tried it with mine, made sure the port 8000 was open and did python
manage.py runserver IP:8000 and got the server to initially start, but
immediately after it displays the "Quit the server with CTRL-BREAK"
line I get "Error: (10049, "Can't assign requested address")" error.

if anyone has had this error, please let me know and i can work with
our network admin to fix it. the server runs fine when it's just on my
machine at 127.0.0.1:8000.

chris

On Jul 8, 2:33 pm, moos3 <[EMAIL PROTECTED]> wrote:
> Also you could use mod_python or fastcgi so you can see how its going
> to act when deployed.
>
> On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote:
>
> > hey all,
>
> > i'm trying to open up my development server to a couple of our other
> > staff members to help me start testing next week. to open up the
> > development server to others on our network, do i set runserver to my
> > IP or the network's IP?
>
> > chris


  
--~--~-~--~~~---~--~~
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: connection.queries - show improper SQL?

2008-07-08 Thread Matthias Kestenholz

2008/7/8 Peter <[EMAIL PROTECTED]>:
>
> When I look at generated sql from connection.queries, it doesn't show
> any quotes around strings.
>
> For example:
 from django.db import connection
 from django.contrib.auth.models import User
 User.objects.filter(username="bob")
> []
 connection.queries[-1]
> {'time': '0.000', 'sql': u'SELECT `auth_user`.`id`,
> `auth_user`.`username`, `auth_user`.`first_name`,
> `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`,
> `auth_user`.`is_staff`, `auth_user`.`is_active`,
> `auth_user`.`is_superuser`, `auth_user`.`last_login`,
> `auth_user`.`date_joined` FROM `auth_user` WHERE
> `auth_user`.`username` = bob  ORDER BY `auth_user`.`username` ASC'}

>
> As one would imagine, when I execute:
>
> mysql> SELECT `auth_user`.`id`, `auth_user`.`username`,
> `auth_user`.`first_name`, `auth_user`.`last_name`,
> `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
> `auth_user`.`is_active`, `auth_user`.`is_superuser`,
> `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
> WHERE `auth_user`.`username` = bob  ORDER BY `auth_user`.`username`
> ASC;
>
> It complains with "Unknown column 'bob' in 'where clause'".
>
> It's obvious how I would change that code to execute properly, but I'd
> like to know exactly what query django is building.
> (for example you can get away with passing a number into a query
> against a varchar, and that can affect the efficiency of complex
> queries)
>
> Is this Django-MySQL 5.x specific?  Is this a full-on django bug?
>

The behavior you see stems from the fact, that different database backends
need different quoting and escaping of values. The SQL queries from
connection.queries
are not literally executed; the statements and the parameters get passed
separately to the backend as as good practice recommends.

What you see is not a Django bug then, but maybe not Django-MySQL specific
either. If you need to know more you'd have to dig into the django db or the
python-mysql source code.

--~--~-~--~~~---~--~~
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: determining model subclass

2008-07-08 Thread David K

Dave's method is what I also use.  I was hoping someone would come up
with an easier way, but I think it is a limitation of the way the
database tables are created in multitable inheritance.

David

On Jul 8, 6:13 am, Chester <[EMAIL PROTECTED]> wrote:
> André,
> I'm assuming that you are using the Trunk version of Django because
> subclassing isn't supported in previous versions.
>
> Assuming that.
>
> You can either have Item be an Abstract class which does not act like
> a table but just a parent class containing common items. (this is not
> what you are trying...)
>
> Or
>
> Each sub class is a seperate model from Item (assuming this is what
> you want).   From the documentation you should be able to do the
> following:
>
> items = Item.objects.all()
> for item in items:
>   try:
> x = Item.task
> type = "Task"
>   except:
> try:
>x = Item.event
>type = "Event"
> except:
>type = "Item"
>   Do something pertaining to the item type
>
> I haven't tried this but according to the docs it should work You
> should also fill in the correct exception.  I just don't know what it
> is.
>
> Hope it helps.
>
> Dave.
>
> On Jul 8, 2:12 am, "Andre Meyer" <[EMAIL PROTECTED]> wrote:
>
> > hi all
>
> > is it possible to determine the subclass of a model instance?
>
> > what i mean is this:
> > if you have a (n abstract) model class and two subclasses, like
>
> > class Item(models.Model):
> > pass
>
> > class Task(Item):
> > pass
>
> > class Event(Item):
> > pass
>
> > and you retrieve
>
> > items = Item.objects.all()
>
> > how can you know whether the items are either tasks or events?
>
> > items[0].__class__ returns just .
>
> > thanks for sharing your insights
> > regards
> > André

--~--~-~--~~~---~--~~
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: Issue with django-tagging 0.3 (svn) with models definition

2008-07-08 Thread Nicolas Steinmetz

Nicolas Steinmetz wrote:

> 
> Hello,
> 
> Despite I read a lot of time the overview.txt on the django tagging svn
> repository, I still can't stand how to use it at my model's level. I'm
> quite new to python and may miss some elements.
> 
> When diving into the register part, it says it requiers a field for tag
> which is supposed to be "tags". But what kind of type is this tag supposed
> to be ? a TagField() ?
> 
> I came down to this kind of things which looks not the optimum for me (at
> least at validate & runserver step, it stops shouting...):
> 
> from django.db import models
> import tagging
> from tagging.models import Tag
> from tagging.fields import TagField
> 
> # Create your models here.
> class Links(models.Model):
> title = models.CharField(max_length=80)
> description = models.TextField()
> url = models.URLField()
> tags = TagField()
> 
> class Admin:
> list_display = ('title', 'description', 'url', 'tags',)
> list_filter = ['title', 'tags']
> search_fields = ['title','tags',]
> 
> class Meta:
> verbose_name = "Lien"
> verbose_name_plural = "Liens"
> 
> tagging.register(Links)
> 
> But when I try to save a link, I got :
> 
> IntegrityError at /admin/links/links/add/
> tagging_taggeditem.object_id may not be NULL
> 
> What did I miss ?
> 
> Regards,
> Nicolas
> 

Nobody is in a similar case than mine ?
-- 
Nicolas Steinmetz
http://www.steinmetz.fr/
http://www.unelectronlibre.info/


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



Transitioning old webapp to Django

2008-07-08 Thread William

Hi, I'm moving an old PHP & MySQL3 application to Django SVN with
mysql5, and I've run into a problem. The passwords for the old user
accounts were stored in the database and used the mysql PASSWORD()
function for hashing. MySql 5 changed the hashing function, but kept
the old hashing function under OLD_PASSWORD() for compatibility. I
would like to have django use the OLD_PASSWORD() function for the
user's first login, and then recreate the hash using the current
PASSWORD() function. Does anyone know of a good way to have Django use
the OLD_PASSWORD() function? It would be nice to use a modified
version of contrib.auth, but I'm not sure if its possible.

Thanks,
William

--~--~-~--~~~---~--~~
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: how to make input widgets smaller

2008-07-08 Thread Torsten Bronger

Hallöchen!

I use newforms.ModelForm to get a form from one of my models.
However, the HTML  fields are all too wide.  Okay, I could
re-define all fields that need narrower s like

class SixChamberChannelForm(ModelForm):
gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
class Meta:
model = models.SixChamberChannel

however, then I lose the information contained in max_length and
help_text in the model.  How can I just put a "size" attribute to
the 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: connection.queries - show improper SQL?

2008-07-08 Thread Alex Koshelev

While you don't have an exception if using ORM so it isn't bug it is
feature.

On Jul 8, 10:07 pm, Peter <[EMAIL PROTECTED]> wrote:
> When I look at generated sql from connection.queries, it doesn't show
> any quotes around strings.
>
> For example:>>> from django.db import connection
> >>> from django.contrib.auth.models import User
> >>> User.objects.filter(username="bob")
> []
> >>> connection.queries[-1]
>
> {'time': '0.000', 'sql': u'SELECT `auth_user`.`id`,
> `auth_user`.`username`, `auth_user`.`first_name`,
> `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`,
> `auth_user`.`is_staff`, `auth_user`.`is_active`,
> `auth_user`.`is_superuser`, `auth_user`.`last_login`,
> `auth_user`.`date_joined` FROM `auth_user` WHERE
> `auth_user`.`username` = bob  ORDER BY `auth_user`.`username` ASC'}
>
>
>
> As one would imagine, when I execute:
>
> mysql> SELECT `auth_user`.`id`, `auth_user`.`username`,
> `auth_user`.`first_name`, `auth_user`.`last_name`,
> `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
> `auth_user`.`is_active`, `auth_user`.`is_superuser`,
> `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
> WHERE `auth_user`.`username` = bob  ORDER BY `auth_user`.`username`
> ASC;
>
> It complains with "Unknown column 'bob' in 'where clause'".
>
> It's obvious how I would change that code to execute properly, but I'd
> like to know exactly what query django is building.
> (for example you can get away with passing a number into a query
> against a varchar, and that can affect the efficiency of complex
> queries)
>
> Is this Django-MySQL 5.x specific?  Is this a full-on django bug?
>
> Regards.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Markup languages vs HTML

2008-07-08 Thread Ned Batchelder

The important consideration is what is the best representation for your 
data?  Since you are talking about user-edited content, you need to 
think about the user experience, and what data format is best for your 
users.  The database concerns don't really matter after that.  If you 
users need or expect to edit HTML, then you should offer that and store 
the HTML in the database.  Don't be distracted by the fact that HTML is 
often generated from structured data: it can also be a perfectly 
reasonable data storage format itself.

On the other hand, if your users would be more comfortable editing 
Markdown, then use that.  The user experience concerns are far more 
important, and will dictate the data storage.

--Ned.
http://nedbatchelder.com

Matic Žgur wrote:
> Hi,
>
> I'm working on some project, a part of which is a small blog app. All
> the blog posts are saved as HTML (using TinyMCE in admin). I was
> wondering, after reading some stuff about Markdown, what are pros and
> cons of each method, ie. saving posts with some markup language vs.
> html. I must admit, that I feel a bit uncomfortable saving html to the
> database - it just doesn't seem right to me. So, what is your opinion
> on this matter?
>
> Thanks,
> Matic Žgur
>
> >
>
>   


--~--~-~--~~~---~--~~
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: Markup languages vs HTML

2008-07-08 Thread Ned Batchelder

The important consideration is what is the best representation for your 
data?  Since you are talking about user-edited content, you need to 
think about the user experience, and what data format is best for your 
users.  The database concerns don't really matter after that.  If you 
users need or expect to edit HTML, then you should offer that and store 
the HTML in the database.  Don't be distracted by the fact that HTML is 
often generated from structured data: it can also be a perfectly 
reasonable data storage format itself.

On the other hand, if your users would be more comfortable editing 
Markdown, then use that.  The user experience concerns are far more 
important, and will dictate the data storage.

--Ned.

Matic Žgur wrote:
> Hi,
>
> I'm working on some project, a part of which is a small blog app. All
> the blog posts are saved as HTML (using TinyMCE in admin). I was
> wondering, after reading some stuff about Markdown, what are pros and
> cons of each method, ie. saving posts with some markup language vs.
> html. I must admit, that I feel a bit uncomfortable saving html to the
> database - it just doesn't seem right to me. So, what is your opinion
> on this matter?
>
> Thanks,
> Matic Žgur
>
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


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



Re: running development server

2008-07-08 Thread mccomas . chris

thnx, i got that, but the IP is that my machine's IP on the network,
or the network's IP?

i tried it with mine, made sure the port 8000 was open and did python
manage.py runserver IP:8000 and got the server to initially start, but
immediately after it displays the "Quit the server with CTRL-BREAK"
line I get "Error: (10049, "Can't assign requested address")" error.

if anyone has had this error, please let me know and i can work with
our network admin to fix it. the server runs fine when it's just on my
machine at 127.0.0.1:8000.

chris

On Jul 8, 2:33 pm, moos3 <[EMAIL PROTECTED]> wrote:
> Also you could use mod_python or fastcgi so you can see how its going
> to act when deployed.
>
> On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote:
>
> > hey all,
>
> > i'm trying to open up my development server to a couple of our other
> > staff members to help me start testing next week. to open up the
> > development server to others on our network, do i set runserver to my
> > IP or the network's IP?
>
> > chris
--~--~-~--~~~---~--~~
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: running development server

2008-07-08 Thread moos3

Also you could use mod_python or fastcgi so you can see how its going
to act when deployed.

On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote:
> hey all,
>
> i'm trying to open up my development server to a couple of our other
> staff members to help me start testing next week. to open up the
> development server to others on our network, do i set runserver to my
> IP or the network's IP?
>
> chris
--~--~-~--~~~---~--~~
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: running development server

2008-07-08 Thread moos3

python manage.py runserver IP:PORT I hope that helps.

On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote:
> hey all,
>
> i'm trying to open up my development server to a couple of our other
> staff members to help me start testing next week. to open up the
> development server to others on our network, do i set runserver to my
> IP or the network's IP?
>
> chris
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



running development server

2008-07-08 Thread mccomas . chris

hey all,

i'm trying to open up my development server to a couple of our other
staff members to help me start testing next week. to open up the
development server to others on our network, do i set runserver to my
IP or the network's IP?

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



connection.queries - show improper SQL?

2008-07-08 Thread Peter

When I look at generated sql from connection.queries, it doesn't show
any quotes around strings.

For example:
>>> from django.db import connection
>>> from django.contrib.auth.models import User
>>> User.objects.filter(username="bob")
[]
>>> connection.queries[-1]
{'time': '0.000', 'sql': u'SELECT `auth_user`.`id`,
`auth_user`.`username`, `auth_user`.`first_name`,
`auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`,
`auth_user`.`is_staff`, `auth_user`.`is_active`,
`auth_user`.`is_superuser`, `auth_user`.`last_login`,
`auth_user`.`date_joined` FROM `auth_user` WHERE
`auth_user`.`username` = bob  ORDER BY `auth_user`.`username` ASC'}
>>>

As one would imagine, when I execute:

mysql> SELECT `auth_user`.`id`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`,
`auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
`auth_user`.`is_active`, `auth_user`.`is_superuser`,
`auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
WHERE `auth_user`.`username` = bob  ORDER BY `auth_user`.`username`
ASC;

It complains with "Unknown column 'bob' in 'where clause'".

It's obvious how I would change that code to execute properly, but I'd
like to know exactly what query django is building.
(for example you can get away with passing a number into a query
against a varchar, and that can affect the efficiency of complex
queries)

Is this Django-MySQL 5.x specific?  Is this a full-on django bug?

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



Re: User is in models.py

2008-07-08 Thread Juanjo Conti

You have to pass request.user from some view to the apropiate save method.

views.py:

def save_human(reqiest):
# do some stuff
human.save(request.user)

models.py:

class Human(Model):
# ...

def save(self, user):
# do something with user
# may be
# self.user = user
super(Human, self).save()

Greets!

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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: Grouping Items In Multiple Categories

2008-07-08 Thread [EMAIL PROTECTED]

Thanks Arien, this was what I was looking for, I just couldn't figure
out what the syntax needed to be, they really should add this example
to the Django documentation.

On Jul 8, 1:30 pm, Arien <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 8, 2008 at 11:25 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Does anyone know of an elegant way in Django to group database items
> > under 2 categories.
>
> Don't know about elegant, but something like this would work:
>
> {% regroup committees by state as committee_state_list %}
> {% for committee_state in committee_state_list %}
>   {{ committee_state.grouper }}
>   {% regroup committee_state.list by committee_type as committee_type_list %}
>   {% for committee_type in committee_type_list %}
>     {{ committee_type.grouper }}
>     {% for committee in committee_type.list %}
>       {{ committee.name }}
>     {% endfor %}
>   {% endfor %}
> {% endfor %}
>
> 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: Markup languages vs HTML

2008-07-08 Thread Norman Harman

Matic Žgur wrote:
> Hi,
> 
> I'm working on some project, a part of which is a small blog app. All
> the blog posts are saved as HTML (using TinyMCE in admin). I was
> wondering, after reading some stuff about Markdown, what are pros and
> cons of each method, ie. saving posts with some markup language vs.
> html. I must admit, that I feel a bit uncomfortable saving html to the
> database - it just doesn't seem right to me. So, what is your opinion
> on this matter?

I often will create two(three) fields.

body_markup -> "source" text in markup
body_rendered   -> body_markup rendered to html
[markup_style]  -> optional choice field that defines what markup 
body_markup is in

Edit body_markup.  Display body_rendered. Render body_markup to 
body_rendered on save().   body_rendered is probably a pre-optimization. 
  But, I use it anyway.

Could use the cache system for something similar, your needs probably vary.

markup is good for sophisticated / power users / niches where markup is 
expected (e.g. wikis)

TinyMCE / js editor is good for the masses.

-- 
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: How to create field not stored in database, but visible in admin?

2008-07-08 Thread Norman Harman

Marek Stępniowski wrote:
> How to create a field that is not stored in database, but is visible
> in Django newforms-admin? (I'm assuming there is a way)
> 
> I would like to define a field which acts as a kind of proxy. Setting
> and getting value of this field actually runs some defined operation
> (for example executes custom SQL query) and returns it's results. This
> field has a related form field which is visible in Django
> newforms-admin among the form fields for other fields of containing
> model.

Nothing requires there to be a 1-to-1 mapping of form to model.  In fact 
I've made a forms that have no model at all.

> As I'm using newforms-admin, I could add the form field to the
> ModelForm of my model in ModelAdmin and define custom save method for
> this form, which would execute a defined operation. But I want to have
> this functionality in two my different projects, and this approach
> would not be DRY.

Put functionality in base class(es) and or library that both projects 
inherit/use.

I would be wary of putting functionality other than data 
collection/validation/munging into a form.  "save" sounds like it needs 
to be in a Model or Manager.

> So is there a way to create such model field? Or maybe there is a
> better way to achieve what I want? Please help.

Know about Python properties? 
http://www.python.org/download/releases/2.2.3/descrintro/#property
They are exactly what I'd use to implement "Setting and getting value of 
this field actually runs some defined operation"




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



ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

2008-07-08 Thread Rodrigo Culagovski

In a production site, all of a sudden while trying to edit the site
via the admin interface I get:

ProgrammingError: (2014, "Commands out of sync; you can't run this
command now")

This is when trying to access the record list: "/admin/core/pagina/"
This is only while trying to edit this one specific model ('pagina'),
I can edit the others without errors.
I dumped the database to my development server, and I get the same
error. It was working fine right before importing the DB from the
production server, so I'm thinking there's a problem in the actual DB.
I ran Optimize, Check and Repair on the DB in MySQL Administrator. No
dice.
I haven't updated or changed anything on either server. Development's
running XP, production Linux.

Full traceback:

Traceback (most recent call last):

  File "C:\django\djtrunk\django\core\servers\basehttp.py", line 277,
in run
self.result = application(self.environ, self.start_response)

  File "C:\django\djtrunk\django\core\servers\basehttp.py", line 631,
in __call__
return self.application(environ, start_response)

  File "C:\django\djtrunk\django\core\handlers\wsgi.py", line 205, in
__call__
response = self.get_response(request)

  File "C:\django\djtrunk\django\core\handlers\base.py", line 117, in
get_response
receivers = dispatcher.send(signal=signals.got_request_exception,
request=request)

  File "C:\django\djtrunk\django\dispatch\dispatcher.py", line 360, in
send
**named

  File "C:\django\djtrunk\django\dispatch\robustapply.py", line 47, in
robustApply
return receiver(*arguments, **named)

  File "C:\django\djtrunk\django\db\__init__.py", line 73, in
_rollback_on_exception
transaction.rollback_unless_managed()

  File "C:\django\djtrunk\django\db\transaction.py", line 149, in
rollback_unless_managed
connection._rollback()

  File "C:\django\djtrunk\django\db\backends\mysql\base.py", line 195,
in _rollback
BaseDatabaseWrapper._rollback(self)

  File "C:\django\djtrunk\django\db\backends\__init__.py", line 24, in
_rollback
return self.connection.rollback()

ProgrammingError: (2014, "Commands out of sync; you can't run this
command now")

--~--~-~--~~~---~--~~
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: Grouping Items In Multiple Categories

2008-07-08 Thread Arien

On Tue, Jul 8, 2008 at 11:25 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Does anyone know of an elegant way in Django to group database items
> under 2 categories.

Don't know about elegant, but something like this would work:

{% regroup committees by state as committee_state_list %}
{% for committee_state in committee_state_list %}
  {{ committee_state.grouper }}
  {% regroup committee_state.list by committee_type as committee_type_list %}
  {% for committee_type in committee_type_list %}
{{ committee_type.grouper }}
{% for committee in committee_type.list %}
  {{ committee.name }}
{% endfor %}
  {% endfor %}
{% endfor %}

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: Markup languages vs HTML

2008-07-08 Thread rui
Hi Matic,

I really think that html should not be saved on your database.
Markup languages are more "human readable" and can be easily converted
to HTML, if needed.

And really, it just don´t look right :)

Cheers and good luck.
--
Rui

--~--~-~--~~~---~--~~
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: What's the best way to simulate a request?

2008-07-08 Thread Norman Harman

Andrew wrote:
> Here's the situation:
> 
> I'm creating an RESTful internal API as an app in our project. Our
> 'main' app (we'll call it main) is a client of the API app. Since
> we're building the API piece by piece as we use it, the emphasis on
> all of this is simple simple simple -- with our eye on eventually
> opening up pieces of the API to the public.
> 
> The general flow looks like:
> request => main app handling => API client => API logic.
> 
> Because right now both of the apps live in the same project and are
> being served from the same boxes (and the API won't be running on a
> separate machine for a while), I figured, hey, why not just fake an
> HttpRequest from the main app logic and pass it over to API? That way,
> we don't need to worry about exposing the internal URLs, we don't need
> to worry about authentication right now, it'll be simple.
> 
> Right now the API client I've written takes an HTTP method, path, and
> params, uses resolve(path, api.urls) to get the view, and then calls
> the view using a fake HttpRequest that I populate myself.
> 
> The one problem is that I'm finding it much harder to fake the
> HttpRequests than I thought -- namely because the RESTful handlers on
> the API side are expecting things like request._get_post_and_files()
> to be present.
> 
> So, my thoughts:
> a) Continue using the lightweight API "client" I've written, but
> instead of building a HttpRequest, fake a WSGIRequest instead (with
> the _minimum_ data needed)
> b) Patch the django test client to deal with PUT and DELETE and use
> that as our API client
> c) Import the API urls.py into the main urls.py and call the API
> methods by generating actual HTTP requests
> 
> I'm not crazy about c) since it requires more infrastructure work now.
> 
> Any thoughts?

Yeah, give more than lip service to "simple simple simple".  You say 
that then outline how you are reimplementing HTTP because you don't want 
to be "exposing the internal URLs" yet.

I suggest spending an hour, a day learning about how your webserver(s) 
handle auth and start using it.  My $.02US (only about .01 at today's rates)

Baring that, option B is best since the code will at least be useful for 
tests.  Where as the other options' code become mostly worthless once 
you start using real requests.

-- 
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: Grouping Items In Multiple Categories

2008-07-08 Thread rui

Hi Josh,

Have you tried passing a tuple with the two columns to the group_by method ?

Cheers.

--
Rui


On Tue, Jul 8, 2008 at 1:25 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Does anyone know of an elegant way in Django to group database items
> under 2 categories.
>
> For example I have a database model that contains the following
> information:
>
> State
> Committee_Type
> Committee
>
> When I send it out to the template, I need to be able to group each
> committee under its type and state so that it looks something like
> this:
>
> State 1:
>  Committee_Type1:
>  Committee1
>  Committee2
>  Committee_Type2:
>  Committee1
>  Committee2
>
> State 2:
>  Committee_Type1:
>  Committee1
>  Committee2
>  Committee_Type2:
>  Committee1
>  Committee2
>
> etc...
>
> I looked at the regroup tag but I can only get it to group the items
> by a single category, any help would be appreciated.
>
> >
>

--~--~-~--~~~---~--~~
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: Calculating on generic view

2008-07-08 Thread Gonzalo Delgado
El Tue, 8 Jul 2008 09:15:36 -0700 (PDT)
rocco_s <[EMAIL PROTECTED]> escribió:

> 
> Hi there,
> 
> im very new at Django, and i have a little problem.
> 
> Is there a way to do some calculation on generic views?
> 
> Example: Ich have a table in the db with the columns "distance" and
> "time", and i want to display an html-table with "distance", "time"
> and "km/h" for each row.
> How can i calculate this "km/h"?
> 
> 
> r.
> 

read this:
http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/

especially the "Getting more out of a generic view" part. Hope it helps.

Hope it helps.

-- 
P.U. Gonzalo Delgado <[EMAIL PROTECTED]>
http://djangopeople.net/gonzalo/


pgpot6SShJfO3.pgp
Description: PGP signature


one to one symmetric relationship

2008-07-08 Thread Aldo

Hello,

Thanks for your answer Malcom.
My mistake was to suppose that one to one relationships were
symmetric.

Do you have an idea on how to design a symmetric one to one
relationship ?
I tried with ForeignKey(unique=True) but it is not symmetric.
I even tried ManyToManyField(unique=True), which is symmetric but not
really unique in an object point of view.
It is unique in a DB point of view.
We can add (A,B) and (C,A) tuples in the m2m table, which creates
multiple relationships A-B and A-C.

Is it possible with existing fields ?

Regards,
Aldo
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Grouping Items In Multiple Categories

2008-07-08 Thread [EMAIL PROTECTED]

Does anyone know of an elegant way in Django to group database items
under 2 categories.

For example I have a database model that contains the following
information:

State
Committee_Type
Committee

When I send it out to the template, I need to be able to group each
committee under its type and state so that it looks something like
this:

State 1:
  Committee_Type1:
  Committee1
  Committee2
  Committee_Type2:
  Committee1
  Committee2

State 2:
  Committee_Type1:
  Committee1
  Committee2
  Committee_Type2:
  Committee1
  Committee2

etc...

I looked at the regroup tag but I can only get it to group the items
by a single category, any help would be appreciated.

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



Calculating on generic view

2008-07-08 Thread rocco_s

Hi there,

im very new at Django, and i have a little problem.

Is there a way to do some calculation on generic views?

Example: Ich have a table in the db with the columns "distance" and
"time", and i want to display an html-table with "distance", "time"
and "km/h" for each row.
How can i calculate this "km/h"?


r.

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



Markup languages vs HTML

2008-07-08 Thread Matic Žgur

Hi,

I'm working on some project, a part of which is a small blog app. All
the blog posts are saved as HTML (using TinyMCE in admin). I was
wondering, after reading some stuff about Markdown, what are pros and
cons of each method, ie. saving posts with some markup language vs.
html. I must admit, that I feel a bit uncomfortable saving html to the
database - it just doesn't seem right to me. So, what is your opinion
on this matter?

Thanks,
Matic Žgur

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



elusive Post error

2008-07-08 Thread Adam Fraser

I was wondering if anyone else has ever run into this problem...

When filling out a form, I click submit and get a POST error claiming
that the page does not support POST.  However, if I refresh the error
page, the request goes through, and all is happy.

I don't have much experience with web applications, so I'm not sure
where to start here.  We're running on Apache and using SSL for
authentication, but I disabled SSL and the problem persists.

Here's my settings file anyway... any ideas?

-Adam


# Django settings for ProjectProfiler project.

import posix  # for getuid
import pwd# for getpwuid

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql'# 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.

# Check whether to use the test or production version of the DB
if (pwd.getpwuid(posix.getuid())[0] == "imageweb") :
DATABASE_NAME = 'projectprofiler'# Or path to database
file if using sqlite3.
else :
DATABASE_NAME = 'projectprofilertest'# Or path to database
file if using sqlite3.

DATABASE_USER = 'cpuser' # Not used with sqlite3.
DATABASE_PASSWORD = 'cPus3r' # Not used with sqlite3.
DATABASE_HOST = 'imgdb01.broad.mit.edu'  # Set to empty string for
localhost. Not used with sqlite3.
DATABASE_PORT = ''   # Set to empty string for
default. Not used with sqlite3.

TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
MEDIA_ROOT = '/home/radon01/afraser/projectprofiler/trunk/
projectprofiler/media/'
MEDIA_URL = 'http://127.0.0.1:8000/projectprofiler/media/'
ADMIN_MEDIA_PREFIX = '/projectprofiler/media/admin/'
SECRET_KEY = '&[EMAIL PROTECTED]&a886+2(2w9fu$6=-'

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
#'django.contrib.auth.middleware.AuthenticationMiddleware',
'projectprofiler.sslauth.middleware.SSLAuthMiddleware',
'django.middleware.doc.XViewMiddleware',
'projectprofiler.middleware.threadlocals.ThreadLocals',
)

ROOT_URLCONF = 'projectprofiler.urls'

TEMPLATE_DIRS = (
'/home/radon01/afraser/projectprofiler/trunk/projectprofiler/
templates',
'/imaging/analysis/People/imageweb/projectprofiler/trunk/
projectprofiler/templates',
'/Users/ljosa/research/projectprofiler/projectprofiler/trunk/
projectprofiler/templates',
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
#'django.contrib.sites',
'projectprofiler.sslauth',
'projectprofiler.projects',
'django.contrib.admin',
)

AUTHENTICATION_BACKENDS = (
'projectprofiler.sslauth.backends.SSLAuthBackend',
#'django.contrib.auth.backends.ModelBackend',
)

def myusernamegen(ssl_info):
import re
return re.sub('@mit.edu', '', ssl_info.subject_email)

SSLAUTH_CREATE_USER_CALLBACK = myusernamegen
SSLAUTH_CREATE_USER = True

--~--~-~--~~~---~--~~
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: Sort a list of objects by an attribute of the objects

2008-07-08 Thread Ned Batchelder
This is a bit more complicated than you need.  This will work:

def sort_by_attr_inplace(seq, attr):
import operator
seq.sort(key=operator.attrgetter(attr))

--Ned.
http://nedbatchelder.com

joshuajonah wrote:
> Resolved.
>
> Answer for those interested:
>
> def sort_by_attr(seq, attr):
> import operator
> intermed = map(None, map(getattr, seq, (attr,)*len(seq)),
> xrange(len(seq)), seq)
> intermed.sort()
> return map(operator.getitem, intermed, (-1,) *
> len(intermed))
>
> def sort_by_attr_inplace(lst, attr):
> lst[:] = sort_by_attr(lst, attr)
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


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



Re: integer form fields

2008-07-08 Thread Jonathan Buchanan

On Tue, Jul 8, 2008 at 4:28 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>
> I need to limit  an integerfield form type to 6 digits.  I've tried
> max_length and max_digits but those don't work.  Is there anything
> that does that or will I need to do a custom validation?

How about max_value=99?

Regards,
Jonathan.

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



  1   2   >