Re: site/admin/doc error in django's model_detail.html using "filter escape" VS "autoescape"

2008-10-17 Thread Scott SA

> You've apparently layered a recent version of Django on top of an older one
> without first deleting the older one.  This file
> 'django/contrib/admin/templates/admin_doc/model_detail.html' no longer
> exists in the source tree, it has been moved to under
> 'django/contrib/admindoc/templates'.  The version you have is from sometime
> before autoescape was implemented, but the code that is running is from
> after.  If I were you I would delete everything under
> '/Library/Python/2.5/site-packages/django/' and reinstall from scratch
> because if you have this file left over you may have more, and they will
> only lead to confusing errors.

LOL, Makes perfect sense and trivial to fix.

I have a few versions running (963, 1.0 and trunk) and obviously
messed up somewhere.

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



QuerySet extra() duplicate table

2008-10-17 Thread Rares Vernica

Hello,

I am using QuerySet "extra()" function. For the "tables" parameter I
need to specify the same table multiple times, so I included an alias
for each table. Unfortunately Django quotes the table names and
everything is messed up.

The "tables" parameter for the "extra()" is:

  tables ['FName F0', 'FName_Person Fp0', 'FName F1', 'FName_Person Fp1']

Here is how the generated query looks like:

  SELECT COUNT(DISTINCT `Person`.`id`)
  FROM
`Person` ,
`FName F0` ,
`FName_Person Fp0` ,
`FName F1` , 
`FName_Person Fp1` 
  WHERE ...

If I remove the alias, Django does not realize that I give the same
table multiple times and does not generate any aliases.

I really need the same table multiple times.

Is there a way around this?

An easy fix might be to ask Django not to quote the "tables"
parameter. Is there a easy way to do this?

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: ViewDoesNotExist No module. where is it being called, I don't want it to.

2008-10-17 Thread Eric Abrahamsen


On Oct 18, 2008, at 3:42 AM, KillaBee wrote:

>
> I keep getting this error that says ViewDoesNotExist:  Could not
> import intranet.timesheets.views. Error was: No module named User.  No
> i do not have a User module, I don't want nor need one.  How do I find
> out Where it is being call at?  I got this error today, and I have
> been trying to get the users logged in.  I do have A feild in my times
> model named user, and Have been getting errors about not know what
> username is.  not sure where it's coming from.
> View:  Because It is an error in the view I was thinking that it was
> in the view.py or a template.  no matter want the url or view is bing
> used it still comes up.  Does that sound like I am looking in the
> right spot?

I can't tell what's going on, but you have a whole lot of extraneous  
and redundant imports in your views module, including importing  
auth.models.User where you don't need it; try cleaning up your imports  
first. Importing auth and then in the next line doing 'from auth  
import x y z' is only going to make debugging harder.

Another thing to note, though I don't know quite what it means, is  
that the error message "No module named User" indicates that something  
is doing "import User" rather than "from  import User".  
That could help track down the problem.

E


> error   http://dpaste.com/85152/
> url   http://dpaste.com/85153/
> views   http://dpaste.com/85154/
> modelshttp://dpaste.com/85158/
>
> Hope you can understand the problem.
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Get External IP Address

2008-10-17 Thread Dj Gilcrease

request.META.get('REMOTE_ADDR')


Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.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: Custom template tag problem: "No module named models"

2008-10-17 Thread Chris Amico

I think it's fixed now. After much refreshing (I'm editing in Coda) a
bookmarks.pyc file appeared. Once that was gone, the tag library did
load correctly. I have a different error coming up now, which I'll try
to fix or post separately if I can't.

Thanks for the help and patience, folks.

On Oct 16, 2:43 pm, Chris Amico <[EMAIL PROTECTED]> wrote:
> OK, tried all that, got pretty much the same results:
>
> >> import bookmarks
> >>> dir(bookmarks)
>
> ['__builtins__', '__doc__', '__file__', '__name__', '__path__',
> 'models']>>> bookmarks.__file__
>
> '/home/chrisamico/lib/python2.5/bookmarks/__init__.pyc'>>> from bookmarks 
> import templatetags
> >>> dir(templatetags)
>
> ['__builtins__', '__doc__', '__file__', '__name__', '__path__']>>> 
> templatetags.__file__
>
> '/home/chrisamico/lib/python2.5/bookmarks/templatetags/__init__.pyc'>>> from 
> bookmarks.templatetags import bookmark_tags
> > /home/chrisamico/lib/python2.5/bookmarks/templatetags/bookmark_tags.py(4)()
>
> -> from bookmarks.modelsimport Bookmark
> (Pdb) from bookmarks.modelsimport Bookmark
> *** ImportError:Nomodulenamedmodels
>
> Outside the debugger (in python manage.py shell):
>
> >>> from bookmarks.modelsimport Bookmark
>
> So it's only hitting the import error within bookmark_tags.py. Here's
> the directory structure:
>
> *bookmarks
>     __init__.py
>     admin.py
>    models.py
>     views.py
>     *templatetags
>         __init__.py
>         bookmark_tags.py
>
> On Oct 16, 12:56 am, felix <[EMAIL PROTECTED]> wrote:
>
> > oh well.
>
> > check that you have an __init__.py file in the templatetags directory
>
> > try this:
> > in bookmark_tags.py  (and do keep the name that way, or later you will be
> > caught by this)
>
> > right before the import line throw it in into the debugger:
>
> > import pdb; pdb.set_trace()
>
> > in the debugger try:
>
> > >>> import bookmarks
> > >>> dir(bookmarks)
> > >>> bookmarks.__file__
>
> > if you can't even import bookmarks then its not actually on your python
> > path.  remember that your python path needs to include the directory
> > directly above the bookmarks app.
>
> > f;lix
>
> > On Thu, Oct 16, 2008 at 4:53 AM, Chris Amico <[EMAIL PROTECTED]> wrote:
>
> > > Tried that. Stillnogood. I renamed the file as bookmark_tags.py and
> > > deleted every .pyc file in the app. Nothing in my templatetags
> > > directory actually compiled--neither __init__.py nor bookmarks.py
> > > (even after being renamed).
>
> > > Like I said before, when I take out the import line (from
> > > bookmarks.modelsimport Bookmark) the library loads (even when called
> > > bookmarks.py) and only hits an error when it tries to access
> > > Bookmark.objects.all().
>
> > > On Oct 15, 6:22 pm, felix <[EMAIL PROTECTED]> wrote:
> > > > this gets me every time.
>
> > > > the error is yes because thetemplatetag is called bookmarks.py
> > > > and its inside amodulecalled bookmarks.py
>
> > > > rename it to bookmarks_tags.py ...
>
> > > > and now 
>
> > > > DELETE THE DAMNED OLD bookmarks.pyc file !
>
> > > > python is still finding the old compiled file.
>
> > > > its happened to me twice already in the exact same fashion.
>
> > > > -f;lix
>
> > > > On Oct 15, 7:17 pm, Chris Amico <[EMAIL PROTECTED]> wrote:
>
> > > > > The templatetag file is indeed called bookmarks.py. I thought of that,
> > > > > tried renaming it as bookmark_tags.py, and got the same error. I'll
> > > > > add that the bookmarks app lives on my python path, not in any
> > > > > particular project, since I'm trying to make this as reusable as
> > > > > possible.
>
> > > > > At one point, I tried just removing the line 'from bookmarks.models
> > > > > import Bookmark', and the library loaded, but it hit an error
> > > > > (correctly) when I tried use it, saying Bookmark wasn't defined.
>
> > > > > On Oct 14, 11:45 pm, Daniel Roseman <[EMAIL PROTECTED]>
> > > > > wrote:
>
> > > > > > On Oct 15, 7:38 am, Chris Amico <[EMAIL PROTECTED]> wrote:
>
> > > > > > > I have a simple bookmarks model based on the one in James 
> > > > > > > Bennett's
> > >  > > > > > > href="http://code.google.com/p/cab/source/browse/trunk/models.py?
> > > > > > > r=130">Cab application. I'm using a generic relation so it can
> > > > > > > live in its own app and a user can bookmark any object on the site
> > > > > > > (I'm planning on reusing this app on a couple projects). I'm
> > > running
> > > > > > > into a problem creating an {% if_bookmarked %}templatetag.
>
> > > > > > > When I load the tag library I get this error: 'bookmarks' is not a
> > > > > > > valid tag library: Could not loadtemplatelibrary from
> > > > > > > django.templatetags.bookmarks,Nomodulenamedmodels
>
> > > > > > > Here's what the tagmodulelooks like:
>
> > > > > > 
>
> > > > > > > The bookmarking model works fine on its own, and I've gotten the
> > > > > > > functions in thetemplatetag to work in isolation in the
> > > interpreter,
> > > > > > > but when I load the tag library it breaks thetemplate. What am I
> > > 

Re: Getting lists/dictionaries out of the database

2008-10-17 Thread Eric Abrahamsen


On Oct 18, 2008, at 4:38 AM, timc3 wrote:

>
> Thanks for the help. Yeah, my terminology is quite often wrong, to
> much context switching with other things.
>
> Unfortunately I am never sure what will go in to that field, just data
> that's sourced from various types of media, and populated from another
> system. I do know that it will almost always probably be in that
> format though.

Depending on what you're expecting to store, and how you're expecting  
to use it, you can also pickle python objects and store them in the  
database. From your example, it looks like you could associate a  
dictionary of metadata with each model instance, pickle that  
dictionary, and store the result in the database field. One more  
option...

E

> So I am going to try your method, I have thought to fix it properly I
> should use a datatype within PostgreSQL that supports what I am trying
> to do, but alas Django doesn't support it and neither does the other
> application.
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Highlight current active page

2008-10-17 Thread Nathaniel Whiteinge

A slight variation that doesn't require repeating the whole navigation
div in each base_SECTION.html template:

# base.html
{% block content %}...{% endblock %}
{% block navigation %}

Section
1
Section
2

{% endblock %}

# base_section1.html
{% extends "base.html" %}
{% block active_section_1 %} class="active"{% endblock %}

# base_section2.html
{% extends "base.html" %}
{% block active_section_2 %} class="active"{% endblock %}

# section1_specific_page.html
{% extends "base_section1.html" %}
{% block content %}...{% endblock %}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Getting lists/dictionaries out of the database

2008-10-17 Thread Ned Batchelder

If you are going to use eval, and the data comes from somewhere else, 
you should try safe_eval (http://code.activestate.com/recipes/364469/) 
as a way to get the convenience of unpacking Python literals, but 
without the danger of full evaluation. 

If a malicious user could get data into that field, he could add 
"[os.system('rm -rf /etc')]" to it, and a full eval would cause havoc, 
for example.

--Ned.
http://nedbatchelder.com

timc3 wrote:
> Thanks for the help. Yeah, my terminology is quite often wrong, to
> much context switching with other things.
>
> Unfortunately I am never sure what will go in to that field, just data
> that's sourced from various types of media, and populated from another
> system. I do know that it will almost always probably be in that
> format though.
>
> So I am going to try your method, I have thought to fix it properly I
> should use a datatype within PostgreSQL that supports what I am trying
> to do, but alas Django doesn't support it and neither does the other
> application.
>
> >
>
>   

-- 
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: cheeserater css reference

2008-10-17 Thread coderb

forgot to mention that I did actually change the template css
references to match settings.py, but obviously still got it wrong. I'm
using django 1.0 on win XP.

thanks

On Oct 18, 1:16 am, coderb <[EMAIL PROTECTED]> wrote:
> hi all,
>
> I'm learning django using a downloaded copy of cheeserater  (thanks
> Jacob)
>
> but am stuck at an early hurdle.
>
> The template base.html has the following css references:
>         http://media.jacobian.org/cheeserater/
> reset.css" type="text/css">
>         http://media.jacobian.org/cheeserater/
> cheeserater.css" type="text/css">
>
> I'm trying to change this template to reference the dowloaded project
> css files located in
> cheeserater/media/
>
> my attempts by changing the settings.py  MEDIA_ROOT  and MEDIA_URL
> values have all failed.
>
> I know django docs mentions using media as a static class definition,
> but thats not the way cheeserater is defined (I think), so if anyone
> give me a quick pointer here, I'd really appreciate it.
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



cheeserater css reference

2008-10-17 Thread coderb

hi all,

I'm learning django using a downloaded copy of cheeserater  (thanks
Jacob)

but am stuck at an early hurdle.

The template base.html has the following css references:
http://media.jacobian.org/cheeserater/
reset.css" type="text/css">
http://media.jacobian.org/cheeserater/
cheeserater.css" type="text/css">

I'm trying to change this template to reference the dowloaded project
css files located in
cheeserater/media/

my attempts by changing the settings.py  MEDIA_ROOT  and MEDIA_URL
values have all failed.

I know django docs mentions using media as a static class definition,
but thats not the way cheeserater is defined (I think), so if anyone
give me a quick pointer here, I'd really appreciate it.

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



Re: Get External IP Address

2008-10-17 Thread Jeff Johnson

I stumbled on this a while back.  It may only work on Linux because of 
the fcntl.

import socket
import fcntl
import struct

def get_ip_address(ifname):
 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 return socket.inet_ntoa(fcntl.ioctl(
 s.fileno(),
 0x8915,  # SIOCGIFADDR
 struct.pack('256s', ifname[:15])
 )[20:24])


 >>> get_ip_address('lo')
'127.0.0.1'

 >>> get_ip_address('eth0')
'38.113.228.130'

