Re: new forms and read-only rendering

2007-06-14 Thread Malcolm Tredinnick

On Wed, 2007-06-13 at 20:54 +, eXt wrote:
> I know that, but generic view needs a template created by hand (or I
> missed something). I want to automatically generate some html code (as
> new forms do).

I think your expectations are a little different than what Django
provides. Django gives you a framework for hndling the pieces of a
project that can be automated most of the time. Laying out the
information on a page is not one of those pieces, since it's very
particular to each project.

SThere isn't anything in core that takes a model and produces any sort
of HTML static page for it. It would be simple enough for you to write
one for your own purposes if you wanted. Have a look at how, say,
django.newsforms.utils.form_for_model() iterates over the fields and use
that to generate a template string.

The newforms portion is not appropriate for this though, since forms are
for input, not static data presentation. You could emulate the result
use the "attrs" parameter to various widgets, but that would require as
much (or more) hand-coding as either writing a template or a simple
utility method.

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: "Powered by Django" directory - Designer Wanted!

2007-06-14 Thread Kelvin Nicholson


> 
> There are now 6 sites listed at www.djangosites.org which has fleshed
> out the front page a bit. Thanks for submitting your sites so far
> guys.

Then there were 10.

When you get the chance, it would be nice if the URL for each blog was
the slug, instead of just a number.

I'm starting to feel like a statistic.

Kelvin

-- 
Kelvin Nicholson
Voice: +886 9 52152 336
Voice: +1 503 715 5535
GPG Keyid: 289090AC
Data: [EMAIL PROTECTED]
Skype: yj_kelvin
Site: http://www.kelvinism.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: Trouble with custom context processor and model

2007-06-14 Thread Malcolm Tredinnick

On Wed, 2007-06-13 at 21:03 +, [EMAIL PROTECTED] wrote:
> I have a custom context processor that is in my settings file, so it
> is being called on each request.  When making any request, I receive
> the following error.
> 
> Traceback (most recent call last):
> File "c:\Python24\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   77. response = callback(request, *callback_args, **callback_kwargs)
> File "c:\Python24\lib\site-packages\django\contrib\admin\views
> \decorators.py" in _checklogin
>   65. return _display_login_form(request, message)
> File "c:\Python24\lib\site-packages\django\contrib\admin\views
> \decorators.py" in _display_login_form
>   28. }, context_instance=template.RequestContext(request))
> File "c:\Python24\lib\site-packages\django\template\context.py" in
> __init__
>   100. self.update(processor(request))
> File "C:\djangosites\AGD\..\AGD\context_processors.py" in member
>   5. member = Member.objects.get(user=request.user)
> File "c:\Python24\lib\site-packages\django\db\models\manager.py" in
> get
>   73. return self.get_query_set().get(*args, **kwargs)
> File "c:\Python24\lib\site-packages\django\db\models\query.py" in get
>   250. obj_list = list(clone)
> File "c:\Python24\lib\site-packages\django\db\models\query.py" in
> __iter__
>   108. return iter(self._get_data())
> File "c:\Python24\lib\site-packages\django\db\models\query.py" in
> _get_data
>   470. self._result_cache = list(self.iterator())
> File "c:\Python24\lib\site-packages\django\db\models\query.py" in
> iterator
>   183. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or
> "") + ",".join(select) + sql, params)
> File "c:\Python24\lib\site-packages\django\db\backends\util.py" in
> execute
>   24. self.db.queries.append({
> 
>   TypeError at /admin/
>   __str__ returned non-string (type instance)
> 
> All of my __str__ methods are returning strings according to the
> model.

There might be other __str__ methods being called apart from the one on
Member; it's hard to tell. If you can't work this out from looking at
the local variables in the debug page's traceback, try putting a
try...except block around that line in Django's source and printing out
the types of everything involved there. Basically, you have to catch it
in the act and work backwards.

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: database connections

2007-06-14 Thread Malcolm Tredinnick

On Wed, 2007-06-13 at 22:25 +, [EMAIL PROTECTED] wrote:
> Greetings. I am about 75% through creating a django application as a
> new section of my company's site, www.etsy.com. It's basically a CMS,
> something that I know django is especially well suited to (tho I can
> tell it would work for nearly any domain).
> 
> Recently, my site ops team started asking me questions about
> reliability with the database and such. After asking around in the irc
> channel and doing some google searches, and even trying to browse
> through the source a bit, I still have some questions:
> 
> 1) Is there some way to tell django to talk to two different databases
> (sort of a fail-over system), eg, behaviour matching the pseudo-code:

No.

[...]

> Is there some way to activate this functionality? As far as I can
> tell, the answer is "no"; in that case, can you suggest how I might go
> about adding it myself? Where in the django source I would have to
> tinker to get this behaviour?
> 
> 2) Site ops might be able to handle database fail-over at the network
> configuration level, but I need to know whether the django orm, when
> using postgress, keeps a pool of persistent connections. If so, and if
> the connections fail or are disconnected, will it automatically
> attempt to reconnect them upon future requests?
> 
> Again, I don't mind writing the code myself to handle this if it is
> not already handled. If I must write it myself, can you point me in
> the direction of where I would handle this. Is monkeypatching a class
> or method considered superior to editing the source locally? Coming
> from a Ruby background, that would be my natural response.

One of the benefits of everything being a first-class object in Python
is so that things can be replaced at runtime. The only question is
whether you can get in early enough in the pipeline to replace the
functionality before it is used. I'm not sure in this case, although it
might be tricky to do so.

Database connections are set up in django/db/__init__.py

The real heavy lifting for each backend is in
django/db/backends//base.py in the DatabaseWrapper class.
You'll probably be wanting to replace the cursor() method there, I would
guess.

It might be simplest to create your own pseudo-backend that essentially
imports everything from an existing backend and then sub-classes the
DatabaseWrapper class to provide the functionality you want. Last
Tuesday, in a thread called "inspectdb and mssql", I laid out the steps
needed to create a new backend. I'm thinking this might be most
appropriate because then you are only adding new code, rather than
modifying existing code. Updating Django's source then only requires
remembering to move your new code across without having to repatch
certain files. Likely to be more robust.

Regards,
Malcolm


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



Re: Problems with running Django on a remote machine

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 03:40 +, Graham Dumpleton wrote:
[...]
>  No one
> though seems to want to update the documentation.

Which ticket is this?

You keep complaining about this and yet it's unlikely that somebody like
me is going to remember a throwaway comment on the list when I sit down
to do some work, given how unlikely I am to stumble across the problem
myself. Sometimes I remember to capture your comments in ticket reports
but usually not because there's a lot of mail to plough through and
answer each day. You keep referring to "ancient" versions, but a
maintainer's idea of ancient is often more aggressive than the
real-worlds. So we would want to include the version at which this
became a safe thing to do.

Please help us to make your life easier.

Thank you,
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: How to render date and time separately with newforms.SplitDateTimeWidget

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 00:12 +, Paul wrote:
> Is this possible?  The old forms module allowed you to render the date
> and time separately in the template for the form.  Now it seems this
> is no longer possible.  So it isn't possible for instance to render
> the date on one row of a table and the time on the following row just
> below it like:
> {{form.blah}}{{form.mydate.date}}
> {{form.blah2}}{{form.mydate.time}}

It's not possible with the default SplitDateTime widget, but it would be
easy enough to subclass it to provide the functionality you want.
Newforms are designed around encouraging people to subclass things as
they need to add new features, rather than trying to provide everything
by default (which becomes too difficult to use in the common cases).

Create a SplitDateTimeWidget subclass and add date() and time() methods
that return the respective widgets (would replicate some of the logic in
MultiWidget.render)

Or your could write a patch for MultiWidget that allowed access to the
n-th widget in the sequence and post that to Trac. I can't think of
another generic method on MultiWidget that would help, since it's meant
to be able to handle an arbitrary number of contained values, not just
the date+time case.

Regards,
Malcolm


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



Re: Problems with running Django on a remote machine

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 01:30 +0200, Dirk van Oosterbosch, IR labs wrote:
> Hello,
> Django newbie here.
> 
> 
> I just started with learning and trying Django. I quite like it.
> I'm developing a little site on my Powerbook, but now I want to deploy
> it on a remote machine and I have some problems. I have three issues.
> 
> 
> 1. First I tried to use manage.py runserver on the remote machine. But
> the issue I am running into is that every time I try to view a page,
> the runserver process quits out on me and from the browser I get the
> response 'connection refused'.
> (I have two Terminal windows open, both logged into the remote machine
> through ssh, one with '% python manage.py runserver', the other with
> '% links http://127.0.0.1:8000' )
> I can't see why the runserver quits, i.e. there are no error messages
> popping up on in the Terminal. Is there another place to look for an
> error log from runserver? Or is there another way to debug this?

So when it "quits" you just get the prompt back? That would be very
unusual. You could try putting debug printing into
django/core/servers/basehttp.py to see what is going on. I haven't heard
of this happening before.

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: override get_next_by_FOO() / get_previous_by_FOO()

2007-06-14 Thread Malcolm Tredinnick

On Sat, 2007-06-09 at 20:12 -0400, Jonathan Stockdill wrote:
> I found myself in a similar position and used the following:
>  def get_next_pub(self):
>return self.get_next_by_pub_date(pub_date__lt=datetime.now 
> (),is_draft=False)
>  def get_previous_pub(self):
>return self.get_previous_by_pub_date(pub_date__lt=datetime.now 
> (),is_draft=False)
> 
> but already have these filters in a Manager and was wondering, is  
> there a way to specify the methods to use a different manager than  
> the default?

Sorry for missing this reply -- it was way back in my mailbox archives
and I didn't notice it.

The answer to your question is "no", you can't replace the manager used
there. The actual code being executed is in django/db/models/base.py in
Model::_get_next_or_previous_by_FIELD() and it uses the default manager
always.

The way you are doing looks appropriate.

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: new Django site: critterwatch.org

2007-06-14 Thread drewda

If you haven't already come across it, you might enjoy the Washington
Post's database of U.S. Congress votes: 
http://projects.washingtonpost.com/congress/

--Drew

On Jun 13, 8:25 pm, "Bryan L. Fordham" <[EMAIL PROTECTED]>
wrote:
> Michael Trier wrote:
> > Nice work. You need someone to spice up the UI, but the content rocks.
> >  Great job.
>
> Thanks
>
> And yeah, I'm not a UI design guy. Given a design I can code it, but I
> suck at coming up with the design from scratch.
>
> So if anyone on this list wants to donate a nice design, feel free 8)
>
> --B


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



REAL PLAYER is FREE and is considered the Best,Music Player Available Today !!

2007-06-14 Thread niku

Hi There,

Real Player Update !!

Now Real Player New Version is available for FREE.

With Real Player, Transfer music to iPod and other portable media
players..


www.chulbul.com/real.htm


Have Fun


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



Re: Problems with running Django on a remote machine

2007-06-14 Thread Graham Dumpleton

On Jun 14, 5:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-06-14 at 03:40 +, Graham Dumpleton wrote:
>
> [...]
>
> >  No one
> > though seems to want to update the documentation.
>
> Which ticket is this?
>
> You keep complaining about this and yet it's unlikely that somebody like
> me is going to remember a throwaway comment on the list when I sit down
> to do some work, given how unlikely I am to stumble across the problem
> myself. Sometimes I remember to capture your comments in ticket reports
> but usually not because there's a lot of mail to plough through and
> answer each day. You keep referring to "ancient" versions, but a
> maintainer's idea of ancient is often more aggressive than the
> real-worlds. So we would want to include the version at which this
> became a safe thing to do.
>
> Please help us to make your life easier.

I have occasionally pointed it out that I believe it is possibly
wrong, but no one yet that I am aware of who is connected with Django
development has acknowledged that this may be the case even though in
the past I have asked for someone who knows better to comment. I don't
personally use Django for anything nor know the code in any detail so
I can't back up my observations with any proof and have been waiting
for anyone connected with actual Django development to acknowledge
that my comments may be true to any degree and start an informed
conversation about it. Since there has been silence I have only been
able to take it that people either don't really care or disagree and
that prefork is seen as the only safe way to use Django. I haven't
created a ticket as I saw the mailing list as a preferred place for
initial discussion especially when I have seen tickets where comments
were added taking issue with people using it for conversations.

