Re: Change password / Log out doesn't work with apache2

2005-11-23 Thread [EMAIL PROTECTED]

I change the base.html, maybe not a good idea, but it works now:

-{% trans 'Welcome,' %} {% if
user.first_name %}{{ user.first_name }}{% else %}{{ user.username }}{%
endif %}. {% block userlinks %}{% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %}
+{% trans 'Welcome,' %} {% if
user.first_name %}{{ user.first_name }}{% else %}{{ user.username }}{%
endif %}. {% block userlinks %}{% trans 'Change password' %} / {% trans 'Log out' %}{% endblock %}



Re: Change password / Log out doesn't work with apache2

2005-11-23 Thread Kenneth Gonsalves

On Thursday 24 Nov 2005 9:45 am, wang bin wrote:
> hi, when I trying to setup my project on apache2 with mod_python,
> following the document everything seems good except the Change
> password / Log out doesn't work. When I click the link I get the
> "The requested URL /admin/password_change/ was not found on this
> server." Error, could anyone tell me the reason or how to solve
> this problem ?

i have the same problem. my admin site url is:
localhost/myapp/admin/
but logout points to:
localhost/admin/logout instead of
localhost/myapp/admin/logout

same with change password - there is a bug here

-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!


Re: Django Trac Spam

2005-11-23 Thread Jacob Kaplan-Moss


On Nov 23, 2005, at 10:12 PM, Adrian Holovaty wrote:

On 11/23/05, Tom Tobin <[EMAIL PROTECTED]> wrote:
Someone's been spamming the Django Trac today, screwing up tickets  
and

whatnot.  Is there any way to fix and/or prevent this?

I've been deleting 'em as they come in. Maybe we can hack Trac so that
it silently ignores comments that include naughty words.


I've also been keeping an eye on it.  FYI, this is ticket #454 in  
Trac itself (http://projects.edgewall.com/trac/ticket/454); I'm about  
to jump in #trac and bug people about it.


Jacob


Change password / Log out doesn't work with apache2

2005-11-23 Thread wang bin
hi, when I trying to setup my project on apache2 with mod_python,
following the document everything seems good except the Change
password / Log out doesn't work. When I click the link I get the "The
requested URL /admin/password_change/ was not found on this server."
Error, could anyone tell me the reason or how to solve this problem ?


Django Trac Spam

2005-11-23 Thread Tom Tobin

Someone's been spamming the Django Trac today, screwing up tickets and
whatnot.  Is there any way to fix and/or prevent this?


'log' is not a valid tag library

2005-11-23 Thread Kenneth Gonsalves

hi
am using the latest svn up - did init and install etc - main site 
works fine. When i try to log into admin, after entering username 
and password i get this error:

'log' is not a valid tag library
Request Method: GET
Request URL:http://localhost/bambanks/admin/
Exception Type: TemplateSyntaxError
Exception Value:'log' is not a valid tag library
Exception Location: 
/usr/lib/python2.3/site-packages/django/core/template/defaulttags.py 
in do_load, line 631

any clues?
-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!


Re: Extend list template of admin app?

2005-11-23 Thread Adrian Holovaty

On 11/23/05, oggie rob <[EMAIL PROTECTED]> wrote:
> How many more changes are expected on that branch? And is there an ETA
> on when it might merge/if it might merge with the head?

The branch is done. I'm planning on merging it in the next couple of
days -- or as soon as tonight or tomorrow, if I can flee the
Thanksgiving festivities effectively.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


Re: Performance tuning tips?

2005-11-23 Thread Milton Waddams

no idea why I put it there, I tried moving it to the top, the response
times went back to around 3 seconds.

On 11/24/05, Eugene Lazutkin <[EMAIL PROTECTED]> wrote:
>
> Interesting that the session middleware was the culprit. BTW, why did you
> put it at the end of your middleware list?
>
> The default order is:
>
> "django.middleware.sessions.SessionMiddleware",
> "django.middleware.common.CommonMiddleware",
> "django.middleware.doc.XViewMiddleware",
>
> (see
> http://www.djangoproject.com/documentation/settings/#middleware-classes).
>
> Thanks,
>
> Eugene


Re: admin suggestions

2005-11-23 Thread oggie rob

Oops! I guess I hadn't tried it as much as I thought!
Unfortunately #2 there causes a problem when they aren't overridden (a
TypeError if '%s' is not included in the post_url).
I guess a possible fix is to do a find, e.g.:
if post_url.find('%s') >= 0:
   post_url = post_url % pk_value
return HttpResponseRedirect(post_url)
but that is not as clean as I would like.
Anyway it points out that the post_url_continue value may run into the
same problem if it is overridden with a %s argument, however it is
quite unlikely anybody would do that.

 -rob



Re: raw_id_admin

2005-11-23 Thread Adrian Holovaty

On 11/23/05, Grigory Fateyev <[EMAIL PROTECTED]> wrote:
> class Article(meta.Model):
> author = meta.ForeignKey(User, raw_id_admin=True)
>
> vews/articles.py generate form:
>
> Author: {{ form.author }}
> {% if form.author.errors %}*** {{ form.author.errors|join:", " }}
> {% endif % }
>
> If the field is filled by username, form give an error. If it filled
> user_id form works correct. How to make form that can be filled by
> username insted of user_id?

Hi Grigory,

raw_id_admin supports only entry of IDs (primary key fields).

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


Re: init fails

2005-11-23 Thread Adrian Holovaty

On 11/23/05, David Ascher <[EMAIL PROTECTED]> wrote:
> I've had the same problem in cases when I forget to use named parameters to
> my FloatFields, which then generates invalid SQL with "None" in it.  That's
> a bug, IMO.  I may even try to fix it =).