Ty wrote:
> I'd like to grab the users external IP address. I'm using it for a
> spam catching class that I'm porting over to Django/Python. Is this
> possible?
> 
> This person outlines how to 'hack' it, but I'd rather not depend on an
> external site.
> http://dmiessler.com/blog/how-to-use-python-to-get-your-external-ip
> > 
> 
> 
> 
> 
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.173 / Virus Database: 270.8.1/1730 - Release Date: 10/17/2008 
> 8:07 AM
> 

-- 
Jeff

Jeff Johnson
[EMAIL PROTECTED]
Phoenix Python User Group - [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: Figuring out prefork v. worker

2008-10-17 Thread Doug Van Horn



On Oct 16, 5:31 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Oct 17, 7:14 am, Doug Van Horn <[EMAIL PROTECTED]> wrote:

> What is the mod_wsgi configuration you are using and how many
> processes/threads are you using for Apache child processes and
> mod_wsgi daemon processes?

For what it's worth, here's what I ended up settling on:

  MPM Worker (mod_worker)

  WSGIDaemonProcess foo maximum-requests=1000 stack-size=524288
threads=10
  WSGIProcessGroup foo


> I don't see how business applications vs social networking sites makes
> any difference. Care to explain?

I was trying to convey the fact that my applications aren't oriented
around thousands or more users as a typical social site would likely
be, or at least hope to be.

doug.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: ViewDoesNotExist No module. where is it being called, I don't want it to.

2008-10-17 Thread KillaBee



On Oct 17, 4:25 pm, ryan <[EMAIL PROTECTED]> wrote:
> "I do have A feild in my times
> model named user"
>
> Is it a ForeignKey to Django's User model?
> If so you need to import that at the top of your models.py file
>
> -ryan
>
> On Oct 17, 3:42 pm, KillaBee <[EMAIL PROTECTED]>
> wrote:
>
> > I keep getting this error that says ViewDoesNotExist:  Could not
> > import intranet.timesheets.views. Error was: No module named User.  No
> > i do not have a User module, I don't want nor need one.  How do I find
> > out Where it is being call at?  I got this error today, and I have
> > been trying to get the users logged in.  I do have A feild in my times
> > model named user, and Have been getting errors about not know what
> > username is.  not sure where it's coming from.
> > View:  Because It is an error in the view I was thinking that it was
> > in the view.py or a template.  no matter want the url or view is bing
> > used it still comes up.  Does that sound like I am looking in the
> > right spot?
>
> > error                      http://dpaste.com/85152/
> > url                          http://dpaste.com/85153/
> > views                      http://dpaste.com/85154/
> > models                    http://dpaste.com/85158/
>
> > Hope you can understand the problem.
>
>

the models.py is where it comes from, if you are talking about view.py
these are the two entries that I thought should have taken care of
it.  The error that that it was looking for class name User,like the
one that is the auth.models, but from my view.py.  If I am read it
right.

from django.contrib.auth.models import User
from intranet.timesheets.models import user, worked, fedtime

Is Django case sensitive?  Is user and User the same thing?

class time(models.Model):

user = models.CharField(max_length=20, blank=True)

fedtime = models.IntegerField(null=True, blank=True)

date = models.DateField(null=True, blank=True)

worked = models.CharField(max_length=3, blank=True)
year = models.IntegerField(null=True, blank=True)

month = models.IntegerField(null=True, blank=True)
day = models.IntegerField(null=True, blank=True)
#t=time(user=user, fedtime=fedtime, date=date, worked=worked)
#times.objects
#
#t.obejects
#all_times= times.objects.all()
class Meta:

db_table = u'timesheet'
class calendarpopup(forms.TextInput):
class Media:
js = ('calendar.js', 'calendar1.js', 'calendar2.js')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: ViewDoesNotExist No module. where is it being called, I don't want it to.

2008-10-17 Thread ryan

no, i just checked yr code.  that's not it.

On Oct 17, 5:25 pm, ryan <[EMAIL PROTECTED]> wrote:
> "I do have A feild in my times
> model named user"
>
> Is it a ForeignKey to Django's User model?
> If so you need to import that at the top of your models.py file
>
> -ryan
>
> On Oct 17, 3:42 pm, KillaBee <[EMAIL PROTECTED]>
> wrote:
>
> > I keep getting this error that says ViewDoesNotExist:  Could not
> > import intranet.timesheets.views. Error was: No module named User.  No
> > i do not have a User module, I don't want nor need one.  How do I find
> > out Where it is being call at?  I got this error today, and I have
> > been trying to get the users logged in.  I do have A feild in my times
> > model named user, and Have been getting errors about not know what
> > username is.  not sure where it's coming from.
> > View:  Because It is an error in the view I was thinking that it was
> > in the view.py or a template.  no matter want the url or view is bing
> > used it still comes up.  Does that sound like I am looking in the
> > right spot?
>
> > error                      http://dpaste.com/85152/
> > url                          http://dpaste.com/85153/
> > views                      http://dpaste.com/85154/
> > models                    http://dpaste.com/85158/
>
> > Hope you can understand the problem.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Get External IP Address

2008-10-17 Thread Jeff Anderson
Ty wrote:
> I'd like to grab the users external IP address. I'm using it for a
> spam catching class that I'm porting over to Django/Python. Is this
> possible?
>
> This person outlines how to 'hack' it, but I'd rather not depend on an
> external site.
> http://dmiessler.com/blog/how-to-use-python-to-get-your-external-ip
>   
There might be a Python networking library out there, or you could parse
the output of "ifconfig" on linux, or "ipconfig" on windows.
You could look at the SERVER_NAME environmental variable, which is
usually the server's fqdn, which is as good as the IP address.

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: ViewDoesNotExist No module. where is it being called, I don't want it to.

2008-10-17 Thread ryan

"I do have A feild in my times
model named user"

Is it a ForeignKey to Django's User model?
If so you need to import that at the top of your models.py file

-ryan


On Oct 17, 3:42 pm, KillaBee <[EMAIL PROTECTED]>
wrote:
> I keep getting this error that says ViewDoesNotExist:  Could not
> import intranet.timesheets.views. Error was: No module named User.  No
> i do not have a User module, I don't want nor need one.  How do I find
> out Where it is being call at?  I got this error today, and I have
> been trying to get the users logged in.  I do have A feild in my times
> model named user, and Have been getting errors about not know what
> username is.  not sure where it's coming from.
> View:  Because It is an error in the view I was thinking that it was
> in the view.py or a template.  no matter want the url or view is bing
> used it still comes up.  Does that sound like I am looking in the
> right spot?
>
> error                      http://dpaste.com/85152/
> url                          http://dpaste.com/85153/
> views                      http://dpaste.com/85154/
> models                    http://dpaste.com/85158/
>
> Hope you can understand the problem.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Get External IP Address

2008-10-17 Thread Ty

I'd like to grab the users external IP address. I'm using it for a
spam catching class that I'm porting over to Django/Python. Is this
possible?

This person outlines how to 'hack' it, but I'd rather not depend on an
external site.
http://dmiessler.com/blog/how-to-use-python-to-get-your-external-ip
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Json Serialization / Form Validation error

2008-10-17 Thread [EMAIL PROTECTED]

Hello,

I'm having a hard time understanding why Django won't let me serialize
a dictionary of form errors. Can anyone explain why Django throws an
error if I try to serialize someform.errors, even if I copy it into a
plain dictionary?

#!/usr/bin/env python
from django.utils import simplejson
from project.main.models import SampleForm

test = {}
simplejson.dumps(test) # works

test = {'key': [u"value"]}
simplejson.dumps(test) # works

# suppose SampleForms wants a text and url field
# I just give it a text field to test
form = SampleForm({"text": "sample text"})
d = {} # make a new dictionary
# update d so we're working with a plain dictionary
d.update(f.errors)
type(d) # returns dict

# fails: 
# is not JSON serializable
simplejson.dumps(d)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Named URL Patterns

2008-10-17 Thread Karen Tracey
On Fri, Oct 17, 2008 at 3:30 PM, dkadish <[EMAIL PROTECTED]> wrote:

>
> Okay. I think the issue is that I am trying to use reverse( ) in the
> URLConf file. According to the django docs, "the reverse() function
> has to import all of your URLConf files and examine the name of each
> view". My thinking is that this is leading to to attempt to import
> itself as it evaluates the URL.
>
> Can anyone confirm this? Is there a known workaround?
>
>
Specify the post_save_redirect as a callable instead of an object in the
extra_context dictionary:

def reverse_home():
return reverse('project-home')

urlpatterns = patterns('',
   url(r'^$', list_detail.object_list,
   {'queryset': Project.objects.all()}, 'project-home'),
   url(r'^new$', create_update.create_object,
   {'model': Project, 'post_save_redirect': reverse_home},
'project-new'),
)

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: Getting lists/dictionaries out of the database

2008-10-17 Thread timc3

Thanks for the help. Yeah, my terminology is quite often wrong, to
much context switching with other things.

Unfortunately I am never sure what will go in to that field, just data
that's sourced from various types of media, and populated from another
system. I do know that it will almost always probably be in that
format though.

So I am going to try your method, I have thought to fix it properly I
should use a datatype within PostgreSQL that supports what I am trying
to do, but alas Django doesn't support it and neither does the other
application.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Add foreign key name to admin's list_display?

2008-10-17 Thread Ty

Great! Changing the list_display to 'post' and changing the return
value of Post's __unicode__ worked perfectly. Thanks for your help!

On Oct 17, 4:16 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 17, 2008 at 3:21 PM, Ty <[EMAIL PROTECTED]> wrote:
>
> > # admin.py:
> > from django.contrib import admin
> > from clydefrog.blog.models import Post, Comment
>
> > class PostAdmin(admin.ModelAdmin):
> >        list_display = ('name', 'slug', 'date', 'is_published',)
> >        list_filter = ('is_published',)
> >        ordering = ('is_published', '-date', 'name',)
> >        search_fields = ['name', 'raw_body',]
>
> > class CommentAdmin(admin.ModelAdmin):
> >        list_display = ('name', 'email', 'website', 'date', 'approved',
> > 'is_admin',)
> >        list_filter = ('approved', 'is_admin',)
> >        ordering = ('-date','name',)
> >        search_fields = ['raw_body','name','email','website',]
>
> > admin.site.register(Post, PostAdmin)
> > admin.site.register(Comment, CommentAdmin)
>
> > --
>
> > Hey everyone. This is working perfectly for me, however I'd like to
> > display what post each comment belongs to in the comment
> > administration list.
>
> > I've tried something like this but I can't get anything working:
> > list_display = ('Post.name', 'name', 'email', 'website', 'date',
> > 'approved', 'is_admin',)
>
> > Is this currently possible?
>
> Certainly.  Here's the doc on what you can put in list_display:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display
>
> If the __unicode__ method of the Post model displays its name, then you
> simply add the name of the ForeignKey field for Post in Comment and you'll
> get what you were looking for by trying 'Post.name'.  If Post's __unicode__
> method isn't what you want to see, write a method on the CommentAdmin model
> that returns what you want to see and include it in list_display.
>
> 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
-~--~~~~--~~--~--~---



What's a good way to have an integrated blog for my django site with the same user login for blog comments?

2008-10-17 Thread MikeN

I want to create an integrated blog for my Django powered site.  I
want it to be integrated with my site in the following ways:
1) I want to be able to use my base django template to frame the outer
portion of all the displayed blog content
--> I want to be able to put the entire contents of the blog in a
block from my base site.
2) I want the blog to use the auth user logins from my site for blog
comments
3) I want all of the data in the blog to be in a separate database
from my sites application so that no vulnerability in the blog code
would lead to my site being compromised.

I realize 2 and 3 might conflict with each other since at least the
user table would have to be shared, unless each database (my
application's database and the blog's database) has a duplicate copy
of the user table.

I was looking to try and achieve this integration with Wordpress, has
anyone had luck with a similar usage of wordpress in a django powered
site?  Would one of the django based blog applications be better for
this kind of integration?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Add foreign key name to admin's list_display?

2008-10-17 Thread Karen Tracey
On Fri, Oct 17, 2008 at 3:21 PM, Ty <[EMAIL PROTECTED]> wrote:

>
> # admin.py:
> from django.contrib import admin
> from clydefrog.blog.models import Post, Comment
>
> class PostAdmin(admin.ModelAdmin):
>list_display = ('name', 'slug', 'date', 'is_published',)
>list_filter = ('is_published',)
>ordering = ('is_published', '-date', 'name',)
>search_fields = ['name', 'raw_body',]
>
> class CommentAdmin(admin.ModelAdmin):
>list_display = ('name', 'email', 'website', 'date', 'approved',
> 'is_admin',)
>list_filter = ('approved', 'is_admin',)
>ordering = ('-date','name',)
>search_fields = ['raw_body','name','email','website',]
>
> admin.site.register(Post, PostAdmin)
> admin.site.register(Comment, CommentAdmin)
>
> --
>
> Hey everyone. This is working perfectly for me, however I'd like to
> display what post each comment belongs to in the comment
> administration list.
>
> I've tried something like this but I can't get anything working:
> list_display = ('Post.name', 'name', 'email', 'website', 'date',
> 'approved', 'is_admin',)
>
> Is this currently possible?
>

Certainly.  Here's the doc on what you can put in list_display:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display

