Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread Kenneth Gonsalves

On Thursday 09 Feb 2006 3:23 am, Siah wrote:
> I would say start your app with the latest version of SVN and
> always keep it updated. On every SVN update read backward
> incompatible changes
> (http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges)
>, address them on spot and let your application evolve with it.

+1

-- 
regards
kg

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


ifequal raises exception when variable isn't set

2006-02-08 Thread jy

Heya all

Just posting in order to get some "clarifications" about the ifequal
(and to some extent, ifnotequal) tag.

I'll give a concrete example, in order to make things clear, for
everyone.



"result" is a tuple, which we get from a mysql query (cursor.fetchone).

I'm using some kind of template with forms and lists, on a model like
this:

  
no
yes

  


Hence, sometimes, the result variable isn't set, when the query didn't
return any result at all.

According to the docs, I thought the variable was silently ignored when
not set, and the situation would be the same as in an "if" tag.
Nonetheless, it doesn't, it raises the VariableDoesNotExist exception,
instead of using some kind of TEMPLATE_STRING_IF_INVALID variable
replacement.

Solved the problem by surrounding with an "if" tag, but I'd like to
know if it's the "normal" situation. Googling didn't bring any answer
so far :/

Additional info: used django 0.90, upgraded to 0.91.

Please accept my apologies if this question was already raised, and
answered.

Thanking you in advance,

jy



Re: Deleting ForeignKey Delets my Object!

2006-02-08 Thread Jonathan Ellis
On 2/8/06, Siah <[EMAIL PROTECTED]> wrote:
I have a model similar to:class Phone(meta.Model):number = meta.CharField(maxlength=50, null=True)class Contact(meta.Model):phone = meta.ForeignKey(Phone, null=True)name = meta.CharField
(maxlength=200)After I have data in, I want to be able to delete a contact's phone. Assoon as I remove phone, it will automatically delete my contact objecttoo.It sounds like what you want is the django equivalent of ON DELETE SET NULL.


But you haven't given enough detail to really rule out "your schema is
horribly screwed up and you should read up on normalization" instead. :)-- Jonathan Ellishttp://spyced.blogspot.com


Re: login via url

2006-02-08 Thread David Pratt


Hi Amit. That sounds interesting. I looking at something so allow a 
credentials to be passed in a similar fashion to zope as a url. Do you 
have any further details you are able to share?  Many thanks.


Regards,
David

Amit Upadhyay wrote:
On 2/8/06, *Jason F. McBrayer* <[EMAIL PROTECTED] 
> wrote:



On Wed, 2006-02-08 at 06:04 -0800, [EMAIL PROTECTED]
 wrote:
 > Does someone have a recipe for logging in via url only.  I would like
 > to have it work with admin or   regular user where
 > credentials can be passed as parameters in a url and they are
logged in
 > and directed to the url. For admin login I am wanting it to
simply log
 > into admin index.

You _could_ do this by looking at the admin interface's login view, and
handling request.GET the way it handles request.POST.  But IMO you
_shouldn't_ do this, as it may (depending on other things) open up quite
a few new ways to steal credentials (think about referrers, and about
httpd logs).


One option could be to use a one time login url.

* Create a model containing GUID/UUID.
* Create a view that sends you a mail containing a login url
  everytime you hit it.
* Create a view that server this url containing GUID/UUID as
  parameter, and if it matches with one in database, delete that
  object and log user in.

I have done something similer for invitations, as soon as i get a 
request containing previously generated GUID, i create a user and log 
user in with that user.


--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701


Re: truncate html filter?

2006-02-08 Thread Adrian Holovaty

On 2/8/06, Milton Waddams <[EMAIL PROTECTED]> wrote:
> I'm wondering if anyone has a filter which safely truncates html so as
> not to chop through tags.

Hey Milton,

You could try using the Python interface to HTML Tidy:

http://www.egenix.com/files/python/mxTidy.html

Adrian

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


Re: Custom output formats in admin

2006-02-08 Thread Milton Waddams

> Does this cover what you are looking for?
>
>  http://www.djangoproject.com/documentation/outputting_csv/

Doing the actual csv generation isn't a problem, I was wondering about
making it automated so that each module in the admin had the export
ability. In my case it's a CSV that I need to export, though I can see
other people wanting to export other formats as well.

The most important thing for me is that the filtering/searching is
reflected in the exported data.


Re: truncate html filter?

2006-02-08 Thread limodou