As of changeset 1314 (http://code.djangoproject.com/changeset/1314),
the model validator (which runs automatically during "django-admin
runserver") complains if you don't max_digits and decimal_places on
FloatFields. Is it missing an edge case?

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


Re: Atom and web services interfaces

2005-11-23 Thread Adrian Holovaty

On 11/23/05, tonemcd <[EMAIL PROTECTED]> wrote:
> I'm thinking of using Django as the front-end to an experimental
> Atom-enabled 'store' as outlined by Joe Gregorio at
> http://www.xml.com/pub/a/2005/09/21/atom-store-web-database.html
> [...]
> Any thoughts gratefully received.

Hi Tone,

Django's very REST-friendly, so the task should be straightforward.
Feel free to post specific questions, and keep us posted on how it's
coming!

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


Sequence in PostgreSQL is not updated when doing manual insert

2005-11-23 Thread pgross

In order to load some test data into the database, I'm using the
following code:

from django.core.db import db
cursor = db.cursor()

cursor.execute("insert into cities (id, name) values (1,
'Chicago');")
cursor.execute("insert into cities (id, name) values (2,
'Miami');")
 ...

This works fine, but then when I try to use django later to add to this
table, I get an error:

cities.City(name='Madison').save()

ERROR: duplicate key violates unique constraint "cities_pkey"

I've tracked down the problem, and it seems that when I do my manual
inserts, the sequence (cities_id_seq) that PostgreSQL uses for primary
keys isn't updated.  Therefore, when I try to save my object with
django, the primary key collides with an already existing key.

I've implemented a simple fix by manually settings the sequence value
after I do my inserts, but I'm wondering why django/postgresql doesn't
do the right thing.  Has anyone seen this before?



Model updates in early development stages

2005-11-23 Thread Maniac


There is a thread in django-developers list talking about the way Django 
and Rails handle frequent changes to models on early stages of 
development ('prototyping' - to sound cool). Neither framwork does this 
transparently which is understandable because it's definitely hard and 
even arguably desirable at all :-).


I'd like to share my method of doing this task where I use one 
undocumented feature that Adrian Holovaty once mentioned in this list. 
I'm writing here because I'm not sure if it's ready for the Cookbook in 
the wiki. May be everyone will reply that I'm doing it incredibly 
painful way and should just read this URL and that URL to do it right 
:-). Also feel free to correct my English since it's not my native 
language. So to the point.


1. I begin designing a model to the whole depths of my current domain 
knowledge. But I'm absolutely sure that in a near future my knowledge 
will change and will require changing models.


2. Significant changes to models that require database changes are: 
adding/removing/renaming fields, adding/removing/renaming tables, 
changing types and sizes of fields. But there is no point of doing 
something with database when adding some custom method or changing META 
class.


3. When database change is required I use:

   django-admin.py sqlreset 

... which effectvely wipes out entire application structure then creates 
new one.


4. But this also wipes all the test data in your database and if you had 
to recreate it by hand each time it would defeat the whole point of this 
method :-). Luckily you can easily automate it. After creating the 
structure 'sqlreset' tries to locate and execute SQL script in


   /apps//sql/.sql

This script should contain SQL statements that create test data for your 
application.


Creating this file from scratch by hand is boring. Instead I create all 
the data using shiny Django's admin interface and then use database 
tools to generate such script. For PostgreSQL this utility called 
pg_dump and can be used like this:


   pg_dump -a -D  > .sql