So, if I knew for sure if my complaint was even half valid I would
create a ticket, but I don't know as no one with any authority has
responded. By responding are you acknowledging that Django probably is
okay to use with worker MPM or are there still issues with database
caching or other areas?

BTW, mod_python 3.1.3 was released almost 3 1/2 years ago. Although
mod_python 3.1.4 was released 2 1/2 years ago, it only contained a
security bug fix with code otherwise exactly the same. Given that
there have been two major releases and three minor releases since then
those 3.1.X versions are looking quite old.

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: problems with a shared host setup

2007-06-14 Thread Amit Ramon

I guess the actual configuration depends on your host, but I do it a bit 
differently. I'm on site5, but you may want to take a look at 
http://forums.site5.com/showthread.php?t=10236

Also, I noted that your handler is using /usr/bin/python, whereas most 
instructions I saw say to use virtual python (so you can install your own 
stuff in site-packages. Maybe this gives you some troubles.

I'm pasting here my .htaccess and the handler script, perhaps they'll help 
you. They're slightly different than yours:

# .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^(admedia/.*)$ - [L]
RewriteRule ^(media/.*)$ - [L]
RewriteCond %{REQUEST_URI} !(dispatch.fcgi)
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]


# dispatch.cgi

#!/home/amitrain/bin/python
import sys

# add the path to the django sites root directory
# to python path. this shouldn't be changed for different
# sites as long as they all under this root.
sys.path += ['/home/amitrain/django_sites']

from fastcgi.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os

# point django to the specific site settings module
os.environ['DJANGO_SETTINGS_MODULE'] = 'kennel.settings'

WSGIServer(WSGIHandler()).run()

# end of code

All the best,

Amit





ביום חמישי 14 יוני 2007, 07:28, נכתב על ידי [EMAIL PROTECTED]:
> 
> I've been trying to get django up and running on a shared account, and
> i'm having troubles - I have done everything I think I'm supposed to
> as per the setup documentation, but it just seems to hang when I try
> to access the page I setup.
> 
> Here is a copy of my config and the error message I receive:
> 
> 
> http://dpaste.com/12229/
> 
> ty
> 
> 
> > 
> 

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



jsonrpc working example

2007-06-14 Thread Dushyant Sharma

has any body used jsonrpc with django if yes kindly help me
here is how to use it but i cant use it with django facing problems
http://json-rpc.org/wiki/python-json-rpc


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



Email problem

2007-06-14 Thread Brij

Hi,

I am using the django.core.mail for sending mail to users in my
application...I have defined EMAIL_HOST but havenot defined EMAIL_PORT
because my smtp server doesnt require a port number...

Following is the view function im using :::

def send_email(request, sender, reciepient):
subject = 'Test Mail from OST'
message = 'Testing email from OST'
from_email = '[EMAIL PROTECTED]'
if subject and message and from_email:
   try:
   send_mail(subject, message, from_email,
['[EMAIL PROTECTED]'])
   except BadHeaderError:
   return render_to_response('Error.html', {
'reason': 'Objective Successfully
Assigned...Problem Sending Email to the user',
   })
   return render_to_response('success.html', {
'reason': 'Objective Successfully Assigned...Email
Successfully Send to the user.'
 })
else:
# In reality we'd use a manipulator
# to get proper validation errors.
return HttpResponse('Make sure all fields are entered and
valid.')



The error which i m getting is :::
Exception Value: (10054, 'Connection reset by peer')
Exception Location: C:\Python24\Lib\socket.py in readline, line 340


Please guide me as to how should i go about this 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: jsonrpc working example

2007-06-14 Thread Kenneth Gonsalves


On 14-Jun-07, at 6:00 PM, Dushyant Sharma wrote:

> has any body used jsonrpc with django if yes kindly help me
> here is how to use it but i cant use it with django facing problems

would be helpful if you stated what you tried and what the errors were

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



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



Re: jsonrpc working example

2007-06-14 Thread Dushyant Sharma

here is what i am doing
server code

from jsonrpc import handleCGI, ServiceMethod
from django.core import serializers
@ServiceMethod
def hello(msg):
json = serializers.serialize("json",msg)# initially i tried
return(msg)only but i was getting error JSONDecodeException at /c/
testhello/
 
#Expected []{}," or Number, Null, False or True
return HttpResponse(json)
or
   return (json)

or i can use
return HttpResponse(json,mimetype='application/javascript')

none of them works

at client side i use
def testhello(response):
s = ServiceProxy("http://localhost/s/hello";)
resp=s.hello('hello')# this is where i am doubtful
return HttpResponse(resp)

when calling it shows error
JSONDecodeException at /c/testhello/
Expected []{}," or Number, Null, False or True

what i am trying is creating two projects setup with apache virtual
host. one is interacting with user as we do normally. another is
serving the first project by taking requests and sending response to
the first without letting the user know anything.

On Jun 14, 5:39 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 14-Jun-07, at 6:00 PM, Dushyant Sharma wrote:
>
> > has any body used jsonrpc with django if yes kindly help me
> > here is how to use it but i cant use it with django facing problems
>
> would be helpful if you stated what you tried and what the errors were
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


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



Re: Email problem

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 05:35 -0700, Brij wrote:
> Hi,
> 
> I am using the django.core.mail for sending mail to users in my
> application...I have defined EMAIL_HOST but havenot defined EMAIL_PORT
> because my smtp server doesnt require a port number...

All services require a port number. If you don't specify the EMAIL_PORT,
it will use the default (and standard value) of 25. That's fine; just
making you aware that it is using a port number even if you don't
specify it.


> Following is the view function im using :::
> 
> def send_email(request, sender, reciepient):
> subject = 'Test Mail from OST'
> message = 'Testing email from OST'
> from_email = '[EMAIL PROTECTED]'
> if subject and message and from_email:
>try:
>send_mail(subject, message, from_email,
> ['[EMAIL PROTECTED]'])

[...]
> The error which i m getting is :::
> Exception Value: (10054, 'Connection reset by peer')
> Exception Location: C:\Python24\Lib\socket.py in readline, line 340

There's no way I can think of to tell what the problem is from this
information. All the error message is saying is that you made a
connection to a server (so something is listening on port 25 on the
machine you specified) and then it hung up on you at some later point.

Debugging network transactions like this is difficult. Ideally, use a
network sniffer to see the traffic going back and forth between the
client and the server so that you can tell where the problem occurs
(since an email sending interaction is a series of requests and
responses, there are a number of places it can go wrong). If you have
access to the mail logs on the server, that is another way to determine
what is going wrong (not normally posssible in many environments,
though, so it's unlikely you'll be able to use this route).

Check to see if you SMTP server requires using a TLS connection, rather
than just a plain connection (if so, use the TLS parameter from the
latest Django code -- this option won't be available in the 0.96
release, however).

There's not really much I can think to suggest short of finding a way to
watch the network traffic (with something like WireShark), since you
need to know what went wrong and when. At the moment, all you know is
that "it didn't work", which could mean any one of a hundred things.

Some other respondents may have other ideas, though.

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



Reset form field during validation

2007-06-14 Thread Michal

Hello,
is there any way how to set a value to FormField during clean_ 
method?

I have registration form on my site. There is obvious fields like 
username, email, and 2 fields for passwords. After submiting the form I 
validate it, and if there is some error, I would like to set both 
password fields to "" (because I don't want show to the world, what 
password user want to set).

Is there any chance, that I could do this during validation of data? (I 
try to set self.cleaned_data['password1']='' during clean_ method 
and also clean method of the form, but without success).

I am using newforms and Django trunk.


Regards
Michal

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



Re: Email problem

2007-06-14 Thread Dushyant Sharma

i think you should try port 25 at EMAIL_PORT after all you wont loss
anything giving a try

On Jun 14, 6:12 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-06-14 at 05:35 -0700, Brij wrote:
> > Hi,
>
> > I am using the django.core.mail for sending mail to users in my
> > application...I have defined EMAIL_HOST but havenot defined EMAIL_PORT
> > because my smtp server doesnt require a port number...
>
> All services require a port number. If you don't specify the EMAIL_PORT,
> it will use the default (and standard value) of 25. That's fine; just
> making you aware that it is using a port number even if you don't
> specify it.
>
> > Following is the view function im using :::
>
> > def send_email(request, sender, reciepient):
> > subject = 'Test Mail from OST'
> > message = 'Testing email from OST'
> > from_email = '[EMAIL PROTECTED]'
> > if subject and message and from_email:
> >try:
> >send_mail(subject, message, from_email,
> > ['[EMAIL PROTECTED]'])
>
> [...]
>
> > The error which i m getting is :::
> > Exception Value: (10054, 'Connection reset by peer')
> > Exception Location: C:\Python24\Lib\socket.py in readline, line 340
>
> There's no way I can think of to tell what the problem is from this
> information. All the error message is saying is that you made a
> connection to a server (so something is listening on port 25 on the
> machine you specified) and then it hung up on you at some later point.
>
> Debugging network transactions like this is difficult. Ideally, use a
> network sniffer to see the traffic going back and forth between the
> client and the server so that you can tell where the problem occurs
> (since an email sending interaction is a series of requests and
> responses, there are a number of places it can go wrong). If you have
> access to the mail logs on the server, that is another way to determine
> what is going wrong (not normally posssible in many environments,
> though, so it's unlikely you'll be able to use this route).
>
> Check to see if you SMTP server requires using a TLS connection, rather
> than just a plain connection (if so, use the TLS parameter from the
> latest Django code -- this option won't be available in the 0.96
> release, however).
>
> There's not really much I can think to suggest short of finding a way to
> watch the network traffic (with something like WireShark), since you
> need to know what went wrong and when. At the moment, all you know is
> that "it didn't work", which could mean any one of a hundred things.
>
> Some other respondents may have other ideas, though.
>
> 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: "Powered by Django" directory - Designer Wanted!

2007-06-14 Thread Adam Fast
I'm getting a list index out of range error here:

http://www.djangosites.org/most-comments/

I'm looking forward to keeping an eye on this, and as I deploy more django
sites, putting them up myself.

Adam

On 6/14/07, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
>
>
>
> >
> > There are now 6 sites listed at www.djangosites.org which has fleshed
> > out the front page a bit. Thanks for submitting your sites so far
> > guys.
>
> Then there were 10.
>
> When you get the chance, it would be nice if the URL for each blog was
> the slug, instead of just a number.
>
> I'm starting to feel like a statistic.
>
> Kelvin
>
> --
> Kelvin Nicholson
> Voice: +886 9 52152 336
> Voice: +1 503 715 5535
> GPG Keyid: 289090AC
> Data: [EMAIL PROTECTED]
> Skype: yj_kelvin
> Site: http://www.kelvinism.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
-~--~~~~--~~--~--~---



Did someone write an anti-spam module in django?

2007-06-14 Thread kernel1983

My weblog has got lots of spam.

I'll try to deal with them.

Any one has done this job?
Would you mind share your code?


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



Re: Reset form field during validation

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 15:15 +0200, Michal wrote:
> Hello,
> is there any way how to set a value to FormField during clean_ 
> method?
> 
> I have registration form on my site. There is obvious fields like 
> username, email, and 2 fields for passwords. After submiting the form I 
> validate it, and if there is some error, I would like to set both 
> password fields to "" (because I don't want show to the world, what 
> password user want to set).
> 
> Is there any chance, that I could do this during validation of data? (I 
> try to set self.cleaned_data['password1']='' during clean_ method 
> and also clean method of the form, but without success).

Modifying cleaned_data for other fields is probably a bit fragile in
clean_ methods. For a start, you can only hope to succeed if
those other fields were cleaned before your field, which means the
ordering of fields is a constraint.

A more logical (in terms of the design of newforms data cleaning) place
to do multi-field validation and cleaning is the form's clean() method.
At that point, you have full access to cleaned_data (in fact, it's what
that method returns) and the _errors dictionary so you can see if any
fields have errors and, if so, clean out (or just remove the keys) for
the password fields.

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: Did someone write an anti-spam module in django?

2007-06-14 Thread Christian M Hoeppner

> My weblog has got lots of spam.
>
> I'll try to deal with them.
>
> Any one has done this job?
> Would you mind share your code?

On django snippets, there's a piece of code to integrate akismet into the 
django comment app. I'd rather write my own app instead of hacking on the 
sources, but that's up to you.

Good Luck,
Chris Hoeppner
www.pixware.org

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



Odd behaviour from Signals - dispatcher.connect

2007-06-14 Thread Tipan

I've recently made some modifications to my views/urls and settings
files to improve portability of the application. This took out some
explicit references to the application files.

For example, the line:

from test.promotions.models import * was reduced to:
from promotions.models import *

Now when I save to a table that has a dispatcher.connect listening to
the event - it duplicates and runs the dispatcher code twice for each
save event. Having spent some time trying to troubleshoot, when I
reset the import statements to explicit references then the despatcher
code only runs once.

Has anyone encountered similar behaviour?

Any advice on troubleshooting welcomed. I don't want to have explicit
references on my import statements, very un Djangoesque!


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



Laptops giving chronic back pain to millions

2007-06-14 Thread CANE20043 ANAMIKA
* Laptops giving chronic back pain to millions

Booming sales of laptops have led to a surge in the number of computer users
with back and muscle problems, experts have
warne
*

*FOR MORE INFORMATION LOG
ON:
*

*
http://tomorrowsmedicinetoday.blogspot.com/2007/06/laptops-giving-chronic-back-pain-to.html
*

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



/admin/doc/ problem with decorators

2007-06-14 Thread Wolfram Kriesing

i found out that the admin site provides docs, which is pretty cool,
but the problem when clicking on a view-function that has a decorator
(no matter if it is login_required or transaction.*) I always get an
error page

below the link it says:
 View function: django.contrib.auth.decorators._checklogin

and accordingly it tries to open the URL
  /admin/doc/views/django.contrib.auth.decorators._checklogin/

and i get a 404 for this

is there any solution for that?

-- 
cu

Wolfram

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



Re: Reset form field during validation

2007-06-14 Thread Michal

> At that point, you have full access to cleaned_data (in fact, it's what
> that method returns) and the _errors dictionary so you can see if any
> fields have errors and, if so, clean out (or just remove the keys) for
> the password fields.

Remove from where? I try to set there (in clean() method):

   self.cleaned_data['password1'] = ''

and on second try:

   self.cleaned_data.pop('password1')

Both of these attempts didn't set password1 to ''

Could you tell me please, what I am doing wrong?


Regards
Michal

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



Re: Odd behaviour from Signals - dispatcher.connect

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 06:33 -0700, Tipan wrote:
> I've recently made some modifications to my views/urls and settings
> files to improve portability of the application. This took out some
> explicit references to the application files.
> 
> For example, the line:
> 
> from test.promotions.models import * was reduced to:
> from promotions.models import *
> 
> Now when I save to a table that has a dispatcher.connect listening to
> the event - it duplicates and runs the dispatcher code twice for each
> save event. Having spent some time trying to troubleshoot, when I
> reset the import statements to explicit references then the despatcher
> code only runs once.
> 
> Has anyone encountered similar behaviour?

It's ticket #3951, most likely. As you'll see in the comments there,
there is an approach for fixing it. However, it's likely to wait until
after some serious surgery is done on the signals module and that is
ongoing work at the moment. So for now, you'll just have to work around
it a bit.

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: Did someone write an anti-spam module in django?

2007-06-14 Thread Julio Nobrega

  I was getting around 5 spams daily on my website when it had 1.5k
impressions daily. I've implemented a very simple anti-spam solution
which has eliminated every spam, while I've tripled my traffic.

  It's called "negative captcha", and it's very easy to implement. One
day some spammers will learn how to defeat it but for now, it's doing
the job :)

  http://damienkatz.net/2007/01/negative_captch.html