If the __unicode__ method of the Post model displays its name, then you
simply add the name of the ForeignKey field for Post in Comment and you'll
get what you were looking for by trying 'Post.name'.  If Post's __unicode__
method isn't what you want to see, write a method on the CommentAdmin model
that returns what you want to see and include it in list_display.

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: site/admin/doc error in django's model_detail.html using "filter escape" VS "autoescape"

2008-10-17 Thread Karen Tracey
On Fri, Oct 17, 2008 at 2:46 PM, Scott SA <[EMAIL PROTECTED]> wrote:

>
> I'm having a consistent problem across multiple projects with the self-
> documentation and I'm hoping somone here might have an idea what is
> wrong and how I might fix it. Thanks in advance for any assistance!
>
> I have tried a couple of different versions of django including the
> latest svn release and I consistently get the error:
>
> "filter escape" is not permitted.  Use the "autoescape" tag instead.
>
> Offending Line:
> {% filter escape|linebreaksbr %}{% trans description %}{% endfilter
> %}
>
> In template /Library/Python/2.5/site-packages/django/contrib/admin/
> templates/admin_doc/model_detail.html
>
>
> [snip]


You've apparently layered a recent version of Django on top of an older one
without first deleting the older one.  This file
'django/contrib/admin/templates/admin_doc/model_detail.html' no longer
exists in the source tree, it has been moved to under
'django/contrib/admindoc/templates'.  The version you have is from sometime
before autoescape was implemented, but the code that is running is from
after.  If I were you I would delete everything under
'/Library/Python/2.5/site-packages/django/' and reinstall from scratch
because if you have this file left over you may have more, and they will
only lead to confusing errors.

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



http://alt.coxnewsweb.com/statesman/img/photos/3699112.jpg

2008-10-17 Thread Norman Harman

is there

Sorry for the screw up
-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro coverage in print and online!

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



ensuring a string does not get escaped in views.py

2008-10-17 Thread Kevin

All,

I am new to Python and Django. I'm quickly catching on but have
finally run in to my first issue.

I'm building a simple app that will work with Google's Picasa. The
idea is to copy an album from one account to another, something that
Picasa won't let you do in its interface.

Here's the thing--I have this working within the Python shell, but
can't make it work with Django.

To retrieve an Album from Picasa, the code looks something like this:
album_uri_to_copy = request.POST['album_uri']
gclient1 = gdata.photos.service.PhotosService()
gclient1.ClientLogin( guser1, gpassword1 )
album_feed = gclient1.GetFeed(album_uri_to_copy)

And album_uri_to_copy might look like:
http://www.ggpht.com//data/feed/api/user/someuser/album?id=4rdioE_s=photo

When calling:
album_feed = gclient1.GetFeed(album_uri_to_copy)

from a Python shell it works fine. When calling it from Django it
returns an Exception saying that album_uri_to_copy isn't a valid uri
or atom feed (this is a google error message).

I SUSPECT that the & is getting changed to "". The thing is, I've
used {{ album_uri|safe }} in my template, so album_uri_to_copy should
be safe! I'm thinking that Django is interfering with the
album_uri_to_copy string in the GetFeed() call.

Can anyone give me some troubleshooting options?

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: Admin won't display datetime widget with custom form?

2008-10-17 Thread mthorley

Oh I see. I thought that a DateTimeField had a split date widget by
default. Now I see that it does not. I was rendering as a input field
because that IS the default widget for a DateTimeField.

Thanks for that last clarification, that dispelled all confusion.



On Oct 17, 12:40 pm, "Keith Eberle" <[EMAIL PROTECTED]> wrote:
> I believe the idea is that if you override a field in your custom form, you
> are then working off the default implementation of a field, which doesn't
> include any of the niceties that the admin has added for you.
>
> keith
>
> On Fri, Oct 17, 2008 at 10:34 AM, mthorley <[EMAIL PROTECTED]> wrote:
>
> > Thanks Keith, that worked perfectly. Can you tell me the reason I have
> > to use the admin widgets and can't use regular form widgets as I might
> > with any other form?
>
> > On Oct 17, 7:11 am, "Keith Eberle" <[EMAIL PROTECTED]> wrote:
> > > I had a project where I needed to set the initial value to the current
> > > week's week ending date (Sat), so I needed a custom form too.  I used the
> > > AdminDateWidget, but I think this will be the correct widget for your
> > needs.
>
> > > # import the widgets
> > > from django.contrib.admin import widgets
>
> > > # use the widget on this line
> > > date = forms.DateTimeField(widget=widgets.AdminSplitDateTime)
>
> > > keith
>
> > > On Thu, Oct 16, 2008 at 6:23 PM, mthorley <[EMAIL PROTECTED]> wrote:
>
> > > > Hello, I'm building a custom admin site with a custom form and the
> > > > datetime widget shows up as a text input. When I set the widget for
> > > > the date field to textarea I get a textarea, but when I set it to
> > > > datetime, I get I text input. I also tried not specifying any widget
> > > > and I still get just a text input.
>
> > > > Can some one please tell me why or how to fix it?
>
> > > > Thanks much
> > > > --
> > > > matthew
>
> > > > from django import forms
> > > > from django.contrib import admin
> > > > from colorcode.trainertools.models import Workshop
>
> > > > class WorkshopForm(forms.Form):
> > > >  name = forms.CharField(max_length=64)
> > > >  date = forms.DateTimeField(widget=forms.DateTimeInput())
> > > >  code = forms.CharField()
>
> > > > class WorkshopAdmin(admin.ModelAdmin):
> > > >  def get_form(self, request, obj=None, **kwargs):
> > > >    return WorkshopForm
>
> > > > trainers_admin = admin.sites.AdminSite()
> > > > trainers_admin.register(Workshop, WorkshopAdmin)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ViewDoesNotExist No module. where is it being called, I don't want it to.

2008-10-17 Thread KillaBee

I keep getting this error that says ViewDoesNotExist:  Could not
import intranet.timesheets.views. Error was: No module named User.  No
i do not have a User module, I don't want nor need one.  How do I find
out Where it is being call at?  I got this error today, and I have
been trying to get the users logged in.  I do have A feild in my times
model named user, and Have been getting errors about not know what
username is.  not sure where it's coming from.
View:  Because It is an error in the view I was thinking that it was
in the view.py or a template.  no matter want the url or view is bing
used it still comes up.  Does that sound like I am looking in the
right spot?

error   http://dpaste.com/85152/
url   http://dpaste.com/85153/
views   http://dpaste.com/85154/
modelshttp://dpaste.com/85158/

Hope you can understand the problem.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Enter Valid Date/Time ...

2008-10-17 Thread Karen Tracey
On Fri, Oct 17, 2008 at 11:48 AM, dbee <[EMAIL PROTECTED]> wrote:

>
> I keep getting the same stupid error ... "Enter valid date/time". I've
> done everything I can think of to let django know that the value in
> question can be blank ...
>
>
http://code.djangoproject.com/ticket/8898

Sounds like you are hitting this:

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

Perhaps the comments or patch in that ticket can help, this is not something
I've looked at at all.

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: Named URL Patterns

2008-10-17 Thread dkadish

Okay. I think the issue is that I am trying to use reverse( ) in the
URLConf file. According to the django docs, "the reverse() function
has to import all of your URLConf files and examine the name of each
view". My thinking is that this is leading to to attempt to import
itself as it evaluates the URL.

Can anyone confirm this? Is there a known workaround?

Cheers,

David

On Oct 17, 11:25 am, dkadish <[EMAIL PROTECTED]> wrote:
> Do you know if there's an easy way to try and figure out where
> reverse( ) is looking for the pages?
>
> On Oct 17, 11:24 am, dkadish <[EMAIL PROTECTED]> wrote:
>
> > Nope. Tried that.
>
> > This shouldn't (I don't think) make any difference but I am running
> > Django 1.0, Python 2.5, Apache 2.210 on Windows Server 2003 with SQL
> > Server 2005 as the db (I know, I know...out of my hands)
>
> > David
>
> > On Oct 17, 11:19 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > > dkadish wrote:
> > > > I'm having issues with a named URL pattern in my code. Django does not
> > > > seem to be finding the correct URL when the {% url %} and reverse( )
> > > > tag/functions are used.
>
> > > > the urls.py file at app_root/project/urls.py contains:
>
> > > > from django.views.generic import list_detail, create_update
> > > > from maverick.project.models import Project
> > > > from django.conf.urls.defaults import patterns, url
> > > > from django.core.urlresolvers import reverse
>
> > > > urlpatterns = patterns('maverick.project.views',
> > > >     url(r'^$', list_detail.object_list, {'queryset':
> > > > Project.objects.all()}, 'project-home'),
> > > >     url(r'^new$', create_update.create_object, {'model': Project,
> > > > 'post_save_redirect': reverse('project-home')}, 'project-new'),
> > > > )
>
> > > > and I am referencing the URL pattern (in addition to in the second
> > > > link) in the file app_root/home/templates/base.html:
>
> > > > 
> > > >    
> > > >            
> > > >            Maverick
> > > >    
> > > >    
> > > >            
> > > >                    Projects
> > > >                    Calibrations
> > > >            
> > > >            
> > > >                    {% block section_menu %}{% endblock %}
> > > >            
> > > >            
> > > >                    {% block content %}{% endblock %}
> > > >            
> > > >            
> > > >                    {% block footer %}{% endblock %}
> > > >            
> > > >    
> > > > 
>
> > > > If you need more information, just let me know what to post.
>
> > > Looks like it should work. Does it make any difference if you change the
> > > minus signs to underscores?
>
> > > regards
> > >  Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: nOOb alert, accessing set variables in template

2008-10-17 Thread R. Gorman

You could use {{ for obj in A.a_set.all }} and print out the
{{ obj }}.

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



Add foreign key name to admin's list_display?

2008-10-17 Thread Ty

# admin.py:
from django.contrib import admin
from clydefrog.blog.models import Post, Comment

class PostAdmin(admin.ModelAdmin):
list_display = ('name', 'slug', 'date', 'is_published',)
list_filter = ('is_published',)
ordering = ('is_published', '-date', 'name',)
search_fields = ['name', 'raw_body',]

class CommentAdmin(admin.ModelAdmin):
list_display = ('name', 'email', 'website', 'date', 'approved',
'is_admin',)
list_filter = ('approved', 'is_admin',)
ordering = ('-date','name',)
search_fields = ['raw_body','name','email','website',]

admin.site.register(Post, PostAdmin)
admin.site.register(Comment, CommentAdmin)

--

Hey everyone. This is working perfectly for me, however I'd like to
display what post each comment belongs to in the comment
administration list.

I've tried something like this but I can't get anything working:
list_display = ('Post.name', 'name', 'email', 'website', 'date',
'approved', 'is_admin',)

Is this currently possible?

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



page not updating right away

2008-10-17 Thread ashbii

I am new to Django, but love it so far.  I went through a tutorial and
created a basic blog app.  I'm using Django's admin interface to add
new blog posts -- I have a blog "Post" model.

My problem is that whenever I enter and save a new blog post via
admin, its not showing up on the web page (template) right away.  It
usually shows up after a few hours.  It shows up right away on the
admin side though.  This leads me to believe that there is some sort
of caching going on, but I do not have any type of Django cache
setting going on in my settings.py file.  Is this a python cache
issue?  I've tried pkill python, but doesn't work either.  Is there a
template/web page cache in Django?

My host is Dreamhost, so I am running Django with FastCGI.  I know
thats not the preferred set up, but just getting my feet wet with
Django.  Thanks for any advice!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: unable to open database file - sqlite3/apache problem - help?

2008-10-17 Thread Emilio

I found the solution:

http://django.freelancernepal.com/errors/django-says-unable-to-open-database-file-when-using-sqlite3/

Regards,

Emilio

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



site/admin/doc error in django's model_detail.html using "filter escape" VS "autoescape"

2008-10-17 Thread Scott SA

I'm having a consistent problem across multiple projects with the self-
documentation and I'm hoping somone here might have an idea what is
wrong and how I might fix it. Thanks in advance for any assistance!

I have tried a couple of different versions of django including the
latest svn release and I consistently get the error:

"filter escape" is not permitted.  Use the "autoescape" tag instead.

Offending Line:
{% filter escape|linebreaksbr %}{% trans description %}{% endfilter
%}

In template /Library/Python/2.5/site-packages/django/contrib/admin/
templates/admin_doc/model_detail.html


Exception Location:
/Library/Python/2.5/site-packages/django/template/defaulttags.py in
do_filter, line 549

Python Executable:
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/
Python.app/Contents/MacOS/Python

Python Version:
2.5.1

Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/views/
decorators.py" in _checklogin
  33. return view_func(request, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admindocs/
views.py" in model_detail
  254. }, context_instance=RequestContext(request))
File "/Library/Python/2.5/site-packages/django/shortcuts/__init__.py"
in render_to_response
  18. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/Library/Python/2.5/site-packages/django/template/loader.py" in
render_to_string
  102. t = get_template(template_name)
File "/Library/Python/2.5/site-packages/django/template/loader.py" in
get_template
  81. template = get_template_from_string(source, origin,
template_name)
File "/Library/Python/2.5/site-packages/django/template/loader.py" in
get_template_from_string
  89. return Template(source, origin, name)
File "/Library/Python/2.5/site-packages/django/template/__init__.py"
in __init__
  166. self.nodelist = compile_string(template_string, origin)
File "/Library/Python/2.5/site-packages/django/template/__init__.py"
in compile_string
  187. return parser.parse()