Options mean:
-a: dump only data, not structure (because structure will be created by 
sqlreset)

-D: use INSERT statements with column names

Then I edit the resulting file removing all core data leaving only 
INSERTS into my applications tables.


It still sounds a bit complex but I've done it only first time. On all 
subsequent changes it's easier to correct this file by hand. And often 
it's not even required when you, for example, just change the length of 
a text field.


6. The 'sqlreset' outputs all SQL statements to console. To further 
automate the task I redirect this output into command-line database 
client instead of copy-pasting it by hand:


   django-admin.py sqlreset  | psql 


raw_id_admin

2005-11-23 Thread Grigory Fateyev

Hello!

In model i use this field:

class Article(meta.Model):
author = meta.ForeignKey(User, raw_id_admin=True)

vews/articles.py generate form:

Author: {{ form.author }} 
{% if form.author.errors %}*** {{ form.author.errors|join:", " }}
{% endif % }  

If the field is filled by username, form give an error. If it filled
user_id form works correct. How to make form that can be filled by
username insted of user_id?

-- 
Всего наилучшего!
greg [at] anastasia [dot] ru Григорий.


Re: init fails

2005-11-23 Thread David Ascher
On 11/23/05, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
On Wednesday 23 Nov 2005 2:46 pm, Kenneth Gonsalves wrote:> hi> i have a working django app. i did an svn checkout of the app> into another machine. When i try to run init, i am getting this> error:
>> Error: The database couldn't be initialized.> name 'true' is not defined>  this is with postgres - any clues?ok - solved, that was a syntax error in my modelI've had the same problem in cases when I forget to use named parameters to my FloatFields, which then generates invalid SQL with "None" in it.  That's a bug, IMO.  I may even try to fix it =).
--david


Re: Sequence in PostgreSQL is not updated when doing manual insert

2005-11-23 Thread Jacob Kaplan-Moss


On Nov 23, 2005, at 11:15 AM, pgross wrote:

I've tracked down the problem, and it seems that when I do my manual
inserts, the sequence (cities_id_seq) that PostgreSQL uses for primary
keys isn't updated.  Therefore, when I try to save my object with
django, the primary key collides with an already existing key.

I've implemented a simple fix by manually settings the sequence value
after I do my inserts, but I'm wondering why django/postgresql doesn't
do the right thing.  Has anyone seen this before?


Yeah, this is an annoying postgresql wart.  We've run into it enough  
that we've rolled the fix into the django-admin utility.  "django- 
admin sqlsequencereset " will print out the statements to fix  
the sequences.


Programmatically, you can get at this SQL from the  
django.core.management.get_sql_sequence_reset() function.


Jacob



Re: Performance tuning tips?

2005-11-23 Thread Eugene Lazutkin

Interesting that the session middleware was the culprit. BTW, why did you 
put it at the end of your middleware list?

The default order is:

"django.middleware.sessions.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.doc.XViewMiddleware",