On 6/14/07, kernel1983 <[EMAIL PROTECTED]> wrote:
>
> My weblog has got lots of spam.
>
> I'll try to deal with them.
>
> Any one has done this job?
> Would you mind share your code?
>
>
> >
>


-- 
Julio Nobrega - http://www.inerciasensorial.com.br

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

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 15:35 +0200, Wolfram Kriesing wrote:
> i found out that the admin site provides docs, which is pretty cool,
> but the problem when clicking on a view-function that has a decorator
> (no matter if it is login_required or transaction.*) I always get an
> error page
> 
> below the link it says:
>  View function: django.contrib.auth.decorators._checklogin
> 
> and accordingly it tries to open the URL
>   /admin/doc/views/django.contrib.auth.decorators._checklogin/
> 
> and i get a 404 for this
> 
> is there any solution for that?

This is ticket #1840 (hadn't realised it was quite that old, but there
you go).

It's always a little annoying to have things like that floating around.
Known issue, but a little low priority at the moment. From time to time
I'm tempted to fix it with a variation on the solution Luke Plant
mentioned in that ticket. We can probably write something fairly
lightweight to act as a proper decorator. I personally just haven't
gotten to it yet (other priorities) and obviously neither has any
committer.

So, sorry, but known issue with no current fix (none of the patches on
the ticket are appropriate for the reasons mentioned in the comments).
Somebody write a good decorator wrapper that's small and neat and we'll
include it. The one pointed to in the comments (even if we just take the
decorator module from there) seemed a bit heavyweight when I looked at
it a long time ago. I can't remember my exact problems right now, though
(which is bad software engineering practice, I realise, but life's like
that sometimes).

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



Django developer required

2007-06-14 Thread Ru

Hi, looking for a django developer to do some work on django auth and
hooking django's user / member / register / comments etc in with some
existing legacy systems that work in php.

Interested, please get me at rudoyle at gmail dot com

Kind Regards
Ruairi


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

2007-06-14 Thread handsome greg

Hi guys, quick question: There's no current way to specify how model
fields are mapped to form fields for a model with
newforms.form_for_model is there? I know you can change the formfield
callback but the model doesn't impact that function in any way by
default. What I'm looking for is a way for a model to define the form/
field relationships so form_for_model will return a custom form class
for the model without me having to know anything about it. Is this in
newforms at all?


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



Re: Problems with running Django on a remote machine

2007-06-14 Thread Dirk van Oosterbosch, IR labs

On 14-jun-2007, at 9:34, Malcolm Tredinnick wrote:

>> I tried to use manage.py runserver on the remote machine. But
>> the issue I am running into is that every time I try to view a page,
>> the runserver process quits out on me and from the browser I get the
>> response 'connection refused'.
>> (I have two Terminal windows open, both logged into the remote  
>> machine
>> through ssh, one with '% python manage.py runserver', the other with
>> '% links http://127.0.0.1:8000' )
>> I can't see why the runserver quits, i.e. there are no error messages
>> popping up on in the Terminal. Is there another place to look for an
>> error log from runserver? Or is there another way to debug this?
>
> So when it "quits" you just get the prompt back? That would be very
> unusual. You could try putting debug printing into
> django/core/servers/basehttp.py to see what is going on. I haven't  
> heard
> of this happening before.
>

Exactly. It runs untill I try to load a page (from another ssh  
shell). And I just get the prompt back:
[EMAIL PROTECTED]: ~/mysite_project/mysite]% python manage.py runserver
Validating models...
0 errors found.

Django version 0.96, using settings 'opop.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[EMAIL PROTECTED]: ~/mysite_project/mysite]%

Where would you advice to put debugging on in django/core/servers/ 
basehttp.py?
Put __debug__=True at the top of the module?
Or which method are we interested in?

Thanks,
dirk





-
Dirk van Oosterbosch
de Wittenstraat 225
1052 AT Amsterdam
the Netherlands

http://labs.ixopusada.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: Email problem

2007-06-14 Thread oliver

I have noticed you need to define all the email options in your
settings file for send_mail to work. I took me quite a while to find
out why my app wasnt sending emails out.
add this to your settings file with your details.

EMAIL_HOST = 'host.dns'
EMAIL_HOST_USER = 'XYZ'
EMAIL_HOST_PASSWORD = 'FOO'
EMAIL_PORT = 25

by the looks of it if you are not running your email server on the
localhost you need to specfy all of these, not sure if this is a bug
or not as Port should be default, but sendmail didnt work for me till
i put all the info in.

check that your smtp server lets you relay..

o

On Jun 14, 1:35 pm, Brij <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using the django.core.mail for sending mail to users in my
> application...I have defined EMAIL_HOST but havenot defined EMAIL_PORT
> because my smtp server doesnt require a port number...
>
> Following is the view function im using :::
>
> def send_email(request, sender, reciepient):
> subject = 'Test Mail from OST'
> message = 'Testing email from OST'
> from_email = '[EMAIL PROTECTED]'
> if subject and message and from_email:
>try:
>send_mail(subject, message, from_email,
> ['[EMAIL PROTECTED]'])
>except BadHeaderError:
>return render_to_response('Error.html', {
> 'reason': 'Objective Successfully
> Assigned...Problem Sending Email to the user font>',
>})
>return render_to_response('success.html', {
> 'reason': 'Objective Successfully Assigned...Email
> Successfully Send to the user.'
>  })
> else:
> # In reality we'd use a manipulator
> # to get proper validation errors.
> return HttpResponse('Make sure all fields are entered and
> valid.')
>
> The error which i m getting is :::
> Exception Value: (10054, 'Connection reset by peer')
> Exception Location: C:\Python24\Lib\socket.py in readline, line 340
>
> Please guide me as to how should i go about this 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
-~--~~~~--~~--~--~---



Flat pages contrib + caching?

2007-06-14 Thread Adam

Hello,

I'm using flat pages quite a bit on a site, and would like to be able
to cache them.  I'm not finding any reference to this in the group or
documentation, will I have to change the flatpage middleware itself or
is there already a way to accomplish this (without a whole-site or
anonymous only cache)?


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



database filter with datetime ranges

2007-06-14 Thread ZebZiggle

Howdy!

Starting with something like this:

start = 9pm on Monday
end = 3am on Tuesday

table.objects.filter(moment__range=(start, end))

Only brings back data until midnight on Monday.

Shouldn't range use the time component of a datetime?

Am I missing something?

Thx in advance,
Sandy


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



Re: Odd behaviour from Signals - dispatcher.connect

2007-06-14 Thread Tipan


> It's ticket #3951, most likely. As you'll see in the comments there,
> there is an approach for fixing it. However, it's likely to wait until
> after some serious surgery is done on the signals module and that is
> ongoing work at the moment. So for now, you'll just have to work around
> it a bit.

Thanks for the feedback Malcom.

I think that's exactly what is happening. Reading through the ticket
discussion it suggests that the workround is similar to that employed
with the model loading function where the source filename is checked.
Can you point me to where I can read more about how to do this?

I guess I should then be able to identify the two "instances" cleanly
and modify my despatcher function to only handle the first one.

Regards, Tim


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



Re: deleting rows with generic relations

2007-06-14 Thread Brian Luft

I'm interested in this problem as well since I'll be using generic
relations for an app I'm working on.  I haven't done any analysis yet
so I'm just writing to bump this back up in hopes that the smart
people will chime in.

Here are some very naive solutions:
1) Write a cron job to periodically remove any rows in the models
containing the generic relations.  This of course implies sound logic
in your code and not assuming that the "foreign keys" are valid on
those models in which case you might end up writing more code overall
than just overriding the delete() methods on your models.

2) Use one of the signals.  I'm thinking either class_prepared or pre/
post_delete.  With class_prepared maybe you would use a mixin class
that provides a delete() method that looks for all generic relation
models pointing the instance being deleted.  Or use the same line of
logic in a pre or post_delete signal.  Sorry, I haven't thought
through the pros/cons with either of these and I'm still waiting for
the coffee to kick in after a long night of network alerts :p

