Re: one to many

2007-07-06 Thread Jeremy Dunck

On 7/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> class content(model.Models):
>   link = models.URLField(verify_exists=True)
>   mods = models.SomeKindOfManyToOne(lotsOfMods)


Both in the database and in Django's ORM, it's done the other
direction.  What you're looking for is called a foreign key
(ForeignKey in Django).

Let's take the Article / Reporter models as an example.  An article
has one reporter, but a reporter can have more than one article.

To model this in the database, we make a reporter table with a primary
key-- that's a value that uniquely identifies the reporter record.

In the article table, we make a foreign key to the reporter's primary key.

reporter table:
id   name
1joe
2   lisa

article table
id  reporter_id title
1   1 "spamalot rocks"
2   2 "sushi sundae"
3   1 "ratatouille smoothies"



>From these records, we see that joe and lisa are reporters, and that
"spamalot rocks" and "ratatouille smoothies" are articles written by
joe, while "sushi sundae" was written by lisa.

In the Django Model definition, it's like this:

class Reporter(models.Model):
name = models.CharField(maxlength=50)

class Article(models.Model):
reporter = models.ForeignKey(Reporter)
   title = models.CharField(maxlength=50)


Clear?

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



one to many

2007-07-06 Thread [EMAIL PROTECTED]

Hi,

I'm new to DB issues. I'm hoping Django can help me out.

I'm trying to figure out how to do a one to many relationship. As I
understand it, this means that a single table entry for a particular
model would refer to many entries of another model table. Is that
correct?

Imagine a site like Digg or Reddit. There is an idea of content, which
is submitted. Then there is an idea of modding up, which I'd like to
explicitly log and create a model for. I'm not sure if this is
standard practice (making a model and DB entry for a "verb" like a
modding-up event). But I want to do it.

So how can I do it? The docs seem light on this format:
http://www.google.com/search?q=one+to+many+site%3Ahttp%3A%2F%2Fwww.djangoproject.com%2Fdocumentation

class content(model.Models):
  link = models.URLField(verify_exists=True)
  mods = models.SomeKindOfManyToOne(lotsOfMods)

class mod(model.Models):
  # time, user, up/down choice, etc.


There are going to many, many more mods than content, so I don't
really see having a many-to-one relationship making sense. Wouldn't
that mean heavier weight searches to find stats about a particular
piece of content?

Thanks,
Ivan


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



Re: newforms-admin character encoding problem

2007-07-06 Thread leifbyron

Hi Malcom,

Thanks for the quick reply! I will wait for the Unicode changes to be
ported to the newforms-admin branch.

Just so I understand the situation... Does the current newforms-admin
branch always trigger errors when non-ASCII data such as é and ¢ are
entered into text fields?

And while we're on the subject, do you know the ETA  for merging
newforms-admin into trunk?

Thanks again,
Leif


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



Re: __unicode__() doesn't work in model

2007-07-06 Thread Olli Wang

Sorry, my mistake. I should refer tutorial for version 0.96.
Thanks. :)

On Jul 7, 10:45 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2007-07-07 at 02:42 +, Olli Wang wrote:
> > Hi, I'm new to Django. I just followed the tutorial - Poll example
> > (http://www.djangoproject.com/documentation/tutorial01/) . It said
> > that adding __unicode__() to models may change object's
> > representations, but don't know why that doesn't take effect on my
> > computer. Run "Poll.objects.all()" in shell still gave me "[(Poll:
> > Poll object)]" back, but if I change __unicode__() to __str__(),
> > everything works fine(I'm not sure with really unicode char), any
> > idea? Thanks.
>
> Are you using a recent checkout of the code? The link you gave refers to
> the very latest code, so if you are using something from before, say,
> July 4, then that documentation won't apply.
>
> Regards,
> Malcolm
>
> --
> No one is listening until you make a mistake.http://www.pointy-stick.com/blog/


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



Re: __unicode__() doesn't work in model

2007-07-06 Thread Malcolm Tredinnick

On Sat, 2007-07-07 at 02:42 +, Olli Wang wrote:
> Hi, I'm new to Django. I just followed the tutorial - Poll example
> (http://www.djangoproject.com/documentation/tutorial01/) . It said
> that adding __unicode__() to models may change object's
> representations, but don't know why that doesn't take effect on my
> computer. Run "Poll.objects.all()" in shell still gave me "[(Poll:
> Poll object)]" back, but if I change __unicode__() to __str__(),
> everything works fine(I'm not sure with really unicode char), any
> idea? Thanks.

Are you using a recent checkout of the code? The link you gave refers to
the very latest code, so if you are using something from before, say,
July 4, then that documentation won't apply.

Regards,
Malcolm

-- 
No one is listening until you make a mistake. 
http://www.pointy-stick.com/blog/


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



__unicode__() doesn't work in model

2007-07-06 Thread Olli Wang

Hi, I'm new to Django. I just followed the tutorial - Poll example
(http://www.djangoproject.com/documentation/tutorial01/) . It said
that adding __unicode__() to models may change object's
representations, but don't know why that doesn't take effect on my
computer. Run "Poll.objects.all()" in shell still gave me "[(Poll:
Poll object)]" back, but if I change __unicode__() to __str__(),
everything works fine(I'm not sure with really unicode char), any
idea? 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: problem with django dev server and subprocess.Popen

2007-07-06 Thread Robert Coup

Robert Coup wrote:
> Carl Karsten wrote:
>   
>> Malcolm Tredinnick wrote:
>>   
>> 
>>> I don't know what htmldoc does, but if it tries to access the url you
>>> give it, you can't do that. The dev server is single threaded. It is
>>> already serving one request (running your view), so it can't serve the
>>> second parallel access to localhost:8000.
>>> 
>>>   
>> Could a 2nd instance of dev server be run on localhost:8001 ? (and then 
>> htmldoc? 
>> be pointed at that, and hope it isn't recursive or something.)
>>   
>> 
> It certainly could. Try it :)
>   
Not that I explained how.

python manage.py runserver 0.0.0.0:8001

(0.0.0.0 allows access to your server from any IP that can route to it. 
If you're only working on localhost you could change it to 127.0.0.1:8001)

Rob :)

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



Re: problem with django dev server and subprocess.Popen

2007-07-06 Thread Robert Coup

Carl Karsten wrote:
> Malcolm Tredinnick wrote:
>   
>> I don't know what htmldoc does, but if it tries to access the url you
>> give it, you can't do that. The dev server is single threaded. It is
>> already serving one request (running your view), so it can't serve the
>> second parallel access to localhost:8000.
>> 
> Could a 2nd instance of dev server be run on localhost:8001 ? (and then 
> htmldoc? 
> be pointed at that, and hope it isn't recursive or something.)
>   
It certainly could. Try it :)

Rob :)

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



Re: newforms-admin character encoding problem

2007-07-06 Thread Malcolm Tredinnick

On Sat, 2007-07-07 at 02:23 +, leifbyron wrote:
> Hello,
> 
> I have run into a character-encoding error while developing a custom
> admin site with the newforms-admin branch.

newforms-admin has not had the Unicode changes ported across to it yet.
Using it with non-ASCII data is not recommended.

Regards,
Malcolm

-- 
The early bird may get the worm, but the second mouse gets the cheese. 
http://www.pointy-stick.com/blog/


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



newforms-admin character encoding problem

2007-07-06 Thread leifbyron

Hello,

I have run into a character-encoding error while developing a custom
admin site with the newforms-admin branch.

Everything works fine with standard alphanumeric input, but as soon as
I enter a special character (an accented e or a pound sign, for
example) into a text field or textarea, I get the following error:

^
UnicodeEncodeError at /admin/profile/profile/1/
'ascii' codec can't encode character u'\xe9' in position 5: ordinal
not in range(128)

Request Method: POST
Request URL:http://127.0.0.1:8000/admin/profile/profile/1/
Exception Type: UnicodeEncodeError
Exception Value:'ascii' codec can't encode character u'\xe9' in
position 5: ordinal not in range(128)
Exception Location: /Library/Frameworks/Python.framework/Versions/2.4/
lib/python2.4/site-packages/django/db/backends/util.py in execute,
line 17
Python Executable:  /Library/Frameworks/Python.framework/Versions/2.4/
Resources/Python.app/Contents/MacOS/Python
Python Version: 2.4.4
Traceback (innermost last)

Switch to copy-and-paste view

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/core/handlers/base.py in get_response
response = callback(request, *callback_args,
**callback_kwargs) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/contrib/admin/sites.py in root
return self.model_page(request, *url.split('/', 2)) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/contrib/admin/sites.py in model_page
return admin_obj(request, rest_of_url) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/contrib/admin/options.py in __call__
return self.change_view(request, unquote(url)) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/contrib/admin/options.py in change_view
return self.save_change(request, model, form,
inline_formsets) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/contrib/admin/options.py in save_change
new_object = form.save(commit=True) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/newforms/models.py in save
return save_instance(self, instance, fields, fail_message,
commit) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/newforms/models.py in save_instance
instance.save() ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/db/models/base.py in save
db_values + [pk_val]) ...

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/django/db/backends/util.py in execute
return self.cursor.execute(sql, params) ...

--

In that particular case, the offending data was u'asdf \xe9' (It was
entered as asdf é). FYI, I am using Postgres.

Does anyone have a clue what is going on? I have found at least four
references to this problem in previous posts and tickets, but no solid
explanations or answers.

Any help would be greatly appreciated! I've already spent a half-day
trying to figure this out.

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



Make money now!!!

2007-07-06 Thread Asher

WHY NOT MAKE MONEY AND CHANGE YOUR
LIFE FOREVER< THIS REALLY DOES WORK.
I found this on a bulletin board and decided to try it. A little
while back, I was browsing through newsgroups, just like you are now,
and came across an article similar to this that said you could make
thousands of dollars within weeks with only an initial investment of
$6.00! So I thought, "Yeah right, this must be a scam", but
like most of us, I was curious, so I kept reading. Anyway, it said
that you send $1.00 to each of the 6 names and address stated in the
article. You then place your own name and address in the bottom of
the list at #6, and post the article in at least 200 newsgroups.
(There are thousands) No catch, that was it. So after thinking it
over, and talking to a few people first, I thought about trying it. I
figured: "what have I got to lose except 6 stamps and $6.00,
right?" Then I invested the measly $6.00. Well GUESS WHAT!?...
within 7 days, I started getting money in the mail! I was shocked! I
figured it would end soon, but the money just kept coming in. In my
first week, I made about $25.00. By the end of the second week I had
made a total of over $1,000.00! In the third week I had over
$10,000.00 and it's still growing. This is now my fourth week and I
have made a total of just over $42,000.00 and it's still coming in
rapidly. It's certainly worth $6.00, and 6 stamps, I have spent more
than that on the lottery!! Let me tell you how this works and most
importantly, WHY it works... Also, make sure you print a copy of this
article NOW, so you can get the information off of it as you need it.
I promise you that if you follow the directions exactly, that you
will start making more money than you thought possible by doing
something so easy!
Suggestion: Read this entire message carefully! (print it out or
download it.) Follow the simple directions and watch the money come
in!
It's easy. It's legal. And, your investment is only $6.00 (Plus
postage)
IMPORTANT: This is not a rip-off; it is not indecent; it is not
illegal; and it is 99% no risk - it really works!
If all of the following instructions are adhered to, you will receive
extraordinary dividends.
PLEASE NOTE:
Please follow these directions EXACTLY, and $50,000 or more can be
yours in 20 to 60 days. This program remains successful because of
the honesty and integrity of the participants. Please continue its
success by carefully adhering to the instructions.
You will now become part of the Mail Order business. In this business
your product is not solid and tangible, it's a service. You are in
the business of developing Mailing Lists. Many large corporations are
happy to pay big bucks for quality lists. However, the money made
from the mailing lists is secondary to the income which is made from
people like you and me asking to be included in that list.
Here are the 4 easy steps to success:
STEP 1: Get 6 separate pieces of paper and write the following on
each piece of paper "PLEASE PUT ME ON YOUR MAILING LIST." Now
get 6 US $1.00 bills and place ONE inside EACH of the 6 pieces of
paper so the bill will not be seen through the envelope (to prevent
thievery). Next, place one paper in each of the 6 envelopes and seal
them. You should now have 6 sealed envelopes, each with a piece of
paper stating the above phrase, your name and address, and a $1.00
bill. What you are doing is creating a service. THIS IS ABSOLUTELY
LEGAL! You are requesting a legitimate service and you are paying for
it! Like most of us I was a little skeptical and a little worried
about the legal aspects of it all. So I checked it out with the U.S.
Post Office (1-800-725-2161) and they confirmed that it is indeed
legal. Mail the 6 envelopes to the following addresses:
#1) Mike Calhoon
727 Lakeview Dr.
Cortland,OH 44410
#2) James Smith
547 Knowlton Rd # 25
Knowlton , Quebec J0E 1V0
#3) Marilyn Wilson
211 Maple St
Sutton, Quebec J0E 2K0
#4) Barbara Fuller
1072 Knowlton Rd Trailer # 47
West Brome, Quebec J0B 2P0
#5) Kelly Leblanc
266 Lawrence # 130
Greenfield Park, Quebec J4V-2Z4
#6) Andrew Hicks
609 Greenspring terrace
Bear,DE 19701