(see 
http://www.djangoproject.com/documentation/settings/#middleware-classes).

Thanks,

Eugene 





Atom and web services interfaces

2005-11-23 Thread tonemcd

Hello,

I'm thinking of using Django as the front-end to an experimental
Atom-enabled 'store' as outlined by Joe Gregorio at
http://www.xml.com/pub/a/2005/09/21/atom-store-web-database.html

I'm a real newbie to Django, having spent the last 7 years in
Zope-land, and am looking at Django as an adjunct to the many many Zope
systems we run here (I just had reason to play around with
PageTemplates and PythonScripts this morning and the frustration was
intense!)

Any thoughts gratefully received.

Tone



Re: Paginating complex queries

2005-11-23 Thread Afternoon



On 23 Nov 2005, at 15:07, Simon Willison wrote:

The aim with the template system has always been to keep it de- 
coupled from the request/response stuff, so it can be used as a  
standalone component. It's hard to see how the request object could  
be exposed to custom tags without breaking that separation. That  
said, it would be enable some very neat custom template tag tricks.


Right. I think that decoupling is a Good Thing. I use template  
systems for a variety of purposes outside of web app development and  
it's nice to have a standard option for all requirements.


I personally haven't bashed my head against Django that much yet so I  
feel I'm getting a bit out of my depth here. Perhaps the best thing  
is just to keep explicitly passing in the pagination arguments.




Afternoon, man about the Internet -- http://aftnn.org/




Re: Paginating complex queries

2005-11-23 Thread Simon Willison



On 23 Nov 2005, at 14:59, Afternoon wrote:

Is there a way that the request object could be exposed to custom  
tag code, but not the template itself?


The aim with the template system has always been to keep it de- 
coupled from the request/response stuff, so it can be used as a  
standalone component. It's hard to see how the request object could  
be exposed to custom tags without breaking that separation. That  
said, it would be enable some very neat custom template tag tricks. 


Re: Paginating complex queries

2005-11-23 Thread Afternoon



On 23 Nov 2005, at 14:42, Colin Howlett wrote:


+1 to putting the request object into the context as standard, or at
least into DjangoContext. I've only been playing with Django for a few
days, and it's already obvious that this single change would make
writing useful custom tags a whole lot easier.


This also means that there's more of a temptation to use the request  
object directly in template logic.


Is there a way that the request object could be exposed to custom tag  
code, but not the template itself?




Afternoon, man about the Internet -- http://aftnn.org/




Re: Bi-Directional ManyToMany

2005-11-23 Thread plisk

Its not that needs to be done asap, i'll wait until new-admin merges
and then give it a try.



Extend list template of admin app?

2005-11-23 Thread Benjamin Reitzammer

Hi,
I would like to add some custom mass-editing capabilities to the admin
app, and for this I would like to know if it's possible to extend the
list template of the admin app.

Looking at the code in django/contrib/admin/views/main.py I see, that
the template is entirely dynamically created (which is obvious as the
admin app doesn't know which model there will be), which makes
extending the template impossible.

But maybe there's some hook or some other trick to allow this.

Thanks in advance

Benjamin



Re: Performance tuning tips?

2005-11-23 Thread Milton Waddams

Yes I am running openload on localhost, I don't trust my DSL enough to
get accurate results :(

my MIDDLEWARE_CLASSES:

"django.middleware.common.CommonMiddleware",
"django.middleware.doc.XViewMiddleware",
"django.middleware.sessions.SessionMiddleware",

I'm caching on a view by view basis (hope that's the correct
terminology) using this code.

index = cache_page(index, 180)

After looking at those middleware classes I removed the session
middleware and it has dropped response times to a very respectable:

Total TPS: 144.27
Avg. Response time:  0.034 sec.
Max Response time:   0.675 sec
Total Requests:1951
Total Errors: 0

So I believe my problem was the session middleware. At present I don't
require the session middleware (I will move the admin). However in the
near future the forum will change to requiring user authentication,
any thoughts about the best way for me to enable caching with the
sessions enabled? If need be what would help my problems is if the
session caching time can't be improved then if sessions are enabled
only for certain views? As an example, in one of my sites I have no
session requirements, except when generating a captcha and then
verifying the captcha when the comment is submitted.

Thanks for your help!



On 11/23/05, Eugene Lazutkin <[EMAIL PROTECTED]> wrote:
>
> For comparison I ran openload against my blog page
> (http://lazutkin.com/blog/). It is 38012 bytes at the moment. I don't know
> how many db transactions required to build it, but with cache it's a moot
> point anyway. Incidentally I use "file:" cache. The site is hosted with
> DreamHost --- cheap community hosting company.
>
> Over Internet using my home connection I got:
>
> Total TPS:  12.54
> Avg. Response time:  0.781 sec.
> Max Response time:   1.641 sec
> Total Requests: 503
> Total Errors: 0
>
> With average ping ~40ms, it correspondes to ~400kbps, which looks about
> right order of magnitude.
>
> Judging by your times you probably used "localhost" for load testing, or you
> had some intermediate caching, or you have really fat connection to get 24k
> in 20ms. ;-)
>
> I don't know what the exact problem is, but I would suggest to check basic
> stuff first: check footprint (maybe swapping is an issue); check database
> speed (e.g., using Django's database API with some rudimentary timing
> program); if you run db and apache/django on the same server, try to
> separate them (sometimes there is an interference between programs); to get
> realistic test results, try to run openload from separate computer (or
> several copies of openload from separate computers for even more realism).
> If everything works as expected, you probably found a bug in cache subsystem
> and we need to find a way to reproduce it.
>
> BTW, could you cut'n'paste your MIDDLEWARE_CLASSES? The order is important.
>
> Thanks,
>
> Eugene


Re: init fails

2005-11-23 Thread Kenneth Gonsalves

On Wednesday 23 Nov 2005 2:46 pm, Kenneth Gonsalves wrote:
> hi
> i have a working django app. i did an svn checkout of the app
> into another machine. When i try to run init, i am getting this
> error:
>
> Error: The database couldn't be initialized.
> name 'true' is not defined
>  this is with postgres - any clues?

ok - solved, that was a syntax error in my model

-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!