File "/Library/Python/2.5/site-packages/django/template/__init__.py"
in parse
  283. compiled_result = compile_func(self, token)
File "/Library/Python/2.5/site-packages/django/template/
loader_tags.py" in do_extends
  169. nodelist = parser.parse()
File "/Library/Python/2.5/site-packages/django/template/__init__.py"
in parse
  283. compiled_result = compile_func(self, token)
File "/Library/Python/2.5/site-packages/django/template/
loader_tags.py" in do_block
  147. nodelist = parser.parse(('endblock', 'endblock %s' %
block_name))
File "/Library/Python/2.5/site-packages/django/template/__init__.py"
in parse
  283. compiled_result = compile_func(self, token)
File "/Library/Python/2.5/site-packages/django/template/
defaulttags.py" in do_if
  782. nodelist_true = parser.parse(('else', 'endif'))
File "/Library/Python/2.5/site-packages/django/template/__init__.py"
in parse
  283. compiled_result = compile_func(self, token)
File "/Library/Python/2.5/site-packages/django/template/
defaulttags.py" in do_filter
  549. raise TemplateSyntaxError('"filter %s" is not
permitted.  Use the "autoescape" tag instead.' % func.__name__)

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



cannot import name SimpleCookie on new Django install

2008-10-17 Thread Wayne Collier

Hello.I am new to Django and I am having some trouble installing it. I 
running Python 2.5 and mod_python on Apache with RH linux. I installed 
Django-0.95.   When I go to my mysite directory and run "python 
manage.pyrunserver"command, I get the following result:

[EMAIL PROTECTED] mysite]# python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File 
"/usr/local/lib/python2.5/site-packages/Django-0.95.4-py2.5.egg/django/core/management.py",
 
line 1319, in execute_manager
execute_from_command_line(action_mapping, argv)
  File 
"/usr/local/lib/python2.5/site-packages/Django-0.95.4-py2.5.egg/django/core/management.py",
 
line 1271, in execute_from_command_line
action_mapping[action](addr, port, options.use_reloader)
  File 
"/usr/local/lib/python2.5/site-packages/Django-0.95.4-py2.5.egg/django/core/management.py",
 
line 1029, in runserver
from django.core.handlers.wsgi import WSGIHandler
  File 
"/usr/local/lib/python2.5/site-packages/Django-0.95.4-py2.5.egg/django/core/handlers/wsgi.py",
 
line 1, in 
from django.core.handlers.base import BaseHandler
  File 
"/usr/local/lib/python2.5/site-packages/Django-0.95.4-py2.5.egg/django/core/handlers/base.py",
 
line 3, in 
from django import http
  File 
"/usr/local/lib/python2.5/site-packages/Django-0.95.4-py2.5.egg/django/http/__init__.py",
 
line 2, in 
from Cookie import SimpleCookie
ImportError: cannot import name SimpleCookie


This also results when I Django-1.0.  Any help would be greatly appreciated.

Wayne


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



nOOb alert, accessing set variables in template

2008-10-17 Thread Mr. T

Just start with Django and liking it a lot. Made a database and a page
that displays queries as html table. It was all too easy.

In one of my models I use a Foreign key to ref another object.

class A:


class B:
a = ForeignKey(A)

When I include A in the context of my template, I see that the
variable {{A.a_set}} is there. How could I "stringify" that set and
put it in one of the cells of my table?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: unable to open database file - sqlite3/apache problem - help?

2008-10-17 Thread Emilio

Same exact problem in Debian Lenny. I've tried debugging it but I'm
out of ideas.

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



How to setup Apache, mod_python and a reverse proxy to Lighttpd for Django on Ubuntu

2008-10-17 Thread Alexis Bellido

Hi guys, I've got my first 'serious' Django application running on a
production environment and after learning a lot from the great Django
community and extensive documenation I decided to give something back.

Here's a simple tutorial on how to setup Apache, mod_python and a
reverse proxy to Lighttpd for Django on Ubuntu:

http://ventanazul.com/webzine/tutorials/setup-apache-lighttpd-django-ubuntu

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



Re: Admin won't display datetime widget with custom form?

2008-10-17 Thread Keith Eberle
I believe the idea is that if you override a field in your custom form, you
are then working off the default implementation of a field, which doesn't
include any of the niceties that the admin has added for you.

keith


On Fri, Oct 17, 2008 at 10:34 AM, mthorley <[EMAIL PROTECTED]> wrote:

>
> Thanks Keith, that worked perfectly. Can you tell me the reason I have
> to use the admin widgets and can't use regular form widgets as I might
> with any other form?
>
>
>
> On Oct 17, 7:11 am, "Keith Eberle" <[EMAIL PROTECTED]> wrote:
> > I had a project where I needed to set the initial value to the current
> > week's week ending date (Sat), so I needed a custom form too.  I used the
> > AdminDateWidget, but I think this will be the correct widget for your
> needs.
> >
> > # import the widgets
> > from django.contrib.admin import widgets
> >
> > # use the widget on this line
> > date = forms.DateTimeField(widget=widgets.AdminSplitDateTime)
> >
> > keith
> >
> > On Thu, Oct 16, 2008 at 6:23 PM, mthorley <[EMAIL PROTECTED]> wrote:
> >
> > > Hello, I'm building a custom admin site with a custom form and the
> > > datetime widget shows up as a text input. When I set the widget for
> > > the date field to textarea I get a textarea, but when I set it to
> > > datetime, I get I text input. I also tried not specifying any widget
> > > and I still get just a text input.
> >
> > > Can some one please tell me why or how to fix it?
> >
> > > Thanks much
> > > --
> > > matthew
> >
> > > from django import forms
> > > from django.contrib import admin
> > > from colorcode.trainertools.models import Workshop
> >
> > > class WorkshopForm(forms.Form):
> > >  name = forms.CharField(max_length=64)
> > >  date = forms.DateTimeField(widget=forms.DateTimeInput())
> > >  code = forms.CharField()
> >
> > > class WorkshopAdmin(admin.ModelAdmin):
> > >  def get_form(self, request, obj=None, **kwargs):
> > >return WorkshopForm
> >
> > > trainers_admin = admin.sites.AdminSite()
> > > trainers_admin.register(Workshop, WorkshopAdmin)
> >
> >
> >
>

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

2008-10-17 Thread Daniel Roseman

On Oct 17, 5:50 pm, Jeff Gentry <[EMAIL PROTECTED]> wrote:
> > Oops. It could also read
> >     from django import newforms as forms
> > in which case you should change it to
> >     from django import forms
>
> Right, that's what I was thinking.
>
> > but I hope you've got the idea: basically newforms has *become* forms.
>
> Yup - just wasn't sure on that.  I had remembered seeing something along
> those lines a while back but wasn't sure if it had said it *was* changing
> names or *wasn't* :)  Plus with all of the chatter on both forms and
> newforms I couldn't find a definitive answer to this question when
> searching.
>
> They have some other "old stuff-isms", some I noticed on my own, some were
> easier to search on and I'm sure I'll come across more.
>
> Thanks all :)
> -J

You might find this page useful:
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges

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



Re: Named URL Patterns

2008-10-17 Thread dkadish

Do you know if there's an easy way to try and figure out where
reverse( ) is looking for the pages?

On Oct 17, 11:24 am, dkadish <[EMAIL PROTECTED]> wrote:
> Nope. Tried that.
>
> This shouldn't (I don't think) make any difference but I am running
> Django 1.0, Python 2.5, Apache 2.210 on Windows Server 2003 with SQL
> Server 2005 as the db (I know, I know...out of my hands)
>
> David
>
> On Oct 17, 11:19 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > dkadish wrote:
> > > I'm having issues with a named URL pattern in my code. Django does not
> > > seem to be finding the correct URL when the {% url %} and reverse( )
> > > tag/functions are used.
>
> > > the urls.py file at app_root/project/urls.py contains:
>
> > > from django.views.generic import list_detail, create_update
> > > from maverick.project.models import Project
> > > from django.conf.urls.defaults import patterns, url
> > > from django.core.urlresolvers import reverse
>
> > > urlpatterns = patterns('maverick.project.views',
> > >     url(r'^$', list_detail.object_list, {'queryset':
> > > Project.objects.all()}, 'project-home'),
> > >     url(r'^new$', create_update.create_object, {'model': Project,
> > > 'post_save_redirect': reverse('project-home')}, 'project-new'),
> > > )
>
> > > and I am referencing the URL pattern (in addition to in the second
> > > link) in the file app_root/home/templates/base.html:
>
> > > 
> > >    
> > >            
> > >            Maverick
> > >    
> > >    
> > >            
> > >                    Projects
> > >                    Calibrations
> > >            
> > >            
> > >                    {% block section_menu %}{% endblock %}
> > >            
> > >            
> > >                    {% block content %}{% endblock %}
> > >            
> > >            
> > >                    {% block footer %}{% endblock %}
> > >            
> > >    
> > > 
>
> > > If you need more information, just let me know what to post.
>
> > Looks like it should work. Does it make any difference if you change the
> > minus signs to underscores?
>
> > regards
> >  Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Named URL Patterns

2008-10-17 Thread dkadish

Nope. Tried that.

This shouldn't (I don't think) make any difference but I am running
Django 1.0, Python 2.5, Apache 2.210 on Windows Server 2003 with SQL
Server 2005 as the db (I know, I know...out of my hands)

David

On Oct 17, 11:19 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> dkadish wrote:
> > I'm having issues with a named URL pattern in my code. Django does not
> > seem to be finding the correct URL when the {% url %} and reverse( )
> > tag/functions are used.
>
> > the urls.py file at app_root/project/urls.py contains:
>
> > from django.views.generic import list_detail, create_update
> > from maverick.project.models import Project
> > from django.conf.urls.defaults import patterns, url
> > from django.core.urlresolvers import reverse
>
> > urlpatterns = patterns('maverick.project.views',
> >     url(r'^$', list_detail.object_list, {'queryset':
> > Project.objects.all()}, 'project-home'),
> >     url(r'^new$', create_update.create_object, {'model': Project,
> > 'post_save_redirect': reverse('project-home')}, 'project-new'),
> > )
>
> > and I am referencing the URL pattern (in addition to in the second
> > link) in the file app_root/home/templates/base.html:
>
> > 
> >    
> >            
> >            Maverick
> >    
> >    
> >            
> >                    Projects
> >                    Calibrations
> >            
> >            
> >                    {% block section_menu %}{% endblock %}
> >            
> >            
> >                    {% block content %}{% endblock %}
> >            
> >            
> >                    {% block footer %}{% endblock %}
> >            
> >    
> > 
>
> > If you need more information, just let me know what to post.
>
> Looks like it should work. Does it make any difference if you change the
> minus signs to underscores?
>
> regards
>  Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Named URL Patterns

2008-10-17 Thread Steve Holden

dkadish wrote:
> I'm having issues with a named URL pattern in my code. Django does not
> seem to be finding the correct URL when the {% url %} and reverse( )
> tag/functions are used.
>
> the urls.py file at app_root/project/urls.py contains:
>
> from django.views.generic import list_detail, create_update
> from maverick.project.models import Project
> from django.conf.urls.defaults import patterns, url
> from django.core.urlresolvers import reverse
>
> urlpatterns = patterns('maverick.project.views',
> url(r'^$', list_detail.object_list, {'queryset':
> Project.objects.all()}, 'project-home'),
> url(r'^new$', create_update.create_object, {'model': Project,
> 'post_save_redirect': reverse('project-home')}, 'project-new'),
> )
>
> and I am referencing the URL pattern (in addition to in the second
> link) in the file app_root/home/templates/base.html:
>
> 
>   
>   
>   Maverick
>   
>   
>   
>   Projects
>   Calibrations
>   
>   
>   {% block section_menu %}{% endblock %}
>   
>   
>   {% block content %}{% endblock %}
>   
>   
>   {% block footer %}{% endblock %}
>   
>   
> 
>
> If you need more information, just let me know what to post.
>   
Looks like it should work. Does it make any difference if you change the
minus signs to underscores?

regards
 Steve


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



Named URL Patterns

2008-10-17 Thread dkadish

I'm having issues with a named URL pattern in my code. Django does not
seem to be finding the correct URL when the {% url %} and reverse( )
tag/functions are used.

the urls.py file at app_root/project/urls.py contains:

from django.views.generic import list_detail, create_update
from maverick.project.models import Project
from django.conf.urls.defaults import patterns, url
from django.core.urlresolvers import reverse

urlpatterns = patterns('maverick.project.views',
url(r'^$', list_detail.object_list, {'queryset':
Project.objects.all()}, 'project-home'),
url(r'^new$', create_update.create_object, {'model': Project,
'post_save_redirect': reverse('project-home')}, 'project-new'),
)

and I am referencing the URL pattern (in addition to in the second
link) in the file app_root/home/templates/base.html:




Maverick



Projects
Calibrations


{% block section_menu %}{% endblock %}


{% block content %}{% endblock %}


{% block footer %}{% endblock %}




If you need more information, just let me know what to post.

Cheers,

David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: ordering a query set randomly

2008-10-17 Thread Steve Holden

Orcun Avsar wrote:
> hi,
> problem is that i want to order model instances for an attribute and
> slice it. then sort list randomly.
> 
>>> query=order_by("date")[:20]
>>> query.order_by("?")
> returns an error because query set has been sliced
> 
> 
>>> query=order_by("date")[:100]
>>> random.shuffle(query)
> also returns error bacuse query set doesn't behave like a list and
> doesn't support item assignment.
> 
> dirty solution was creating a list contains model instances by putting
> query in a for loop then shuffle it. is there any alternative solution.