STEP 2: Now take the #1 name off the list that you see above, move
the other names up (6 becomes 5, 5 becomes 4, etc...) and add YOUR
Name as number 6 on the list.
STEP 3: Change anything you need to, but try to keep this article as
close to original as possible. Now, post your amended article to at
least 200 newsgroups. (I think there are close to 24,000 groups) All
you need is 200, but remember, the more you sell, the more money you
make! You won't get very much unless you post like crazy. :)
Dont forget to get your friends and family involved too.
Charge $1 for a copy of this letter and tell them to mail $1 to the
rest of the people on the list.
This is perfectly legal! If you have any doubts, refer to Title 18
Sec. 1302 & 1341 of the Postal lottery laws.
Keep a copy of these steps for yourself and, whenever you need money,
you can use it again, and again.
PLEASE 

Re: Database caching, querysets not evaluating?

2007-07-06 Thread ejot

Hmm, Im guessing this might also have something to do with local() for
threads?

Made my app work by using an extra and from my point of view
uneccesary worker thread that does the polling on the database.. .
anyone willing to offer some insight on this? I see people are trying
to do external (from django) applications but suggestions have been to
do cron jobs or use views in django to trigger an eventflow. These
things aren't always applicable tho, as in my case where i have to
keep a connection up on IRC while polling.