HTH, let me know if you find any elegant solutions.

Cheers
-Brian

On Jun 13, 6:59 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> hello everyone,
>
> Say I have
>
> Model1
> Model2
> Model3
>
> And generic relations pointing to these...
>
> Like, say, Comments or Tags
>
> When deleting Model1, 2, 3 I obviously need to delete all the generic
> ones! Is there any smarter way to go about this except for overriding
> delete( ) and doing it by hand?
>
> If there's a lot of models and a lot of generic relations, this becomes
> a bit of a pain... Add one more generic => change all delete's!
>
>   - bram


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



Re: database filter with datetime ranges

2007-06-14 Thread ZebZiggle

Further investigation ... the sql looks good I think:

...
FROM ...
WHERE ( ...
AND "igapp_stockticker"."moment" < 2007-06-14 05:00:00
AND "igapp_stockticker"."moment" >= 2007-06-13 05:00:00)

Is there some special markup required for postgres to utilize the time
info?

Baffled.

PS> Yes, the data exists.


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



Re: Reset form field during validation

2007-06-14 Thread Michal

Michal wrote:
>> At that point, you have full access to cleaned_data (in fact, it's what
>> that method returns) and the _errors dictionary so you can see if any
>> fields have errors and, if so, clean out (or just remove the keys) for
>> the password fields.
> 
> Remove from where? I try to set there (in clean() method):
> 
>self.cleaned_data['password1'] = ''
> 
> and on second try:
> 
>self.cleaned_data.pop('password1')
> 
> Both of these attempts didn't set password1 to ''
> 
> Could you tell me please, what I am doing wrong?

It is still impossible to me set the value of cleaned_data in clean() 
method.

But! I found this usefull source: 
http://groups.google.com/group/django-users/browse_thread/thread/f0d2a42fe633b87c/19b240ca9bd150e7?lnk=raot

There is special attribute for PasswordField: "render_value". If you set 
it to True, framework will not render value to the form.

Regards
Michal

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



Re: database connections

2007-06-14 Thread [EMAIL PROTECTED]

Thanks so much for your help, Malcolm. I'm pretty sure I'll create a
new backend if I can't convince site ops we don't yet need it; that
makes a lot of sense.

- Jared Nuzzolillo

On Jun 14, 3:18 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> One of the benefits of everything being a first-class object in Python
> is so that things can be replaced at runtime. The only question is
> whether you can get in early enough in the pipeline to replace the
> functionality before it is used. I'm not sure in this case, although it
> might be tricky to do so.
>
> Database connections are set up in django/db/__init__.py
>
> The real heavy lifting for each backend is in
> django/db/backends//base.py in the DatabaseWrapper class.
> You'll probably be wanting to replace the cursor() method there, I would
> guess.
>
> It might be simplest to create your own pseudo-backend that essentially
> imports everything from an existing backend and then sub-classes the
> DatabaseWrapper class to provide the functionality you want. Last
> Tuesday, in a thread called "inspectdb and mssql", I laid out the steps
> needed to create a new backend. I'm thinking this might be most
> appropriate because then you are only adding new code, rather than
> modifying existing code. Updating Django's source then only requires
> remembering to move your new code across without having to repatch
> certain files. Likely to be more robust.
>
> 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
-~--~~~~--~~--~--~---



RequestContext to a login form

2007-06-14 Thread JP

Hi, I trying to avoid that any user not validated enter
to my site pages, I've read several times the section: "The
login_required decorator"
in:

 http://www.djangoproject.com/documentation/authentication/

and works fine, except when someone tries to access the page directly
(giving the full link), in this case it redirects to my login page,
but, does't fill the form wrapper in the
template so my login template appears with no login form.

Thanks for your 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: database filter with datetime ranges

2007-06-14 Thread Nis Jorgensen

ZebZiggle wrote:
> Further investigation ... the sql looks good I think:
>
> ...
> FROM ...
> WHERE ( ...
> AND "igapp_stockticker"."moment" < 2007-06-14 05:00:00
> AND "igapp_stockticker"."moment" >= 2007-06-13 05:00:00)
>
> Is there some special markup required for postgres to utilize the time
> info?
>   
That looks very strange. Date literals are supposedly required to be in
single quotes in postgresql.

Nis


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



Re: database filter with datetime ranges

2007-06-14 Thread ZebZiggle

Yes, and it gets worse. I changed my query to be:

ticks = list(StockTicker.objects.filter(exchange = 1) \
.extra(where = ["symbol = '@Gold' AND moment >= '%s' AND
moment < '%s' " % (postgresDate(start), postgresDate(end))]) \
.order_by('moment'))

(which works directly in psql)

But the single quotes are being escaped to \' blah \' which again
causes the query to fail. Is there a way to turn the escaping off?

I may have to go down to raw sql for the whole query.

-Sandy


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



Could someone help me with a template filter?

2007-06-14 Thread [EMAIL PROTECTED]

What I want to do is take the number of words, divide by 2 (and round
down a whole number), then apply a span to the first half.

I tried to find truncatewords, as I figured that would be a good
starting point (at least seeing how to count words), but I can't seem
to track it down.

Any help appreciated. Thanks.


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



Re: Email problem

2007-06-14 Thread Dirk van Oosterbosch, IR labs
Hi Brij

I don't know if I'm helping much with the following. But just  
recently me too experienced strange problems with using send_mail.

My problem turned out to be an Apache setting (maxClassProcesses was  
too low, it gave an error reached dynamicMaxClassProcs, since  
send_mail spawns a sub-process). However, YMMV.


Try if you can send mail by using the command line (% python  
manage.py shell) with send_mail or even lower level with smtplib  
directly. This will tell you if you can reach the smtp server at all.

>>> from django.core.mail import send_mail
>>> send_mail('Test subject', 'test message',  
'[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'])
1
or
>>> import smtplib
>>> msg = 'From: [EMAIL PROTECTED]:  
[EMAIL PROTECTED]: Test subject\r\ntest message\r\n'
>>> server = smtplib.SMTP('mail.your.smtphost.com')
>>> server.sendmail('[EMAIL PROTECTED]',  
'[EMAIL PROTECTED]', msg)
{}
>>> server.quit()


HTH
dirk


On 14-jun-2007, at 14:35, Brij wrote:

> The error which i m getting is :::
> Exception Value: (10054, 'Connection reset by peer')
> Exception Location: C:\Python24\Lib\socket.py in readline, line 340
>




-
Dirk van Oosterbosch
de Wittenstraat 225
1052 AT Amsterdam
the Netherlands

http://labs.ixopusada.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: database filter with datetime ranges

2007-06-14 Thread ZebZiggle

Actually ... scratch that last point ... my bad. I think I'm onto the
solution and the above query seems fine.

But there's definitely a django bug in there somewhere. I'll submit it
later.


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



newbie seeks relevant examples

2007-06-14 Thread Sells, Fred

I've got a java webstart app that I would like to rebuild in django.  It is
basicly a simple structured text editor where the user can select employees
and update goals/scheduled tasks/accomplishments with some industry specific
details that are not too important for this discussion.

So I need some menu/selection capability and a series of identical text
editor windows.  Not all that hard, but ...

I would appreciate it if anyone could point me toward some sample web sites
to get an idea of what can be done.  My searches so far have shown me alot
of "newsletter" style web pages, but I need interactive user editors.  

Any pointers would be appreciated.

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---

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



matching a hyphen '-' character in urls

2007-06-14 Thread hotani

Having issues matching a hyphen character in my urls file. Here is an
example of what needs to be passed: "12-34-56".

In python, the "\w+" matches this, but django urls will not. I have
also tried (from another post in this forum) "\[-w]+" which did not
match it either. The only way I have been able to get django to match
this string is with a wildcard like so: ".+". I'm sure there is a
better way, but I'm not seeing it.


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



Re: RequestContext to a login form

2007-06-14 Thread JP

Well I figure it out the issue, when you use
django.contrib.auth.views.login,
the destination template ("registration/login.html" or whatever you
use) has
to invoke the form wrapper with the name "form" e.g.
"{{ form.username}}"
this is mandatory, I was trying to use another convenient name.



On Jun 14, 11:18 am, JP <[EMAIL PROTECTED]> wrote:
> Hi, I trying to avoid that any user not validated enter
> to my site pages, I've read several times the section: "The
> login_required decorator"
> in:
>
>  http://www.djangoproject.com/documentation/authentication/
>
> and works fine, except when someone tries to access the page directly
> (giving the full link), in this case it redirects to my login page,
> but, does't fill the form wrapper in the
> template so my login template appears with no login form.
>
> Thanks for your 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
-~--~~~~--~~--~--~---



Newforms field for one to many relationship that is similar to edit in line.

2007-06-14 Thread Dannoo

I have a "Faves" model that has a foreignkey to the User model.

I need to create a form that works similar to the edit inline fields,
someone could add/edit multiple faves for a user.

What is the best way to do this with newforms?


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



Re: Could someone help me with a template filter?

2007-06-14 Thread [EMAIL PROTECTED]

OK, I tracked down truncatewords, and I'm thinking of something like
this:

def spanned_string(value):
""" adds span around first half of string """
words = s.split()
halfwords = len(words)/2
firsthalf = words[halfwords:]
lasthalf = words[:halfwords]
return + ' '.join(firsthalf) + + ' '.join(lasthalf)

On Jun 14, 12:23 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> What I want to do is take the number of words, divide by 2 (and round
> down a whole number), then apply a span to the first half.
>
> I tried to find truncatewords, as I figured that would be a good
> starting point (at least seeing how to count words), but I can't seem
> to track it down.
>
> Any help appreciated. Thanks.


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



Re: Captcha module Version 1.1 ready for testing

2007-06-14 Thread Martin Winkler

Am Thu, 14 Jun 2007 12:00:11 +0800
schrieb "Nimrod A. Abing" <[EMAIL PROTECTED]>:

> Are you planning to implement a configuration to allow in-memory
> images?

One thing that annoys me with in-memory images is that you have to
change your urls.py, and I want the CaptchaField as unobtrusive as
possible. Furthermore this method needs some kind of session data
stored somewhere, and therefore also cookies. All this annoys me a bit,
to be honest.

> Characters that can confuse users have been removed from this set. But
> some fonts are more legible than others, so it should be possible to
> configure the characters to use. Are considering implementing this?

Good idea! Although I already have used an incomplete alphabet for
this, it seems natural that developers want to use their own "alphabet"
- which might be only digits, and no characters.
So I made a nice configuration possibility for my captcha module. You
can define it in your settings.py, and also adjust individual forms, if
you wish.

> 3. No "twists" are applied to characters. I have found that distorting
> characters tends to confuse users even more. Will there be a
> configuration that will disable "twists"?

Yes. You can specify rotation, sizes, vertical positions and other
values according to your needs. The only thing that is not so elegant
is: all characters are aligned on top. That means that a lowercase
character might look as if it is superscript. If you only use uppercase
and numbers, then this is no problem.
(BTW: The user can enter only lowercase characters - the captcha test
is also successful, even if the image also shows uppercase characters)

> I really hope your module gets included in contrib since I really like
> the "one standard way" for doing things approach.

Me too!

There is a significantly updated version available now:
 http://django.agami.at/captchatest/  - with download, docs and demo
 ("reload" the page, if you have already been there...)

 * The old version had a bug in not removing outdated captchas. FIXED
 * new configuration options
 * save as gif image with adaptive color palette to minimize filespace.
   if it*s not possible to save as gif, it falls back to jpg. 
   (I had a problem on FreeBSD with gif images)
 * there is now an "iterations" option - which writes many captchas
   over each other for testing purposes. (so you can adjust width and
   height of your captcha according to your font settings)

Hope you like it,

Martin

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



Re: Could someone help me with a template filter?

2007-06-14 Thread [EMAIL PROTECTED]

That worked, except for a couple of errors. Revised version (in case
it ever helps someone else):

from django.template import Library
register = Library()

@register.filter

def spannedstring(value):
""" adds span around first half of string """
words = value.split()
halfwords = len(words)/2
firsthalf = words[:halfwords]
lasthalf = words[halfwords:]
return ''+ ' '.join(firsthalf) + ' '+ ' '.join(lasthalf)


On Jun 14, 12:50 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> OK, I tracked down truncatewords, and I'm thinking of something like
> this:
>
> def spanned_string(value):
> """ adds span around first half of string """
> words = s.split()
> halfwords = len(words)/2
> firsthalf = words[halfwords:]
> lasthalf = words[:halfwords]
> return + ' '.join(firsthalf) + + ' '.join(lasthalf)
>
> On Jun 14, 12:23 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > What I want to do is take the number of words, divide by 2 (and round
> > down a whole number), then apply a span to the first half.
>
> > I tried to find truncatewords, as I figured that would be a good
> > starting point (at least seeing how to count words), but I can't seem
> > to track it down.
>
> > Any help appreciated. Thanks.


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



App.objects.get(user='John') error

2007-06-14 Thread Vincent Nijs

Hi,

I have the following model

class App(models.Model):
user = models.ForeignKey(User, unique=True, editable=False)

In a view I now want to check if a user is indeed in the database table. I
tried the following

user_exists = Application.objects.get(user='john')

But this give the following error:

invalid input syntax for integer: "john"

Any ideas on how to do this check?

Thanks,

Vincent




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



Re: App.objects.get(user='John') error

2007-06-14 Thread Nimrod A. Abing

On 6/15/07, Vincent Nijs <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have the following model
>
> class App(models.Model):
> user = models.ForeignKey(User, unique=True, editable=False)
>
> In a view I now want to check if a user is indeed in the database table. I
> tried the following
>
> user_exists = Application.objects.get(user='john')
>
> But this give the following error:
>
> invalid input syntax for integer: "john"

If you are using the User model from django.contrib.auth.models then
you can check directly:

user_exists = False
try:
u = User.objects.get(username='john')
user_exists = True
except User.DoesNotExist:
pass # or do something here

or following your code above:

user_exists = False
try:
u = App.objects.get(user_username='john')
except User.DoesNotExist:
pass # or do something here

HTH.
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.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
-~--~~~~--~~--~--~---



Help Wanted at CritterWatch.Org

2007-06-14 Thread Bryan L. Fordham

As I announced recently, I'm currently working on a project at 
www.critterwatch.org. The overall goal is to provide people with 
up-to-date information on how their state represenatives and senators 
are voting, as well as data on legislation. Long term goals include an 
API to make this information available to other projects.

The near term goal, however, is to load all the data for all 50 states 
into the database, and keep it updated. That's where you can come in:

If you're interested in helping this project by writing some scripts to 
get the information for your state, please reply to me off-list. I 
haven't worked everything out just yet, but essentially you'd be 
screen-scraping your state legislature's website and putting the 
information into a standard format, which would be loaded into the database.

Another way to help is to suggest new features. You can also be my BFF 
if you submit ideas on how to make the interface look better.

As always, any feedback at all is appreciated.

Thanks
--B

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



Re: Captcha module Version 1.1 ready for testing

2007-06-14 Thread Forest Bond
On Thu, Jun 14, 2007 at 08:14:54PM +0200, Martin Winkler wrote:
> Am Thu, 14 Jun 2007 12:00:11 +0800
> schrieb "Nimrod A. Abing" <[EMAIL PROTECTED]>:
> 
> > Are you planning to implement a configuration to allow in-memory
> > images?
> 
> One thing that annoys me with in-memory images is that you have to
> change your urls.py, and I want the CaptchaField as unobtrusive as
> possible. Furthermore this method needs some kind of session data
> stored somewhere, and therefore also cookies. All this annoys me a bit,
> to be honest.

You can do it without external persistence (sessions and/or database table) by
encrypting the correct response in the image filename.  But, really, these are
web applications.  It's not entirely unreasonable to expect people to modify
their code/databases to add a feature, is it?  Writing files to disk isn't
exactly non-intrusive either.

-Forest


signature.asc
Description: Digital signature


Re: Captcha module ready for testing

2007-06-14 Thread Iapain

Hi,

Nice implementation but dont see any logic to save captcha temporary,
you should add option like "nosave" and use cStringIO in that case.

Cheers,
Deepak

On Jun 13, 5:11 pm, MartinWinkler <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I just uploaded the captcha module I recently mentioned 
> tohttp://django.agami.at/media/captcha/
>
> Please take a look at it and tell me what you think of it. I really
> hope this module can be put into the trunk on django.contrib some day.
> Maybe one of the lead developers can take a look too - after any rough
> edges are eliminated?
>
> And I am really committed to maintain this module, since it's my
> little baby ;-)
>
> Martin


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

2007-06-14 Thread handsome greg

Oh, looks like maybe I can do this with a custom metaclass for my
model.  I'll just use it to tack on custom formfield() methods to my
_meta.fields list for the model.  Make sense?

On Jun 14, 9:35 am, handsome greg <[EMAIL PROTECTED]> wrote:
> Hi guys, quick question: There's no current way to specify how model
> fields are mapped to form fields for a model with
> newforms.form_for_model is there? I know you can change the formfield
> callback but the model doesn't impact that function in any way by
> default. What I'm looking for is a way for a model to define the form/
> field relationships so form_for_model will return a custom form class
> for the model without me having to know anything about it. Is this in
> newforms at all?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from 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 render date and time separately with newforms.SplitDateTimeWidget

2007-06-14 Thread Paul

I don't think that is possible.  When you reference the field inside
the template (with form.my_field) you are accessing a BoundField that
is tied to the formfield in question.  From this BoundField you don't
actually have access to the widget.  Rather you call as_widget or
as_hidden (or __unicode__ which calls as_widget).  I don't see any way
in there to access anything that I add to my widget.  Even if I could
access the widget directly, I wouldn't have the data to render since
that is in the BoundField.  It seems to me that the only way to get
this to work is to make changes to BoundField (maybe adding some
BoundWidget class even) to allow you to get sub-widgets out of a
MultiWidget.  Otherwise there simply isn't any way to access the sub-
widget while also passing the data and attrs to that widget.

-Paul

On Jun 14, 12:32 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-06-14 at 00:12 +, Paul wrote:
> > Is this possible?  The old forms module allowed you to render the date
> > and time separately in the template for the form.  Now it seems this
> > is no longer possible.  So it isn't possible for instance to render
> > the date on one row of a table and the time on the following row just
> > below it like:
> > {{form.blah}}{{form.mydate.date}}
> > {{form.blah2}}{{form.mydate.time}}
>
> It's not possible with the default SplitDateTime widget, but it would be
> easy enough to subclass it to provide the functionality you want.
> Newforms are designed around encouraging people to subclass things as
> they need to add new features, rather than trying to provide everything
> by default (which becomes too difficult to use in the common cases).
>
> Create a SplitDateTimeWidget subclass and add date() and time() methods
> that return the respective widgets (would replicate some of the logic in
> MultiWidget.render)
>
> Or your could write a patch for MultiWidget that allowed access to the
> n-th widget in the sequence and post that to Trac. I can't think of
> another generic method on MultiWidget that would help, since it's meant
> to be able to handle an arbitrary number of contained values, not just
> the date+time case.
>
> 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: App.objects.get(user='John') error

2007-06-14 Thread Iapain

Of course it'll give you error,  suppose your User is

class User(models.Model):
  first_name = models.CharField(maxlength=256)

class App(models.Model):
   user = models.ForeignKey(User, unique=True, editable=False)

then use:
try:
  user_exists = Application.objects.get(user__first_name='john')
except Application.DoesNotExist:
  #whatever you want here

Cheers,
Deepak

On Jun 15, 12:20 am, Vincent Nijs <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I have the following model
>
> class App(models.Model):
> user = models.ForeignKey(User, unique=True, editable=False)
>
> In a view I now want to check if a user is indeed in the database table. I
> tried the following
>
> user_exists = Application.objects.get(user='john')
>
> But this give the following error:
>
> invalid input syntax for integer: "john"
>
> Any ideas on how to do this check?
>
> Thanks,
>
> Vi ncent


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

2007-06-14 Thread Iapain

Its only available in Developer version!

D.

On Jun 15, 1:24 am, handsome greg <[EMAIL PROTECTED]> wrote:
> Oh, looks like maybe I can do this with a custom metaclass for my
> model.  I'll just use it to tack on custom formfield() methods to my
> _meta.fields list for the model.  Make sense?
>
> On Jun 14, 9:35 am, handsome greg <[EMAIL PROTECTED]> wrote:
>
> > Hi guys, quick question: There's no current way to specify how model
> > fields are mapped to form fields for a model with
> > newforms.form_for_model is there? I know you can change the formfield
> > callback but the model doesn't impact that function in any way by
> > default. What I'm looking for is a way for a model to define the form/
> > field relationships so form_for_model will return a custom form class
> > for the model without me having to know anything about it. Is this in
> > newforms at all?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from 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 field for one to many relationship that is similar to edit in line.

2007-06-14 Thread Iapain

Use two forms for your two different model, newforms currently not
supporting edit inline.

Cheers,
D

On Jun 14, 10:43 pm, Dannoo <[EMAIL PROTECTED]> wrote:
> I have a "Faves" model that has a foreignkey to the User model.
>
> I need to create a form that works similar to the edit inline fields,
> someone could add/edit multiple faves for a user.
>
> What is the best way to do this with newforms?


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

2007-06-14 Thread [EMAIL PROTECTED]

Thanks for the idea, but that doesn't quite work either.  If someone
only has 3 events, then the for loop runs through 3 times, and I end
up with only three TD's.  I'm pretty sure what I need can't be
accomplished in template code.

I think I need to assign all the variables in view code, then send the
resulting information to the template.  Something like:

for event in events.objects.all():
if event = "golfing", then golfer = "1"
else golfer ="0"

if event = "hiking', then hiker = "1"
else hiker = "0"

...

or something.  I'll dig more, comparing data like this seems similar
to something someone would do for "tagging" posts in a blog
application.  I'll start there.

On Jun 13, 6:40 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> You just need something like:
>  {% for p in object.events.all %}
>   {% if p.event_name %}
>   {{ p.event_name }},
>   {% else %}>
>   {% endif %}
>  {% endfor %}
>
> You could put the whole row in the IF, if you like.
>
> On Jun 12, 8:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > I think that requires more logic in the template than possible.
>
> > My brain says tot do exactly what you suggest.  But my template looks
> > similar to this:
> > {% for p in object.events.all %}
> > 
> > {{ p.event_name }},
> > 
> > {% endfor %}
>
> > If the Member isn't registered to one of the events, then I don't get
> > a  for that event, and it throws off the rest of the format
> > for the table...
>
> > On Jun 12, 6:32 pm, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
>
> > > [snip
>
> > > > The trouble I'm having is, if someone is not assigned to an event, I
> > > > get nothing displayed (duh, there's not an event); except I'm
> > > > displaying this in a table, and if I don't have any data, then the
> > > > cell formatting doesn't line up correctly.
>
> > > [snip]
>
> > > I just quickly perused your email; if the only problem you are having is
> > > the loop creating the table row/column when there isn't any actual data,
> > > couldn't you just create an {% if object %} in the template, and adjust
> > > the formatting accordingly?
>
> > > Just a quick thought,
> > > Kelvin


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



reverse() is quite slow for named url patterns

2007-06-14 Thread Smoo.Master

I have using django to make a sort of library website.

Since I am mostly using generic views, I use the {% url %} tag (which
calls reverse) with named url patterns in my templates. However this
became quite slow (as I verified with the hotshot profiler). On a page
with several hundred links, it takes thirty seconds just to resolve
the links. Even on a page with just a few links, it takes a large
fraction of a second. This is true on both the development server and
apache with mod_python.

Hardcoding the url patterns in the templates fixes the performance
problems, but makes them brittle to changes in the url patterns.

any suggestions?

-Smoo ()


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



Re: newbie seeks relevant examples

2007-06-14 Thread Brian Luft

I'm not familiar with the Web Start technology so its not clear what
areas you need help on transitioning your knowledge.  If you
understand traditional web programming principles (basic form
processing, data driven applications) then you're already in good
shape and if not, you'll probably have a few stumbles along the way
but that's how we learn.  If you're grounded in object oriented design
and/or the features of Python then you'll quickly find yourself in a
love affair with Django.


>"to get an idea of what can be done."

...well, the sky's the limit!  Go through the tutorials if you haven't
already.  If you've already found some open sourced Django apps then
still utilize those.  The underlying principles are still the same
regardless of the specific use of the application.  Form data and/or
client-side state is sent to the server, the request is processed, a
response is generated, the client receives the response and processes
and/or renders it.  I don't mean to overstate the obvious but Django
does not care if your application uses HTTP or XHR requests, form-
encoded data or JSON or XML, etc.  Try to think about breaking your
application down into a set of distinct actions.  Each action will map
to a view in Django.  The view will be determined by the rules you
have set up in your URL configuration(s).  The view will receive the
data in the request, do something with it which effectively changes
the state of the application, and return a response.  From a high-
level perspective, it does not matter if your form contains a single
text input or dozens of inputs of all types.  Of course, as your
application increases in complexity there is a burden of focusing
sound design.

Without knowing any more than what you described about the
application, there are many possible design scenarios that could come
into play.  When you say "interactive" that sounds like you are
looking for a dynamic or rich client application.  Depending on how
you look at it, Django does not offer support in the way of AJAX or
DHTML functionality - or some may say that it does by getting
completely out of the way and not forcing you into any particular
paradigm.  The same can be said for the presentation layer or
templating system.  It is very basic and that is one of its greatest
strenghts - it is efficient, doesn't impose any particular paradigms
upon you and is easy to extend.  It should also be fairly trivial to
drop in any of the other Python-based templating solutions out there.
If you are looking for a full-featured widget or UI component system
then Django by itself may not suit your needs.

My advice is to start simple and continue adding on and refactoring to
approach what you desire.  I think you'll get the most mileage from
this list if you can break your problems down into specifc questions.
"How do I accomplish some specific task within the framework?".  If
you're looking for higher-level design help it will probably be harder
to get answers since we won't know the specific context or
requirements.

Cheers
-Brian

On Jun 14, 10:35 am, "Sells, Fred" <[EMAIL PROTECTED]> wrote:
> I've got a java webstart app that I would like to rebuild in django.  It is
> basicly a simple structured text editor where the user can select employees
> and update goals/scheduled tasks/accomplishments with some industry specific
> details that are not too important for this discussion.
>
> So I need some menu/selection capability and a series of identical text
> editor windows.  Not all that hard, but ...
>
> I would appreciate it if anyone could point me toward some sample web sites
> to get an idea of what can be done.  My searches so far have shown me alot
> of "newsletter" style web pages, but I need interactive user editors.
>
> Any pointers would be appreciated.
>
> ---
> The information contained in this message may be privileged and / or
> confidential and protected from disclosure. If the reader of this message is
> not the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please notify the sender
> immediately by replying to this message and deleting the material from any
> computer.
> ---


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



Re: reverse() is quite slow for named url patterns

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 14:17 -0700, Smoo.Master wrote:
> I have using django to make a sort of library website.
> 
> Since I am mostly using generic views, I use the {% url %} tag (which
> calls reverse) with named url patterns in my templates. However this
> became quite slow (as I verified with the hotshot profiler). On a page
> with several hundred links, it takes thirty seconds just to resolve
> the links. Even on a page with just a few links, it takes a large
> fraction of a second. This is true on both the development server and
> apache with mod_python.
> 
> Hardcoding the url patterns in the templates fixes the performance
> problems, but makes them brittle to changes in the url patterns.
> 
> any suggestions?

Make reverse() faster. :-)

The execution time is related to the number of URL patterns. In fact,
it's O(n^2) for uniformly random lookups (O(n) best case and O(n^2)
worst case if you work through the details).

There are at least a couple of optimisation possibilities in reverse()
that would cut down on the work; mostly just a matter of finding time,
or a volunteer, to work on them.

A couple I know of:
- have a module-level cache of RegexURLResolver classes keyed
off the urlconf file so that we don't have to compile it every
time. That would save an O(n) factor (for both forwards and
backwards lookups).

- convert the lookup in RegexURLResolver to be hashed-based off
the url name (and view function), rather than a linear scan of
the patterns dictionary. The current behaviour is poor for large
lists of url patterns where you aren't matching against the
early entries. This would change the O(n) scan time into O(1)
for reverse lookups.

I suspect forward lookups can't be better than O(n) unless one was to
get unbelievably tricky doing a regex rewrite and that's a much harder
problem and even then it will be O(n) worst case, still.

However, both of the above changes wouldn't be too hard and don't have a
downside.

If you (or somebody else) wants to work on this, it should only be an
evening or so of work to make the changes and test that it still works
(and is faster).

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: newbie seeks relevant examples

2007-06-14 Thread Joseph Heck

Just so you're aware - switching from a Web Start application to
Django is a fairly significant change in how you attack some problems.
With WebStart, you have a full user interface API with Swing (or
whatever you're using) running in it's own JVM, and in Django you're
pushing this all into a browser and doing the web application
post-back-to-send-data sort of set up.

It's certainly not impossible to make this kind of conversion, and if
you're conversant in javascript and comfortable with Ajax style
programming (as Brian Luft alludes to), you can do quite a bit - but
there's a significant different metaphor in operation.

The djangoproject wiki has a number of links to sites
(http://code.djangoproject.com/wiki/DjangoResources) that include
source code. Djangoproject's site
(http://code.djangoproject.com/browser/djangoproject.com/django_website)
itself is available, and Jeff Croft has made some source available for
a couple of sites
(http://www2.jeffcroft.com/blog/2007/feb/25/two-new-django-sites-both-source-available/).

Not knowing more about the specifics of what you're trying to
accomplish, it's hard to point you in any better direction.

-joe

On 6/14/07, Sells, Fred <[EMAIL PROTECTED]> wrote:
> I've got a java webstart app that I would like to rebuild in django.  It is
> basicly a simple structured text editor where the user can select employees
> and update goals/scheduled tasks/accomplishments with some industry specific
> details that are not too important for this discussion.
>
> So I need some menu/selection capability and a series of identical text
> editor windows.  Not all that hard, but ...
>
> I would appreciate it if anyone could point me toward some sample web sites
> to get an idea of what can be done.  My searches so far have shown me alot
> of "newsletter" style web pages, but I need interactive user editors.
>
> Any pointers would be appreciated.
>
> ---
> The information contained in this message may be privileged and / or
> confidential and protected from disclosure. If the reader of this message is
> not the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please notify the sender
> immediately by replying to this message and deleting the material from any
> computer.
> ---
>
> >
>

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



Re: reverse() is quite slow for named url patterns

2007-06-14 Thread Malcolm Tredinnick

On Fri, 2007-06-15 at 07:40 +1000, Malcolm Tredinnick wrote:
> On Thu, 2007-06-14 at 14:17 -0700, Smoo.Master wrote:
> > I have using django to make a sort of library website.
> > 
> > Since I am mostly using generic views, I use the {% url %} tag (which
> > calls reverse) with named url patterns in my templates. However this
> > became quite slow (as I verified with the hotshot profiler). On a page
> > with several hundred links, it takes thirty seconds just to resolve
> > the links. Even on a page with just a few links, it takes a large
> > fraction of a second. This is true on both the development server and
> > apache with mod_python.
> > 
> > Hardcoding the url patterns in the templates fixes the performance
> > problems, but makes them brittle to changes in the url patterns.
> > 
> > any suggestions?
> 
> Make reverse() faster. :-)
> 
> The execution time is related to the number of URL patterns. In fact,
> it's O(n^2) for uniformly random lookups (O(n) best case and O(n^2)
> worst case if you work through the details).
> 
> There are at least a couple of optimisation possibilities in reverse()
> that would cut down on the work; mostly just a matter of finding time,
> or a volunteer, to work on them.

Whilst I remembered, I opened ticket #4566 to remind us of this, even if
nobody wants to work on it right away.

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: Noob here. Accessing data across relationships

2007-06-14 Thread Brian Luft

I recommend writing a custom template tag.  (http://
www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags).

So you would have for example:
{ list_member_events object }  

Then in your template tag code you would be able to handle the logic
that is a little too complex to achieve elegantly with the standard
template tags.  This isn't much different than handling the logic in
the view function itself, but in my opinion the view functions should
be focused solely on pulling together the data for an action and
performing any special processing required in preparation to hand off
to the presentation layer.  Semantically, its easy to fall into a trap
and associate "view" with presentation layer but I prefer to think of
"view" as more analogous to a database view - a collection of data
that is pulled together based on a set of conditions.  The job of the
view is done when the set of data has been pulled together and made
ready to hand off to the presentation layer - without any regard to
how that data will be presented.  The template tag is taking on the
task of formatting that data into a specific markup to be rendered.
Now you have uncoupled your presentation from your business or
application logic and you could reuse that same view for other actions
in your application without having to special case the code for how
that data will actually be rendered :)

Cheers
-Brian



On Jun 14, 1:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thanks for the idea, but that doesn't quite work either.  If someone
> only has 3 events, then the for loop runs through 3 times, and I end
> up with only three TD's.  I'm pretty sure what I need can't be
> accomplished in template code.
>
> I think I need to assign all the variables in view code, then send the
> resulting information to the template.  Something like:
>
> for event in events.objects.all():
> if event = "golfing", then golfer = "1"
> else golfer ="0"
>
> if event = "hiking', then hiker = "1"
> else hiker = "0"
>
> ...
>
> or something.  I'll dig more, comparing data like this seems similar
> to something someone would do for "tagging" posts in a blog
> application.  I'll start there.
>
> On Jun 13, 6:40 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > You just need something like:
> >  {% for p in object.events.all %}
> >   {% if p.event_name %}
> >   {{ p.event_name }},
> >   {% else %}>
> >   {% endif %}
> >  {% endfor %}
>
> > You could put the whole row in the IF, if you like.
>
> > On Jun 12, 8:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > I think that requires more logic in the template than possible.
>
> > > My brain says tot do exactly what you suggest.  But my template looks
> > > similar to this:
> > > {% for p in object.events.all %}
> > > 
> > > {{ p.event_name }},
> > > 
> > > {% endfor %}
>
> > > If the Member isn't registered to one of the events, then I don't get
> > > a  for that event, and it throws off the rest of the format
> > > for the table...
>
> > > On Jun 12, 6:32 pm, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
>
> > > > [snip
>
> > > > > The trouble I'm having is, if someone is not assigned to an event, I
> > > > > get nothing displayed (duh, there's not an event); except I'm
> > > > > displaying this in a table, and if I don't have any data, then the
> > > > > cell formatting doesn't line up correctly.
>
> > > > [snip]
>
> > > > I just quickly perused your email; if the only problem you are having is
> > > > the loop creating the table row/column when there isn't any actual data,
> > > > couldn't you just create an {% if object %} in the template, and adjust
> > > > the formatting accordingly?
>
> > > > Just a quick thought,
> > > > Kelvin


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



Re: Odd behaviour from Signals - dispatcher.connect

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 08:51 -0700, Tipan wrote:
> 
> > It's ticket #3951, most likely. As you'll see in the comments there,
> > there is an approach for fixing it. However, it's likely to wait until
> > after some serious surgery is done on the signals module and that is
> > ongoing work at the moment. So for now, you'll just have to work around
> > it a bit.
> 
> Thanks for the feedback Malcom.
> 
> I think that's exactly what is happening. Reading through the ticket
> discussion it suggests that the workround is similar to that employed
> with the model loading function where the source filename is checked.
> Can you point me to where I can read more about how to do this?

See django/db/models/loading.py, in the register_models() function.

I'm not 100% certain that will be the right fix, but from reading the
ticket and the model dispatching code, it looked like the right idea.
Not a change worth making to core just yet, though, since Brian Harring
is rewriting signal dispatching, so it will either be done as part of
that or something we can fix when he's finished.

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: database filter with datetime ranges

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 18:57 +0200, Nis Jorgensen wrote:
> ZebZiggle wrote:
> > Further investigation ... the sql looks good I think:
> >
> > ...
> > FROM ...
> > WHERE ( ...
> > AND "igapp_stockticker"."moment" < 2007-06-14 05:00:00
> > AND "igapp_stockticker"."moment" >= 2007-06-13 05:00:00)
> >
> > Is there some special markup required for postgres to utilize the time
> > info?
> >   
> That looks very strange. Date literals are supposedly required to be in
> single quotes in postgresql.

What you see is not quite what you (or the database) gets, in this case.
 
The SQL printed by Django in its debug log is not precisely what is sent
to the backend. There is still a layer of quoting that is done by the
database wrapper (psycopg or MySQLdb, etc) and we print out the debug
SQL *before* that happens.

So what is sent to the database is correctly quoted. Otherwise every
datetime query in Django would fail.

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: matching a hyphen '-' character in urls

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 17:36 +, hotani wrote:
> Having issues matching a hyphen character in my urls file. Here is an
> example of what needs to be passed: "12-34-56".
> 
> In python, the "\w+" matches this, but django urls will not. 

Since Django's URL pattern matching is done using Python reg-exps, this
can't be correct. In fact, \w does not match a hyphen in Python (it
matches alphanumeric and underscore only).

What  you want is "[-A-Za-z0-9_]+".

The reason [-\w] doesn't work is because inside character classes
([...]), \w no longer means "alphanumeric characters". It's just a
character escape.

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: matching a hyphen '-' character in urls

2007-06-14 Thread SmileyChris

> What  you want is "[-A-Za-z0-9_]+".
>
> The reason [-\w] doesn't work is because inside character classes
> ([...]), \w no longer means "alphanumeric characters". It's just a
> character escape.

Alternately, make the string a "raw" one (note the r before the
quote):
r'[-\w]+'


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



Re: Problems with running Django on a remote machine

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 16:37 +0200, Dirk van Oosterbosch, IR labs wrote:
[...]
> 
> Exactly. It runs untill I try to load a page (from another ssh shell).
> And I just get the prompt back:
> [EMAIL PROTECTED]: ~/mysite_project/mysite]% python manage.py runserver
> Validating models...
> 0 errors found.
> 
> 
> Django version 0.96, using settings 'opop.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
> [EMAIL PROTECTED]: ~/mysite_project/mysite]%
> 
> 
> Where would you advice to put debugging on in
> django/core/servers/basehttp.py?
> Put __debug__=True at the top of the module?
> Or which method are we interested in?

That's just truly bizarre. The development server is, at heart a
standard Python HTTPServer (from the BaseHTTPServer standard library
module). That is a TCPServer which just loops forever accepting
requests. So there really is no way that I know of for it to "just exit"
without the HTTPServer printing an error message.

Each request is handled by the handle() method in the WSGIRequestHandler
class, but the server itself is the WSGIServer class and that should
just keep running forever (via the serve_forever method in Python's
SocketServer.BaseServer, ultimately).

So maybe shove some debug prints in handle(), but, in general, you're
going to have to try to work out how far it gets before stopping. I
cannot imagine what is going wrong here. The whole silent failure bit is
confusing.

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: matching a hyphen '-' character in urls

2007-06-14 Thread Forest Bond
On Thu, Jun 14, 2007 at 10:13:32PM -, SmileyChris wrote:
> > What  you want is "[-A-Za-z0-9_]+".
> >
> > The reason [-\w] doesn't work is because inside character classes
> > ([...]), \w no longer means "alphanumeric characters". It's just a
> > character escape.
> 
> Alternately, make the string a "raw" one (note the r before the
> quote):
> r'[-\w]+'

Not sure that's true.  Malcolm was indicating that it is a character escape at
the reg-exp level, not the Python string-parsing level.

Character classes can't be merged in Python reg-exps.  \w represents an entire
character class, and, consequently, can't be merged with other classes by
putting \w inside the new character class.

-Forest


signature.asc
Description: Digital signature


Re: matching a hyphen '-' character in urls

2007-06-14 Thread Jeremy Dunck

On 6/14/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> Alternately, make the string a "raw" one (note the r before the
> quote):
> r'[-\w]+'

r'(-|\w)+'

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



Re: matching a hyphen '-' character in urls

2007-06-14 Thread Forest Bond
On Thu, Jun 14, 2007 at 05:30:33PM -0500, Jeremy Dunck wrote:
> 
> On 6/14/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> > Alternately, make the string a "raw" one (note the r before the
> > quote):
> > r'[-\w]+'
> 
> r'(-|\w)+'

Hey, hadn't thought about that, but I like it!

-F


signature.asc
Description: Digital signature


Re: How to render date and time separately with newforms.SplitDateTimeWidget

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 20:30 +, Paul wrote:
> I don't think that is possible.  When you reference the field inside
> the template (with form.my_field) you are accessing a BoundField that
> is tied to the formfield in question.  From this BoundField you don't
> actually have access to the widget.  Rather you call as_widget or
> as_hidden (or __unicode__ which calls as_widget).  I don't see any way
> in there to access anything that I add to my widget.  Even if I could
> access the widget directly, I wouldn't have the data to render since
> that is in the BoundField. 

Yeah, you're right. I'd forgotten you wouldn't have the data available
to be able to just work with {{form.my_field.field.widget}} directly.

It might be that you just have to create two form fields in that case.
The concept of rendering "a particular part of a field" for separate
placement like this via BoundFields doesn't feel like it's going to lead
to lead to a very nice API.

Sorry I can't be of more help.

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: matching a hyphen '-' character in urls

2007-06-14 Thread Malcolm Tredinnick

On Thu, 2007-06-14 at 18:24 -0400, Forest Bond wrote:
> On Thu, Jun 14, 2007 at 10:13:32PM -, SmileyChris wrote:
> > > What  you want is "[-A-Za-z0-9_]+".
> > >
> > > The reason [-\w] doesn't work is because inside character classes
> > > ([...]), \w no longer means "alphanumeric characters". It's just a
> > > character escape.
> > 
> > Alternately, make the string a "raw" one (note the r before the
> > quote):
> > r'[-\w]+'
> 
> Not sure that's true.  Malcolm was indicating that it is a character escape at
> the reg-exp level, not the Python string-parsing level.
> 
> Character classes can't be merged in Python reg-exps.  \w represents an entire
> character class, and, consequently, can't be merged with other classes by
> putting \w inside the new character class.

Chris is right; I am clearly on drugs (again).

In [6]: re.match(r'[-\w]+', '12-34-56').group()
Out[6]: '12-34-56'

That was what I thought the answer was and then when I tested it before
making my reply it didn't work and the rationalisation seemed sound, so
I went with what worked. However, I must have made a typo when testing.

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: matching a hyphen '-' character in urls

2007-06-14 Thread Forest Bond
On Fri, Jun 15, 2007 at 08:59:51AM +1000, Malcolm Tredinnick wrote:
> 
> On Thu, 2007-06-14 at 18:24 -0400, Forest Bond wrote:
> > On Thu, Jun 14, 2007 at 10:13:32PM -, SmileyChris wrote:
> > > > What  you want is "[-A-Za-z0-9_]+".
> > > >
> > > > The reason [-\w] doesn't work is because inside character classes
> > > > ([...]), \w no longer means "alphanumeric characters". It's just a
> > > > character escape.
> > > 
> > > Alternately, make the string a "raw" one (note the r before the
> > > quote):
> > > r'[-\w]+'
> > 
> > Not sure that's true.  Malcolm was indicating that it is a character escape 
> > at
> > the reg-exp level, not the Python string-parsing level.
> > 
> > Character classes can't be merged in Python reg-exps.  \w represents an 
> > entire
> > character class, and, consequently, can't be merged with other classes by
> > putting \w inside the new character class.
> 
> Chris is right; I am clearly on drugs (again).
> 
> In [6]: re.match(r'[-\w]+', '12-34-56').group()
> Out[6]: '12-34-56'
> 
> That was what I thought the answer was and then when I tested it before
> making my reply it didn't work and the rationalisation seemed sound, so
> I went with what worked. However, I must have made a typo when testing.

Oh.  Didn't know that you could do that, and, as a result, assumed you were
right.  Sorry about that.

-Forest


signature.asc
Description: Digital signature


Re: "Powered by Django" directory - Designer Wanted!

2007-06-14 Thread Ross Poulton

On Thu, 14 Jun 2007 15:07:15 +0800, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
> When you get the chance, it would be nice if the URL for each blog was
> the slug, instead of just a number.
> 
> I'm starting to feel like a statistic.

Awesome idea... and it's implemented! Also fixed a little bug pointed out by 
Malcolm where a trace was thrown up on the most-commented page as no pages yet 
have any comments. Thanks, Malcolm!

Ross

-- 
Ross Poulton
www.rossp.org
[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: Did someone write an anti-spam module in django?

2007-06-14 Thread Kelvin Nicholson


>   It's called "negative captcha", and it's very easy to implement. One
> day some spammers will learn how to defeat it but for now, it's doing
> the job :)

As Tony the Tiger would say, GREAAT!

Thanks for pointing out this technique, I think I'll go this route
instead of the Kitten CAPTCHA route.

-- 
Kelvin Nicholson
Voice: +886 9 52152 336
Voice: +1 503 715 5535
GPG Keyid: 289090AC
Data: [EMAIL PROTECTED]
Skype: yj_kelvin
Site: http://www.kelvinism.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: matching a hyphen '-' character in urls

2007-06-14 Thread hotani

Thanks for the comments. I'll post back tomorrow with the python
script I was using that worked (somehow?) for matching the hyphen with
a '\w+'. I'll also try these suggestions and post back the 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: Did someone write an anti-spam module in django?

2007-06-14 Thread SmileyChris

> Thanks for pointing out this technique, I think I'll go this route
> instead of the Kitten CAPTCHA route.
Here's a snippet for that http://www.djangosnippets.org/snippets/131/

If you do want to run with the captcha method, here's a reCAPTCHA
field implementation:
http://smileychris.tactful.co.nz/ramblings/recaptcha/


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



Doing query with 'ne' terms.

2007-06-14 Thread Nicholas Ding
I found Django can not do '<>' operation in SQL, such as "where column <>
%s".
While diving into the source code, it seems easy to add a 'ne' to existing
query terms.
But why Django doesn't include this, it's confuse me a lot.

Best Regards.
-- 
Nicholas @ Nirvana Studio
http://www.nirvanastudio.org

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



[no subject]

2007-06-14 Thread Young Gyu Park
> class Category(models.Model):
> name = models.CharField(maxlength=20)
> parent = models.ForeignKey('self', null=True, related_name='child_set')
>
> def __str__(self):
> return self.name
>
>
I try to embody this Model. But In the admin page, I want to see the whole
category path, I mean there is a category which has two parent category.

I want to see like this

A -> B -> C

To do this I try to modify __str__ function by recursive function

To get the parent category I need to call the filter function, But the
python told me

Traceback (most recent call last):
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/template/__init__.py"
> in render_node
>   706. result = node.render(context)
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/template/__init__.py"
> in render
>   862. dict = func(*args)
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/contrib/admin/templatetags/admin_list.py"
> in result_list
>   182. return {'cl': cl,
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/contrib/admin/templatetags/admin_list.py"
> in results
>   179. yield list(items_for_result(cl,res))
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/contrib/admin/templatetags/admin_list.py"
> in items_for_result
>   132. result_repr = escape(getattr(result, f.name))
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/utils/html.py"
> in escape
>   27. html = str(html)
> File "/data/webroot/django-projects/ggum/shop/models.py" in __str__
>   79. return self.test_path()
> File "/data/webroot/django-projects/ggum/shop/models.py" in test_path
>   75. self.objects.get_query_set().filter(name="aaa")
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/manager.py"
> in __get__
>   110. raise AttributeError, "Manager isn't accessible via %s instances" %
> type.__name__
>
>
which mean I can't access the Manage via the Model.

So I want to know there is any other way to get the model data?

Big appreciating django framework

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



Re: Doing query with 'ne' terms.

2007-06-14 Thread Todd O'Bryan

Django uses different functions for this. To get the opposite of this
(the ne version)

Foo.objects.filter(bar__exact='something')

do

Foo.objects.exclude(bar__exact='something')

HTH,
Todd

On Fri, 2007-06-15 at 11:37 +0800, Nicholas Ding wrote:
> I found Django can not do '<>' operation in SQL, such as "where column
> <> %s".
> While diving into the source code, it seems easy to add a 'ne' to
> existing query terms.
> But why Django doesn't include this, it's confuse me a lot.
> 
> Best Regards.
> -- 
> Nicholas @ Nirvana Studio
> http://www.nirvanastudio.org
> > 


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



How can access the model.manager in the model?

2007-06-14 Thread Young Gyu Park
I resubmit this article due to omitting the subject

-- Forwarded message --
From: Young Gyu Park <[EMAIL PROTECTED]>
Date: Jun 15, 2007 12:43 PM
Subject:
To: django-users@googlegroups.com


class Category(models.Model):
> name = models.CharField(maxlength=20)
>
> parent = models.ForeignKey('self', null=True, related_name='child_set')
>
> def __str__(self):
> return self.name
>
>
I try to embody this Model. But In the admin page, I want to see the whole
category path, I mean there is a category which has two parent category.

I want to see like this

A -> B -> C

To do this I try to modify __str__ function by recursive function

To get the parent category I need to call the filter function, But the
python told me

Traceback (most recent call last):
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/template/__init__.py"
> in render_node
>   706. result = node.render(context)
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/template/__init__.py"
> in render
>   862. dict = func(*args)
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/contrib/admin/templatetags/admin_list.py"
> in result_list
>   182. return {'cl': cl,
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/contrib/admin/templatetags/admin_list.py"
> in results
>   179. yield list(items_for_result(cl,res))
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/contrib/admin/templatetags/admin_list.py"
> in items_for_result
>   132. result_repr = escape(getattr(result, f.name))
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/utils/html.py"
> in escape
>   27. html = str(html)
> File "/data/webroot/django-projects/ggum/shop/models.py" in __str__
>   79. return self.test_path()
> File "/data/webroot/django-projects/ggum/shop/models.py" in test_path
>   75. self.objects.get_query_set().filter(name="aaa")
> File 
> "/usr/pkg/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/manager.py"
> in __get__
>   110. raise AttributeError, "Manager isn't accessible via %s instances" %
> type.__name__
>
>
which mean I can't access the Manage via the Model.

So I want to know there is any other way to get the model data?

Big appreciating django framework

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



Re: Doing query with 'ne' terms.

2007-06-14 Thread Nicholas Ding
but I wanna 'where column1 <> %s and column2 <> %s'
If I were using exclude, the SQL must be 'where not (column1 = %s and
column2 = %s), that's different.

On 6/15/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>
>
> Django uses different functions for this. To get the opposite of this
> (the ne version)
>
> Foo.objects.filter(bar__exact='something')
>
> do
>
> Foo.objects.exclude(bar__exact='something')
>
> HTH,
> Todd
>
> On Fri, 2007-06-15 at 11:37 +0800, Nicholas Ding wrote:
> > I found Django can not do '<>' operation in SQL, such as "where column
> > <> %s".
> > While diving into the source code, it seems easy to add a 'ne' to
> > existing query terms.
> > But why Django doesn't include this, it's confuse me a lot.
> >
> > Best Regards.
> > --
> > Nicholas @ Nirvana Studio
> > http://www.nirvanastudio.org
> > >
>
>
> >
>


-- 
Nicholas @ Nirvana Studio
http://www.nirvanastudio.org

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



Re: How can access the model.manager in the model?

2007-06-14 Thread James Bennett

On 6/14/07, Young Gyu Park <[EMAIL PROTECTED]> wrote:
> To do this I try to modify __str__ function by recursive function
>
> To get the parent category I need to call the filter function, But the
> python told me

No, you can do it pretty easily like this:

def __str__(self):
if self.parent:
return "%s -> %s" % (self.parent, self.title)
else:
return self.title


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

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



form works but not in base skeleton template

2007-06-14 Thread tammy

Hi

I am new to django. Java developer, just trying it out.
I created a base "skeleton" template per the djangobook (chapter 4).

When I create form in the body of a template that extends my base
template, the form post works great.

When I copy the same form into the base skeleton template, the form
post gives an error. It does not even reach my view method. The odd
thing is that the error message indicates that the URL posted to did
not exist in my mysite.urls and says "The current URL, .html, didn't match any of these." The template it is referring
to is the template that my view method would have returned. But my
view method does not get called at all because the first line of it is
a print statement that does not get printed.

What is going on?!

Any insight or WAGs appreciated!

Thanks
 t


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



Re: Doing query with 'ne' terms.

2007-06-14 Thread Todd O'Bryan

You can do a custom SQL query. I don't think you'd *have* to for this,
but someone else will have to provide the correct translation.

Todd

On Fri, 2007-06-15 at 11:50 +0800, Nicholas Ding wrote:
> but I wanna 'where column1 <> %s and column2 <> %s'
> If I were using exclude, the SQL must be 'where not (column1 = %s and
> column2 = %s), that's different.
> 
> On 6/15/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> 
> Django uses different functions for this. To get the opposite
> of this
> (the ne version)
> 
> Foo.objects.filter(bar__exact='something')
> 
> do
> 
> Foo.objects.exclude(bar__exact='something')
> 
> HTH,
> Todd
> 
> On Fri, 2007-06-15 at 11:37 +0800, Nicholas Ding wrote:
> > I found Django can not do '<>' operation in SQL, such as
> "where column
> > <> %s".
> > While diving into the source code, it seems easy to add a
> 'ne' to 
> > existing query terms.
> > But why Django doesn't include this, it's confuse me a lot.
> >
> > Best Regards.
> > --
> > Nicholas @ Nirvana Studio
> > http://www.nirvanastudio.org
> > >
> 
> 
> 
> 
> 
> 
> 
> -- 
> Nicholas @ Nirvana Studio
> http://www.nirvanastudio.org
> > 


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



Re: How can access the model.manager in the model?

2007-06-14 Thread Young Gyu Park
This is only valid when the category have one depth.

But what about two or three depth?

like the child have a parent and the parent have a parent and the parent
have a parent .

I want to generalize regardless of how many depth it is.


On 6/15/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 6/14/07, Young Gyu Park <[EMAIL PROTECTED]> wrote:
> > To do this I try to modify __str__ function by recursive function
> >
> > To get the parent category I need to call the filter function, But the
> > python told me
>
> No, you can do it pretty easily like this:
>
> def __str__(self):
> if self.parent:
> return "%s -> %s" % (self.parent, self.title)
> else:
> return self.title
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>

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



Re: How can access the model.manager in the model?

2007-06-14 Thread James Bennett

On 6/14/07, Young Gyu Park <[EMAIL PROTECTED]> wrote:
> This is only valid when the category have one depth.
>
> But what about two or three depth?

Look at it carefully; it works with *any* depth of categories.

To confirm, run this simplified example which uses plain Python
objects instead of models:

class Category(object):
def __init__(self, title, parent=None):
self.title = title
self.parent = parent

def __str__(self):
if self.parent:
return "%s -> %s" % (self.parent, self.title)
else:
return self.title

A = Category(title='A')
B = Category(title='B', parent=A)
C = Category(title='C', parent=B)
D = Category(title='D', parent=C)
E = Category(title='E', parent=D)

print A
print B
print C
print D
print E

You'll get this output:

A
A -> B
A -> B -> C
A -> B -> C -> D
A -> B -> C -> D -> E

Look carefully at that __str__ method to see why this works.

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

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



Re: Doing query with 'ne' terms.

2007-06-14 Thread SmileyChris

On Jun 15, 3:50 pm, "Nicholas Ding" <[EMAIL PROTECTED]> wrote:
> but I wanna 'where column1 <> %s and column2 <> %s'
> If I were using exclude, the SQL must be 'where not (column1 = %s and
> column2 = %s), that's different.