A much cheaper solution would be to create a list of range(20),
randomize that with shuffle and use successive elements to index the slice.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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
-~--~~~~--~~--~--~---



ordering a query set randomly

2008-10-17 Thread Orcun Avsar

hi,
problem is that i want to order model instances for an attribute and
slice it. then sort list randomly.

>>query=order_by("date")[:20]
>>query.order_by("?")
returns an error because query set has been sliced


>>query=order_by("date")[:100]
>>random.shuffle(query)
also returns error bacuse query set doesn't behave like a list and
doesn't support item assignment.

dirty solution was creating a list contains model instances by putting
query in a for loop then shuffle it. is there any alternative solution.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: [solved] Re: delete tables

2008-10-17 Thread felix
I just pulled it directly from django's source code.

I would only recommend doing syncdb in a development environment.  I just
use it as part of an import / convert from an old website's schema.

probably for what you are doing (a user doing something on a form) this is
too dangerous to do.

syncdb generates sql
checks for an admin user
and installs any initial_data fixtures

by looking at how it does that you should be to isolate just the commands
you want for just the application and db tables that you want.  look at
manage.py and keep following the code.

if you know which db you will be running on then maybe its better just to
delete the models and then reset the auto increment sequence using raw sql
as steve holden suggested.

maybe better is to delete all the models except for the 0 and 1
so they will still be there.

-f;lix




On Fri, Oct 17, 2008 at 4:34 PM, Mirto Silvio Busico <[EMAIL PROTECTED]>wrote:

>  Wanderful!
> This was exactly what I needed!
>
> There is any documentation about "call_command" and the other commnds you
> used?
>
>
> Thanks alot.
> Mirto
>
> felix ha scritto:
>
>
> here's what I'm using:
>
> from django.core import management
> from django.db import connection
> cursor = connection.cursor()
> # don't delete these tables
> # note that I'm also keeping auth_user
> tables =
> ['comments','objekt_objekt','tag','tags','user_objekt_tag','auth_user','auth_session']
>
> current_tables = connection.introspection.table_names()
>
> for table in current_tables:
> if table not in tables:
> try:
> cursor.execute("drop table %s" % table)
> except Exception,e:
> raise e
> #pass
>
> management.call_command('syncdb')
>
>
>
>
>
>
>
> On Fri, Oct 17, 2008 at 3:41 PM, Mirto Silvio Busico <[EMAIL PROTECTED]>wrote:
>
>>
>> Sorry  I was not clear.
>>
>> I have some utilities in view.py which have to reload tables content
>> (migration from the legacy database; clearing a table and reloading with
>> base content; ...)
>>
>> I know from the shell it is enough an "python manage py flush", but I
>> have two problems:
>>
>>* the action have to be triggered by a user action on a form
>>* the id have to be resetted because for me the id=0 and id=1 rows
>>  have a fixed special meaning
>>
>> I have not found anything about deleting tables in
>> http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that
>> "database api" has gone in 1.0)
>> The only thing that seems I can use is "Executing custom SQL" in
>> http://docs.djangoproject.com/en/dev/topics/db/models/
>>
>> There is a better/recommended method?
>>
>> Thanks
>>Mirto
>>
>>
>> Erik Allik ha scritto:
>>  > $ manage.py dbshell
>> >  > DROP TABLE table_name;
>> >
>> > Django does not currently have a database schema management tool (with
>> > the exception of syncdb and sql* commands).
>> >
>> > Erik
>> >
>> >
>> > On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
>> >
>> >
>> >> Hi all,
>> >>
>> >> what is the django way o deleting all table content and resetting the
>> >> primary key counter?
>> >>
>> >> Thanks
>> >>Mirto
>> >>
>> >> --
>> >>
>> >>
>> _
>> >> Busico Mirto Silvio
>> >> Consulente ICT
>> >> cell. 333 4562651
>> >> email [EMAIL PROTECTED]
>> >>
>> >>
>> >>
>> >
>> >
>> > >
>> >
>> >
>>
>>
>> --
>>
>> _
>> Busico Mirto Silvio
>> Consulente ICT
>> cell. 333 4562651
>> email [EMAIL PROTECTED]
>>
>>
>>
>>
>
>
>
>
> --
>
> _
> Busico Mirto Silvio
> Consulente ICT
> cell. 333 4562651
> email [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: Getting lists/dictionaries out of the database

2008-10-17 Thread Steve Holden

timc3 wrote:
> I am having a problem with getting lists/dictionaries out of the
> database.
>
> If I have for instance this in a field of my database:
>
> [['Image format', 'JPEG'], ['Image mode', 'RGB'], ['Image size',
> '1440x900'], ['Compression', '21.0 times']]
>
This is a single field? That's unfortunate.
> And I call it from django, I would get the following string:
Be careful: this isn't a string, it's a list with a single dictionary in
it (but that's really just picking nits). By "call it" I assume you mean
"retrieve it". I know it's tedious of me to correct you on these terms,
but you need to understand that you are dealing with a bunch of geeks
who ascribe precise technical meaning to terms like "call" ... anyway,
enough with the linguistics. And sorry if English isn't your first language.
>
> [{'metadata': u"[['Image format', 'JPEG'], ['Image mode', 'RGB'],
> ['Image size', '1280x960'], ['Compression', '14.0 times']]", 'title':
> u'Technical Metadata'}]
>
> Because of the 'u' UTF it seems that I can't then properly use it as a
> list with dictionaries like so:
>
The u stands for "Unicode", not "UTF". But you will note that "metadata"
isn't a Unicode string, it's a regular ASCII string, so Unicode doesn't
come into that.

You seem to have the basics correct, and

myProblemObject[0]

should indeed be a dictionary. Therefore

myProblemObject[0]['metadata']

will be the (Unicode) string (ignoring any wrapping the mail system does)

u"[['Image format', 'JPEG'], ['Image mode', 'RGB'], ['Image size',
'1280x960'], ['Compression', '14.0 times']]"

This means that
> myProblemObject[0]['metadata'][0]
will give you a single character, u"[", the first character from that
string.
>
> Any ideas? I presume this is Django's handling of the data within the
> database being the problem not a python problem in general?
I prefer to suggest that the way you are *storing* the data is a
problem, since it would really be better if your model had separate
fields for image format, image mode, image size (possibly separating
width and heigh) and compression. Otherwise youo will forever be
fighting to extract meaningful information form the data stored on the
database.

If you want a really dirty solution you could try

metadata = eval(myProblemObject[0]['metadata'])

which will give you a list of two-element lists, but this is very
fragile and extremely unsafe if anyone else can add to the database
contents.

regards
 Steve


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



Re: newforms question

2008-10-17 Thread Jeff Gentry

> Oops. It could also read
> from django import newforms as forms
> in which case you should change it to
> from django import forms

Right, that's what I was thinking.

> but I hope you've got the idea: basically newforms has *become* forms.

Yup - just wasn't sure on that.  I had remembered seeing something along
those lines a while back but wasn't sure if it had said it *was* changing
names or *wasn't* :)  Plus with all of the chatter on both forms and
newforms I couldn't find a definitive answer to this question when
searching.

They have some other "old stuff-isms", some I noticed on my own, some were
easier to search on and I'm sure I'll come across more.

Thanks all :)
-J


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

2008-10-17 Thread Steve Holden

Jeff Gentry wrote:
> Hi there ...
> 
> To date, I've not been using Django's form system (nor 'newforms'), but am
> trying to integrate another app into a suite that I'm developing.  The
> code on this is a bit older and is using newforms - when I fire up the
> server (running off of the 1.0 branch) I get "No module named
> newforms".  I've been a bit lax in trying to follow how this all shook
> out, but am I correct in my thinking that 'newforms' is now simply
> 'forms'?
> 
Oops. It could also read

from django import newforms as forms

in which case you should change it to

from django import forms

but I hope you've got the idea: basically newforms has *become* forms.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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
-~--~~~~--~~--~--~---



Getting lists/dictionaries out of the database

2008-10-17 Thread timc3

I am having a problem with getting lists/dictionaries out of the
database.

If I have for instance this in a field of my database:

[['Image format', 'JPEG'], ['Image mode', 'RGB'], ['Image size',
'1440x900'], ['Compression', '21.0 times']]

And I call it from django, I would get the following string:

[{'metadata': u"[['Image format', 'JPEG'], ['Image mode', 'RGB'],
['Image size', '1280x960'], ['Compression', '14.0 times']]", 'title':
u'Technical Metadata'}]

Because of the 'u' UTF it seems that I can't then properly use it as a
list with dictionaries like so:

myProblemObject[0]['metadata'][0]

Any ideas? I presume this is Django's handling of the data within the
database being the problem not a python problem in general?

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: newforms question

2008-10-17 Thread Steve Holden

Jeff Gentry wrote:
> Hi there ...
> 
> To date, I've not been using Django's form system (nor 'newforms'), but am
> trying to integrate another app into a suite that I'm developing.  The
> code on this is a bit older and is using newforms - when I fire up the
> server (running off of the 1.0 branch) I get "No module named
> newforms".  I've been a bit lax in trying to follow how this all shook
> out, but am I correct in my thinking that 'newforms' is now simply
> 'forms'?

If the statement that is failing used the recommended mechanism and reads

import django.newforms as forms

then you simply have to change it to

import django.forms

Otherwise you'll have to change every occurrence of "newforms" to
"forms". The code should work, though, modulo any incompatible changes
made to the newforms module before incorporation as the standard package.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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



Re: newforms question

2008-10-17 Thread Jeff Anderson
Jeff Gentry wrote:
> Hi there ...
>
> To date, I've not been using Django's form system (nor 'newforms'), but am
> trying to integrate another app into a suite that I'm developing.  The
> code on this is a bit older and is using newforms - when I fire up the
> server (running off of the 1.0 branch) I get "No module named
> newforms".  I've been a bit lax in trying to follow how this all shook
> out, but am I correct in my thinking that 'newforms' is now simply
> 'forms'?
>   
This is correct. oldforms was removed, and newforms was renamed to
forms. This happened before the 1.0 release.

You just need to change your code to reflect this, and it should likely
work.

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Extending the User model

2008-10-17 Thread krylatij

Take a look at http://code.google.com/p/django-profile/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 question

2008-10-17 Thread Jeff Gentry

Hi there ...

To date, I've not been using Django's form system (nor 'newforms'), but am
trying to integrate another app into a suite that I'm developing.  The
code on this is a bit older and is using newforms - when I fire up the
server (running off of the 1.0 branch) I get "No module named
newforms".  I've been a bit lax in trying to follow how this all shook
out, but am I correct in my thinking that 'newforms' is now simply
'forms'?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 parse an XML file with django.

2008-10-17 Thread JFQueralt

Hi, people.

Thanks a lot for the indications. Will work on them and sure will find
a way to implement what I am looking for :-)

Take care.

Jean

On Oct 16, 9:39 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-10-16 at 00:19 -0700, JFQueralt wrote:
> > Hi, James.
>
> > Does that imply I can use Pythong´s XML manipulation libraries in
> > Django blocks?
>
> > There has to be a way to retrieve information fron a file in Django (I
> > ´ve seen official docs on it).
> > XML is nothing than a structured data file so there should be a way to
> > retrieve a value and use it in a template.
>
> I think you're missing something here. Planning to do complex data
> manipulation in templates is almost always the wrong place. The view
> functions -- the pure Python code -- is where your data manipulations
> take place and templates are just a way of specifying how the objects
> passed to them are converted to strings (since the result of rendering a
> template is a string).
>
> There are limited ways to convert any Python object into a string in a
> template. In decreasing order of complexity, they are:
>
>         1) Pass it to a template tag.
>         2) Pass the object through a template filter
>         3) Call a method on the object that takes no arguments
>         4) Look up an attribute or dictionary key on the object.
>         5) Call the objects __unicode__ or __str__ method (this is
>         essentially a special case of point 3, but it's what happens
>         automatically when you put "{{ some_var }}" into a template).
>
> So there's not really a question of passing "an XML file" to a template
> and then working with it in the template. You only pass Python objects
> of some variety to templates. Instead, work with the XML file in the
> view (using Python's existing XML libraries, as James and Russell have
> mentioned) and convert it to one or more Python objects that can then be
> rendered in the templates using the one of the above options.
>
> You could write a template tag that took a Python file object or a
> variable containing the name of the file and then used the Python code
> behind the template tag to read in the file and do whatever you want
> with it. In some circumstances, that might be a useful idiom. However,
> if you're just starting out with Django, it will no doubt be easier to
> start by doing the initial processing entirely in the view, so that you
> only have to look at options 3, 4 and 5 above. Then, after you are
> comfortable with that (and right now you seem to have some confusion
> about what "Django" means in terms of what it does for you), you might
> be able to abstract out somethings into template tags if that makes
> things easier (it's not necessarily a given that it will make things
> easier, either).
>
> 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: Admin won't display datetime widget with custom form?

2008-10-17 Thread [EMAIL PROTECTED]

I had a similar issue having to use an admin's widget.

from django.contrib.admin.widgets import AdminFileWidget

which shows a link to the file if the FileField is not empty.

Wondered if that coud have been more straightforward.

best,

Haroldo