On 2/9/06, Milton Waddams <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I'm wondering if anyone has a filter which safely truncates html so as
> not to chop through tags.
>
> A problem that I find I have quite often is that I want to provide a
> summary of the content (eg. on a homepage) with a more info link... I
> run into issues with the content being truncated mid tag or not having
> correct closing tags so then it breaks the formatting for the rest of
> the page. I've tried removing as many tags as I can (via the filter),
> however I would like to keep things like images though sometimes they
> get chopped up causing broken images :(
>
> Any help would be greatly appreciated.
>
I'm not have a useable souce code for now, but I think maybe you could
use sgmllib module to parse the html code, and count the number of
characters, if the number reaches what you want, then close the tag(if
need) and output the text.

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit


Re: Custom output formats in admin

2006-02-08 Thread Russell Keith-Magee
On 2/9/06, Milton Waddams <[EMAIL PROTECTED]> wrote:
What is involved in creating a custom output format for all the listing views?Does this cover what you are looking for?
http://www.djangoproject.com/documentation/outputting_csv/Yours,Russ Magee %-)


Re: memory usage

2006-02-08 Thread Kenneth Gonsalves

On Wednesday 08 Feb 2006 8:39 pm, Jason F. McBrayer wrote:
> On Wed, 2006-02-08 at 13:36 +0530, Kenneth Gonsalves wrote:
> > i have three django sites on a box. It is virtual hosting. The
> > active memory allotted is 75MB. I am getting complaints that i
> > am exceeding this memory. What can be done? as far as i can
> > see, each time someone accesses the site, a new httpd process
> > is started which takes up about 12 mb - 6 hits and the memory
> > is exhausted
>
> It will probably take more specific information to answer this. 
> What is the webserver (apache, lighttpd, other), and what method
> are you using to connect django to it (mod-python, fast-cgi,
> scgi, other)?  If fast-cgi, how is your program started (apache
> mod-fastcgi process manager, or standalone)?  All of those could
> have some impact on memory usage.

it is a freebsd box, on it i have a virtual box, my memory quota is 
75MB, but it is not a hard quota. Debug is off. Am using 
apache+mod_python. For three sites, when there are no hits, the 
memory used is 42 mb (that includes the httpd and everything else). 
6 hits takes the memory usage to 150mb. The sites are small - each 
with around 5-10 models. 
-- 
regards
kg

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


truncate html filter?

2006-02-08 Thread Milton Waddams

Hi All,

I'm wondering if anyone has a filter which safely truncates html so as
not to chop through tags.

A problem that I find I have quite often is that I want to provide a
summary of the content (eg. on a homepage) with a more info link... I
run into issues with the content being truncated mid tag or not having
correct closing tags so then it breaks the formatting for the rest of
the page. I've tried removing as many tags as I can (via the filter),
however I would like to keep things like images though sometimes they
get chopped up causing broken images :(

Any help would be greatly appreciated.


Re: custom admin view for edit_inline object

2006-02-08 Thread Colleen Owens

So I'm replying to my own message here, but I want to tell you how I
did this in case
a) someone wants to show me a better way
b) it could be useful to someone

Again, what I'm trying to do is customize the way inline-edited objects
are displayed for one of my applications (without affecting any other
application).

First I changed line 52 of
django/contrib/admin/templates/admin/change_form.html to read:

{% for related_object in bound_manipulator.inline_related_objects %}{%
block related_object_display %}{% edit_inline related_object %}{%
endblock %}{% endfor %}

(i.e. I added the block and endblock tags).

Then I created another change_form.html file in my template directory
that simply contains:

{% extends "admin/change_form" %}
{% block related_object_display %}{% include
"admin/news/edit_news_inline" %}{% endblock %}

admin/news/edit_news_inline simply points to my custom template that
contains the code I want. I'll customize the url rewrite to point to
the default change_form for all applications, but my news application
will point to my new change_form.

Does this seem like a reasonable way to do this? I still don't quite
have a handle on all this so sometimes I feel like I'm doing things in
a very convoluted way.

Thanks.

Colleen



Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread ToddG

Right, I just really can't get a sense of how far off 0.92 (assuming
that's the merge) is. I'm not sure how (if) the milestones in trac
reflect the status of 0.92/magic merge. If it's roughly in the next few
weeks that (magic-removal) would seem to be the obvious choice. I
didn't want to make any assumptions though...



Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread Sean Perry


ToddG wrote:

I'm going to be starting a project in the next few weeks, and I was
wondering what people recommend building on at this point. I've been
exploring with the svn of trunk, but I'm not sure on what version of
the codebase would be best to start a "real" project with. Any
suggestions?



You do say "weeks" here. The magic removal branch may well be 0.92 by 
then. If so, start there. Otherwise, go with 0.91 and be ready to shift 
to 0.92.


'magic removal' will become the standard once it is released. Might as 
well plan for it.


Re: Deleting ForeignKey Delets my Object!

2006-02-08 Thread Siah

Please excuse the lack of applicability for this example. It was meant
to serve as an example, apparently not a good one.

In my database, I have tons of such relationships. I have a Person
model having foreign keys to django authentication user model, to the
current branch he resides (a foreignkey to branch), etc. They aren't
necessarily meant to represent 1-many relationship, rather, just
pointing to another object data.

Thanks,
Sia



Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread ToddG

Thanks guys. I'm familiar enough to be confused as to which to use, and
to know changes are happening in lots of spots, but not familiar enough
to know exactly where and when. Part of the fun I guess!



Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread Ian Holsman

If you are not really familiar with django, I would suggest you use the trunk.
it is better documented, and more people can help you out.

It is also painful debugging your code, only to find out it is a bug
in the framework which happened since the last SVN checkout..


On 2/9/06, ToddG <[EMAIL PROTECTED]> wrote:
>
> Hi all - I know nobody wants to hear "when will it be done" type
> questions, so I hope this isn't annoying.
>
> I'm going to be starting a project in the next few weeks, and I was
> wondering what people recommend building on at this point. I've been
> exploring with the svn of trunk, but I'm not sure on what version of
> the codebase would be best to start a "real" project with. Any
> suggestions?
>
> Ideally I wouldn't want to have to rewrite a huge % of the thing when
> branches are merged, but also I don't want to spend all my time trying
> to figure out what I did wrong and then finding out a problem is due to
> unfinished code or known bugs rather than a mistake I made. (since I'm
> sure I"ll have plenty of my own mistakes!)
>
> So balancing those (obvious) desires (to avoid unavoidable tradeoffs),
> what would you say is the best path?
>
> Thanks!
>
>


--
[EMAIL PROTECTED] -- blog: http://feh.holsman.net/ -- PH: ++61-3-9877-0909

If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Deleting ForeignKey Delets my Object!

2006-02-08 Thread Siah

The title should say: deletes, not delets



Re: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread Siah

Hey Todd,

I am working on a large web app with django and backward
incompatibility issues shows up on my nightmares from time to time.

I would say start your app with the latest version of SVN and always
keep it updated. On every SVN update read backward incompatible changes
(http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges),
address them on spot and let your application evolve with it.

Best of luck,
Sia



Deleting ForeignKey Delets my Object!

2006-02-08 Thread Siah

Hi,

I have a model similar to:

class Phone(meta.Model):
number = meta.CharField(maxlength=50, null=True)

class Contact(meta.Model):
phone = meta.ForeignKey(Phone, null=True)
name = meta.CharField(maxlength=200)

After I have data in, I want to be able to delete a contact's phone. As
soon as I remove phone, it will automatically delete my contact object
too. This would make sense with poll/choice, but not everywhere. What
is the magic keyword for me to ask it to stop messing with me. :)

contacts.get_list()[0].get_phone().delete()

Thanks,
Sia



Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread ToddG

Hi all - I know nobody wants to hear "when will it be done" type
questions, so I hope this isn't annoying.

I'm going to be starting a project in the next few weeks, and I was
wondering what people recommend building on at this point. I've been
exploring with the svn of trunk, but I'm not sure on what version of
the codebase would be best to start a "real" project with. Any
suggestions?

Ideally I wouldn't want to have to rewrite a huge % of the thing when
branches are merged, but also I don't want to spend all my time trying
to figure out what I did wrong and then finding out a problem is due to
unfinished code or known bugs rather than a mistake I made. (since I'm
sure I"ll have plenty of my own mistakes!)

So balancing those (obvious) desires (to avoid unavoidable tradeoffs),
what would you say is the best path?

Thanks!



Re: Tiny myce

2006-02-08 Thread akaihola

The tiny_mce editor should appear nevertheless.

View the source of an admin page where tiny_mce should appear. Check
the  tags. You should have something like this (I've set my
ADMIN_MEDIA_PREFIX to '/admin_media/'):