I think you want:
objects.exclude(column1=test1).exclude(column2=test2)


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



Re: Doing query with 'ne' terms.

2007-06-14 Thread Nick

On Jun 15, 12:50 pm, "Nicholas Ding" <[EMAIL PROTECTED]> wrote:
> but I wanna 'where column1 <> %s and column2 <> %s'
> If I were using exclude, the SQL must be 'where not (column1 = %s and
> column2 = %s), that's different.

http://www.djangoproject.com/documentation/db-api/#complex-lookups-with-q-objects

Not sure if there's a neater way to do this, but:

q = QNot(Q(bar='something')) & QNot(Q(bar='something-else'))

Foo.objects.filter(q)

should do something like:
(NOT (foo = %s)) AND (NOT (foo = %s))


> On 6/15/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Django uses different functions for this. To get the opposite of this
> > (the ne version)
>
> > Foo.objects.filter(bar__exact='something')
>
> > do
>
> > Foo.objects.exclude(bar__exact='something')
>
> > HTH,
> > Todd
>
> > On Fri, 2007-06-15 at 11:37 +0800, Nicholas Ding wrote:
> > > I found Django can not do '<>' operation in SQL, such as "where column
> > > <> %s".
> > > While diving into the source code, it seems easy to add a 'ne' to
> > > existing query terms.
> > > But why Django doesn't include this, it's confuse me a lot.
>
> > > Best Regards.
> > > --
> > > Nicholas @ Nirvana Studio
> > >http://www.nirvanastudio.org
>
> --
> Nicholas @ Nirvana Studiohttp://www.nirvanastudio.org


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