On 17 oct, 12:34, mthorley <[EMAIL PROTECTED]> wrote:
> Thanks Keith, that worked perfectly. Can you tell me the reason I have
> to use the admin widgets and can't use regular form widgets as I might
> with any other form?
>
> On Oct 17, 7:11 am, "Keith Eberle" <[EMAIL PROTECTED]> wrote:
>
> > I had a project where I needed to set the initial value to the current
> > week's week ending date (Sat), so I needed a custom form too.  I used the
> > AdminDateWidget, but I think this will be the correct widget for your needs.
>
> > # import the widgets
> > from django.contrib.admin import widgets
>
> > # use the widget on this line
> > date = forms.DateTimeField(widget=widgets.AdminSplitDateTime)
>
> > keith
>
> > On Thu, Oct 16, 2008 at 6:23 PM, mthorley <[EMAIL PROTECTED]> wrote:
>
> > > Hello, I'm building a custom admin site with a custom form and the
> > > datetime widget shows up as a text input. When I set the widget for
> > > the date field to textarea I get a textarea, but when I set it to
> > > datetime, I get I text input. I also tried not specifying any widget
> > > and I still get just a text input.
>
> > > Can some one please tell me why or how to fix it?
>
> > > Thanks much
> > > --
> > > matthew
>
> > > from django import forms
> > > from django.contrib import admin
> > > from colorcode.trainertools.models import Workshop
>
> > > class WorkshopForm(forms.Form):
> > >  name = forms.CharField(max_length=64)
> > >  date = forms.DateTimeField(widget=forms.DateTimeInput())
> > >  code = forms.CharField()
>
> > > class WorkshopAdmin(admin.ModelAdmin):
> > >  def get_form(self, request, obj=None, **kwargs):
> > >    return WorkshopForm
>
> > > trainers_admin = admin.sites.AdminSite()
> > > trainers_admin.register(Workshop, WorkshopAdmin)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Enter Valid Date/Time ...

2008-10-17 Thread dbee

I keep getting the same stupid error ... "Enter valid date/time". I've
done everything I can think of to let django know that the value in
question can be blank ...

# Store the people who need reminding of things
class TeleInt (models.Model):

call_back = models.DateTimeField( null=True, blank=True )
meeting_date = models.DateTimeField( null=True, blank=True )


# Teleint
form
class TeleIntForm(ModelForm):

call_back = forms.DateTimeField(required=False)
meeting_date = forms.DateTimeField(required=False)

class Meta:
model = TeleInt

Yet i still get that error everytime. It's very, very annoying. Anyone
got any ideas ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get a page in Django?

2008-10-17 Thread Gnarlodious

David Reynolds uttered this profundity:

> http://diveintopython.org/

Thanks, I'll spend a few months on that material.

-- Gnarlie
http://Gnarlodious.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: login_required for imported apps

2008-10-17 Thread bruno desthuilliers

On 17 oct, 16:18, Heather <[EMAIL PROTECTED]> wrote:
> I have a couple of projects that use the same application
> (particularly, photologue).  In one project, I want the views of the
> imported application to require users be signed in.  All the views in
> this imported application are generic.  So, is it possible to use
> login_required w/o having to go into photologue.urls and add the
> decorator?  Is it possible to do this in my projects urls file?

Technically, yes - but I failed to find a clean way to do so. Here's
some possible (*untested*) hack:

# project's urls.py

import photologue.urls
for purl in photologue.urls.urlpatterns:
callback = purl.callback
purl._callback = login_required(callback)

AFAICT, this _should_ work - but well, this is a (dirty) hack, and as
such is not garanteed in any way.


And if there's a better way (not requiring to rewrite all photologue
urls by hand), I'd be happy to know about it !-)

>  I am
> new to Python so I'm not sure I'm on the right track but I thought I
> should do something along the lines of writing my own wrapper that
> would take  photologue.urls as an argument (the **kwargs argument,
> maybe?)  Like:
>
> @login_required
> restrict_access(*args, **kwargs)
> #if this is indeed the right idea, this is where I'm not quite
> sure what to do...
> if kwargs.list_object(*args, **kwargs)
>   return kwargs.list_object
>
> I know this isn't right but I am not 100% sure of the concept of
> decorators.

The first thing to understand is that in Python, everything is an
object - including functions. The second point is that functions are
mostly a specific case of callable objects - a callable object being
any object implementing the __call__ operator (iow : having a __call__
method). FWIW, classes (classes being objects too...) are callable
objects too (you call them to instanciate them).

IOW :
- you can use functions and classes like any other objects (passing
them as args, returning them from function, etc, etc)
- you can define your own callable types

Now : a decorator is a callable object that takes a (single) callable
object as argument and returns a (single) callable object.


FWIW, the

@decorator
def somefunc(...):
   # XXX

notation is only syntactic sugar for

def somefunc(...):
   # XXX
somefunc = decorator(somefunc)


HTH
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: No FlatPage matches the given query.

2008-10-17 Thread uucell 管家



On Oct 6, 6:36 am, Matt <[EMAIL PROTECTED]> wrote:
> I had not. Thanks!
>
> On Oct 5, 6:27 pm, John Allen <[EMAIL PROTECTED]> wrote:
>
> > Have you looked at these notes on how to get the Practical Django
> > Projects examples to 
> > work:http://blog.haydon.id.au/2008/08/notes-on-practical-django-projects.html
> > ?


how do you   make it work?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: everything works except apache seeing django app

2008-10-17 Thread bruno desthuilliers

On 17 oct, 15:48, "Stephen Moore" <[EMAIL PROTECTED]> wrote:
> for the record, I fixed the problem
>
> it seems the permissions have to be correct for every level of the directory.
>
> so for /home/iambo/web then /, /home, /home/iambob and
> /home/iambob/web had to have the right permissions :)

doh :(

Should have known better...


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



Re: Admin won't display datetime widget with custom form?

2008-10-17 Thread mthorley

Thanks Keith, that worked perfectly. Can you tell me the reason I have
to use the admin widgets and can't use regular form widgets as I might
with any other form?



On Oct 17, 7:11 am, "Keith Eberle" <[EMAIL PROTECTED]> wrote:
> I had a project where I needed to set the initial value to the current
> week's week ending date (Sat), so I needed a custom form too.  I used the
> AdminDateWidget, but I think this will be the correct widget for your needs.
>
> # import the widgets
> from django.contrib.admin import widgets
>
> # use the widget on this line
> date = forms.DateTimeField(widget=widgets.AdminSplitDateTime)
>
> keith
>
> On Thu, Oct 16, 2008 at 6:23 PM, mthorley <[EMAIL PROTECTED]> wrote:
>
> > Hello, I'm building a custom admin site with a custom form and the
> > datetime widget shows up as a text input. When I set the widget for
> > the date field to textarea I get a textarea, but when I set it to
> > datetime, I get I text input. I also tried not specifying any widget
> > and I still get just a text input.
>
> > Can some one please tell me why or how to fix it?
>
> > Thanks much
> > --
> > matthew
>
> > from django import forms
> > from django.contrib import admin
> > from colorcode.trainertools.models import Workshop
>
> > class WorkshopForm(forms.Form):
> >  name = forms.CharField(max_length=64)
> >  date = forms.DateTimeField(widget=forms.DateTimeInput())
> >  code = forms.CharField()
>
> > class WorkshopAdmin(admin.ModelAdmin):
> >  def get_form(self, request, obj=None, **kwargs):
> >    return WorkshopForm
>
> > trainers_admin = admin.sites.AdminSite()
> > trainers_admin.register(Workshop, WorkshopAdmin)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[solved] Re: delete tables

2008-10-17 Thread Mirto Silvio Busico
Wanderful!
This was exactly what I needed!

There is any documentation about "call_command" and the other commnds 
you used?


Thanks alot.
Mirto

felix ha scritto:
>
> here's what I'm using:
>
> from django.core import management
> from django.db import connection
> cursor = connection.cursor()
> # don't delete these tables
> # note that I'm also keeping auth_user
> tables = 
> ['comments','objekt_objekt','tag','tags','user_objekt_tag','auth_user','auth_session']
>
> current_tables = connection.introspection.table_names()
>
> for table in current_tables:
> if table not in tables:
> try:
> cursor.execute("drop table %s" % table)
> except Exception,e:
> raise e
> #pass
>
> management.call_command('syncdb')
>
>
>
>
>
>
>
> On Fri, Oct 17, 2008 at 3:41 PM, Mirto Silvio Busico 
> <[EMAIL PROTECTED] > wrote:
>
>
> Sorry  I was not clear.
>
> I have some utilities in view.py which have to reload tables content
> (migration from the legacy database; clearing a table and
> reloading with
> base content; ...)
>
> I know from the shell it is enough an "python manage py flush", but I
> have two problems:
>
>* the action have to be triggered by a user action on a form
>* the id have to be resetted because for me the id=0 and id=1 rows
>  have a fixed special meaning
>
> I have not found anything about deleting tables in
> http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that
> "database api" has gone in 1.0)
> The only thing that seems I can use is "Executing custom SQL" in
> http://docs.djangoproject.com/en/dev/topics/db/models/
>
> There is a better/recommended method?
>
> Thanks
>Mirto
>
>
> Erik Allik ha scritto:
> > $ manage.py dbshell
> >  > DROP TABLE table_name;
> >
> > Django does not currently have a database schema management tool
> (with
> > the exception of syncdb and sql* commands).
> >
> > Erik
> >
> >
> > On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
> >
> >
> >> Hi all,
> >>
> >> what is the django way o deleting all table content and
> resetting the
> >> primary key counter?
> >>
> >> Thanks
> >>Mirto
> >>
> >> --
> >>
> >>
> _
> >> Busico Mirto Silvio
> >> Consulente ICT
> >> cell. 333 4562651
> >> email [EMAIL PROTECTED] 
> >>
> >>
> >>
> >
> >
> > >
> >
> >
>
>
> --
>
> _
> Busico Mirto Silvio
> Consulente ICT
> cell. 333 4562651
> email [EMAIL PROTECTED] 
>
>
>
>
>
> >


-- 

_
Busico Mirto Silvio
Consulente ICT
cell. 333 4562651
email [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: delete tables

2008-10-17 Thread Steve Holden

Mirto Silvio Busico wrote:
> Sorry  I was not clear.
> 
> I have some utilities in view.py which have to reload tables content 
> (migration from the legacy database; clearing a table and reloading with 
> base content; ...)
> 
> I know from the shell it is enough an "python manage py flush", but I 
> have two problems:
> 
> * the action have to be triggered by a user action on a form
> * the id have to be resetted because for me the id=0 and id=1 rows
>   have a fixed special meaning
> 
> I have not found anything about deleting tables in 
> http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that 
> "database api" has gone in 1.0)
> The only thing that seems I can use is "Executing custom SQL" in 
> http://docs.djangoproject.com/en/dev/topics/db/models/
> 
> There is a better/recommended method?
> 
> Thanks
> Mirto
> 
> 
> Erik Allik ha scritto:
>> $ manage.py dbshell
>>  > DROP TABLE table_name;
>>
>> Django does not currently have a database schema management tool (with  
>> the exception of syncdb and sql* commands).
>>
If 0 and 1 have special significance as primary key values then it's
very fragile to rely on the database to insert them for you. Instead
you'd be better off writing them specifically.

It's not possible to reset the automatically generated IDs in a
platform-independent way because of the huge differences between (say)
PostgreSQL serials vs. Oracle sequences (which as far as I can tell
actually require a stored procedure to increment the sequence and insert
the value into a table, though I am no Oracle expert).

If you can suggest a suitable API then it might be considered for
inclusion into Django in some future version. The API reference is still
available, by the way, at

  http://docs.djangoproject.com/en/dev/topics/db/queries/

In the meantime you are left with raw SQL as the only suitable way to do
what you want, and the API documentation does give you some guidance as
to how to implement raw SQL. As for the exact details of the counter
reset, you'd need to tell us which database engine you are running against.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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
-~--~~~~--~~--~--~---



login_required for imported apps

2008-10-17 Thread Heather

I have a couple of projects that use the same application
(particularly, photologue).  In one project, I want the views of the
imported application to require users be signed in.  All the views in
this imported application are generic.  So, is it possible to use
login_required w/o having to go into photologue.urls and add the
decorator?  Is it possible to do this in my projects urls file?  I am
new to Python so I'm not sure I'm on the right track but I thought I
should do something along the lines of writing my own wrapper that
would take  photologue.urls as an argument (the **kwargs argument,
maybe?)  Like:

@login_required
restrict_access(*args, **kwargs)
#if this is indeed the right idea, this is where I'm not quite
sure what to do...
if kwargs.list_object(*args, **kwargs)
  return kwargs.list_object

I know this isn't right but I am not 100% sure of the concept of
decorators.

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



Re: How to get a page in Django?

2008-10-17 Thread Steve Holden