On Jul 6, 4:50 pm, ejot <[EMAIL PROTECTED]> wrote:
> Im really banging my head against a wall trying to get my threaded
> application to play nice with djangos ORM...
>
> this is what my thread does for each iteration..
> def run(self):
> while self.keepRunning:
> print repr(Topic.objects.get(id=1).content_set.order_by("-
> id")[0])
> time.sleep(5)
>
> Now, the docs say that a query should evaluate when calling repr(),
> but it doesnt... what i do is start up my thread and in the shell:
>
> t = Topic.objects.get(id=1)
> eo = EntryObject(payload="Some random text")
> eo.save()
> e = Entry(content_object=eo, belongs_to=t)
> e.save()
>
> Still, the thread reports that the last object in content_set created
> is the one that is evaluated or printed when the thread does its first
> iteration what's going on here?
>
> What Im trying to accomplish is an application (just using Djangos
> ORM) that polls the database for new entries created, and based on
> that sends an message out on IRC.


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



Re: custom template tag

2007-07-06 Thread [EMAIL PROTECTED]

You might want to have a look at this, if not to use it, at least to
see how the templatetags are done: 
http://code.google.com/p/django-template-utils/

On Jul 6, 4:39 pm, dystopia <[EMAIL PROTECTED]> wrote:
> Hi,
>  I've been trying to get something together to
> see if I can get to grips with writing my own tempalte tags. In the
> end I came up with something
> like this (so far):
>
> from myproject.shop.models import Product
> from django import template
>
> register = template.Library()
>
> def get_latest_products(parser, token):
> # Get list of products by date.
> latestProducts = Product.objects.all().order_by('pub_date')[:5]
> return latestProductsNode()
>
> class latestProductsNode(template.Node):
>
> def __init__(self):
> # Get list of products by date.
> self.latestProducts =
> Product.objects.all().order_by('pub_date')[:5]
>
> def render(self, context):
> return self.latestProducts
>
> register.tag('latest_products', get_latest_products)
>
> Something tells me this is not the way to go about what I want to do.
> All I want is a tag that outputs a list of  the five most recent
> products.
>
> Anyone care to give me any pointers on this?
>
> 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: Error log interpretation

2007-07-06 Thread Vincent Nijs

Graham,

Looks like you are right. If I hit the reload button repeatedly this message
pops up in the error logs. Doesn't seem like a serious error then.

Thanks for helping me sort that out!

Vincent

On 7/5/07 9:47 PM, "Graham Dumpleton" <[EMAIL PROTECTED]> wrote:

> 
> On Jul 6, 9:38 am, Vincent Nijs <[EMAIL PROTECTED]>
> wrote:
>> Could anyone help me identify if the error message below (from apache log)
>> might be a network/apache error or something in my Django/python code. My
>> site is deployed using apache and mod_python.
>> 
>> [error] [client ] PythonHandler django.core.handlers.modpython: Traceback
>> (most recent call last):, referer:https://mysite.org
>> [error] [client ] PythonHandler django.core.handlers.modpython:   File
>> "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in
>> HandlerDispatch\nresult = object(req), referer:https://mysite.org
>> [error] [client ] PythonHandler django.core.handlers.modpython:   File
>> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line
>> 177, in handler\nreturn ModPythonHandler()(req),
>> referer:https://mysite.org
>> [error] [client ] PythonHandler django.core.handlers.modpython:   File
>> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line
>> 169, in __call__\nreq.write(chunk), referer:https://mysite.org
>> [error] [client ] PythonHandler django.core.handlers.modpython: IOError:
>> Write failed, client closed connection., referer:https://mysite.org
> 
> The IOError simply indicates that the browser connection was closed
> before a response could be completely sent. Did you press the stop or
> reload buttons on the browser in the middle of a page load?
> 
> Graham
> 
> 
> > 

-- 
Vincent R. Nijs
Assistant Professor of Marketing
Kellogg School of Management, Northwestern University
2001 Sheridan Road, Evanston, IL 60208-2001
Phone: +1-847-491-4574 Fax: +1-847-491-2498
E-mail: [EMAIL PROTECTED]
Skype: vincentnijs




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



Re: caching and authentication

2007-07-06 Thread Jeremy Dunck

On 7/6/07, patrickk <[EMAIL PROTECTED]> wrote:
>
> when having a header where the username and a logout-button is
> displayed, how do you cache this page/view?

There's a CACHE_MIDDLEWARE_ANONYMOUS_ONLY setting if you want to only
do anonymous caching.

But I think you must have your cache middleware in the wrong order if
you're seeing this problem.

page_cache and the cache middleware both are keyed by the Vary header,
and the Vary header will contain 'Cookie' if you've accessed the
session object-- which you must have done if you have the request.user
in your template.

Please post your MIDDLEWARE_CLASSES tuple.

> is this (using the low-level cache) the best way doing this?
>

I'm not convinced you need 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
-~--~~~~--~~--~--~---



Is possible run silently the pysqlite.exe on windows?

2007-07-06 Thread mamcxyz

I wonder if exist a way to install
http://initd.org/pub/software/pysqlite/releases/2.3/2.3.4/pysqlite-2.3.4.win32-py2.4.exe
using the command line and avoiding the GUI...


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



Re: cross-table unique_together?

2007-07-06 Thread Todd O'Bryan

On Fri, 2007-07-06 at 21:50 +, Nathan Ostgard wrote:
> You would either have to duplicate the Title foreign key in the Copy
> model or write a custom check in the save method.
> 
> To enforce uniqueness over several columns you would use the
> "unique_together" field of the Meta class for your Copy model. (see:
> http://www.djangoproject.com/documentation/model-api/#unique-together)
> This creates the appropriate unique index for your table. However,
> this means you can only enforce uniqueness for fields within an
> individual model.
> 
Thanks. That's what I was afraid of, but the idea of duplicating the
title ForeignKey never occurred to me.

On the other hand, I guess that would require overriding __setattr__
method to set the title whenever the purchase_group is set, so it might
just be easier to put the constraint in the save method.

Todd


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



Re: cross-table unique_together?

2007-07-06 Thread Nathan Ostgard

You would either have to duplicate the Title foreign key in the Copy
model or write a custom check in the save method.

To enforce uniqueness over several columns you would use the
"unique_together" field of the Meta class for your Copy model. (see:
http://www.djangoproject.com/documentation/model-api/#unique-together)
This creates the appropriate unique index for your table. However,
this means you can only enforce uniqueness for fields within an
individual model.

Nathan

On Jul 6, 11:30 am, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> I'm writing an app to deal with checking out textbooks to students. The
> models are
>
> Title:
> the book
> PurchaseGroup:
> when purchased and how much they cost, foreign key to Title
> Copy:
> number, foreign key to PurchaseGroup
>
> I'd like to make it so that no two copies have the same number and
> title, i.e. copies #1 and #2 of The Django Book are legal as is copy #1
> of The Mythical Man-Month, but having two copy #1's of the same book
> would be forbidden.
>
> Will the ORM do that, or do I have to just write a check in the Copy
> class's save method?
>
> Thanks!
> Todd


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



[Now making $1,000+ a day is easy.]

2007-07-06 Thread AShopper.net

We've been helping people

like you profit online since 1994.

Here are some of the ways

we can help:

* you already have a website

and need custom design

* you need your domain

hosted or need to get a domain

* you want to have

an online home business
but aren't sure how to get started

* you want a profitable

online business but have
no products of your own to sell

* you have a home

based business and want
additional products to sell

* you want video on your website

* you want live sales people to close online
business for you 24 hours a day

* you have never profited online

and want to know
how

* you'd like to be trained

by professionals about
how the Internet works

and how to profit online

To get started, go to

http://ashopper.net/specials

buy your Silver/Platinum Package

you will receive an email from us

with password and instructions.

You will log in to the

LIVE Business Center where
trained personnel are LIVE

24 hours a day to assist you.

Log IN now!

We are standing by RIGHT NOW to assist you.

When you arrive in the LIVE Business Center just
say 'Hi', and we'll start helping you.

Pete Felicies - President Ashopper.net

& Worldprofit Dealer/Your Sponsor

Email: [EMAIL PROTECTED]
URL:   http://ashopper.net

Looking forward to hearing from you!

Make it a great prosperous day today!

Get your Silver/Platinum Package today!

Do not miss out!

=
(C) Ashopper.net 2007 All Rights Reserved.
=


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



Re: Anyone running Django and MySQL Cluster

2007-07-06 Thread Brian Morton

I have not done this before with Django, but I have set up a MySQL
cluster before.  It is the same as a standard MySQL server.  Just
connect to the management node as your SQL server.

On Jul 6, 3:01 pm, johnny <[EMAIL PROTECTED]> wrote:
> Is it even possible to run Django and MySQL Cluster or I have to write
> some patch to django for it to work (I am not a python or Django
> guru.)?


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



Re: caching and authentication

2007-07-06 Thread [EMAIL PROTECTED]

Yes.  However, you can probably cut down on your code in the view a
bit by saying if the user is authenticated, then don't add it to the
cache.  If they are not authenticated, cache the result.  This should
allow you to render the template once, then conditionally cache the
result after rendering.

On Jul 6, 5:40 am, patrickk <[EMAIL PROTECTED]> wrote:
> when having a header where the username and a logout-button is
> displayed, how do you cache this page/view?
>
> when using the per-view cache, the authentication doesn´t work
> anymore (that means that my username is still displayed in the
> header, although I´m already logged out).
> when using the low-level cache it works, but we have to split the
> templates:
> - first render (and cache) the site without the header
> - then render the cached template with the header
>
> is this (using the low-level cache) the best way doing this?
>
> thanks,
> patrick


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



Re: Checkout with Tortoise SVN

2007-07-06 Thread [EMAIL PROTECTED]

I have seen this error before.

It is usually because your proxy doesn't support the PROPFIND
command.  Ask your administrator to upgrade the proxy (usually squid)
to a version that supports this, or to reconfigure the proxy to allow
this HTTP method.

On Jul 6, 5:21 am, tsc <[EMAIL PROTECTED]> wrote:
> Sorry, but I've forgotten to set the proxy server in Tortoise. Now it
> worked a little better. But other repositories work witout the proxy
> settings too, hmm strange.
> Now I get another error:
> REPORT request failed on '/svn/!svn/vcc/default'
> REPORT of '/svn/!svn/vcc/default': 400 Bad Request (http://
> code.djangoproject.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: Filtering foreignkey results with newforms form_for_model

2007-07-06 Thread [EMAIL PROTECTED]

Thank you James, for both the solution and the advice. I really liked
forms_for_model as a crutch while I got up to speed on newforms, but
like most crutches, I'm finding I may spend more time working against
it. Still, a nifty thing for a simple, straightforward form.

On Jul 6, 3:12 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 7/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> >  EventFormClass.base_fields['club'].widget =
> > widgets.Select(choices=Club.objects.filter(approved=True))
>
> > But that throws
> > TypeError at /clubs/events/
> > unpack non-sequence
>
> The 'choices' argument should look like this:
>
> ((1, 'Foo'),
> (2, 'Bar'),
> (3, 'Baz'),
> (4, 'Quux'))
>
> Instead, it's going to look like this:
>
> [,
>  ,
>  ,
>  ]
>
> So when the form goes to look "inside" each item to pull out the id
> and string value of the choice, it finds that it can't -- it was
> expecting a tuple or a list, and got a model instance instead.
>
> What you want is something like
>
> EventFormClass.base_fields['club'].widget =
> widgets.Select(choices=[(club.id, str(club)) for club in
> Club.objects.filter(approved=True)]
>
> Also, it's often a good idea to *not* try to shoehorn things into
> form_form_model... usually it's quicker to write a custom form which
> does what you want than to add/remove things from form_for_model.
>
> --
> "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: Error loading MySQLdb module

2007-07-06 Thread Bryan L. Fordham

looks like you need to install MySQLdb: 
http://sourceforge.net/projects/mysql-python
Jalil wrote:
> I keep getting this below error when I try to sync my database. 
> I am using python2.3. Any ideas?
>
>
>
> [no job set:~/dev/mysite] 113% python2.3  manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
> execute_manager(settings)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py", 
> line 1672, in execute_manager
> execute_from_command_line(action_mapping, argv)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py", 
> line 1571, in execute_from_command_line
> action_mapping[action](int(options.verbosity), options.interactive)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py", 
> line 486, in syncdb
> from django.db import connection, transaction, models, 
> get_creation_module
>   File "/usr/lib/python2.3/site-packages/django/db/__init__.py", line 
> 11, in ?
> backend = __import__('django.db.backends.%s.base' % 
> settings.DATABASE_ENGINE, {}, {}, [''])
>   File 
> "/usr/lib/python2.3/site-packages/django/db/backends/mysql_old/base.py", 
> line 12, in ?
> raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb 
> module: No module named MySQLdb
> bykergrove [no job set:~/dev/mysite] 114%


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



custom template tag

2007-07-06 Thread dystopia

Hi,
 I've been trying to get something together to
see if I can get to grips with writing my own tempalte tags. In the
end I came up with something
like this (so far):

from myproject.shop.models import Product
from django import template

register = template.Library()

def get_latest_products(parser, token):
# Get list of products by date.
latestProducts = Product.objects.all().order_by('pub_date')[:5]
return latestProductsNode()

class latestProductsNode(template.Node):

def __init__(self):
# Get list of products by date.
self.latestProducts =
Product.objects.all().order_by('pub_date')[:5]

def render(self, context):
return self.latestProducts

register.tag('latest_products', get_latest_products)

Something tells me this is not the way to go about what I want to do.
All I want is a tag that outputs a list of  the five most recent
products.

Anyone care to give me any pointers on this?

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



Error loading MySQLdb module

2007-07-06 Thread Jalil
I keep getting this below error when I try to sync my database.
I am using python2.3. Any ideas?



[no job set:~/dev/mysite] 113% python2.3  manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line
1672, in execute_manager
execute_from_command_line(action_mapping, argv)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line
1571, in execute_from_command_line
action_mapping[action](int(options.verbosity), options.interactive)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line
486, in syncdb
from django.db import connection, transaction, models,
get_creation_module
  File "/usr/lib/python2.3/site-packages/django/db/__init__.py", line 11, in
?
backend = __import__('django.db.backends.%s.base' %
settings.DATABASE_ENGINE, {}, {}, [''])
  File
"/usr/lib/python2.3/site-packages/django/db/backends/mysql_old/base.py",
line 12, in ?
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module:
No module named MySQLdb
bykergrove [no job set:~/dev/mysite] 114%

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



Re: Slug (w/o using SlugField) Problems

2007-07-06 Thread Tim Chase

>> You might need to adopt a different approach to URL construction that is
>> reversible (writing your own version of slugify, possibly?).
> 
> Thanks for the help Malcolm. Using Jeff Croft's "I'm not a programmer"
> excuse, would it be too much trouble to request a small example of a
> reversible slugify? 

Given that any general "slugify" method throws away information
(case, spaces, punctuation, etc), there's no way to fabricate
that information for reversal short of keeping the original and
working backwards.

However, you can use the urllib.quote() and urllib.unquote()
functions instead, which may do the trick.

You may have to modify the regexp in your urls.py to handle
standard quoted characters rather than just "slug" chars.

-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: Filtering foreignkey results with newforms form_for_model

2007-07-06 Thread James Bennett

On 7/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  EventFormClass.base_fields['club'].widget =
> widgets.Select(choices=Club.objects.filter(approved=True))
>
> But that throws
> TypeError at /clubs/events/
> unpack non-sequence

The 'choices' argument should look like this:

((1, 'Foo'),
(2, 'Bar'),
(3, 'Baz'),
(4, 'Quux'))

Instead, it's going to look like this:

[,
 ,
 ,
 ]

So when the form goes to look "inside" each item to pull out the id
and string value of the choice, it finds that it can't -- it was
expecting a tuple or a list, and got a model instance instead.

What you want is something like

EventFormClass.base_fields['club'].widget =
widgets.Select(choices=[(club.id, str(club)) for club in
Club.objects.filter(approved=True)]

Also, it's often a good idea to *not* try to shoehorn things into
form_form_model... usually it's quicker to write a custom form which
does what you want than to add/remove things from form_for_model.

-- 
"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: Filtering foreignkey results with newforms form_for_model

2007-07-06 Thread [EMAIL PROTECTED]

I'm still struggling with this... came up with

 EventFormClass.base_fields['club'].widget =
widgets.Select(choices=Club.objects.filter(approved=True))

But that throws
TypeError at /clubs/events/
unpack non-sequence

Any ideas?


On Jul 5, 2:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have an "Event" model that has a foreignkey relationship with
> "Club", and I'm using form_for_model to create the form. This spits
> out all "Club" entries in a dropdown.
>
> The trick is, "Club" has a boolean field for "approved", and I want to
> filter according to that.
>
> So, is there some way to filter it? At the newform level. Should I get
> 'club.objects.filter(approved=true)' and pass that to form somehow
> (maybe form.club = approvedclubs)?
>
> 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
-~--~~~~--~~--~--~---



OT: NICEST butt EVER!

2007-07-06 Thread JohnZhang

NiceVERY nice ;)

http://www.thepollspace.com/polls.php?pollid=1722


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



Re: Slug (w/o using SlugField) Problems

2007-07-06 Thread Bryan Veloso

> You might need to adopt a different approach to URL construction that is
> reversible (writing your own version of slugify, possibly?).

Thanks for the help Malcolm. Using Jeff Croft's "I'm not a programmer"
excuse, would it be too much trouble to request a small example of a
reversible slugify? I think that's probably my best bet since other
options included adding more models and custom save methods. I've
searched around and have only found a few examples of a rewritten
slugify, other than that I'm completely clueless about how to write
one myself.

If not, then I'll just have to use one of those other ways then.


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



Re: Django Template

2007-07-06 Thread dystopia

Hi Doug,

Thanks for your reply. I've been trying to get something together to
see if I can figure this all out. In the end I came up with something
like this (so far):

from myproject.shop.models import Product
from django import template

register = template.Library()

def get_latest_products(parser, token):
# Get list of products by date.
latestProducts = Product.objects.all().order_by('pub_date')[:5]
return latestProductsNode()

class latestProductsNode(template.Node):

def __init__(self):
# Get list of products by date.
self.latestProducts =
Product.objects.all().order_by('pub_date')[:5]

def render(self, context):
return self.latestProducts

register.tag('latest_products', get_latest_products)

Something tells me this is not the way to go about what I want to do.
Anyone care to give me any pointers on this?

Thanks,

James

On Jun 29, 7:08 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote:
> On Jun 29, 12:59 pm,dystopia<[EMAIL PROTECTED]> wrote:
>
> > [snip]... Would I
> > then have have to implement the functionality of this in every view by
> > calling an cartSummary method and pushing that out into the template?
> > Or is it better to somehow compile all this functionality into a
> > template tag itself - if that's possible?
>
> > Any ideas appreciated,
>
> > James
>
> I've taken the latter approach in my projects.  Something like:
>
> {% load cart_tags %}
> {% get_cart as cart %}
> {% for items in cart %}
> ...
> {% endfor %}
>
> Then, you might put that code somewhere higher up in the template
> hierarchy:
>
> {% block shopping_cart %}
> 
> {% endblock %}
>
> or you might include it as a template:
>
> {% include "shopping_cart.snippet..html" %}
>
> Whatever you do, I would recommend taking the approach of loading the
> shopping cart a tag.
>
> That's my opinion, anyway.
>
> doug.


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



Anyone running Django and MySQL Cluster

2007-07-06 Thread johnny

Is it even possible to run Django and MySQL Cluster or I have to write
some patch to django for it to work (I am not a python or Django
guru.)?


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



Re: Trying to use many-to-many to emulate a one-to-one field

2007-07-06 Thread Charles Wesley

Correction: Use a many-to-ONE field

On Jul 3, 3:06 pm, Charles Wesley <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Since I can't (as far as I can tell) enable inline editing on a one-to-
> one field, I'm trying to use an inline-edited many-to-many field with
> a related object maximum of 1. Trivial example:
>
> class Trivial(models.Model):
> name = models.CharField(maxlength=50)
>
> class Admin:
> pass
>
> class Child(models.Model):
> name = models.CharField(maxlength=50, core=True)
> trivial = models.ForeignKey(Trivial, edit_inline=models.STACKED,
> max_num_in_admin=1)
>
> class Admin:
> pass
>
> This produces the following error message when I try to add a new
> Trivial object in the admin interface:
>
> Traceback (most recent call last):
> File "C:\Python25\lib\site-packages\django\template\__init__.py" in
> render_node
>   723. result = node.render(context)
> File "C:\Python25\Lib\site-packages\django\template\defaulttags.py" in
> render
>   122. nodelist.append(node.render(context))
> File "C:\Python25\lib\site-packages\django\contrib\admin\templatetags
> \admin_modify.py" in render
>   170. bound_related_object = relation.bind(context['form'], original,
> bound_related_object_class)
> File "C:\Python25\lib\site-packages\django\db\models\related.py" in
> bind
>   129. return bound_related_object_class(self, field_mapping,
> original)
> File "C:\Python25\lib\site-packages\django\contrib\admin\templatetags
> \admin_modify.py" in __init__
>   148. self.field_mappings.fill()
> File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
> fill
>   275. field = self.parent_manipulator[full_field_name]
> File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
> __getitem__
>   27. raise KeyError, "Field %s not found\n%s" % (field_name,
> repr(self.fields))
>
>   KeyError at /admin/apptest/trivial/add/
>   'Field child.1.id not found\n[FormField "name", FormField "child.
> 0.id", FormField "child.0.name"]'
>
> As far as I can tell, Django is reaching for child.1.id for some
> reason, when it shouldn't go beyond child.0.id. Is there a way to fix
> this? Am I thinking about the underlying problem wrong to begin with?
>
> Thanks,
> charles


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



Re: Trying to use many-to-many to emulate a one-to-one field

2007-07-06 Thread Charles Wesley

Correction: Use a many-to-ONE field

On Jul 3, 3:06 pm, Charles Wesley <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Since I can't (as far as I can tell) enable inline editing on a one-to-
> one field, I'm trying to use an inline-edited many-to-many field with
> a related object maximum of 1. Trivial example:
>
> class Trivial(models.Model):
> name = models.CharField(maxlength=50)
>
> class Admin:
> pass
>
> class Child(models.Model):
> name = models.CharField(maxlength=50, core=True)
> trivial = models.ForeignKey(Trivial, edit_inline=models.STACKED,
> max_num_in_admin=1)
>
> class Admin:
> pass
>
> This produces the following error message when I try to add a new
> Trivial object in the admin interface:
>
> Traceback (most recent call last):
> File "C:\Python25\lib\site-packages\django\template\__init__.py" in
> render_node
>   723. result = node.render(context)
> File "C:\Python25\Lib\site-packages\django\template\defaulttags.py" in
> render
>   122. nodelist.append(node.render(context))
> File "C:\Python25\lib\site-packages\django\contrib\admin\templatetags
> \admin_modify.py" in render
>   170. bound_related_object = relation.bind(context['form'], original,
> bound_related_object_class)
> File "C:\Python25\lib\site-packages\django\db\models\related.py" in
> bind
>   129. return bound_related_object_class(self, field_mapping,
> original)
> File "C:\Python25\lib\site-packages\django\contrib\admin\templatetags
> \admin_modify.py" in __init__
>   148. self.field_mappings.fill()
> File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
> fill
>   275. field = self.parent_manipulator[full_field_name]
> File "C:\Python25\lib\site-packages\django\oldforms\__init__.py" in
> __getitem__
>   27. raise KeyError, "Field %s not found\n%s" % (field_name,
> repr(self.fields))
>
>   KeyError at /admin/apptest/trivial/add/
>   'Field child.1.id not found\n[FormField "name", FormField "child.
> 0.id", FormField "child.0.name"]'
>
> As far as I can tell, Django is reaching for child.1.id for some
> reason, when it shouldn't go beyond child.0.id. Is there a way to fix
> this? Am I thinking about the underlying problem wrong to begin with?
>
> Thanks,
> charles


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



cross-table unique_together?

2007-07-06 Thread Todd O'Bryan

I'm writing an app to deal with checking out textbooks to students. The
models are

Title:
the book
PurchaseGroup:
when purchased and how much they cost, foreign key to Title
Copy:
number, foreign key to PurchaseGroup

I'd like to make it so that no two copies have the same number and
title, i.e. copies #1 and #2 of The Django Book are legal as is copy #1
of The Mythical Man-Month, but having two copy #1's of the same book
would be forbidden.

Will the ORM do that, or do I have to just write a check in the Copy
class's save method?

Thanks!
Todd


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



Re: Help with a Caching Strategy

2007-07-06 Thread Jeremy Dunck

On 7/6/07, Clint Ecker <[EMAIL PROTECTED]> wrote:
...
> When I set up caching I then just cache this_month_detail for 15
> minutes and previous_month_detail for 10 years or so.

What cache backend are you using?

Note that memcached has an LRU expiry policy, so that if there is
pressure on the cache, it'll toss out an un-accessed item to make room
for a new key.

So that 10 years might be significantly shorter.

...
> Do you mean by "baking the requests", caching the output to a file on
> disk/db or by pickling the request object (pretty sure you don't mean
> this).  If the first is what you mean, how does this differ from using
> file-based caching in Django?

The difference is that Django only supports one backend at a time, and
file-based caching breaks down if you're doing lots of writes (that
is, cache misses) or other disk IO that flushes the OS buffers.

It sounds like your data changes very rarely, and unless the page is
quite large, that number of items sounds reasonable (to me) to use
disk-based on your own.

(I'm assuming, here, that you're using memcache for your write-heavy stuff.)

...
> In another vein,  how does everyone deal with invalidating the cache

It's a hard problem, in that your needs are your needs, and the common
ground is generally pretty fine-grained.

There's a SoC project right now to do queryset-based caching, and
David Cramer hacked up a CachedManager to do similar.

With those approaches, the cache key is basically the queryset
parameters themselves, and the cache miss/regen branch I outlined is
hidden in the QuerySet implementation.  Cache invalidation isn't done,
AFAIK, in David's hack, but it is a goal of the SoC projec to void any
querysets that contain an updated model.

(I think the SoC project is using signals for the invalidation; I have
no idea how they're going to deal with model updates out of the cached
process.)

If you're looking for something coarser, because, for example, you
need to combine multiple querysets or outside data in a complex way,
then that's something that it unlikely to be a common need for Django.

The basic idea is, keep a key for the expensive thing itself, and then
keep a key for each unit-of-invalidation that is a dict of all final
keys which depend on the invalidated thing.

When the component becomes invalid, you look up all the keys that
depend on it, and go delete those.

I suppose you could recurse there-- checking to see if the things
depending on the invalid component are themselves components on which
other things depend.

I personally haven't needed this strategy yet.  :)

> can I trigger what I might call an
> automated rebuild of that template?

I just make HTTP requests for all the expensive views to keep the cache warm.

Just pace the rebuild-- it's easy to affect a site's performance when
specifically calling a bunch of expensive views.

HTH,
  Jeremy

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



Re: Difficulty validating ModelMultipleChoiceField

2007-07-06 Thread danylo

Problem solved thanks to Adrian.

Added:
from django.utils.datastructures import MultiValueDict

and I added the following to the SortedCheckBox widget:

def value_from_datadict(self, data, name):
if isinstance(data, MultiValueDict):
return data.getlist(name)
return data.get(name, None)



On Jul 5, 9:30 pm, danylo <[EMAIL PROTECTED]> wrote:
> I can't get a form to validate and for the life of me, can't figure
> out why.
>
> I keep getting an error on the topics.  Regardless of how many I
> choose, it returns an "Enter a list of values." error.  It looks like
> even though the form returns a list of topics, it doesn't send the
> list to the validator, just a single value.
>
> I've also tried converting the topics bit to a MutlipleChoiceField,
> but didnt' have any mroe luck with it.
>
> Any suggestions of where to look are much appreciated.  Thanks,
>
> dan
>
> class AddBlogForm(forms.Form):
> def __init__( self, *args, **kwargs ):
> super( AddBlogForm, self ).__init__( *args, **kwargs )
> self.fields['location'] =
> GroupedChoiceField(choices=location_drop_tags())
> self.fields['topics'] = forms.ModelMultipleChoiceField(
> queryset=Tags.objects.exclude(location__exact=True).order_by('-
> parent_tag', 'tag'), widget=SortedCheckBox)
> owner = forms.CharField()
> password = forms.CharField(widget=forms.PasswordInput)
> url = forms.URLField(initial='http://', verify_exists=True)
> title = forms.CharField(max_length=100)
> description = forms.CharField(max_length=500, required=False,
> widget=forms.Textarea(attrs={'rows': '3'}))
>
> (this is the widget used for the topic)
> class SortedCheckBox(forms.Select):
> def render(self, name, value, attrs=None, choices=()):
> from django.utils.html import escape
> from django.newforms.util import flatatt, smart_unicode
> final_attrs = self.build_attrs(attrs, name=name)
> output = []
> if value is None:
> value = ''
> str_value = tuple([smart_unicode(v) for v in value])
> for t in
> self.choices.queryset.filter(parent_tag__isnull=True):
> output.append(u'')
> option_value = smart_unicode(t.id)
> option_label = smart_unicode(t.tag)
> selected_html = (option_value in str_value) and u'checked
> ' or ''
> output.append(u' value="%s" %s/>%s' % (option_value, selected_html,
> option_label))
> for t_child in
> self.choices.queryset.filter(parent_tag__tag=t.tag):
> option_value = smart_unicode(t_child.id)
> option_label = smart_unicode(t_child.tag)
> selected_html = (option_value in str_value) and
> u'checked ' or ''
> output.append(u' value="%s" %s/>%s' % (option_value, selected_html,
> option_label))
> output.append(u'')
> return u'\n'.join(output)


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



Re: Help with a Caching Strategy

2007-07-06 Thread Clint Ecker

Thanks Jeremy,
   I'll try to expand a bit, and give some insight into a solution I
crafted this morning after reading your message (it flipped a switch
in my brain)

> How's the data updated?  Need to know how to get the update info to
> the cache.  :)

The data is updated by a crontab job that  runs a python script.  This
script pulls down RSS feeds, scrapes web sites, etc., mines out data
into my format, adds rows to the database using the Django ORM, etc.
every 15 minutes.

> As a hack, you could have a stub view that just decides if it's the
> current month or not, then dispatch either of 2 real views, each with
> its own cache_page.

This is how I implemented it this morning. I think there might a few
edge cases that aren't being handled but what I did is I send everyone
to:

month_detail(...)

which then decides whether or not they are requesting this month or a
previous month, and they're forwarded to the following views,
respectively:

this_month_detail(...) and previous_month_detail(...) which both do a
call to real_month_detail(...) which has all the shared code.

When I set up caching I then just cache this_month_detail for 15
minutes and previous_month_detail for 10 years or so.

> For an actual solution, more detail's needed.
>
> How many other parameters from the request come into play?

Pretty much every parameter that's taken into account comes through my
function arguments, (year, month, entity).  That is, the output of the
view depends wholly on the unique combinations of those 3 items.

> If a small number of permutations, you could bake all the data (that
> is, pull requests into a flat file to be served cheaply later, in
> which "invalidating cache" is deleting a file).

I'd say that there are (3 years)*(12 months)*(65 entities)
permutations (~2300) and that obviously grows every month and as we
add more entities, which happens at the rate of approximately 1-2 a
month.

Do you mean by "baking the requests", caching the output to a file on
disk/db or by pickling the request object (pretty sure you don't mean
this).  If the first is what you mean, how does this differ from using
file-based caching in Django?

> If you decide to use the low-level cache due to too many permutations,
> this is the general approach:
>
> expensive_thing = cache.get(some_key)
> if not expensive_thing:
> expensive_thing = expensive_process
>cache.set(some_key, expensive_thing, cache_timeout)
>
> You can, of course, do that as much as you want.

> I have some views that do two or 3 phases, in which I cache a whole
> resultset, then munge or whittle it depending on parameters and cache
> that bit with a more fine-grained key.

I may look into this a bit more to target my intensive bits of that
particular view.


In another vein,  how does everyone deal with invalidating the cache
and the resulting penalty the next client to request that view
receives? These old views can take near 30 seconds to regenerate from
a non-cached state. Say for whatever reason, a month from 5 months ago
recieves a new bit of data and I kill the cache for it.  How do you
regenerate that view?

Is there a way to do it programatically from within Django?

i.e. when I add a new bit of data to an old month in my cron script
and invalidate that month's cache, can I trigger what I might call an
automated rebuild of that template?

I would prefer that the penalty take place during my cron'd script's
execution rather than the user have a perceived delay the next time
that particular view is requested.

Also, thanks a bunch, Jeremy!
Clint

-- 
Clint Ecker
Sr. Web Developer - Stone Ward Chicago
p: 312.464.1443
c: 312.863.9323
---
twitter: clint
skype: clintology
AIM: idiosyncrasyFG
Gtalk: [EMAIL PROTECTED]

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



Re: Newforms Attribute Errors

2007-07-06 Thread robo

Ok,

For the record, I finally figured out the problem.
Guess what? Nothing was wrong with my code.
I simply updated from 0.96-pre to 0.97-pre and everything went well.

Hopefully this discussion will help some other poor lonely developer
out there who will stumble across this miserable error.

Regards,

Robo

ps: thanks everyone who tried to 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: Feeds don't work with Unicode URLs

2007-07-06 Thread web-junkie

On Jul 6, 4:44 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-07-06 at 07:25 -0700, web-junkie wrote:
> > Thanks for your reply. I'll give more information:
>
> > #  c:\django_src\django\core\handlers\base.py in get_response
>
> >   77. response = callback(request, *callback_args,
> > **callback_kwargs) ...
>
> > # c:\django_src\django\contrib\syndication\views.py in feed
>
> >   19. feedgen = f(slug, request.path).get_feed(param) ...
>
> > # c:\django_src\django\contrib\syndication\feeds.py in get_feed
>
> >   81. feed_url = add_domain(current_site,
> > self.__get_dynamic_attr('feed_url', obj)), ...
>
> > # c:\django_src\django\contrib\syndication\feeds.py in add_domain
>
> >   13. url = u'http://%s%s' % (domain, url) ...
>
> > print repr(domain) and print repr(url) in add_comain produces
>
> > u'www.example.com'
> > '/gie%C3%9Fen/'
> > 
> > '/feeds/gie\xc3\x9fen/'
>
> And so we see the advantage of providing details about how a problem
> occurs. This makes things clear. :-)
>
> It's a bug. I'll fix it tomorrow morning because I'm doing something
> else right now and about to stop for the evening. Plus I want to think a
> bit about what the right approach is for cases like this -- possibly we
> should be converting request.path to an IRI portion when we construct
> the HttpRequest. Maybe not.
>
> No need to worry about opening a ticket. I've made a note and will look
> at it first thing.
>
> Regards,
> Malcolm
>
> --
> He who laughs last thinks slowest.http://www.pointy-stick.com/blog/- Hide 
> quoted text -
>
> - Show quoted text -

Great, thank you so much!


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



Re: problem with django dev server and subprocess.Popen

2007-07-06 Thread Carl Karsten

Malcolm Tredinnick wrote:
> On Fri, 2007-07-06 at 07:18 -0700, Filippo Santovito wrote:
>> Hi all,
>> I'm having a strange problem with a view.
>> Its code runs well if I test if in the shell but seems to block the
>> dev server:
>>
>> #django 0.96
>> def html2pdf(request, url = None ):
>> from django.http import HttpResponse
>> import subprocess
>>
>> response = HttpResponse(mimetype='application/pdf')
>> response['Content-Disposition'] = 'attachment;
>> filename=documento.pdf'
>>
>> #with this url (managed by django) the dev server freezes
>> url = r"http://localhost:8000/;
>> #using this one everything works well
>> #url = r"http://www.google.it;
>> output = subprocess.Popen(
>>  ["/usr/bin/htmldoc" , url, "--format", "pdf14",
>> "--webpage", "--charset", "iso-8859-15"],
>>  stdout=subprocess.PIPE,
>>  stderr=subprocess.PIPE
>>  ).communicate()[0]
>>
>> response.write(output)
>> return response
> 
> I don't know what htmldoc does, but if it tries to access the url you
> give it, you can't do that. The dev server is single threaded. It is
> already serving one request (running your view), so it can't serve the
> second parallel access to localhost:8000.
> 

Could a 2nd instance of dev server be run on localhost:8001 ? (and then 
htmldoc? 
be pointed at that, and hope it isn't recursive or something.)

Carl K

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



Re: ubuntu 6.06 deployment issues

2007-07-06 Thread Carl Karsten

Graham Dumpleton wrote:
> On Jul 6, 2:59 pm, John-Scott <[EMAIL PROTECTED]> wrote:
>> On Jul 6, 12:29 am, Graham Dumpleton <[EMAIL PROTECTED]>
>> wrote:
>>
>>> Hmmm, I'm not sure the documentation is actually accurate. When you
>>> use manage.py to run up development server for Django, it will
>>> automatically add the parent directory of where the manage.py file is
>>> located into sys.path for you. Thus, there isn't strictly a need to
>>> add it to PYTHONPATH to get it to work in the first place.
>>> So, the answer is that YES, for mod_python you must use the PythonPath
>>> directive to specify the parent directory of where manage.py is
>>> located in order for your settings file to be found correctly.
>>> Graham
>> Graham - I was suspicious of that. I remember reading that manage.py
>> took care of setting all the environment variables for the development
>> server and interactive shell. But it didn't seem possible for
>> mod_python to have any idea where our projects are implicitly. Should
>> we file a doc bug?
> 
> Someone can correct me, but I think it gets a bit more confusing than
> that, so there is possibly other changes which should be made to the
> mod_python documentation.
> 
> When using manage.py it imports settings.py explicitly, thus there is
> no need to define DJANGO_SETTINGS_MODULE like with mod_python to say
> what the actual settings module name is. At this point though, only
> the directory containing manage.py is effectively in sys.path. This
> would mean that where you have in urls.py:
> 
>   (r'^mysite1/', include('mysite1.apps.foo.urls.foo')),
> 
> it would actually fail to find the referenced module.
> 
> In searching through Django, the only place it adds the parent
> directory to sys.path so that it might find that referenced module is:
> 
> def setup_environ(settings_mod):
> """
> Configure the runtime environment. This can also be used by
> external
> scripts wanting to set up a similar environment to manage.py.
> """
> # Add this project to sys.path so that it's importable in the
> conventional
> # way. For example, if this file (manage.py) lives in a directory
> # "myproject", this code would add "/path/to/myproject" to
> sys.path.
> project_directory = os.path.dirname(settings_mod.__file__)
> project_name = os.path.basename(project_directory)
> sys.path.append(os.path.join(project_directory, '..'))
> project_module = __import__(project_name, {}, {}, [''])
> sys.path.pop()
> 
> If you look carefully, what it does is append the parent directory to
> sys.path and imports the name of the site directory itself. This has
> the effect of importing the __init__.py in the site directory. It then
> removes the parent directory from sys.path.
> 
> Even though it has removed the parent directory from sys.path, the
> import of the module referenced in urls.py by the site name still
> works because of the presence of the 'mysite1' module in sys.modules.
> Ie., Python sees that module, works out from __file__ of the module
> where it is located and searches for the submodule relative to that
> directory.
> 
> So, importing modules by site package root is okay, but problem is
> that the site directory itself is still in sys.path. This means one
> can actually do:
> 
>   (r'^mysite1/', include('apps.foo.urls.foo')),
> 
> Ie., one can leave out the site name in the module path and it will
> still work.
> 
> Some people do imports this way as it means that if you rename the
> site you don't have to change the urls.py file. Also, easier to
> develop reusable components that you can copy from one project to
> another.
> 
> The problem with this is that if an application which uses these
> imports without the site name in them is hosted on mod_python, it will
> not work. This is because not only do you have to set PythonPath to
> include the parent directory of the site, you also have to list the
> site directory path itself. Ie.,
> 
>   PythonPath "['/path/to/parent','/path/to/parent/mysite1'] +
> sys.path"

"will not work" is alarming, but then you say "also have to..." which makes me 
think it will work.  so only problem is PythonPath having an extra entry, right?

I have been developing my site under the impression that  whatever works with 
./manage.py runserver will work with mod_python without having to touch 'the 
app' (I expect to have to touch httpd.conf files.)

Personally, I am not trilled by some of the search path behavior, but the root 
of that is native python, and so as long as django's behavior is somewhat 
consistent with Python's, I will live with it.   If there is something that 
strays too far and is causing problems, I may get fanatical about it.
I setup

> 
> I am not sure this is clearly mentioned in the mod_python document for
> Django or not.
> 
> Certainly, the need to do this is explained on the mailing list every
> so often, so there must be some confusion about it.

I setup a mod_python server last week, and it 

Re: Django books application i18n

2007-07-06 Thread Joseph Heck

I think most everything that you'd like to know is detailed out at
http://www.djangoproject.com/documentation/i18n/

-joe

On 7/6/07, Gianluca <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I'm following the Django tutorial about books application. How can I
> internationalize this application?
> For example, how can I internationalize a field name of insert book
> form?
> Thanks
>
> Gianluca
>
>
> >
>

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



Europython, anyone?

2007-07-06 Thread Michael Radziej

Hi,

I'm going to attend the Europython congress next week, and I'll arrive on
early Sunday afternoon. If anyone would like to gather together, please send
me an email, I'd appreciate!

Cheers,

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

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



Per request internal variables

2007-07-06 Thread PoBK

I've got a case for passing an object between various components
within my framework.

The basic concept is similar to the way Mod_Python does things, where
I can add an attribute to the request instance and that attribute will
persist accross the current request only, irrespective of which
handler is currently operating on the request.

I could hack this into the GET or POST attributes of request, but that
would expose internal objects beyond the scope of application.

Does anyone know of any method of passing variables around per request
in a loosely coupled Djangonic way?

--
Richard


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



Re: TextField in newforms

2007-07-06 Thread Todd O'Bryan

On Fri, 2007-07-06 at 11:00 -0500, James Bennett wrote:
> On 7/6/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> > Is there any reason there's not a TextField in newforms that defaults to
> > use a TextArea widget other than the fact that no one has written one
> > yet?
> 
> http://groups.google.com/group/django-users/browse_frm/thread/b3dc5cc742f3f068/
> 
> 
D'oh! Thanks for not throwing something at me, 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: TextField in newforms

2007-07-06 Thread James Bennett

On 7/6/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> Is there any reason there's not a TextField in newforms that defaults to
> use a TextArea widget other than the fact that no one has written one
> yet?

http://groups.google.com/group/django-users/browse_frm/thread/b3dc5cc742f3f068/


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



TextField in newforms

2007-07-06 Thread Todd O'Bryan

Is there any reason there's not a TextField in newforms that defaults to
use a TextArea widget other than the fact that no one has written one
yet?

Todd


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



Re: --+++Does anybody have instructions to make a photo app+++--

2007-07-06 Thread [EMAIL PROTECTED]

As for impolite, personally I have a bigger problem with subjects
changing back and forth, but that's me...

Anyway, Naco, you're in the ballpark. If it were me, I'd do something
like:

 class Photo(models.Model):
image= ImageField(upload_to="photos/")
title= CharField(maxlength=100)
caption = CharField(maxlength=200)
uploaded=  DateTimeField(auto_now=True)

class Admin:
pass

That will give you your caption, automatically set the uploaded field
so you don't have to, and just pass everything to admin, 'cause it's
easier. Note... I'm really not sure photos/ is a valid path, but then,
I don't know your setup. Make sure it's what you want.

Depending on what you set for MEDIA_ROOT and MEDIA_URL, that should
put the files someplace like /media/photos/

Now, for the view, unless there's something fancy you need to do I'd
just pass the as a generic list view:
(r'^photos/$',
'django.views.generic.list_detail.object_list',dict(queryset=Photo.objects.all()))

That will send all your photos and their info to your template.

Then in the template, you'll have to figure out HOW you want to pass
these. Personally, I usually use slideshowpro (passing the
generic_list to images.xml), but for the sake of brevity, we'll assume
something like:


{%for photo in photo_list%}

{{photo.caption}}
{% endfor %}


There's almost surely errors in the above code, so you won't want to
use it verbatim, but I'm just trying to walk you through what's going
on. Make a note of exactly what {{photo.photo}} spits out. You may
have to tweak the path a little:  . Again, I don't know your exact setup.



On Jul 6, 9:26 am, [EMAIL PROTECTED] (Jason F. McBrayer) wrote:
> Naco <[EMAIL PROTECTED]> writes:
> > Well im looking for tutorials on building a simple photo app to start
> > with
>
> Have a look at stockphoto
> (http://www.carcosa.net/jason/software/django/stockphoto/).  It is a
> bit out of date, and has a few bugs and so forth that are on my to-fix
> list, but it is basically a minimalistic photogallery app that is
> intended to integrate into any django-based site.
>
> --
> +---+
> | Jason F. McBrayer[EMAIL PROTECTED]  |
> | If someone conquers a thousand times a thousand others in |
> | battle, and someone else conquers himself, the latter one |
> | is the greatest of all conquerors.  --- The Dhammapada|


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



Mimicking, generalizing a paper application process

2007-07-06 Thread stv

I'm looking for some information about existing applications that
do ... applications. I tried googling this, but you can see where the
difficult comes in.

Basically, we have a number of paper applications that we want to
automate. Some portion of each application will be the same basic
contact information. Other parts of each application will be specific
to each department. Some will have selection preferences (My first
choice is x, second choice y ... etc). Other applications will have
different rate schedules based on population (vendor, teacher, etc) or
timeliness (180 days out, 90 days out, etc). Adding and changing
applications wouldn't happen frequently, but it shouldn't require
cartwheels.

And so on. Pretty basic stuff, I imagine, and a problem that has been
solved somewhere, maybe even in Django, I imagine. Before we start
rolling our own, I'm wondering if there are any existing projects that
tackle any portion of this problem.

If nothing else, some suggestions for search terms would be
helpful ...

Thanks
--stv


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



function to generate choices list

2007-07-06 Thread David Reynolds

Hi,

I'm trying to pre-populate a choices list for a CharField from some  
folders on the file system, I was doing this by calling a function  
within the models.py which assigned the list of folders to a variable  
which was then used in the charfield. This all worked perfectly using  
the development server, however, when deploying the site under  
apache2/mod_python I find that this list only ever gets updated when  
apache is restarted.  I had vaguely thought of using a signal((pre| 
post)-init) to create the list as a global variable, but that didn't  
seem to work.


Does anyone, please have any idea how I could do this?

Thanks,

Dave

--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


Abstracting the low level API

2007-07-06 Thread Henrik Lied

Hi there!

The cache middleware didn't quite suit my needs, so I threw up a small
function to reset the cache key whenever the object is updated.

The functions look like this: http://dpaste.com/hold/13712/

Sample usage would be
>>> entry = cache_key(request, 'blog', Entry.objects.get(id=1))

The problem with this is that it hits the database, right? So the
whole purpose of the cache is gone.
How can I make this better?


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



Database caching, querysets not evaluating?

2007-07-06 Thread ejot

Im really banging my head against a wall trying to get my threaded
application to play nice with djangos ORM...

this is what my thread does for each iteration..
def run(self):
while self.keepRunning:
print repr(Topic.objects.get(id=1).content_set.order_by("-
id")[0])
time.sleep(5)

Now, the docs say that a query should evaluate when calling repr(),
but it doesnt... what i do is start up my thread and in the shell:

t = Topic.objects.get(id=1)
eo = EntryObject(payload="Some random text")
eo.save()
e = Entry(content_object=eo, belongs_to=t)
e.save()

Still, the thread reports that the last object in content_set created
is the one that is evaluated or printed when the thread does its first
iteration what's going on here?

What Im trying to accomplish is an application (just using Djangos
ORM) that polls the database for new entries created, and based on
that sends an message out on IRC.


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



Re: Feeds don't work with Unicode URLs

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 07:25 -0700, web-junkie wrote:
> Thanks for your reply. I'll give more information:
> 
> #  c:\django_src\django\core\handlers\base.py in get_response
> 
>   77. response = callback(request, *callback_args,
> **callback_kwargs) ...
> 
> # c:\django_src\django\contrib\syndication\views.py in feed
> 
>   19. feedgen = f(slug, request.path).get_feed(param) ...
> 
> # c:\django_src\django\contrib\syndication\feeds.py in get_feed
> 
>   81. feed_url = add_domain(current_site,
> self.__get_dynamic_attr('feed_url', obj)), ...
> 
> # c:\django_src\django\contrib\syndication\feeds.py in add_domain
> 
>   13. url = u'http://%s%s' % (domain, url) ...
> 
> print repr(domain) and print repr(url) in add_comain produces
> 
> u'www.example.com'
> '/gie%C3%9Fen/'
> 
> '/feeds/gie\xc3\x9fen/'

And so we see the advantage of providing details about how a problem
occurs. This makes things clear. :-)

It's a bug. I'll fix it tomorrow morning because I'm doing something
else right now and about to stop for the evening. Plus I want to think a
bit about what the right approach is for cases like this -- possibly we
should be converting request.path to an IRI portion when we construct
the HttpRequest. Maybe not.

No need to worry about opening a ticket. I've made a note and will look
at it first thing.

Regards,
Malcolm

-- 
He who laughs last thinks slowest. 
http://www.pointy-stick.com/blog/


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

2007-07-06 Thread Gianluca

Hello,
I'm following the Django tutorial about books application. How can I
internationalize this application?
For example, how can I internationalize a field name of insert book
form?
Thanks

Gianluca


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



Re: --+++Does anybody have instructions to make a photo app+++--

2007-07-06 Thread Jason F. McBrayer

Naco <[EMAIL PROTECTED]> writes:

> Well im looking for tutorials on building a simple photo app to start
> with

Have a look at stockphoto
(http://www.carcosa.net/jason/software/django/stockphoto/).  It is a
bit out of date, and has a few bugs and so forth that are on my to-fix
list, but it is basically a minimalistic photogallery app that is
intended to integrate into any django-based site.

-- 
+---+
| Jason F. McBrayer[EMAIL PROTECTED]  |
| If someone conquers a thousand times a thousand others in |
| battle, and someone else conquers himself, the latter one |
| is the greatest of all conquerors.  --- The Dhammapada|

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



Re: Feeds don't work with Unicode URLs

2007-07-06 Thread web-junkie

Thanks for your reply. I'll give more information:

#  c:\django_src\django\core\handlers\base.py in get_response

  77. response = callback(request, *callback_args,
**callback_kwargs) ...

# c:\django_src\django\contrib\syndication\views.py in feed

  19. feedgen = f(slug, request.path).get_feed(param) ...

# c:\django_src\django\contrib\syndication\feeds.py in get_feed

  81. feed_url = add_domain(current_site,
self.__get_dynamic_attr('feed_url', obj)), ...

# c:\django_src\django\contrib\syndication\feeds.py in add_domain

  13. url = u'http://%s%s' % (domain, url) ...

print repr(domain) and print repr(url) in add_comain produces

u'www.example.com'
'/gie%C3%9Fen/'

'/feeds/gie\xc3\x9fen/'

You are right when you say that request.path is never passed directly
to add_domain, the error occurs when it uses feed_url.
feed_url is passed to the feed object from request.path

On Jul 6, 4:00 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-07-06 at 06:51 -0700, web-junkie wrote:
> > Hi, I have a problem of getting my feeds to work with unicode URLs.
>
> >  File "/usr/local/lib/python2.4/site-packages/django/contrib/
> > syndication/feeds.py", line 12, in add_domain
> >url = u'http://%s%s' % (domain, url)
>
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> > 19: ordinal not in range(128)
>
> You're only showing the last line of the traceback here. What is the
> full traceback? In particular, I would like to see which of the calls to
> add_domain() is triggering this.
>
> Can you also print out the values of "domain" and "url" inside that
> function -- or rather, print out repr(domain) and repr(url)? The easiest
> way to do this is change the source to catch UnicodeDecodeError in
> add_domain and then print out the values to sys.stderr and re-raise the
> exception.
>
>
>
> > In all my models I correctly encoded and quoted the URLs, I traced the
> > problem back to the request.path not being correctly quoted when it is
> > passed to the feed object.
>
> request.path is never passed directly to add_domain(), so it would help
> if you could explain this a little more. In particular, whenever
> add_domain() is called, it is using either the "link", "item_link" or
> "feed_url" attributes from your Feed class. If you can show us the code
> that is constructing each of those attributes, that would make things
> easier to work out what is going on.
>
>
>
> > There seems to be a bug or I'm doing something wrong, please help.
>
> It's not impossible that this is a bug, but you haven't given enough
> information to determine that. Show us the code that you've written to
> create these URLs and we should be able to get closer to a solution.
>
> Regards,
> Malcolm
>
> --
> The early bird may get the worm, but the second mouse gets the 
> cheese.http://www.pointy-stick.com/blog/


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



Re: ubuntu 6.06 deployment issues

2007-07-06 Thread Vincent Nijs

Maybe an example would be useful as well:

== Apache conf file ===


ServerName site.com
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /home/user/django/site


SetHandler python-program
PythonPath "['/home/user/django'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE recruiting_new.settings
#PythonDebug On


SetHandler None


SetHandler None


Site_media is a sub-directory in my site directory.
Admin_media is a short-cut to the django_src/django/contrib/admin/media
directory. The short-cut is also in the site directory.


== settings.py file ===

MEDIA_ROOT = '/home/user/django/site/site_media/'
ADMIN_MEDIA_PREFIX = '/admin_media/'

Templates:

TEMPLATE_DIRS = (
'/home/user/django/site/templates',
)


This works for me.

Vincent



On 7/6/07 12:09 AM, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:

> 
> On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote:
>> In my settings.py, I now have:
>> MEDIA_ROOT = '/var/www/mysite.com/media/'
>> MEDIA_URL = 'http://mysite.com/media/'
>> ADMIN_MEDIA_PREFIX = '/media/'
> 
> Err, I don't have my code or settings file handy.   This is the kind
> of thing you forget, since it just works once you have it configured.
> 
> But if you plan to serve media other than admin, you'll want to nest
> the admin media dir inside your regular media url.
> 
> So maybe you want MEDIA_URL = http://mysite.com/media/ and
> ADMIN_MEDIA_PREFIX = 'http://mysite.com/media/admin/'
> 
>> Anyway, want to say thanks again to everyone for chiming in, this is
>> one of the friendliest and most helpful user groups I've had the
>> pleasure of participating in.
> 
> That makes me feel kinda fuzzy.  :)
>   -Jeremy
> 
> > 

-- 
Vincent R. Nijs
Assistant Professor of Marketing
Kellogg School of Management, Northwestern University
2001 Sheridan Road, Evanston, IL 60208-2001
Phone: +1-847-491-4574 Fax: +1-847-491-2498
E-mail: [EMAIL PROTECTED]
Skype: vincentnijs




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



Re: problem with django dev server and subprocess.Popen

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 07:18 -0700, Filippo Santovito wrote:
> Hi all,
> I'm having a strange problem with a view.
> Its code runs well if I test if in the shell but seems to block the
> dev server:
> 
> #django 0.96
> def html2pdf(request, url = None ):
> from django.http import HttpResponse
> import subprocess
> 
> response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attachment;
> filename=documento.pdf'
> 
> #with this url (managed by django) the dev server freezes
> url = r"http://localhost:8000/;
> #using this one everything works well
> #url = r"http://www.google.it;
> output = subprocess.Popen(
>  ["/usr/bin/htmldoc" , url, "--format", "pdf14",
> "--webpage", "--charset", "iso-8859-15"],
>  stdout=subprocess.PIPE,
>  stderr=subprocess.PIPE
>  ).communicate()[0]
> 
> response.write(output)
> return response

I don't know what htmldoc does, but if it tries to access the url you
give it, you can't do that. The dev server is single threaded. It is
already serving one request (running your view), so it can't serve the
second parallel access to localhost:8000.

Regards,
Malcolm

-- 
Remember that you are unique. Just like everyone else. 
http://www.pointy-stick.com/blog/


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



problem with django dev server and subprocess.Popen

2007-07-06 Thread Filippo Santovito

Hi all,
I'm having a strange problem with a view.
Its code runs well if I test if in the shell but seems to block the
dev server:

#django 0.96
def html2pdf(request, url = None ):
from django.http import HttpResponse
import subprocess

response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment;
filename=documento.pdf'

#with this url (managed by django) the dev server freezes
url = r"http://localhost:8000/;
#using this one everything works well
#url = r"http://www.google.it;
output = subprocess.Popen(
 ["/usr/bin/htmldoc" , url, "--format", "pdf14",
"--webpage", "--charset", "iso-8859-15"],
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE
 ).communicate()[0]

response.write(output)
return response


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



Re: Redirecting within custom template tags

2007-07-06 Thread Jason F. McBrayer

neebone <[EMAIL PROTECTED]> writes:

> Just to update, I'm getting the form to post to a different url which
> handles the logic of creating the comment then redirects back to the
> article page on success. All good. My only problem is what to do if
> the form contains missing fields - I need to get back to the article
> page and re-populate the form with the entered information _plus_
> error messages (field required etc).

You are probably to the point of where you need to be writing your own
view rather than using generic views and trying to handle things in
the template tags.  It is probably best for you to just let the
article page handle form submissions, so it can handle the errors as
well.

-- 
+---+
| Jason F. McBrayer[EMAIL PROTECTED]  |
| If someone conquers a thousand times a thousand others in |
| battle, and someone else conquers himself, the latter one |
| is the greatest of all conquerors.  --- The Dhammapada|

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



Re: psycopg/psycopg2 - error at the loading

2007-07-06 Thread Thomas Guettler

Am Freitag, 6. Juli 2007 15:43 schrieb uxmal:
> hello,
> I know it isn't directly related to django, but well my django depends
> on it...
>
> yesterday I installed postgresql, mxBase, and psycopg 1.1 on openSUSE
> 10.2,
> and it worked fine until today (Django is really cool!).
>
>
>
> using psycopg :
>  Error loading psycopg module: libpq.so.5: cannot open shared object
> file: No such file or directory

This is the shared library provided by the postgres or postgres-devel
RPM.

It should be under /usr/lib or /usr/lib64.

Starting the sql shell (psql) should fail, too.

> But after upgrading it mysteriously decided to stop working...

What kind of upgrade? (SuSE, Django, Hardware, ...)

 Thomas 

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



Re: Feeds don't work with Unicode URLs

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 06:51 -0700, web-junkie wrote:
> Hi, I have a problem of getting my feeds to work with unicode URLs.
> 
>  File "/usr/local/lib/python2.4/site-packages/django/contrib/
> syndication/feeds.py", line 12, in add_domain
>url = u'http://%s%s' % (domain, url)
> 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 19: ordinal not in range(128)

You're only showing the last line of the traceback here. What is the
full traceback? In particular, I would like to see which of the calls to
add_domain() is triggering this.

Can you also print out the values of "domain" and "url" inside that
function -- or rather, print out repr(domain) and repr(url)? The easiest
way to do this is change the source to catch UnicodeDecodeError in
add_domain and then print out the values to sys.stderr and re-raise the
exception.

> 
> In all my models I correctly encoded and quoted the URLs, I traced the
> problem back to the request.path not being correctly quoted when it is
> passed to the feed object.

request.path is never passed directly to add_domain(), so it would help
if you could explain this a little more. In particular, whenever
add_domain() is called, it is using either the "link", "item_link" or
"feed_url" attributes from your Feed class. If you can show us the code
that is constructing each of those attributes, that would make things
easier to work out what is going on.
> 
> There seems to be a bug or I'm doing something wrong, please help.

It's not impossible that this is a bug, but you haven't given enough
information to determine that. Show us the code that you've written to
create these URLs and we should be able to get closer to a solution.

Regards,
Malcolm

-- 
The early bird may get the worm, but the second mouse gets the cheese. 
http://www.pointy-stick.com/blog/


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



Feeds don't work with Unicode URLs

2007-07-06 Thread web-junkie

Hi, I have a problem of getting my feeds to work with unicode URLs.

 File "/usr/local/lib/python2.4/site-packages/django/contrib/
syndication/feeds.py", line 12, in add_domain
   url = u'http://%s%s' % (domain, url)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
19: ordinal not in range(128)

In all my models I correctly encoded and quoted the URLs, I traced the
problem back to the request.path not being correctly quoted when it is
passed to the feed object.

There seems to be a bug or I'm doing something wrong, please help.
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
-~--~~~~--~~--~--~---



psycopg/psycopg2 - error at the loading

2007-07-06 Thread uxmal

hello,
I know it isn't directly related to django, but well my django depends
on it...

yesterday I installed postgresql, mxBase, and psycopg 1.1 on openSUSE
10.2,
and it worked fine until today (Django is really cool!).

But after upgrading it mysteriously decided to stop working...


using psycopg :
 Error loading psycopg module: libpq.so.5: cannot open shared object
file: No such file or directory

think it is related to a path configured somewhere, but even by re ./
configure-ing psycopg with the postgresql include paths, psycopg
continues to show the error .. :(
or it can be changed somewhere in a psycopg conf ?


so I tried to use psycopg2, but now  :
Error loading psycopg2 module: cannot import name tz
which is a bit enigmatic :)


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: No module named _md5

2007-07-06 Thread Roboto

i'm not great at this, but a shot in the dark - turn off mod_php

On Jul 5, 2:59 pm, e-gor <[EMAIL PROTECTED]> wrote:
> I have python 2.5.1, django report errors:
>
> Mod_python error: "PythonHandler django.core.handlers.modpython"
>
> Traceback (most recent call last):
>
>   File "/usr/local/lib/python2.5/site-packages/mod_python/apache.py",
> line 193, in Dispatch
> result = object(req)
>
>   File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 177, in handler
> return ModPythonHandler()(req)
>
>   File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 145, in __call__
> self.load_middleware()
>
>   File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 31, in load_middleware
> raise exceptions.ImproperlyConfigured, 'Error importing middleware
> %s: "%s"' % (mw_module, e)
>
> ImproperlyConfigured: Error importing middleware
> django.middleware.common: "No module named _md5"
>
> When i write import md5 from python command prompt i have no errors.


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



Re: --+++Does anybody have instructions to make a photo app+++--

2007-07-06 Thread Kai Kuehne

To avoid confusion: Class names *start* with an uppercase letter. :-)

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



Re: --+++Does anybody have instructions to make a photo app+++--

2007-07-06 Thread Kai Kuehne

Hi Naco,

On 7/6/07, Naco <[EMAIL PROTECTED]> wrote:
>
> sorry didnt mean to

Do you have a concrete problem or error message?
I don't know what you mean with Photo-App.
One tip: Class names are upper-case.

There is a snippet on djangosnippets.org to display
thumbnails of ImageField in the admin panel.

Greetings
Kai

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



Re: Slug (w/o using SlugField) Problems

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 11:41 +, Bryan Veloso wrote:
> Alright, well let me get the information out of the way first:
> 
> models.py
> --
> char_id = models.IntegerField('Character ID',
> primary_key=True)
> name= models.CharField('Name', maxlength=90)
> 
> def get_absolute_url(self):
> return "/characters/%s/" % (slugify(self.name))
> --
> 
> urls.py
> --
> character_detail_dict = {
> 'queryset': Character.objects.all(),
> 'template_object_name': 'character',
> 'template_name': 'characters/character_detail.html',
> 'slug_field': 'name',
> }
> 
> (r'^characters/(?P[-\w]+)/$', object_detail,
> dict(character_detail_dict)),
> --
> 
> So, the problem. This is an existing database (ran inspectdb to get
> it) so obviously I can't add a SlugField to the Character model. Now
> I've only been able to get this to work if the character's name is one
> word, without hyphens. Once you start throwing hyphens in there, it
> throws a 404. I know I'm messing something up, but it's either way too
> late for me to think straight, or I just have no idea what to fix. The
> thing that bothers me is that `name` isn't really a `slug_field` as it
> hasn't been slugified, and the only place I slugify is up there with
> the absolute URL.

All of this looks like it should be correct.

However, this assumes that the data in the "name" field of the database
really are in the same form as your URLs. If a field contains "Bob and
Jane", then your get_absolute_url() function (via slugify) willl return
"/characters/bob-and-jane/" and no amount of matching bob-and-jane
against the name field will match the record with "Bob and Jane" in
there. In other words, slugify() is an irreversible. It's also not a
one-to-one mapping, so if you names aren't sufficiently different, you
may get collisions in the URL structure.

You might need to adopt a different approach to URL construction that is
reversible (writing your own version of slugify, possibly?). 

Alternatively, can you just use the "name" values directly in the URL
(and quote them appropriately with django.utils.http.urlquote())?

>  I don't think slug_field can be a property either
> correct?

That's correct. It has to be something you can use in a QuerySet query.

However, it is easy to write your own view that does any pre-processing
you like (by calling a method on your model, even) and then passes
control onto the generic view to do the "real work". See
http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-generic-views/
 for an example.

Regards,
Malcolm

-- 
A conclusion is the place where you got tired of thinking. 
http://www.pointy-stick.com/blog/


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

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 13:25 +0200, Thomas Güttler wrote:
> Hi,
> 
> I read the source of the newforms module, but there
> seems no easy way to get i18n for dates and decimals.
[...]
> 
> The constructor of models.DecimalField could take the
> decimal separator as keyword argument and give his Input
> Widget this method. Of course the to_python() method
> must be changed, too.

We don't want to be putting presentation-layer information like this
into model fields. The presentation form is locale dependent, whereas
model fields store the concrete piece of data (the decimal number
represented by 1.23 in the C locale is always the same number, not
matter what locale you are in).

What we do need to do (prior to 1.0) is add in support for a number of
locale-aware things like this. There is both the presentation side of
things and the validation side (after all, you need to be able to
validate "1,23" when entered in the de locale, too).

I've been looking at things like cmlenz's babel package and other things
a bit lately, trying to work out what design we can use. We probably
don't want to rely on bable unconditionally (for all Django uses), since
we adhere to a "batteries included" policy as much as possible. But it
might be possible to use something like that as an option -- use it if
available. Before anybody gets all excited this isn't any kind of
official decision. It's one possible alternative. There are others, too.

What we can't do is use Python's locale module, since it's not
thread-safe and we need different per-thread locale settings, obviously,
as well as the ability to control the output via something like
translation.activate() (in fact, probably exactly using that).

So, this is on my radar, but not my current active project right at the
moment. Have a look around at what's available. Try to come up with some
ideas that will work for all locales. All contributions welcome,
naturally.

Regards,
Malcolm

-- 
Plan to be spontaneous - tomorrow. 
http://www.pointy-stick.com/blog/


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



Slug (w/o using SlugField) Problems

2007-07-06 Thread Bryan Veloso

Alright, well let me get the information out of the way first:

models.py
--
char_id = models.IntegerField('Character ID',
primary_key=True)
name= models.CharField('Name', maxlength=90)

def get_absolute_url(self):
return "/characters/%s/" % (slugify(self.name))
--

urls.py
--
character_detail_dict = {
'queryset': Character.objects.all(),
'template_object_name': 'character',
'template_name': 'characters/character_detail.html',
'slug_field': 'name',
}

(r'^characters/(?P[-\w]+)/$', object_detail,
dict(character_detail_dict)),
--

So, the problem. This is an existing database (ran inspectdb to get
it) so obviously I can't add a SlugField to the Character model. Now
I've only been able to get this to work if the character's name is one
word, without hyphens. Once you start throwing hyphens in there, it
throws a 404. I know I'm messing something up, but it's either way too
late for me to think straight, or I just have no idea what to fix. The
thing that bothers me is that `name` isn't really a `slug_field` as it
hasn't been slugified, and the only place I slugify is up there with
the absolute URL. I don't think slug_field can be a property either
correct?

Thanks in advance.

~ Bryan


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

2007-07-06 Thread Thomas Güttler

Hi,

I read the source of the newforms module, but there
seems no easy way to get i18n for dates and decimals.

widget.py:
--
class Input(Widget):
def render(self, name, value, attrs=None):
if value is None: value = ''
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
if value != '': final_attrs['value'] = force_unicode(value) # Only add 
the 'value' attribute if a value is non-empty.
return u'' % flatatt(final_attrs)
-

in render() the decimal object becomes a string.

Maybe the Widget class should have a value2str method, which
cares for this.

The constructor of models.DecimalField could take the
decimal separator as keyword argument and give his Input
Widget this method. Of course the to_python() method
must be changed, too.

Is someone already working on this?
 
 Thomas

-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543

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



Re: Redirecting within custom template tags

2007-07-06 Thread neebone



On Jul 6, 9:57 am, neebone <[EMAIL PROTECTED]> wrote:
> On Jul 6, 9:46 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On Fri, 2007-07-06 at 08:26 +, neebone wrote:
>
> > [...]
>
> > > Ok, I've got a page which uses a generic view to load the article into
> > > the template. All good so far. I've then created two template tags,
> > > list_comments and comment_form.
> > > list_comments is displayed first. The tag grabs the comments
> > > associated with article and returns a rendered template.
> > > comment_form does the same expect returns a rendered form. Now,
> > > because the article page sends the request context to its template,
> > > all the tags within the template can read the request variable too.
> > > This means, the form tag can also detect if a POST action has taken
> > > place, and add a comment (which is how it works).
>
> > > So this poses the problem - am I using the tag for the wrong thing? I
> > > dont want to send the post request off to a different url which will
> > > handle adding the commenthowever I could, instead of using a
> > > generic view, use a custom article view to detect a post request and
> > > load a different view to add the comment - redirecting back to article
> > > which solves my problem.
>
> > This is a very unusual way of coding, I suspect. You seem to be trying
> > to put the logic that would normally be part of a view (which is
> > basically the business logic and request handling side of an app) into
> > the template rendering phase instead (presentation logic). So, yes,
> > there are going to be some request handling things you can't do, at
> > least not easily.
>
> > If I were you, I would just use normal views to do this. I can't see
> > that you are saving yourself any code doing it the current way -- you
> > still have to write all the POST processing code, but you've put it in
> > the tag instead of another function.
>
> > Certainly trying to do any acting on the request using redirection or
> > anything like that is inappropriate for the rendering phase. You're
> > already into the "produce output" phase by that point and have gone past
> > the point of controlling where the output goes.
>
> > Regards,
> > Malcolm
>
> > --
> > I don't have a solution, but I admire your 
> > problem.http://www.pointy-stick.com/blog/
>
> Yeh, I see what your saying. I was trying to emulate, to a degree, how
> the django comment stuff works (without actually looking at the code).
> The tag itself is basic - it just calls a comment function which
> handles adding the comment.
>
> I wanted the comments to be dropped into any page (using generic
> relations to any given model). If anything, the main reason I needed
> the redirect was because the comments get listed first, then the form
> gets processed. But obviously when the new comment has been added, the
> list has already been rendered - meaning the new comment wont appear
> until the page is refreshed!
>
> Ok, back to the drawing board... Thanks Malcom.


Just to update, I'm getting the form to post to a different url which
handles the logic of creating the comment then redirects back to the
article page on success. All good. My only problem is what to do if
the form contains missing fields - I need to get back to the article
page and re-populate the form with the entered information _plus_
error messages (field required etc).

Any way to send a POST request from a view to a given url similar to
the way Client works in django.test.client?


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



Re: Checkout with Tortoise SVN

2007-07-06 Thread Daniel S. Reichenbach

Hi,

> I'm on Windows and using Tortoise SVN, which has worked nice so far
> for other projects, but not for django. I dont even get an error
> message. http://code.djangoproject.com/svn/django/trunk/django is the
> right source?
If you are behind a Squid proxy, or any other proxy that restricts
HTTP request methods, you might want to check the SubVersion FAQ (
which applies to TortoiseSVN, too). Namely the HowTo section, see:
http://subversion.tigris.org/faq.html#proxy

http://subversion.tigris.org/faq.html#http-methods lists the used HTTP
methods.

With kind regards,
Daniel

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



Re: Checkout with Tortoise SVN

2007-07-06 Thread Horst Gutmann

It might be a problem with your proxy server. This error looks like
Tortoise sends a REPORT command to the SVN server that the proxy server
doesn't understand. You can find some details about this in the SVN FAQ [1].

[1] http://subversion.tigris.org/faq.html#proxy

- Horst

Gary Doades wrote:
> I can't say I've used Tortoise SVN through a proxy before and I've never 
> seen that error. You might be better off asking the guys over at 
> Tortoise SVN what that error means.
> 
> Regards,
> Gary.
> 
> tsc wrote:
>> Sorry, but I've forgotten to set the proxy server in Tortoise. Now it
>> worked a little better. But other repositories work witout the proxy
>> settings too, hmm strange.
>> Now I get another error:
>> REPORT request failed on '/svn/!svn/vcc/default'
>> REPORT of '/svn/!svn/vcc/default': 400 Bad Request (http://
>> code.djangoproject.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: Checkout with Tortoise SVN

2007-07-06 Thread Gary Doades

I can't say I've used Tortoise SVN through a proxy before and I've never 
seen that error. You might be better off asking the guys over at 
Tortoise SVN what that error means.

Regards,
Gary.

tsc wrote:
> Sorry, but I've forgotten to set the proxy server in Tortoise. Now it
> worked a little better. But other repositories work witout the proxy
> settings too, hmm strange.
> Now I get another error:
> REPORT request failed on '/svn/!svn/vcc/default'
> REPORT of '/svn/!svn/vcc/default': 400 Bad Request (http://
> code.djangoproject.com)
> 
> 
> > 

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



Re: Running fast cgi server

2007-07-06 Thread KpoH

look is an example
http://www.djangoproject.com/documentation/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache

[EMAIL PROTECTED] пишет:
> Hi,
>  Instead of using "python manage.py " to start fast cgi
> server. How to start a server using a single python script.
>
> Thank
> Chatchai
>
>
>   

-- 
Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L.
http://www.asterisksupport.ru
http://www.asterisk-support.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
-~--~~~~--~~--~--~---



caching and authentication

2007-07-06 Thread patrickk

when having a header where the username and a logout-button is  
displayed, how do you cache this page/view?

when using the per-view cache, the authentication doesn´t work  
anymore (that means that my username is still displayed in the  
header, although I´m already logged out).
when using the low-level cache it works, but we have to split the  
templates:
- first render (and cache) the site without the header
- then render the cached template with the header

is this (using the low-level cache) the best way doing this?

thanks,
patrick

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



Re: CharField vs. CharField

2007-07-06 Thread Thomas Güttler

Am Freitag, 6. Juli 2007 10:41 schrieb Malcolm Tredinnick:
> On Fri, 2007-07-06 at 10:35 +0200, Thomas Güttler wrote:
> > Hi,
> >
> > I think it is bad, that there are two CharField classes.
...
> Any particular reason you only want to change CharField? Or any
> technical reason why you think the current situation is bad?

No, this was just an example. I think the base class (and the
used postfix) should be changed to InputField.

But nevermind I can live with the current name, too.

 Thomas

-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543

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



Running fast cgi server

2007-07-06 Thread meledictas

Hi,
 Instead of using "python manage.py " to start fast cgi
server. How to start a server using a single python script.

Thank
Chatchai


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



Re: Attributes for ManyToMany

2007-07-06 Thread patrick k.

here it is:
http://code.djangoproject.com/browser/django/trunk/tests/modeltests/ 
m2m_intermediary/models.py

Am 06.07.2007 um 11:03 schrieb Thomas Güttler:

>
> Hi,
>
> How can you add attributes to ManyToMany Relations?
>
> Given the example:
> http://www.djangoproject.com/documentation/models/many_to_many/
>
> Publication -- N:M -- Article
>
> How can you store the page number of the published article?
>
>  Thomas
>
> -- 
> Thomas Güttler, http://www.tbz-pariv.de/
> Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
> TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
> Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543
>
> >


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



Re: Checkout with Tortoise SVN

2007-07-06 Thread tsc

Sorry, but I've forgotten to set the proxy server in Tortoise. Now it
worked a little better. But other repositories work witout the proxy
settings too, hmm strange.
Now I get another error:
REPORT request failed on '/svn/!svn/vcc/default'
REPORT of '/svn/!svn/vcc/default': 400 Bad Request (http://
code.djangoproject.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: Attributes for ManyToMany

2007-07-06 Thread patrick k.

usually, if you want to have additional fields with a m2m-relation  
you have to use an intermediary table with a foreignkey (e.g. with  
edit-inline).
if this page is working, there´s an example:
http://www.djangoproject.com/documentation/models/

howerver, if you want to have the page-number for an article you may  
just add a field "page_number" to your article-model.

patrick

Am 06.07.2007 um 11:03 schrieb Thomas Güttler:

>
> Hi,
>
> How can you add attributes to ManyToMany Relations?
>
> Given the example:
> http://www.djangoproject.com/documentation/models/many_to_many/
>
> Publication -- N:M -- Article
>
> How can you store the page number of the published article?
>
>  Thomas
>
> -- 
> Thomas Güttler, http://www.tbz-pariv.de/
> Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
> TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
> Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543
>
> >


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



Attributes for ManyToMany

2007-07-06 Thread Thomas Güttler

Hi,

How can you add attributes to ManyToMany Relations?

Given the example:
http://www.djangoproject.com/documentation/models/many_to_many/

Publication -- N:M -- Article

How can you store the page number of the published article?

 Thomas

-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543

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



Re: Redirecting within custom template tags

2007-07-06 Thread neebone



On Jul 6, 9:46 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-07-06 at 08:26 +, neebone wrote:
>
> [...]
>
>
>
> > Ok, I've got a page which uses a generic view to load the article into
> > the template. All good so far. I've then created two template tags,
> > list_comments and comment_form.
> > list_comments is displayed first. The tag grabs the comments
> > associated with article and returns a rendered template.
> > comment_form does the same expect returns a rendered form. Now,
> > because the article page sends the request context to its template,
> > all the tags within the template can read the request variable too.
> > This means, the form tag can also detect if a POST action has taken
> > place, and add a comment (which is how it works).
>
> > So this poses the problem - am I using the tag for the wrong thing? I
> > dont want to send the post request off to a different url which will
> > handle adding the commenthowever I could, instead of using a
> > generic view, use a custom article view to detect a post request and
> > load a different view to add the comment - redirecting back to article
> > which solves my problem.
>
> This is a very unusual way of coding, I suspect. You seem to be trying
> to put the logic that would normally be part of a view (which is
> basically the business logic and request handling side of an app) into
> the template rendering phase instead (presentation logic). So, yes,
> there are going to be some request handling things you can't do, at
> least not easily.
>
> If I were you, I would just use normal views to do this. I can't see
> that you are saving yourself any code doing it the current way -- you
> still have to write all the POST processing code, but you've put it in
> the tag instead of another function.
>
> Certainly trying to do any acting on the request using redirection or
> anything like that is inappropriate for the rendering phase. You're
> already into the "produce output" phase by that point and have gone past
> the point of controlling where the output goes.
>
> Regards,
> Malcolm
>
> --
> I don't have a solution, but I admire your 
> problem.http://www.pointy-stick.com/blog/


Yeh, I see what your saying. I was trying to emulate, to a degree, how
the django comment stuff works (without actually looking at the code).
The tag itself is basic - it just calls a comment function which
handles adding the comment.

I wanted the comments to be dropped into any page (using generic
relations to any given model). If anything, the main reason I needed
the redirect was because the comments get listed first, then the form
gets processed. But obviously when the new comment has been added, the
list has already been rendered - meaning the new comment wont appear
until the page is refreshed!

Ok, back to the drawing board... Thanks Malcom.


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



Re: Checkout with Tortoise SVN

2007-07-06 Thread Gary Doades

I use Tortoise SVN for windows XP without any problems. I update from 
trunk almost daily.

It's certainly the right url that you have. What version of Tortoise SVN 
are you using? Can you browse the repository?

The other way to get it would be to use the Subversion command line 
tools themselves under windows. This works too.

Cheers,
Gary.

tsc wrote:
> Hello,
> 
> I'm on Windows and using Tortoise SVN, which has worked nice so far
> for other projects, but not for django. I dont even get an error
> message. http://code.djangoproject.com/svn/django/trunk/django is the
> right source?
> So are there other ways to get the latest version?
> 
> Thanks, tsc
> 
> 
> > 

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



Re: Redirecting within custom template tags

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 08:26 +, neebone wrote:
[...]
> Ok, I've got a page which uses a generic view to load the article into
> the template. All good so far. I've then created two template tags,
> list_comments and comment_form.
> list_comments is displayed first. The tag grabs the comments
> associated with article and returns a rendered template.
> comment_form does the same expect returns a rendered form. Now,
> because the article page sends the request context to its template,
> all the tags within the template can read the request variable too.
> This means, the form tag can also detect if a POST action has taken
> place, and add a comment (which is how it works).
> 
> So this poses the problem - am I using the tag for the wrong thing? I
> dont want to send the post request off to a different url which will
> handle adding the commenthowever I could, instead of using a
> generic view, use a custom article view to detect a post request and
> load a different view to add the comment - redirecting back to article
> which solves my problem.

This is a very unusual way of coding, I suspect. You seem to be trying
to put the logic that would normally be part of a view (which is
basically the business logic and request handling side of an app) into
the template rendering phase instead (presentation logic). So, yes,
there are going to be some request handling things you can't do, at
least not easily.

If I were you, I would just use normal views to do this. I can't see
that you are saving yourself any code doing it the current way -- you
still have to write all the POST processing code, but you've put it in
the tag instead of another function.

Certainly trying to do any acting on the request using redirection or
anything like that is inappropriate for the rendering phase. You're
already into the "produce output" phase by that point and have gone past
the point of controlling where the output goes.

Regards,
Malcolm

-- 
I don't have a solution, but I admire your problem. 
http://www.pointy-stick.com/blog/


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



Checkout with Tortoise SVN

2007-07-06 Thread tsc

Hello,

I'm on Windows and using Tortoise SVN, which has worked nice so far
for other projects, but not for django. I dont even get an error
message. http://code.djangoproject.com/svn/django/trunk/django is the
right source?
So are there other ways to get the latest version?

Thanks, tsc


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



Re: CharField vs. CharField

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 10:35 +0200, Thomas Güttler wrote:
> Hi,
> 
> I think it is bad, that there are two CharField classes.
> 
> One for OR-Mapping and one for HTML (new)forms. 
> 
> Why not change the HTML classes to ...InputField?

There are lots of names that are used in both model.fields and
newforms.fields. Most of the names are very natural for the type of
thing they describe. Model fields are only used in models and form
fields are only used in forms, so there shouldn't be too much confusion,
since you are usually going to be working on one or the other at any
given moment.

InputField, on the other hand could mean anything (there are lots of
different types of input fields in HTML); it isn't very
self-descriptive.

Any particular reason you only want to change CharField? Or any
technical reason why you think the current situation is bad?

Regards,
Malcolm

-- 
The sooner you fall behind, the more time you'll have to catch up. 
http://www.pointy-stick.com/blog/


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



CharField vs. CharField

2007-07-06 Thread Thomas Güttler

Hi,

I think it is bad, that there are two CharField classes.

One for OR-Mapping and one for HTML (new)forms. 

Why not change the HTML classes to ...InputField?

 Thomas

-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543

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



Re: Redirecting within custom template tags

2007-07-06 Thread neebone



On Jul 6, 9:13 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-07-06 at 08:04 +, neebone wrote:
> > Hi,
>
> > I'm trying to roll my own comments custom template tag and need to
> > action a browser redirect on successful comment posting. My problem is
> > that you can't just return HttpResponseRedirect and expect it to be
> > executed. Is there an "official" way to get the middleware to action
> > the redirect from inside the tag?
>
> I think you're confusing a few unrelated things here. Template tags are
> just a way to produce strings which are inserted into the output. They
> are completely unaware of HTTP or anything like that.
>
> If you want the browser to redirect somewhere after the form is posted,
> that needs to be done by the view that handles the form posting. Now,
> you might want to include where to redirect to in the form itself, which
> is information your template tag could include as a hidden form element
> (for example), but, again, the tag is just producing a string that is
> included verbatim.
>
> One final note: if you do include the final target in the form, remember
> to verify it is correct before the subsequent view acts on it, since the
> value can be changed by anybody submitting the form. Encrypting the
> target value or including a hash of the target with a secret key are a
> couple of approaches there.
>
> Regards,
> Malcolm
>
> --
> Honk if you love peace and quiet.http://www.pointy-stick.com/blog/

Thanks for quick reply. Ok, let me explain in a little more detail

Ok, I've got a page which uses a generic view to load the article into
the template. All good so far. I've then created two template tags,
list_comments and comment_form.
list_comments is displayed first. The tag grabs the comments
associated with article and returns a rendered template.
comment_form does the same expect returns a rendered form. Now,
because the article page sends the request context to its template,
all the tags within the template can read the request variable too.
This means, the form tag can also detect if a POST action has taken
place, and add a comment (which is how it works).

So this poses the problem - am I using the tag for the wrong thing? I
dont want to send the post request off to a different url which will
handle adding the commenthowever I could, instead of using a
generic view, use a custom article view to detect a post request and
load a different view to add the comment - redirecting back to article
which solves my problem.

BUT! That means my comment code isnt self contained within the
tags

I hope that made sense.


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



Re: Redirecting within custom template tags

2007-07-06 Thread Malcolm Tredinnick

On Fri, 2007-07-06 at 08:04 +, neebone wrote:
> Hi,
> 
> I'm trying to roll my own comments custom template tag and need to
> action a browser redirect on successful comment posting. My problem is
> that you can't just return HttpResponseRedirect and expect it to be
> executed. Is there an "official" way to get the middleware to action
> the redirect from inside the tag?

I think you're confusing a few unrelated things here. Template tags are
just a way to produce strings which are inserted into the output. They
are completely unaware of HTTP or anything like that.

If you want the browser to redirect somewhere after the form is posted,
that needs to be done by the view that handles the form posting. Now,
you might want to include where to redirect to in the form itself, which
is information your template tag could include as a hidden form element
(for example), but, again, the tag is just producing a string that is
included verbatim.

One final note: if you do include the final target in the form, remember
to verify it is correct before the subsequent view acts on it, since the
value can be changed by anybody submitting the form. Encrypting the
target value or including a hash of the target with a secret key are a
couple of approaches there.

Regards,
Malcolm

-- 
Honk if you love peace and quiet. 
http://www.pointy-stick.com/blog/


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



Redirecting within custom template tags

2007-07-06 Thread neebone

Hi,

I'm trying to roll my own comments custom template tag and need to
action a browser redirect on successful comment posting. My problem is
that you can't just return HttpResponseRedirect and expect it to be
executed. Is there an "official" way to get the middleware to action
the redirect from inside the tag?

FYI, I realised this bug because I have a separate tag which displays
comments BEFORE the form tag gets loaded (and hence only adds the new
comment AFTER all the existing comments get rendered by the previous
tag in the template...doh!)

Cheers guys/gals


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



Pickle model fields with cache...

2007-07-06 Thread Jens Diemer


I have insert a small cache mechanism. So pickle.loads() would only used for 
the 
first _get_value():

-

class Preference(models.Model):
 def __init__(self, *args, **kwargs):
 self._cache = {}
 super(Preference, self).__init__(*args, **kwargs)

 ...

 def _get_value(self):
 if "value" in self._cache:
 value = self._cache["value"]
 else:
 value = pickle.loads(self._value)
 self._cache["value"] = value
 return value

 def _set_value(self, value):
 self._cache["value"] = value
 self._value = pickle.dumps(value)

 _value = models.TextField()
 value = property(_get_value, _set_value)

 ...

-


-- 
Mfg.

Jens Diemer



A django powered CMS: http://www.pylucid.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: ubuntu 6.06 deployment issues

2007-07-06 Thread Graham Dumpleton

On Jul 6, 2:59 pm, John-Scott <[EMAIL PROTECTED]> wrote:
> On Jul 6, 12:29 am, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
>
> > Hmmm, I'm not sure the documentation is actually accurate. When you
> > use manage.py to run up development server for Django, it will
> > automatically add the parent directory of where the manage.py file is
> > located into sys.path for you. Thus, there isn't strictly a need to
> > add it to PYTHONPATH to get it to work in the first place.
>
> > So, the answer is that YES, for mod_python you must use the PythonPath
> > directive to specify the parent directory of where manage.py is
> > located in order for your settings file to be found correctly.
>
> > Graham
>
> Graham - I was suspicious of that. I remember reading that manage.py
> took care of setting all the environment variables for the development
> server and interactive shell. But it didn't seem possible for
> mod_python to have any idea where our projects are implicitly. Should
> we file a doc bug?

Someone can correct me, but I think it gets a bit more confusing than
that, so there is possibly other changes which should be made to the
mod_python documentation.

When using manage.py it imports settings.py explicitly, thus there is
no need to define DJANGO_SETTINGS_MODULE like with mod_python to say
what the actual settings module name is. At this point though, only
the directory containing manage.py is effectively in sys.path. This
would mean that where you have in urls.py:

  (r'^mysite1/', include('mysite1.apps.foo.urls.foo')),

it would actually fail to find the referenced module.

In searching through Django, the only place it adds the parent
directory to sys.path so that it might find that referenced module is:

def setup_environ(settings_mod):
"""
Configure the runtime environment. This can also be used by
external
scripts wanting to set up a similar environment to manage.py.
"""
# Add this project to sys.path so that it's importable in the
conventional
# way. For example, if this file (manage.py) lives in a directory
# "myproject", this code would add "/path/to/myproject" to
sys.path.
project_directory = os.path.dirname(settings_mod.__file__)
project_name = os.path.basename(project_directory)
sys.path.append(os.path.join(project_directory, '..'))
project_module = __import__(project_name, {}, {}, [''])
sys.path.pop()

If you look carefully, what it does is append the parent directory to
sys.path and imports the name of the site directory itself. This has
the effect of importing the __init__.py in the site directory. It then
removes the parent directory from sys.path.

Even though it has removed the parent directory from sys.path, the
import of the module referenced in urls.py by the site name still
works because of the presence of the 'mysite1' module in sys.modules.
Ie., Python sees that module, works out from __file__ of the module
where it is located and searches for the submodule relative to that
directory.

So, importing modules by site package root is okay, but problem is
that the site directory itself is still in sys.path. This means one
can actually do:

  (r'^mysite1/', include('apps.foo.urls.foo')),

Ie., one can leave out the site name in the module path and it will
still work.

Some people do imports this way as it means that if you rename the
site you don't have to change the urls.py file. Also, easier to
develop reusable components that you can copy from one project to
another.

The problem with this is that if an application which uses these
imports without the site name in them is hosted on mod_python, it will
not work. This is because not only do you have to set PythonPath to
include the parent directory of the site, you also have to list the
site directory path itself. Ie.,

  PythonPath "['/path/to/parent','/path/to/parent/mysite1'] +
sys.path"

I am not sure this is clearly mentioned in the mod_python document for
Django or not.

Certainly, the need to do this is explained on the mailing list every
so often, so there must be some confusion about it.

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