django orm & sqlalchemy

2007-06-14 Thread james_027

Hi,

I have read somewhere else that there is a plan of making sqlalchemy
to work with django. My concern is while sqlalchemy is the more
complete orm, but it lack validation which is something django's own
orm has, am I right?

Thanks
james


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



Re: Doing query with 'ne' terms.

2007-06-14 Thread Nicholas Ding
It works!
But why not add a 'ne' term to do this?
eg. Foo.objects.filter(column1__ne='', column2__ne='')
I think it's more simple.

Thanks.

On 6/15/07, Nick <[EMAIL PROTECTED]> wrote:
>
>
> On Jun 15, 12:50 pm, "Nicholas Ding" <[EMAIL PROTECTED]> wrote:
> > but I wanna 'where column1 <> %s and column2 <> %s'
> > If I were using exclude, the SQL must be 'where not (column1 = %s and
> > column2 = %s), that's different.
>
>
> http://www.djangoproject.com/documentation/db-api/#complex-lookups-with-q-objects
>
> Not sure if there's a neater way to do this, but:
>
> q = QNot(Q(bar='something')) & QNot(Q(bar='something-else'))
>
> Foo.objects.filter(q)
>
> should do something like:
> (NOT (foo = %s)) AND (NOT (foo = %s))
>
>
> > On 6/15/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > Django uses different functions for this. To get the opposite of this
> > > (the ne version)
> >
> > > Foo.objects.filter(bar__exact='something')
> >
> > > do
> >
> > > Foo.objects.exclude(bar__exact='something')
> >
> > > HTH,
> > > Todd
> >
> > > On Fri, 2007-06-15 at 11:37 +0800, Nicholas Ding wrote:
> > > > I found Django can not do '<>' operation in SQL, such as "where
> column
> > > > <> %s".
> > > > While diving into the source code, it seems easy to add a 'ne' to
> > > > existing query terms.
> > > > But why Django doesn't include this, it's confuse me a lot.
> >
> > > > Best Regards.
> > > > --
> > > > Nicholas @ Nirvana Studio
> > > >http://www.nirvanastudio.org
> >
> > --
> > Nicholas @ Nirvana Studiohttp://www.nirvanastudio.org
>
>
> >
>


-- 
Nicholas @ Nirvana Studio
http://www.nirvanastudio.org

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



  1   2   >