chaugen wrote:
> I am new to both Python and Django, and with somewhat limited
> programming experience. That being said, the tutorials set up on
> Django Project (http://docs.djangoproject.com/en/dev/) are excellent.
> I would suggest 'Beginning Python' from O'Brien as well. It took me
> only a few days with both the tutorials, and the book to begin
> developing some very dynamic web projects. One other resource may be
> helpful is 'Practical Django Projects', which will help you build a
> Content Managment System and 'get a page in Django!'.
> 
> Rgs
> 
> On Oct 16, 9:08 pm, Gnarlodious <[EMAIL PROTECTED]> wrote:
>> I don't know anything about Python except for how to run SQLite
>> commands. Mostly my strong point is HTML
>>
>> Is there an example site offered where I can download and install and
>> just run it and get a page? If I can study a working configuration
>> maybe I can figure it out. It seems like including one working example
>> page would really help the beginner get up and running.
>>
>> Thanks for any help.

The standard advice to run through the tutorial does mean the *whole*
tutorial. If you are interested in "just running it and getting a page"
all you need to do is skip ahead to section 3, at

  http://docs.djangoproject.com/en/dev/intro/tutorial03/

There you will see an explanation of URLs and views that should enable
you to strike out on your own if you don't want to follow the tutorial.
It's not like it's a secret or anything, simply that the tutorial puts
in a lot of material about models and the admin site before getting to
views that allow you to manipulate that model.

This ordering may not be the most helpful for an impatient beginner, but
it allows a patient one to relatively quickly get a good understanding
of how Django manipulates database content. The ability to use the admin
site to maintain data does meant the views are a little more interesting
when they do come along.

regards
 Steve--
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.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: delete tables

2008-10-17 Thread felix
here's what I'm using:

from django.core import management
from django.db import connection
cursor = connection.cursor()
# don't delete these tables
# note that I'm also keeping auth_user
tables =
['comments','objekt_objekt','tag','tags','user_objekt_tag','auth_user','auth_session']

current_tables = connection.introspection.table_names()

for table in current_tables:
if table not in tables:
try:
cursor.execute("drop table %s" % table)
except Exception,e:
raise e
#pass

management.call_command('syncdb')







On Fri, Oct 17, 2008 at 3:41 PM, Mirto Silvio Busico <[EMAIL PROTECTED]>wrote:

>
> Sorry  I was not clear.
>
> I have some utilities in view.py which have to reload tables content
> (migration from the legacy database; clearing a table and reloading with
> base content; ...)
>
> I know from the shell it is enough an "python manage py flush", but I
> have two problems:
>
>* the action have to be triggered by a user action on a form
>* the id have to be resetted because for me the id=0 and id=1 rows
>  have a fixed special meaning
>
> I have not found anything about deleting tables in
> http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that
> "database api" has gone in 1.0)
> The only thing that seems I can use is "Executing custom SQL" in
> http://docs.djangoproject.com/en/dev/topics/db/models/
>
> There is a better/recommended method?
>
> Thanks
>Mirto
>
>
> Erik Allik ha scritto:
> > $ manage.py dbshell
> >  > DROP TABLE table_name;
> >
> > Django does not currently have a database schema management tool (with
> > the exception of syncdb and sql* commands).
> >
> > Erik
> >
> >
> > On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
> >
> >
> >> Hi all,
> >>
> >> what is the django way o deleting all table content and resetting the
> >> primary key counter?
> >>
> >> Thanks
> >>Mirto
> >>
> >> --
> >>
> >>
> _
> >> Busico Mirto Silvio
> >> Consulente ICT
> >> cell. 333 4562651
> >> email [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
> > >
> >
> >
>
>
> --
>
> _
> Busico Mirto Silvio
> Consulente ICT
> cell. 333 4562651
> email [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 server crashes without error

2008-10-17 Thread ccpn

about 25% of the total memory:

Mem:   6062488k total,  4693476k used,  1369012k free,   110524k
buffers
Swap:  2104472k total,0k used,  2104472k free,  2460792k
cached

  PID USER  PR  NI  VIRT  RES  SHR S %CPU %MEMTIME+  COMMAND
11954 chris 20   0 1571m 1.3g 5080 S7 23.3   5:45.13 python
 2752 root  20   0  231m  78m  10m S4  1.3   8:06.88 X
11908 chris 20   0  477m  96m  26m S3  1.6   0:21.59 firefox

Chris



On Oct 17, 1:31 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> How much memory is the process using just prior to it crashing?
>
> Graham
>
> On Oct 17, 9:16 pm, ccpn <[EMAIL PROTECTED]> wrote:
>
> > I just updated everything, we are using python-mysql 1.2.2 and
> > MySQL Client API version 5.1.26-rc, which I think are the very latest
> > versions
> > Thecrashesstill occur though. Is there any logfile that tracks what
> > is going wrong?
> > Chris
>
> > On Oct 16, 1:19 am, Graham Dumpleton <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Oct 16, 1:34 am, ccpn <[EMAIL PROTECTED]> wrote:
>
> > > > On Oct 15, 1:08 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > > > wrote:
>
> > > > > On Oct 15, 6:22 pm, ccpn <[EMAIL PROTECTED]> wrote:
>
> > > > > > We are building a django site that involves uploading and processing
> > > > > > of files. We have found that in some instances the server quits 
> > > > > > after
> > > > > > starting the upload process, leaving us with a blank screen. The
> > > > > > problem is that Django is not reporting any errors, and we have no
> > > > > > clue what causes it. The problem occurs more frequently on a macbook
> > > > > > pro than on our linux machines. It doesn't seem to depend on the 
> > > > > > file
> > > > > > that is uploaded, but on the order in which files are uploaded.
>
> > > > > > Anybody any clue?
>
> > > > > What hosting mechanism are you using? Django development server,
> > > > > Apache/mod_python, Apache/mod_wsgi, FASTCGI, something else?
>
> > > > > Is your handler doing any processing of the file while it is being
> > > > > uploaded? If yes, what is it doing and what third party Python modules
> > > > > is it using to do it?
>
> > > > Hi Graham,
>
> > > > thanks for the response. We are using Django development server (on
> > > > localhost) and mysql server
>
> > > > The error occurs not only on uploads (and not always), but we've seen
> > > > it also when simply submitting info to the underlying python scripts.
> > > > We are using a big python object that stays in memory throughout all
> > > > the procedures, maybe that is where it goes wrong?
>
> > > > The third party modules are from a scientific program
> > > > (FormatConverter, probably has no meaning to you, but this is the
> > > > link:http://www.ebi.ac.uk/msd/NMR/NMRtoolkit/formatConverter.html)
>
> > > > Hope it will give you a clue, thanks anyway!
>
> > > I'd be more worried about MySQL actually as there have been some
> > > reports of some versions crashing randomly. Ensure you have an up to
> > > date version of MySQL client libraries and Python wrappers.
>
> > > Graham
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Figuring out prefork v. worker

2008-10-17 Thread john

On Oct 16, 2008, at 4:14 PM, Doug Van Horn wrote:

> I was just wondering if anyone else had been through this cycle?  My
> testing showed I didn't have any issues with mod_wsgi/prefork leaking
> info across apps, but maybe someone else has?
>
> I'm pretty much thinking I shouldn't have bothered with all this fancy
> worker and wsgi stuff and just stuck with the prefork/mod_python
> configuration.  After all, I'm running business applications, not
> social networking sites.

Yeah, actually I had the same problem with timezones in embedded mode,  
and some other weird problems with psycopg2, too. Daemon mode fixed  
all of them, and my experience bears out what Graham said: this setup  
handles more load than prefork with fewer processes and less memory,  
and the footprint's more predictable. There are other benefits, like  
the ability to run different sites as different users, but that was my  
main concern.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: everything works except apache seeing django app

2008-10-17 Thread Stephen Moore

for the record, I fixed the problem

it seems the permissions have to be correct for every level of the directory.

so for /home/iambo/web then /, /home, /home/iambob and
/home/iambob/web had to have the right permissions :)

thankyou for the help.

...

:)

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



Re: delete tables

2008-10-17 Thread Mirto Silvio Busico

Sorry  I was not clear.

I have some utilities in view.py which have to reload tables content 
(migration from the legacy database; clearing a table and reloading with 
base content; ...)

I know from the shell it is enough an "python manage py flush", but I 
have two problems:

* the action have to be triggered by a user action on a form
* the id have to be resetted because for me the id=0 and id=1 rows
  have a fixed special meaning

I have not found anything about deleting tables in 
http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that 
"database api" has gone in 1.0)
The only thing that seems I can use is "Executing custom SQL" in 
http://docs.djangoproject.com/en/dev/topics/db/models/

There is a better/recommended method?

Thanks
Mirto


Erik Allik ha scritto:
> $ manage.py dbshell
>  > DROP TABLE table_name;
>
> Django does not currently have a database schema management tool (with  
> the exception of syncdb and sql* commands).
>
> Erik
>
>
> On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
>
>   
>> Hi all,
>>
>> what is the django way o deleting all table content and resetting the
>> primary key counter?
>>
>> Thanks
>>Mirto
>>
>> -- 
>>
>> _
>> Busico Mirto Silvio
>> Consulente ICT
>> cell. 333 4562651
>> email [EMAIL PROTECTED]
>>
>>
>> 
>
>
> >
>
>   


-- 

_
Busico Mirto Silvio
Consulente ICT
cell. 333 4562651
email [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: ImportError: cannot import name parse_lookup

2008-10-17 Thread [EMAIL PROTECTED]





> Work as if you have no need of the money.
> Love as if nobody ever made you suffer.
> Dance as if nobody is watching you.
> Sing as if nobody is hearing you.
> Live as if the Paradise were on this Earth.
 Good Attitude~I like it~

I have the same error.
Thank You everyone.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 get a page in Django?

2008-10-17 Thread chaugen

I am new to both Python and Django, and with somewhat limited
programming experience. That being said, the tutorials set up on
Django Project (http://docs.djangoproject.com/en/dev/) are excellent.
I would suggest 'Beginning Python' from O'Brien as well. It took me
only a few days with both the tutorials, and the book to begin
developing some very dynamic web projects. One other resource may be
helpful is 'Practical Django Projects', which will help you build a
Content Managment System and 'get a page in Django!'.

Rgs

On Oct 16, 9:08 pm, Gnarlodious <[EMAIL PROTECTED]> wrote:
> I don't know anything about Python except for how to run SQLite
> commands. Mostly my strong point is HTML
>
> Is there an example site offered where I can download and install and
> just run it and get a page? If I can study a working configuration
> maybe I can figure it out. It seems like including one working example
> page would really help the beginner get up and running.
>
> Thanks for any help.
>
> -- Gnarliehttp://Gnarlodious.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: Admin won't display datetime widget with custom form?

2008-10-17 Thread Keith Eberle
I had a project where I needed to set the initial value to the current
week's week ending date (Sat), so I needed a custom form too.  I used the
AdminDateWidget, but I think this will be the correct widget for your needs.

# import the widgets
from django.contrib.admin import widgets

# use the widget on this line
date = forms.DateTimeField(widget=widgets.AdminSplitDateTime)

keith


On Thu, Oct 16, 2008 at 6:23 PM, mthorley <[EMAIL PROTECTED]> wrote:

>
> Hello, I'm building a custom admin site with a custom form and the
> datetime widget shows up as a text input. When I set the widget for
> the date field to textarea I get a textarea, but when I set it to
> datetime, I get I text input. I also tried not specifying any widget
> and I still get just a text input.
>
> Can some one please tell me why or how to fix it?
>
> Thanks much
> --
> matthew
>
> from django import forms
> from django.contrib import admin
> from colorcode.trainertools.models import Workshop
>
>
> class WorkshopForm(forms.Form):
>  name = forms.CharField(max_length=64)
>  date = forms.DateTimeField(widget=forms.DateTimeInput())
>  code = forms.CharField()
>
>
> class WorkshopAdmin(admin.ModelAdmin):
>  def get_form(self, request, obj=None, **kwargs):
>return WorkshopForm
>
>
> trainers_admin = admin.sites.AdminSite()
> trainers_admin.register(Workshop, WorkshopAdmin)
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Extending the User model

2008-10-17 Thread Ulises

> AFAICT, there's some work going on to allow to replace the default
> User model with a custom one. But so far, the recommended solution is
> indeed to use a UserProfile. Else, there's the hackish (IOW : *not*
> recommended) solution - monkeypatching the User model
> http://www.amitu.com/blog/2007/july/django-extending-user-model/

If you want yet another hack you could use a custom authentication
backend with your own user model as described here:
http://monogroncho.com/2008/10/django-gotchas-part-2/ (shameless self
promotion here :)

U

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



Need help with newforms ...

2008-10-17 Thread dbee

I need the user to be able to check the box on groups that apply to
them. This was really easy to do with oldforms ...

   VIEWS:

# Get all that user's
groups
groups =
Groups.objects.filter(userProfile__user__pk=request.user.id)

# Create the FormWrapper, template, context, response
form = forms.FormWrapper(manipulator, new_data, errors)

return render_to_response('myaccount.html', {'form': form,
'user' : request.user,'groups' : groups})


   TEMPLATE:

  {% for g in groups %}

   
 
  {{ g.name }}
 
 
  
 
   

   {% endfor %}

Couldn't be simpler. But now in newforms, i'm a bit lost ...

  VIEWS:

# Get all that user's
groups
groups =
Groups.objects.filter(userProfile__user__pk=request.user.id)


# Campaign
form
class CampaignsForm(forms.Form):

  name = forms.CharField(required=True, max_length=40)
  description = forms.CharField(required=True,
max_length=1000,
widget=forms.Textarea(attrs={'rows':'7','cols':'25'}))
  send_date = forms.CharField(required=False)
  groups = forms.CharField(widget=forms.Select())

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

   super(CampaignsForm, self).__init__(args, kwargs)
   self.fields['groups'].choices = groups

# THis gives me a an empty groups drop-down menu and triggers all
the errors on the form. I also especially want to render checkboxes
using only that user's groups and not have a drop-down menu.

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: delete tables

2008-10-17 Thread Erik Allik

$ manage.py dbshell
 > DROP TABLE table_name;

Django does not currently have a database schema management tool (with  
the exception of syncdb and sql* commands).

Erik


On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:

>
> Hi all,
>
> what is the django way o deleting all table content and resetting the
> primary key counter?
>
> Thanks
>Mirto
>
> -- 
>
> _
> Busico Mirto Silvio
> Consulente ICT
> cell. 333 4562651
> email [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
-~--~~~~--~~--~--~---



delete tables

2008-10-17 Thread Mirto Silvio Busico

Hi all,

what is the django way o deleting all table content and resetting the 
primary key counter?

Thanks
Mirto

-- 

_
Busico Mirto Silvio
Consulente ICT
cell. 333 4562651
email [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 server crashes without error

2008-10-17 Thread Graham Dumpleton

How much memory is the process using just prior to it crashing?

Graham

On Oct 17, 9:16 pm, ccpn <[EMAIL PROTECTED]> wrote:
> I just updated everything, we are using python-mysql 1.2.2 and
> MySQL Client API version 5.1.26-rc, which I think are the very latest
> versions
> The crashes still occur though. Is there any logfile that tracks what
> is going wrong?
> Chris
>
> On Oct 16, 1:19 am, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
>
> > On Oct 16, 1:34 am, ccpn <[EMAIL PROTECTED]> wrote:
>
> > > On Oct 15, 1:08 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > On Oct 15, 6:22 pm, ccpn <[EMAIL PROTECTED]> wrote:
>
> > > > > We are building a django site that involves uploading and processing
> > > > > of files. We have found that in some instances the server quits after
> > > > > starting the upload process, leaving us with a blank screen. The
> > > > > problem is that Django is not reporting any errors, and we have no
> > > > > clue what causes it. The problem occurs more frequently on a macbook
> > > > > pro than on our linux machines. It doesn't seem to depend on the file
> > > > > that is uploaded, but on the order in which files are uploaded.
>
> > > > > Anybody any clue?
>
> > > > What hosting mechanism are you using? Django development server,
> > > > Apache/mod_python, Apache/mod_wsgi, FASTCGI, something else?
>
> > > > Is your handler doing any processing of the file while it is being
> > > > uploaded? If yes, what is it doing and what third party Python modules
> > > > is it using to do it?
>
> > > Hi Graham,
>
> > > thanks for the response. We are using Django development server (on
> > > localhost) and mysql server
>
> > > The error occurs not only on uploads (and not always), but we've seen
> > > it also when simply submitting info to the underlying python scripts.
> > > We are using a big python object that stays in memory throughout all
> > > the procedures, maybe that is where it goes wrong?
>
> > > The third party modules are from a scientific program
> > > (FormatConverter, probably has no meaning to you, but this is the
> > > link:http://www.ebi.ac.uk/msd/NMR/NMRtoolkit/formatConverter.html)
>
> > > Hope it will give you a clue, thanks anyway!
>
> > I'd be more worried about MySQL actually as there have been some
> > reports of some versions crashing randomly. Ensure you have an up to
> > date version of MySQL client libraries and Python wrappers.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django server crashes without error

2008-10-17 Thread ccpn

I just updated everything, we are using python-mysql 1.2.2 and
MySQL Client API version 5.1.26-rc, which I think are the very latest
versions
The crashes still occur though. Is there any logfile that tracks what
is going wrong?
Chris

On Oct 16, 1:19 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Oct 16, 1:34 am, ccpn <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 15, 1:08 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Oct 15, 6:22 pm, ccpn <[EMAIL PROTECTED]> wrote:
>
> > > > We are building a django site that involves uploading and processing
> > > > of files. We have found that in some instances the server quits after
> > > > starting the upload process, leaving us with a blank screen. The
> > > > problem is that Django is not reporting any errors, and we have no
> > > > clue what causes it. The problem occurs more frequently on a macbook
> > > > pro than on our linux machines. It doesn't seem to depend on the file
> > > > that is uploaded, but on the order in which files are uploaded.
>
> > > > Anybody any clue?
>
> > > What hosting mechanism are you using? Django development server,
> > > Apache/mod_python, Apache/mod_wsgi, FASTCGI, something else?
>
> > > Is your handler doing any processing of the file while it is being
> > > uploaded? If yes, what is it doing and what third party Python modules
> > > is it using to do it?
>
> > Hi Graham,
>
> > thanks for the response. We are using Django development server (on
> > localhost) and mysql server
>
> > The error occurs not only on uploads (and not always), but we've seen
> > it also when simply submitting info to the underlying python scripts.
> > We are using a big python object that stays in memory throughout all
> > the procedures, maybe that is where it goes wrong?
>
> > The third party modules are from a scientific program
> > (FormatConverter, probably has no meaning to you, but this is the
> > link:http://www.ebi.ac.uk/msd/NMR/NMRtoolkit/formatConverter.html)
>
> > Hope it will give you a clue, thanks anyway!
>
> I'd be more worried about MySQL actually as there have been some
> reports of some versions crashing randomly. Ensure you have an up to
> date version of MySQL client libraries and Python wrappers.
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ldapauth and TLS

2008-10-17 Thread Daniele Procida

On Thu, Oct 16, 2008, Daniele Procida <[EMAIL PROTECTED]> wrote:

>I'm trying to get django.contrib.auth.ldapauth.LDAPBackend - from:
>
>
>
>working with our LDAP server.
>
>However, if we set any value in LDAP_OPTIONS (other than 'None' - and
>even the one in the example above) we get an error:
>
>Exception Value:   
>'dict' object has no attribute 'LDAP_OPTIONS'
>Exception Location:
>/usr/lib/python2.5/site-packages/django/contrib/auth/ldapauth.py in
>authenticate, line 113

OK - I seem to have found the problem.

Line 113 of ldapauth.py:

self.ldap.set_option(k, self.settings.LDAP_OPTIONS[k])

should be:

self.ldap.set_option(k, self.settings["LDAP_OPTIONS"][k])

I presume that other instances of that syntax need to be changed.

Also, the syntax for settings.py that worked for me were:

import ldap
LDAP_OPTIONS = 'ldap.OPT_X_TLS_DEMAND,1'

I have commented on the ticket.

Thanks for all the help and suggestions.

Daniele


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



Promote a Place to a Restaurant?

2008-10-17 Thread Erik Stein


Hello --

I could not get an answer on the IRC channel and I'm also not finding  
the right keywords for a successful search on the subject[1]:

You all know the model inheritance example with the classes Place and  
Restaurant. Imagine I mapped every Place in my street, now one of this  
empty places is becoming a restaurant. Is there an easy way to express  
this in django-ORM?

I tried

p = Place(number=32)
p.restaurant.create()

which gives

DoesNotExist: Restaurant matching query does not exist.

Am I missing something or is this just not implemented? Is there a  
workaround?


Thanks
-- erik



[1] Apart from http://code.djangoproject.com/ticket/7623

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 get a page in Django?

2008-10-17 Thread David Reynolds


On 17 Oct 2008, at 5:08 am, Gnarlodious wrote:

> I don't know anything about Python except for how to run SQLite
> commands. Mostly my strong point is HTML


If you familiar with another programming language, may I suggest Dive  
into Python?

http://diveintopython.org/

-- 
David Reynolds
[EMAIL PROTECTED]


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



Re: Django development environment (newbie)

2008-10-17 Thread bruno desthuilliers

On 16 oct, 21:49, Trastabuga <[EMAIL PROTECTED]> wrote:
> Can I combine it with Apache so I can serve my static and index.html
> with Apache and the rest with django-admin.py server?

The builtin server is *not* intented for production use.


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



Re: Django development environment (newbie)

2008-10-17 Thread bruno desthuilliers

On 16 oct, 23:00, "Hernan Olivera" <[EMAIL PROTECTED]> wrote:
> > Can I combine it with Apache so I can serve my static and index.html
> > with Apache and the rest with django-admin.py server?
>
> There is a very single configuration option in apache that
> auto-reloads code too, in django documentation.

With some cost wrt/ perfs, and IIRC sometimes some strange results...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Python have a JIT (Just-in-time) compiler?

2008-10-17 Thread bruno desthuilliers



On 17 oct, 00:57, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Thu, 2008-10-16 at 12:02 -0700, bruno desthuilliers wrote:
> > On 16 oct, 20:28, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > > Python have a JIT (Just-in-time) compiler?
>
> > There's psyco, but it only works on x86 and imposes some restrictions
> > in the way you code.
>
> There's also the problem that "Python" isn't well-defined in this
> question. Jython does, for example, in the sense that it's compiled to
> JVM bytecode which is then compiled just in time. PyPy and IronPython
> have similar behaviours that are specific to their implementation.

Indeed. I (perhaps wrongly) assumed that the OP was talking about
CPython.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Extending the User model

2008-10-17 Thread bruno desthuilliers

On 17 oct, 05:30, jeffself <[EMAIL PROTECTED]> wrote:
> I'm working on an application that will need data entry from many
> users.  The users belong to various departments in the organization
> and the information that gets entered by each user should contain the
> department information.  The reason for this is that the users should
> be able to view and edit only records in their department.  They
> should not be able to view any records from any other department.
>
> I'm not sure how to go about doing this.  I definitely want to use the
> User model in Django and I'm thinking that all I want to do is extend
> it with a department field which is a foreign key of the Department
> model that I have created.  On the other hand, I've looked at Profiles
> as well and even created a UserProfile class which contains the user
> and the department.  Which is the correct approach?

AFAICT, there's some work going on to allow to replace the default
User model with a custom one. But so far, the recommended solution is
indeed to use a UserProfile. Else, there's the hackish (IOW : *not*
recommended) solution - monkeypatching the User model
http://www.amitu.com/blog/2007/july/django-extending-user-model/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 get a page in Django?

2008-10-17 Thread bruno desthuilliers

On 17 oct, 06:08, Gnarlodious <[EMAIL PROTECTED]> wrote:
> I don't know anything about Python except for how to run SQLite
> commands.

SQLite is not Python. So I guess you *really* dont know anything about
Python if you're confusing both.

> Mostly my strong point is HTML
>
> Is there an example site offered where I can download and install and
> just run it and get a page? If I can study a working configuration
> maybe I can figure it out. It seems like including one working example
> page would really help the beginner get up and running.

Ok, I guess you have a profound misconception about what Django is and
is not. So to try and make things clear :  Django is *not* a Content
Management System. It is a web programming framework - that is, a
*development* tool. Unless you're interested in becoming a programmer,
it's probably not what you're looking for.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: internationalization and template magic caching

2008-10-17 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-10-16, o godz. 15:45, przez matei:

> You are right. I now know what happened to me and caused confusion. It
> appears to me django is taking the po files from the django admin so
> words like password and change were translated without me specifying
> my own .po .mo files. Not a preferable behaviour for some people
> maybe. Is it a setting? Im sure my values override it nicely but
> still..


If you want to get rid of Django-provided translations (these from  
django/conf/locale/), you have to turn off i18n completely by  
switching USE_I18N to False.

Anyway, I am not sure what happens if Django gets more that one  
translation for the same key (is there any order of preference?), I  
just never tried it.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[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: save existing jpg to model

2008-10-17 Thread Ben Eliott

Hi Steve,
Nope, Linux machine...
???

On 17 Oct 2008, at 01:30, Steve Holden wrote:

>
> [EMAIL PROTECTED] wrote:
>> I have users dumping jpgs into a folder within the media root, the
>> idea is to monitor this folder and programmatically add the jpgs to
>> certain model instances based on a naming convention. It all works
>> fine... except... every time i put a jpg in File object and save to a
>> model the  jpg gets corrupted.
>>
>> I've tried with both regular File() object and default_storage.
>>
>> f = open('%s' % infile, 'w')
>> file = File(f)
>> #file = default_storage.open(infile, 'wb')
>> ProductImage.objects.create(product=product,sort=sort,picture=file)
>>
>> what am i missing here - should i be using PIL in some way?
>>
> Are you perchance running on Windows? If so you must write the files  
> in
> binary mode to avoid the content being mangled ("\n" will be  
> replaced by
> "\r\n" wherever it occurs).
>
> regards
> Steve
>
>
> >


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



Re: How to display image from ImageField in ModelAdmin?

2008-10-17 Thread krylatij

Code above was a bit incorrect. Here better solution:
## widget declaration
from django.utils.safestring import mark_safe
from django.forms.widgets import FileInput

class AdminImageFieldWithThumbWidget(FileInput):

def __init__(self, thumb_width=50, thumb_height=50):
self.width = thumb_width
self.height = thumb_height
super(AdminImageFieldWithThumbWidget, self).__init__({})

def render(self, name, value, attrs=None):
thumb_html = ''
if value and hasattr(value, "url"):
thumb_html = '' %
(value.url, self.width, self.height)
return mark_safe("%s%s" % (thumb_html,
super(AdminImageFieldWithThumbWidget, self).render(name, value,
attrs)))


##form sample
class PhotoBaseInline(admin.StackedInline):
fieldsets = (
(None, {'fields': (('photo', 'default'),)}),
)

thumb_width = 50
thumb_height = 50
def formfield_for_dbfield(self, db_field, **kwargs):
field =
super(PhotoBaseInline,self).formfield_for_dbfield(db_field,**kwargs)
if db_field.name == 'photo':
   return
forms.ImageField(widget=AdminImageFieldWithThumbWidget(thumb_width=self.thumb_width,
thumb_height=self.thumb_height))
return field

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