Re: Beginner on Django and web developing

2008-11-03 Thread David Zhou
On Mon, Nov 3, 2008 at 2:49 PM, bruno desthuilliers <
[EMAIL PROTECTED]> wrote:

>
> On 3 nov, 17:38, "Airton Arantes" <[EMAIL PROTECTED]> wrote:
> > Hello folks, I have aready used python only in desktop. About 1 a week
> > ago I installed the Django 1.0 on Fedora 9. I wonder about the
> > djangobook, its version is 0.96 or 1.0?
> >
> > I don't know nothing about web programming but I'm studying a lot.
> > Can I read this link[1] to learn better about django?
> >
> > [1]http://www.djangobook.com/en/1.0/
>
> Hi.
>
> If you installed django 1.0, yes, indeed, you want djangobook 1.0 too.
> But note that this won't be enough to understand web programming in
> general - for this, you need at least some understanding of the HTTP
> protocol.
>
>
Note that the book is pretty out of date at this point, and some sections --
like the Admin site -- will simply not work.
Your best bet is to go through the tutorials on the Django documentation
site.


David Zhou
[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: Beginner on Django and web developing

2008-11-03 Thread David Zhou
On Mon, Nov 3, 2008 at 4:07 PM, Airton Arantes <[EMAIL PROTECTED]>wrote:

>
> >
> > Note that the book is pretty out of date at this point, and some sections
> --
> > like the Admin site -- will simply not work.
> > Your best bet is to go through the tutorials on the Django documentation
> > site.
>
> So, could I study only book's 1,2,3,4 chapters?
>
>
If you're up to it, I would personally rely strictly on the documentation
online at docs.djangoproject.com.  A side effects of the changes leading up
to the 1.0 release of Django is that a lot of the older documentation and
literature may no longer apply.

The good news is that once you learn Django 1.0, there shouldn't be any
future breaking changes for some time.

-- 
---
David Zhou
[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: ' Change History' for audit, compliance

2008-11-11 Thread David Zhou
On Tue, Nov 11, 2008 at 1:29 PM, Lincoln_Consulting <[EMAIL PROTECTED]>wrote:

>
> Every moden application needs 'Change History' for Audit and
> Compliance purposes.
>
> An application should provide information who changed what data, when
> did they change the data , the old value and the new value etc
>

That's a debatable point, but it would be fairly easy to create a Change
model, and either define save() methods or use pre/post save signals to
populate changes so that you have a change history.


-- 
---
David Zhou
[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: Multithreaded Dev Server

2008-11-15 Thread David Zhou

On Sun, Nov 16, 2008 at 12:11 AM, Chris <[EMAIL PROTECTED]> wrote:

> I'm trying to write a basic Ajax app, which submits a file in one long-
> running request, and periodically polls the status in another request.
> However, it seems like runserver is single threaded, so the second
> request just hangs until the file upload completes, preventing the
> status update. Is there any way to make the dev server multi-threaded?

It's probably easier to just use apache at that point.


--
---
David Zhou
[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: Multithreaded Dev Server

2008-11-15 Thread David Zhou

On Sun, Nov 16, 2008 at 12:40 AM, Chris <[EMAIL PROTECTED]> wrote:

> I understand what you're saying. It's just unfortunate we're throwing
> out the convenience of the dev server.

If you're not interested in setting up something like apache, you can
also maybe use one of the pure python servers out there.  See:

http://www.eflorenzano.com/blog/post/hosting-django-site-pure-python/

-- 
---
David Zhou
[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: Best way for making a "Poll"?

2008-11-16 Thread David Zhou

On Sun, Nov 16, 2008 at 11:20 PM, killsto <[EMAIL PROTECTED]> wrote:

> How can I get choices, a CharField I guess, to show up as radio select
> widgets in a form?

You can manually retrieve form fields and display them however you want:

http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-form-template

-- 
---
David Zhou
[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: cascading drop down lists

2008-11-16 Thread David Zhou

On Sun, Nov 16, 2008 at 10:56 PM, adelevie <[EMAIL PROTECTED]> wrote:

> I want to use a series of drop down lists to define this criteria. For
> example, I want to first have to select the year. Then I hit submit
> and the form is processed on the same page. Then the next drop down
> list will become populated with a list of seasons associated with that
> year. Submit. Then the next drop down list will become populated with
> departments associated with that season and year. Submit. The next
> list is filled with courses associated with with that year, season,
> and department. I hope this gives you the right idea.
> Do I have to create a form model to do this?
> Is there any other way to retrieve POST data?

Look into form wizards and the process_step() method:

http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/#django.contrib.formtools.wizard.FormWizard.process_step

-- 
---
David Zhou
[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: In forms, how add dynamic initial values out of reach for clients?

2008-11-16 Thread David Zhou

On Mon, Nov 17, 2008 at 1:24 AM, dexter <[EMAIL PROTECTED]> wrote:
>
> I want logged in users to be able to add comments but only want some
> of the formfields displayed. Fields 'user', 'date' and 'discussion'
> should be out of reach for my sitevisitors/clients.
> ...
> How should i solve this? I've tried numerous ways but none of them
> really worked.

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

---
David Zhou
[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: avoid cascade delete

2008-11-16 Thread David Zhou

On Mon, Nov 17, 2008 at 2:21 AM, Merrick <[EMAIL PROTECTED]> wrote:
>
> I have two models, links and groups. A Link has an optional foreign
> key Group.
>
> When I delete a Group, Django by default deletes all Links that
> referenced the Group that is being deleted.
>
> How do I avoid the default behavior that does a cascade delete. Of
> course I could use the cursor but would am hoping there is some option
> I don't know of for delete().

Try using clear() prior to deleting:

http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

-- 
---
David Zhou
[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: avoid cascade delete

2008-11-16 Thread David Zhou

On Mon, Nov 17, 2008 at 2:34 AM, David Zhou <[EMAIL PROTECTED]> wrote:
> On Mon, Nov 17, 2008 at 2:21 AM, Merrick <[EMAIL PROTECTED]> wrote:
>>
>> How do I avoid the default behavior that does a cascade delete. Of
>> course I could use the cursor but would am hoping there is some option
>> I don't know of for delete().
>
> Try using clear() prior to deleting:
>
> http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

Another way is to consider using a many to many there, rather than a
one to many.

-- 
---
David Zhou
[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: avoid cascade delete

2008-11-17 Thread David Zhou

On Mon, Nov 17, 2008 at 10:46 AM, Randy Barlow <[EMAIL PROTECTED]> wrote:
>
> On Sun, 16 Nov 2008 23:21:05 -0800 (PST), Merrick <[EMAIL PROTECTED]>
> declared:
>> I have two models, links and groups. A Link has an optional foreign
>> key Group.
>>
>> When I delete a Group, Django by default deletes all Links that
>> referenced the Group that is being deleted.
>>
>> How do I avoid the default behavior that does a cascade delete. Of
>> course I could use the cursor but would am hoping there is some option
>> I don't know of for delete().
>
> I would argue this is more desireable than using clear() explicitly,
> because you don't have to know anything about your models with this
> method.  Any time you have to remember to set a certain
> relationship to null, you are bound to forget about another
> relationship between your objects, and you'll get cascading delete on
> something you didn't expect, and you won't have even noticed that it
> happened!

But that just means you'll need to explicitly set cascade on those
models you *do* want to cascade delete.  And, IMO, the vast majority
of foreign key use cases do benefit from an auto cascading delete.

For the specific Links/Groups example, personally I'd just do it with
a many to many relation.  It's entirely feasible that in the future,
Links will need the ability to associate itself to multiple groups.
For now, I'd just limit a link to one group via some custom
validation.

-- 
---
David Zhou
[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: Passing values to template

2008-11-17 Thread David Zhou

On Mon, Nov 17, 2008 at 10:45 AM, Alex Jonsson <[EMAIL PROTECTED]> wrote:

> So the question is: how do I check (in the template) if the object
> that is being run in the for loop is a dictionary, so that I in turn
> can run a for loop on it? Or is there a better way of doing this other
> than mixing objects and dictionaries in the list?

What about making it a list of tuples, and including a type?

{'articles': [('single', ),
('multiple', {1: , 2: }),
('single', )]}

Then you could just do a {% for type, article in articles %}, and have
a conditional on the type.

-- 
---
David Zhou
[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: Multiple types of output (HTML, JS), same view.

2008-11-18 Thread David Zhou

On Thu, Oct 30, 2008 at 4:08 PM, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> rendering, based on request informations. The points I'm yet really
> happy with are:
> - how to tell the rendering decorator what we want to render
> - how to avoid template duplication for 'full' rendering and 'partial'
> rendering
>
> wrt/ first point, the simplest solution IMHO is to pass a render=json
> or render=partial argument in the query string (default being
> rendering the 'full' page). My main problem is with second point. I
> have a working scheme using two templates, the 'full' one doing an
> include of the 'partial' one. This should work, but I still don't like
> having two distinct templates.

I'd need to check Django's template code to see if this is possible,
but one possibility is to give the decoration a "block" parameter, to
render a specific block from a template.  So you could have something
like:

@render_view('js', 'template.html', block='js_block')
def view:
   pass

-- 
---
David Zhou
[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: Passing values to template

2008-11-18 Thread David Zhou

On Tue, Nov 18, 2008 at 1:54 PM, Ross Dakin <[EMAIL PROTECTED]> wrote:
>
>> Others already gave you practical answers, so this will be mostly a
>> more general ('conceptual' ?) advice: don't mix heterogenous data
>> (objects, whatever) in a list. If you have a compelling reason (ie :
>> ordering) to have heterogenous data, wrap them all in a same 'meta'
>> data structure.
>
> Agreed. The simplest solution might be to just wrap your single
> objects in dictionaries:
>
> my_list = [
>{single_object},
>{'one', 'two'},
>{single_object},
>{'one', 'two'},
>]

That's basically what Alex was doing.  The issue was how to render
different front-end code given that a single list has different
'types' of renderings.

My way put that logic into me template, but ideally, as Bruno said,
each 'type' should be able to dispatch its own specific render.

-- 
---
David Zhou
[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: serving static file via django

2008-11-18 Thread David Zhou

On Tue, Nov 18, 2008 at 6:22 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> my requirement is that I need to serve just one 10x10 gif file via
> django -- so that i can track what users requested the file. can i use
> the above view to serve this file ? what are the drawbacks of using
> this view in a production env ?

Have you considered using request/response signals?

http://docs.djangoproject.com/en/dev/ref/signals/#module-django.core.signals

-- 
---
David Zhou
[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: Show image (but not ImageField) in admin?

2008-11-18 Thread David Zhou

On Tue, Nov 18, 2008 at 6:09 PM, Dave <[EMAIL PROTECTED]> wrote:
>
> What I'm looking to do is have the image path populated by a script
> and allow a user editing the record to see the image, but not be able
> to edit or change anything about it.  It seems easier to use a
> CharField instead of ImageField, but then how do I go about showing it
> inline?  fieldsets.description doesn't allow anything but text.

You can write your only readonly image widget, and apply it in the
admin by specifying your own form:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form

-- 
---
David Zhou
[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: serving static file via django

2008-11-18 Thread David Zhou

On Tue, Nov 18, 2008 at 9:40 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> david,
>
> can you illustrate how ? sorry -- havent worked with django signals
> earlier

I might be misunderstanding your need to track requests to that file,
but if you're using it to track requests in Django in general, you may
be able to do that by using a listening for a request finished signal,
and doing something with it.

What are you specifically trying to do by tracking which users
requested the file?

-- 
---
David Zhou
[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: form issue

2008-11-18 Thread David Zhou

It'll be helpful if you post the entire view, but well, like the error
says, is form defined?

On Wed, Nov 19, 2008 at 12:08 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>
> hi group.
>
> I have the following statement:
>
>return render_to_response('donate-now.html',
> {'form':form,'ErrCode':errcodevalue,'Status':responsestatus,'TextResult':responsetext},
> context_instance=RequestContext(request))
>
>
> Which pushes data back to the template where a form resides.
>
> I'm getting the following error:
>
> global name 'form' is not defined
>
>
> am I missing something?
> >
>



-- 
---
David Zhou
[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: serving static file via django

2008-11-18 Thread David Zhou

I was initially thinking that if you knew which pages you wanted to
track, you could capture those requests via signals, rather than via
requets to a file.

But if it's an explicit requirement to track hits to that file, then
that wouldn't work.

Is the file a transparent gif that's solely used to track hits?

Is there any reason you can't track your hits in views prior to
template rendering?

On Wed, Nov 19, 2008 at 12:34 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> david,
>
> its a biz requirement for me to track what http requests are being
> made to this file. used in generating internal metric reports. I guess
> i'll have to dig into the django code to see how signals are used..do
> you know of any example where the request_finished signal is used ?
>
> thanks,
> -p
>
> On Nov 18, 10:23 pm, "David Zhou" <[EMAIL PROTECTED]> wrote:
>> On Tue, Nov 18, 2008 at 9:40 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>
>> > david,
>>
>> > can you illustrate how ? sorry -- havent worked with django signals
>> > earlier
>>
>> I might be misunderstanding your need to track requests to that file,
>> but if you're using it to track requests in Django in general, you may
>> be able to do that by using a listening for a request finished signal,
>> and doing something with it.
>>
>> What are you specifically trying to do by tracking which users
>> requested the file?
>>
>> --
>> ---
>> David Zhou
>> [EMAIL PROTECTED]
> >
>



-- 
---
David Zhou
[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: serving static file via django

2008-11-18 Thread David Zhou

On Wed, Nov 19, 2008 at 1:54 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> yes..its just a transparent gif...i'm thinking of writing my own view,
> which will get the visitor data and then just call the static serve
> method provided by django.
> just dont know it its ok inproduction env though..

Do you not know which pages the gif will live on?  Why not grab
visitor data in the views of the pages that use the transparent gif?

-- 
---
David Zhou
[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: Why are models referenced without a capital letter in templates

2008-11-23 Thread David Zhou

The key is the sentence above that snippet on that page:

"Given the context variable poll"

'poll' is a variable passed into the template context.  If you called
that variable 'a_poll', you could've done:

{{a_poll.question}}

As for choice, notice the line:

{% for choice in poll.choice_set.all %}

It's populating the choice variable with the items in choice_set.

On Sun, Nov 23, 2008 at 6:16 AM, dash86no <[EMAIL PROTECTED]> wrote:
>
> http://docs.djangoproject.com/en/dev/intro/tutorial03/#intro-tutorial03
>
> I'm following the above tutorial, and I'm confused with the following
> section:
>
> {{ poll.question }}
> 
> {% for choice in poll.choice_set.all %}
>{{ choice.choice }}
> {% endfor %}
> 
>
>
> The 'poll' and 'choice'  are referred to with out the first letters, p
> and c respectively, being capitalized.
>
>
> This is despite the fact that both are declared as 'Poll' and
> 'Choice', respectively, in the models.py.
>
> I have tried this in my own app and find the same to be true there
> too: If I try to refer to a model with a capitalized first letter (as
> they are declared in my models.py), the template doesn't work.
>
> I have a feeling this has something to do with the templates dealing
> with 'Objects' and when an object is instantiated from a class it's
> first letter is automatically converted to lower case.
>
> Am I on the right lines here? If so, what happens if you declare your
> classes with all lower case letters in models.py?
>
>
> Thanks,
> >
>



-- 
---
David Zhou
[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: Why are models referenced without a capital letter in templates

2008-11-23 Thread David Zhou

On Sun, Nov 23, 2008 at 6:31 AM, dash86no <[EMAIL PROTECTED]> wrote:

> So what passes the poll context variable to the template? This isn't
> done explicitly, right? How is the variable name determined?

It's explicitly passed.  There are some variables that are populated
implicitly based on the specific context, but in this case, 'poll' is
something that would be explicitly set.

Refer to the page you linked to earlier:

http://docs.djangoproject.com/en/dev/intro/tutorial03/#write-views-that-actually-do-something

That section explains how views work, and how they pass things to the
template context.


-- 
---
David Zhou
[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: parameter not getting passed to view function

2008-11-24 Thread David Zhou

On Mon, Nov 24, 2008 at 2:14 PM, mahesh_aka_amol <[EMAIL PROTECTED]> wrote:
>
> Parameter not getting passed to view function
>
> upon accessing http://localhost:8000/hello/TEST it merely prints
> "hello there" instead of "hello there TEST"
>
> urls.py
>(r'^hello/(?P)\S+/$', 'swamiji.poll.views.hello')

Check your URL regexp and grouping.


-- 
---
David Zhou
[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: Executing raw Python

2008-11-24 Thread David Zhou
To the more general question of running python like that, just import
the update_s3 method and run it normally.

On Mon, Nov 24, 2008 at 2:46 PM, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
>  if you are using 1.0 or newer, than you can use a file backend to
> directly on S3.
>
> Have a look if http://code.google.com/p/boto/ or
> http://github.com/paltman/django-aws/tree/master
> help you along.
>
> adi
>
> On 24.11.2008 18:35 Uhr, Alex Jonsson wrote:
>> Hey everyone,
>>
>> I use Django together with Photologue and would like to be able to
>> store the images on my Amazon S3 account.
>>
>> I've been doing a lot of thinking about how the easiest way to do this
>> would be, and have come to the conclusion that the easiest way
>> probably would be to upload the image first to my own server, and then
>> at the save() method run the update_s3.py script. It can be found
>> here: http://www.holovaty.com/code/update_s3.py
>>
>> If I want to run this command and copy the entire directory over to
>> S3, how would be the easiest way to do that?
>>
>> Thanks,
>> Alex
>> >
>>
>
>
> --
> Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
> Freelance developer   web:http://www.sieker.info/profile
> SAP-Developer
>
> >
>



-- 
---
David Zhou
[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: Injecting stuff to an existing list?

2008-11-25 Thread David Zhou

On Tue, Nov 25, 2008 at 3:55 AM, sajal <[EMAIL PROTECTED]> wrote:

> Now Id like to show age of the people along with their names.
>
> I have a function which can calculate age callable via calculateAge
> (p.date_of_birth)  but how do I make pass this along with the person
> object?

There's several ways you could approach this:

1. Create a new template tag that takes in a person object and spits
out the age.  For example, {% get_age p %}

2. Add a current_age method to the Person model, that returns the
current age. For example {% p.current_age %}

3. Return a list of tuples in your context processor:

return {'borntoday': [(calculateAge(p.date_of_birth), p) for p in
Person.objects.filter(date_of_birth__month=date.month,
date_of_birth__day=date.day)]}

   Then in your template:

   {% for age, person in borntoday %}
  Current age: {{age}} for person {{person}}
   {% endfor %}


Personally, if the current age of a person is something you'll be
using often, I'd add it to the model.

-- 
---
David Zhou
[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: Injecting stuff to an existing list?

2008-11-25 Thread David Zhou

On Tue, Nov 25, 2008 at 9:05 AM, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> David Zhou wrote:
>> On Tue, Nov 25, 2008 at 3:55 AM, sajal <[EMAIL PROTECTED]> wrote:
> [...]
>>
>> Personally, if the current age of a person is something you'll be
>> using often, I'd add it to the model.
>>
> That's not very good advice, as the current age of a person changes with
> time, and you are introducing unnecessary redundancy into the data
> model. When do you suggest the current age columns should be updated?

Yeah, I meant what Thomas said.  Add a method to the model that
calculates age.  I thought that'd be obvious in context given the
three numbered points, but sorry for the confusion.

-- 
---
David Zhou
[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: Does Django have a function that can be called by every view function ?

2008-11-30 Thread David Zhou

On Mon, Dec 1, 2008 at 2:23 AM, David Shieh <[EMAIL PROTECTED]> wrote:

> I dont' know whether this make any sense .
> Right now , I can't test it , but if django won't initiate the
> views.py as a class , this method will make no sense.

Why not write a decorator?

---
David Zhou
[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: printing from the admin?

2008-12-01 Thread David Zhou

On Mon, Dec 1, 2008 at 7:33 AM, Nitzan Brumer <[EMAIL PROTECTED]> wrote:
> I have a class called customers which generates in the admin some kind of a
> "phone book".
> I want to allow the user to print all the records using a print button.
>
> I guess I can do it with a custom CSS file but I hope there is a simple way.
> Is there?

If you want the layout to be print optimized, the easiest way is going
to be using some custom admin templates that use some custom CSS.

-- 
---
David Zhou
[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: how to create json from template?

2008-12-02 Thread David Zhou

On Wed, Dec 3, 2008 at 1:17 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> To trim last colon wrap it with if statement:
>
> {% if forloop.revcounter0 %},{% endif %}

You can also do:

{% if not forloop.last %},{% endif %}

Which, IMO, is slightly more clear.


---
David Zhou
[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: cursors and raw sql

2008-12-04 Thread David Zhou

On Thu, Dec 4, 2008 at 3:56 AM, bcurtu <[EMAIL PROTECTED]> wrote:

> i need to perform some Raw SQL queries in my django app. I read in the
> doc (http://docs.djangoproject.com/en/dev/topics/db/sql/) I can do sth
> like:

...

> The question is... Do I have to close the cursor?

Assuming it's following standard Python database API practices, you
can, if you want, but it's optional.



-- 
---
David Zhou
[EMAIL PROTECTED]

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



Re: Django is changing my html!

2008-12-04 Thread David Zhou

On Thu, Dec 4, 2008 at 10:19 PM, DragonSlayre <[EMAIL PROTECTED]> wrote:
>
> Thanks for the speedy responses... I was trying to do things *right*
> using xhtml standards, but I guess that it's more trouble than it's
> worth.

But you *weren't* doing things right, since you had the  inside
the .  Fix the markup, and it'll be fine, doctype and all.


-- 
---
David Zhou
[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: Populating form from instance not working

2008-12-05 Thread David Zhou

On Fri, Dec 5, 2008 at 1:44 AM, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>
> But, the form fields aren't being populated. What am I doing wrong?
> form_for_instance is deprecated in 1.0, and everything I'm doing looks
> correct from the docs at: 
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

What does your form class look like?


-- 
---
David Zhou
[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: Ruby on Rails vs Django

2008-12-05 Thread David Zhou
On Fri, Dec 5, 2008 at 9:31 AM, Masklinn <[EMAIL PROTECTED]> wrote:
>
> On 5 Dec 2008, at 14:30 , bruno desthuilliers wrote:
>> On 5 déc, 13:06, "[EMAIL PROTECTED]"
>> <[EMAIL PROTECTED]> wrote:
>>> Hi All,
>>>
>>> I'm new to the django world and I was just wondering how Django
>>> compears with  Ruby on Rails ?
>>
>> Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
>> Quite close overall, and yet very different philosophies.
> I'd say that Rails and Django differ much more than Python and Ruby.
> There are "small" differences between Python and Ruby, but the core
> philosophies and structures of Rails and Django on the other hand are
> completely unrelated and pretty much incompatible.

What do you think are the core philosophies of Rails and Django?

-- 
---
David Zhou
[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:

2008-12-05 Thread David Zhou

On Fri, Dec 5, 2008 at 2:41 PM, PFL <[EMAIL PROTECTED]> wrote:

> A request is definitely sent for each of these cases: "/doc/", "/
> doc#", "/doc#1/".  I can see each of these generating a hit on the
> local dev server standard out.

Are you opening them in a new tab or anything of that nature?

-- 
---
David Zhou
[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: keep html

2008-12-07 Thread David Zhou

On Sun, Dec 7, 2008 at 12:12 AM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> On Sat, Dec 6, 2008 at 9:17 PM, Patricio Palma <[EMAIL PROTECTED]>
> wrote:
>>
>> Is possible to get the html code from an administration page?
>>
>>
>> I mean, my browser is interpreting a html generated by templates and
>> components of my application, some banners and pictures.
>>
>> Is there any way to get that code?
>
> Something like View->Page Source from the browser menu? (That's what Firefox
> calls it -- I'd guess most browsers have some such way to see the raw html
> for a page.)  Or am I misunderstanding your question?

If the question is getting at the actual admin site templates, see:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates


-- 
---
David Zhou
[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: Do you recommend "Practical Django Projects"?

2009-01-05 Thread David Zhou

On Mon, Jan 5, 2009 at 3:27 AM, James Bennett  wrote:
>
> On Jan 5, 2:21 am, HB  wrote:
>> Hey,
>> I'm reading "The Definitive Guide To Django" but it is too out dated.
>> Do you recommend "Practical Django Projects" instead?
>> It seems to me that "The Definitive Guide To Django" is more organized
>> and covers a lot of materials.
>> What do you think?
>
> As the author, I recommend waiting a couple months.

Are you planning to update Practical Django Projects to 1.0?

-- 
---
David Zhou
da...@nodnod.net

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



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread David Zhou

On Mon, Jan 5, 2009 at 3:57 AM, Kenneth Gonsalves
 wrote:
>
> On Monday 05 Jan 2009 2:10:34 pm David Zhou wrote:
>> >> and covers a lot of materials.
>> >> What do you think?
>> >
>> > As the author, I recommend waiting a couple months.
>>
>> Are you planning to update Practical Django Projects to 1.0?
>
> isnt that obvious from the answer?

Your perpetual grouchiness aside, not in any substantial way.

Will the update be new online errata? Or a brand new printed version?
Or perhaps a brand new volume?  A vague "wait a couple months" doesn't
impart any real detail -- hence the further prompting.

Perhaps there is no more detail to give at this stage.

But then, that's not really for you to decide, is it?

---
David Zhou
da...@nodnod.net

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



Re: Django too slow

2009-01-07 Thread David Zhou

On Thu, Jan 8, 2009 at 1:04 AM, Vicky  wrote:
>
> I using the django to generate xml and to fetch datas from database.
> When i run it the response is too slow. it takes nearly 4sec to load
> the page. So what can i do to make my program more efficient. Plse
> tell me some things to avoid so that it becomes faster

First thing you need to do is figure out where the slowness
originates.  Is it from DB access? XML generation?

If it's from DB access, include the code you're using to fetch data.
If XML generation, likewise.



-- 
---
David Zhou
da...@nodnod.net

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



Re: why 'No module named safestring'?

2009-01-11 Thread David Zhou

On Sun, Jan 11, 2009 at 10:25 PM, frank Shi  wrote:
>
> i use django 0.96 ,template render html string.
>
> from django.utils.safestring import mark_safe
> context=Context({
>'div1':mark_safe(obj),
>})
>return HttpResponse(template.render(context))
>
> it's error: No module named safestring?why
> already install python 2.5
>

You need to use a more recent version of Django. Safestring was
introduced after 0.96.  See:

http://code.djangoproject.com/browser/django/trunk/django/utils

vs.

http://code.djangoproject.com/browser/django/tags/releases/0.96/django/utils

-- 
---
David Zhou
da...@nodnod.net

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



Re: Templates Cant find the CSS file

2009-01-12 Thread David Zhou

On Mon, Jan 12, 2009 at 3:25 AM, pyramid...@gmail.com
 wrote:
>
> Im trying to get the template to load the CSS, but it does not load,
> the server output shows a 404.
...
> preferably i dont want the css file there but in a global location,
> can someone tell me whats going on here?

See:

http://docs.djangoproject.com/en/dev/howto/static-files/

And if you're using mod_python, also see:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files

-- 
---
David Zhou
da...@nodnod.net

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



Re: newforms library.

2009-01-12 Thread David Zhou

On Mon, Jan 12, 2009 at 8:25 AM, Karen Tracey  wrote:
> On Mon, Jan 12, 2009 at 6:11 AM, seki  wrote:
>>
>> Hi guys,
>> I have been teaching myself Django and I have worked with the latest
>> release. To me it seems the new library isn't shipped with the
>> newforms library ( i.e Django-1.0.2-final)...
>> I just coppied the library from an older version.
>> Hope that's pretty fine...
>
> newforms was never intended to be a permanent name for the new forms
> package, it was just a temporary name to allow co-existence with the
> original forms and allow for easier migration.

seki, this is why it's always been recommended to do "import newforms
as forms", since that allowed easier migration when newforms was
renamed and replaced forms.


-- 
---
David Zhou
da...@nodnod.net

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



Re: CSS is not updated?

2009-01-12 Thread David Zhou

On Mon, Jan 12, 2009 at 10:08 AM, ltcstyle  wrote:
>
> What does CTRL+F5 do for my browser? sorry I developed in Mac, hence
> Safari.

Does refreshing help? Or clearing the browser cache?

Barring all of that -- are you actually editing the correct CSS file?
There's been times when I spend an inordinate amount of time wondering
why my changes aren't working when I was editing the wrong copy of the
file the entire time.


-- 
---
David Zhou
da...@nodnod.net

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



Re: overriding Model.save(), do I need to override Model.create() also?

2009-01-12 Thread David Zhou

On Mon, Jan 12, 2009 at 10:10 AM, rabbi  wrote:
>
> Is it enough to override the Model.save() method or should I override
> Model.create() also?

Just Model.save() should be enough.  In the past, I've used if not
self.id to case initial creation -- although I don't know if that's
considered best practice.

-- 
---
David Zhou
da...@nodnod.net

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



Re: new django user - no images appear on my site :(

2009-01-12 Thread David Zhou

On Mon, Jan 12, 2009 at 3:59 PM, jazztpt  wrote:
>
> Nope, that's not the problem.  I had read that page, and another that
> suggested a slightly different syntax for the urlpatterns (from
> http://rob.cogit8.org/blog).  Sorry that I forgot to mention that I
> had already put Rob's version in my code -- I wasn't sure if it was
> necessary simply to show any images anywhere on your site (the example
> is of a set of images with a directory and links to each image).

Try a simple test: copy the generated URL for the image, and go there
directly.  Do you get a Django error? If so, what is it?


-- 
---
David Zhou
da...@nodnod.net

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



Re: django 0.96 cancel template render automatically escape?

2009-01-12 Thread David Zhou

On Mon, Jan 12, 2009 at 10:07 PM, frank Shi  wrote:
>
> how do cancel django 0.96  template render automatically escape?
> 0.96 after version can use mark_safe() function..etc..,but i can't
> update new version.

IIRC, 0.96 didn't have any concept of escaping in the sense of
autoescaping later on. What you put in your template is what you got.

-- 
---
David Zhou
da...@nodnod.net

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



Re: Django has "save_model", but what about "delete_model"?

2008-08-19 Thread David Zhou

On Aug 19, 2008, at 12:48 PM, Huuuze wrote:

> The latest Django beta added this method to the admin models:
>
>>> save_model(self, request, obj, form, change)
>
> I have a business case where a "delete_model" method would come in
> very handy.  Does anyone know if this will be included in an upcoming
> release?
>
> If not, here is my dilemma.  When an item is deleted from the admin
> interface, I need to audit the activity using my custom audit
> methods.  One of the attributes in the audit methods is the user ID of
> the actor who executed the action.  In other words, when a delete
> takes place, I'd like to audit who did it.  Unfortunately, I can't
> seem to find a way to access the request object which will provide me
> that information via the admin-related methods.

What about log_deletion?

http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py?rev=8266#L404

---
David Zhou
[EMAIL PROTECTED]




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



Re: Django has "save_model", but what about "delete_model"?

2008-08-19 Thread David Zhou

On Aug 19, 2008, at 1:02 PM, David Zhou wrote:

>
> On Aug 19, 2008, at 12:48 PM, Huuuze wrote:
>
>> The latest Django beta added this method to the admin models:
>>
>>>> save_model(self, request, obj, form, change)
>>
>> I have a business case where a "delete_model" method would come in
>> very handy.  Does anyone know if this will be included in an upcoming
>> release?
>>
>> If not, here is my dilemma.  When an item is deleted from the admin
>> interface, I need to audit the activity using my custom audit
>> methods.  One of the attributes in the audit methods is the user ID  
>> of
>> the actor who executed the action.  In other words, when a delete
>> takes place, I'd like to audit who did it.  Unfortunately, I can't
>> seem to find a way to access the request object which will provide me
>> that information via the admin-related methods.
>
> What about log_deletion?
>
> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py?rev=8266#L404


The link should actually be:

http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L302

For the latest trunk version.

---
David Zhou
[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: override model.save - prevent saving (admin)

2008-08-22 Thread David Zhou

On Aug 22, 2008, at 2:10 AM, jboutros wrote:

> I have a model where I've overridden the save method.  In a specific
> case (validation fails against an external web service), I would like
> to prevent the save from happening.  I have implemented this by not
> calling super.save in this case.
>
> (see 
> http://www.djangoproject.com/documentation/model-api/#overriding-default-model-methods)

...

> Am I missing something obvious?  Any thoughts?

Have you considered adding your own validation via the standard  
newforms way?

http://www.djangoproject.com/documentation/admin/#adding-custom-validation-to-the-admin


---
David Zhou
[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: Hosting with support for Satchmo webstore

2008-08-25 Thread David Zhou

On Aug 25, 2008, at 8:02 AM, Chris Moffitt wrote:

> On Mon, Aug 25, 2008 at 5:17 AM, Benedict Verheyen <[EMAIL PROTECTED] 
> > wrote:
>
> Hi,
>
> i need to develop a website with a webstore and i thought it was
> the perfect time to use Django & more specific Satchmo.
> However, Satcho has a big list of requirements and i'm not sure
> if this will work with the usual providers that have Django enabled.
>
> I don't know of any web hosts that have Satchmo running out of the  
> box. While there are certainly ways to get it running on a standard  
> host, I think a VPS is definitely the way to go. The upfront setup  
> may be a little  bit longer but my opinion is that the long term  
> hassle factor is a lot less.

The post may not be relevant anymore, but Brian appears to have gotten  
Satchmo working on WebFaction:

http://brianmckinney.net/blog/2007/aug/22/installing-satchmo-webfaction/

---
David Zhou
[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: Making Custom Model Methods to Work

2008-08-25 Thread David Zhou


On Aug 24, 2008, at 8:19 AM, rmschne wrote:

> 4.  calling render_to_response is differnt than I thought!
> print render_to_response('mtg_summary.html',{'my_meeting':my_meeting})
>
> Question: in the context of this example, in
> {'my_meeting':my_meeting}), what are these two things opposite of the
> colon?

That's a Python dictionary, with 'my_meeting' as the key, and the  
my_meeting object as the value.  See:

http://docs.python.org/dev/tutorial/datastructures.html#dictionaries

---
David Zhou
[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: Inherited models in new forms admin

2008-08-26 Thread David Zhou

On Aug 26, 2008, at 2:13 PM, Malcolm Tredinnick wrote:

> On Tue, 2008-08-26 at 10:57 -0700, diggs wrote:
>> I'm just starting to port my app over to use nfa and the first thing
>> that I'm seeing is that derived models are showing up twice in the
>> admin. In my case I have a base VideoStory class and
>> TwoPersonVideoStory class that derives from VideoStory using multi-
>> table inheritance. When I create a new TwoPersonVideoStory it shows  
>> up
>> under the list of VideoStorys as well. Is there a way to prevent  
>> this?
>
> No. The row in the VideoStory table has no way of knowing it's  
> linked to
> a row in the TwoPersonVideoStory table at the database level and  
> Django
> doesn't do a query over every possible descendent table every time it
> queries the root table (you may think that sounds acceptable for one
> table, but now add a few more subclasses and give them a few  
> subclasses
> of their own and it rapidly becomes horribly inefficient without  
> trying
> very hard).


Would it work if a ModelAdmin defined its own queryset() method that  
applied some base filters to remove rows it didn't want to show up in  
the ChangeList?

---
David Zhou
[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: site using Django/mod_python/apache2 randomly showing "It worked!" page

2008-08-27 Thread David Zhou

On Aug 27, 2008, at 9:18 PM, Richard Simões wrote:

> I have non-root access to a server with apache2 and mod_python. I
> installed django with svn to a location in my home directory and
> created a test project. When I go to a URL defined with urls.py and
> views.py, 9/10 times the expected page is shown. The remaining 1/10
> times the "It worked!" page pops up. Searching for this problem seems
> a bit difficult. Any idea on what could be happening?

Did you restart the server after making your changes?

---
David Zhou
[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: How to handle platform dependent settings?

2008-08-27 Thread David Zhou

On Aug 27, 2008, at 8:12 PM, Gremmie wrote:

>
> I test my code locally on my PC using the XAMPP package, and deploy
> the real site on Linux with Apache. My code is all common, except for
> settings.py and urls.py. I'd rather not have 2 versions of these files
> and try to manage that in my SVN repository.

...

> Is there a better way? Does this cause a performance hit, or is
> settings.py and urls.py processed only once?

If it's mostly paths that you need to change, check out:

http://rob.cogit8.org/blog/2008/Jun/20/django-and-relativity/

---
David Zhou
[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: Storing some media files on web server and some on external a/v server

2008-08-28 Thread David Zhou

On Aug 28, 2008, at 12:31 PM, [EMAIL PROTECTED] wrote:

> What would be ideal for me to do is to be able to store the images
> that are uploaded via the admin site on the main web server and then
> the audio that we upload via the admin site onto the streaming media
> server.
>
> Is this possible with Django, also if so is there any documentation
> out there on how to set the servers up so I can pass that along to our
> network admin set the servers up for me?


You should be able assign a callable to the upload_to argument for  
FileFields:

http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField

Then you can write your own method that returns the proper path.

---
David Zhou
[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: Dictionary key-value pair

2008-08-28 Thread David Zhou

On Aug 28, 2008, at 12:34 PM, saeb wrote:

> I am using a dictionary to render  a template. But my rendered
> template has the key-value pair  which are out of order. Since
> dictionary uses a hash table to store it elements, I can't rely on
> order of  these key-value pairs. Is there any other way to render
> bunch of key-value items from a view  in a desired order? Thanks for
> help

What are you trying to do, specifically? If order is important, why  
bother with a key? Why not just store all the values in a list?

---
David Zhou
[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: request: auth_user User model, not enough characters in email

2008-08-28 Thread David Zhou

On Aug 28, 2008, at 8:17 AM, Bram de Jong wrote:

> it's obviously a very small hack in the django source code, but it  
> would be nice if the email-field would have a few more characters.
> I have a few pesky users who actually use my site and have a vry  
> long email address.

If you have a recent version from trunk, you should be able to define  
your own length via max_length:

http://docs.djangoproject.com/en/dev/ref/models/fields/#emailfield

---
David Zhou
[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: Dictionary key-value pair

2008-08-28 Thread David Zhou

On Aug 28, 2008, at 12:45 PM, saeb wrote:

> order is important for display, I am calculating sum and average on
> query objects and storing it in dictionary with key/values which are
> used in a template. So I have a dictionary  something like this :
> {'name': user1, 'phone': 723872, 'Total Friends': 20, 'Avg Rating' :
> 3.6}
> so when I render I would these to appear in order.


Can you post the relevant view and template code?

But if it's just those fields, why not refer to them explicitly? Such  
as:

{{dict_variabe.name}} or {{dict_variable.phone}}

---
David Zhou
[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: Dictionary key-value pair

2008-08-28 Thread David Zhou


On Aug 28, 2008, at 1:18 PM, saeb wrote:

> No, it is not just those fields, there are about 20 key-value items. I
> have a Database with about 40 tables. and I am essentially trying to
> render a snapshot of about 15 important table which had foreign key
> relationship with other tables.  Following will give you an idea of
> what I am trying to do. Thanks

Since it looks like you're basically using the dictionary like a list  
of tuples, why not make it a list of tuples?  It should preserve  
ordering too, that way.



---
David Zhou
[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: CSS error in change_password.html

2008-09-01 Thread David Zhou

On Sep 1, 2008, at 4:49 PM, davor wrote:

> On the "change password" page (when you go to edit your users in
> Django administration) submit button is floated right and it's
> container () doesn't wrap around it because
> submit button hasn't got clear:both set. or something similar.

I think you should open a ticket for it.

But an easier way to do it is to just use clearfix:



---
David Zhou
[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: problem with passing dict object to django template

2008-09-02 Thread David Zhou


On Sep 2, 2008, at 1:34 PM, Matt Berg wrote:

> In my template, I want to be able to iterate through the crops with
> info like this:
>
> {{ ci.[crop.id].total }}

Are you using this within another loop?  Where's crop.id coming from?




---
David Zhou
[EMAIL PROTECTED]




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



Re: django web hosting

2008-09-02 Thread David Zhou

I've had pretty good experiences with WebFction.

David

Sent from my iPhone

On Sep 2, 2008, at 7:30 PM, Ed Wong <[EMAIL PROTECTED]> wrote:

>
> hi all,
>
> i am looking for a good web host for my django website.  does anyone
> suggest a good host?  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: django web hosting

2008-09-02 Thread David Zhou

60 megs is kind of low for djangohosting.ch's higher plan --  
webfaction, for example, gives 80 mb memory with their lowest plan.

I also really dislike hosts that claim "unlimited" bandwidth, and then  
say in the fine print that "unlimited" really means no more than 200gb  
a month.  In fact, djangohosting.ch's terms of service flat out  
declares that any usage over 200gb is considered "excessive".  Hardly  
unlimited.

It also doesn't appear to offer PostgreSQL as an option -- the front  
page only lists MySQL.


On Sep 2, 2008, at 8:39 PM, Nikos Delibaltadakis wrote:

> If you want just django then http://djangohosting.ch/ is much better  
> than webfaction, i have accounts in both.
> If you want other platforms too, then prefer webfaction.
>
> 2008/9/3 Ed Wong <[EMAIL PROTECTED]>
>
> hi all,
>
> i am looking for a good web host for my django website.  does anyone
> suggest a good host?  thanks.
>
>
>
>
>
> -- 
> Nikos Delibaltadakis
>
> >

---
David Zhou
[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: How to display Html in my screen

2008-09-02 Thread David Zhou

> I got confused, when i write html scripts in my admin testfield like
> hello and save them in mysql, but when i wanna display them
> in screen, they can not display as bold font as i want, the source
> file writes: <h1>hello</h1>
>
> What can i do to make it right?



Django autoescapes.  See:

http://docs.djangoproject.com/en/dev/topics/templates/#how-to-turn-it-off

---
David Zhou
[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
-~--~~~~--~~--~--~---



MediaTemple Django Containers

2008-09-04 Thread David Zhou

Are now available according to their homepage:

http://mediatemple.net/webhosting/gs/django.html

Was anyone in the beta? I've not used them, so I'm wondering what the  
experience was like.

---
David Zhou
[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: Introducing django-cms

2008-09-08 Thread David Zhou

Nice!

I especially like the page reordering change you've made to the  
admin.  Any chance you could talk a little about how you did that?

On Sep 8, 2008, at 10:15 AM, Thomas Steinacher wrote:

>
> Hello Djangonauts!
>
> I would like to introduce django-cms, a free, BSD-licensed content
> management system based on Django. It is seamlessly integrated with
> Django's admin interface and supports a hierarchical page structure,
> internationalization and much more.
>
> You can find the project page on http://django-cms.org/. There is also
> a demo site set up which allows you to play around with the admin
> interface.
>
> The software is still in development and we would appreciate any
> feedback and contributions.
>
> Greetings from Switzerland,
>
> Thomas Steinacher
> djangohosting.ch
>
> >

---
David Zhou
[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: disable delete checkbox in Inline formset

2008-09-08 Thread David Zhou

On Sep 8, 2008, at 2:30 PM, Kurczak wrote:

> Is there any way to disable/remove the delete checkbox for inline
> formsets ( in admin) ?
> I found nothing about it in docs, and I believe there's no way to pass
> the 'can_delete' parameter to inlineformset_factory. Obviously I can
> disable the "Can delete" permission, but the ugly box is still there.

Have you tried editing the admin templates to not show the checkbox?

---
David Zhou
[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: Double Slash in URL

2008-09-08 Thread David Zhou

On Sep 8, 2008, at 7:04 AM, Thomas Guettler wrote:

> I discovered, that double slashes get through my regular expressions.
> Is it possible to reject URLs with double slashes?
>
> http://.../...//test// (double slash before and after "test")


Another way to approach it is to allow variable amounts of slashes --  
like:

(r'^test/+$', 'modwork.views.test.index'),

---
David Zhou
[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: disable delete checkbox in Inline formset

2008-09-08 Thread David Zhou

On Sep 8, 2008, at 2:55 PM, Kurczak wrote:

> On 8 Wrz, 20:37, David Zhou <[EMAIL PROTECTED]> wrote:
>> On Sep 8, 2008, at 2:30 PM, Kurczak wrote:
>>
>>> Is there any way to disable/remove the delete checkbox for inline
>>> formsets ( in admin) ?
>>> I found nothing about it in docs, and I believe there's no way to  
>>> pass
>>> the 'can_delete' parameter to inlineformset_factory. Obviously I can
>>> disable the "Can delete" permission, but the ugly box is still  
>>> there.
>>
>> Have you tried editing the admin templates to not show the checkbox?
> Hi David,
> thanks for your reply.
> I just did in fact, but that affects every single inline form in the
> project, and that's not what I want. There's no way to load inline
> template (in admin) for selected app from what I learned. And I'd
> rather not modify anything in django code because i don't really
> consider that as solution.
> Is there any other way?


You're not really modifying django, since you can include the templats  
in your templates folder, and override them.

If you want app specific admin templates, one way is to wrap the admin  
views -- for example, see:

http://trac.django-cms.org/trac/browser/trunk/cms/admin_views.py

---
David Zhou
[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: Internal server error upgarding from 0.97 to 1.0

2008-09-09 Thread David Zhou

On Sep 9, 2008, at 11:39 AM, Haku wrote:

>
> Hello, i'm quite frustrated by this problem.
> Today i had the  idea to update my svn from the old 0.97 to the 1.0
> release, and now nothing is working anymore.
>
> I always get an anonymous "Internal Server Error"
> Maybe because my project included mptt, but the fact is that i cant
> figure out why it is crashing. Seems like it's the slug fields but i
> don't really know.
>
> Is there a solution? Or maybe, how can i return to my loved 0.97
> version?

Looks like it's because of newforms-admin.

> [Tue Sep 09 19:35:43 2008] [error] [client 192.168.0.101]
> PythonHandler django.core.handlers.modpython: TypeError: __init__()
> got an unexpected keyword argument 'prepopulate_from'


See:

http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Mergednewforms-adminintotrunk

Specifically, the "Changed prepopulate_from to be defined in the Admin  
class, not database field classes" section.

---
David Zhou
[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: Restricting views

2008-09-11 Thread David Zhou

On Sep 11, 2008, at 11:07 AM, ek_wals wrote:

> How should I restrict a page to a superuser only??
>
> There's a 'staff_member_required' decorator, wht not a
> 'superuser_required'?

It'd be simple enough to write your own decorator to check for  
required permissions.  I usually do so anyway, in case I need to  
change how permission works in the future.

---
David Zhou
[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: Running into errors using S3 backend for Django

2008-09-14 Thread David Zhou


On Sep 15, 2008, at 1:01 AM, vinay wrote:

> File "/usr/lib/python2.5/site-packages/django/core/files/
> storage.py", line 81, in path
>raise NotImplementedError("This backend doesn't support absolute
> paths.")
> NotImplementedError: This backend doesn't support absolute paths.

Sounds like you just need to define that method for the S3 backend.   
It's falling back on the base method that spits out the exception.

---
David Zhou
[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: Recommendations for local web dev on Mac OS X 10.5 vs. developing against WebFaction Linux box

2008-09-15 Thread David Zhou


On Sep 15, 2008, at 7:58 PM, DougI wrote:

> Should I develop locally on my Mac, i.e. install Django/PostgreSQL
> locally and then upload to WebFaction, or create/open files directly
> on my WebFaction server via SSH or FTP?

I would develop locally -- using Django's built in server for testing  
and also using Django's static view to serve media.  Then when  
deploying to WebFaction, be sure to set up static hosting separately.

> Also, recommendations for an IDE would be appreciated - TextMate,
> Komodo, IDLE, etc?

I'm partial to TextMate.  Although, if you're used to VIM at all,  
MacVim (http://code.google.com/p/macvim/) is pretty awesome.

---
David Zhou
[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: actual django stack

2008-09-26 Thread David Zhou


On Sep 26, 2008, at 5:54 AM, Peter Bengtsson wrote:

> On Sep 25, 8:41 pm, "Frédéric Sidler" <[EMAIL PROTECTED]>
> wrote:
>> What it the best Django stack today.
>>
>> In django doc, it says that apache with mod_python is the best
>> solution in production. But in the same time I see that everyblock  
>> use
>> nginx (probably in mode fastcgi).
>>
>> Did you some of you test different solution and can share some  
>> output here.
>>
>> Here are the ones I see actually
>>
>> Apache mod_python
>> Apache in fastcgi mode
>> Lighttpd in fastcgi mode
>> Nginx in fastcgi mode
>>
>
> I've noticed a small performance boost from using Nginx + fcgi
> compared to Apache + mod_python and I hear that Nginx is also a better
> performer on the static content but haven't personally experienced
> that but the blogosphere will probably agree that Nginx is faster.
> The benefit to us with Apache is that we have more knowledge about it
> within the team but this only matters when you do more complicated
> stuff such as advanced authentication stuff or additional security
> hardening. This will probably be the case for many teams since Nginx
> is so new.

I've also heard good things about WSGI -- though I haven't heavily  
tested its stability compared to, say, mod_python.
---
David Zhou
[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: Cannot serve static files

2009-01-22 Thread David Zhou

On Thu, Jan 22, 2009 at 10:53 AM, john  wrote:
>
> No matter what i do i can't get my css to load. 100% Frustrated with
> Django. My index page loads when i request http://127.0.0.1:8000/ but
> it is not styled. Django dev server returns 404 in console for "GET /
> css/styles.css HTTP/1.1"

Try doing:




-- dz

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



Modifying pythonpath in settings.py

2009-02-18 Thread David Zhou

I've been doing the following for a while, but I'm not sure if it has
unintended side effects:

#settings.py
import os, sys
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
'apps'))

I keep pluggable apps in an svn repo, and do checkouts of the ones I
need in the apps folder that's specific to whatever site I'm working
on.  And since I do this for most of my projects, I figured it'd be
easier to make sure it was in the pythonpath rather than relying on
the environment to properly define pythonpath.

Is it considered bad practice to dynamically modify the pythonpath in
something like settings.py?

-- dz

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



Re: Modifying pythonpath in settings.py

2009-02-18 Thread David Zhou

Nevermind -- I'd always imported settings first, but since that's not
always the case (such as third party apps), things act strangely.

Short of changing something in django core, is there any way of adding
to sys.path dynamically before any django code gets run?

-- dz



On Thu, Feb 19, 2009 at 12:10 AM, David Zhou  wrote:
> I've been doing the following for a while, but I'm not sure if it has
> unintended side effects:
>
> #settings.py
> import os, sys
> sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
> 'apps'))
>
> I keep pluggable apps in an svn repo, and do checkouts of the ones I
> need in the apps folder that's specific to whatever site I'm working
> on.  And since I do this for most of my projects, I figured it'd be
> easier to make sure it was in the pythonpath rather than relying on
> the environment to properly define pythonpath.
>
> Is it considered bad practice to dynamically modify the pythonpath in
> something like settings.py?
>
> -- dz
>

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



Removing fields in a form subclass

2009-02-20 Thread David Zhou

Suppose I had this form:

class BaseForm(forms.Form):
field1 = forms.CharField(...)
field2 = forms.Charfield(...)

And then in a subclass, I had:

class SubForm(BaseForm):
field1 = forms.EmailField(...)

What's a good way to remove field2 in SubForm?  Setting field2 = None
didn't work.  I've been resorting to a custom widget that doesn't
display any HTML, but there must be a better way?

I guess I could write an __init__ method that checks for the existence
of field2 and removes it as an attribute, but that doesn't feel very
clean.

-- dz

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



Re: Removing fields in a form subclass

2009-02-20 Thread David Zhou

Do you mean del self.fields['field2'] in SubForm's __init__?

-- dz



On Fri, Feb 20, 2009 at 10:39 AM, Alex Koshelev  wrote:
> Try this:
>
> del SubForm.fields['fields2']
>
>
> On Fri, Feb 20, 2009 at 6:15 PM, David Zhou  wrote:
>>
>> Suppose I had this form:
>>
>> class BaseForm(forms.Form):
>>field1 = forms.CharField(...)
>>field2 = forms.Charfield(...)
>>
>> And then in a subclass, I had:
>>
>> class SubForm(BaseForm):
>>field1 = forms.EmailField(...)
>>
>> What's a good way to remove field2 in SubForm?  Setting field2 = None
>> didn't work.  I've been resorting to a custom widget that doesn't
>> display any HTML, but there must be a better way?
>>
>> I guess I could write an __init__ method that checks for the existence
>> of field2 and removes it as an attribute, but that doesn't feel very
>> clean.
>>
>> -- dz
>>
>>
>
>
> >
>

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



Re: Removing fields in a form subclass

2009-02-20 Thread David Zhou

Is the base_fields diciontary documented somewhere or is this more of
a behind the scenes attribute that the Form metaclass converts field
attributes to?

-- dz



On Fri, Feb 20, 2009 at 10:47 AM, Alex Koshelev  wrote:
> Oh, sorry. Of course `base_field` instead.
>
> class SubForm(BaseForm):
> field1 = forms.EmailField(...)
>
> del SubForm.base_fields['fields2']
>
> On Fri, Feb 20, 2009 at 6:45 PM, Alex Koshelev  wrote:
>>
>> No. Place this code right after the SubForm definition.
>>
>> On Fri, Feb 20, 2009 at 6:42 PM, David Zhou  wrote:
>>>
>>> Do you mean del self.fields['field2'] in SubForm's __init__?
>>>
>>> -- dz
>>>
>>>
>>>
>>> On Fri, Feb 20, 2009 at 10:39 AM, Alex Koshelev 
>>> wrote:
>>> > Try this:
>>> >
>>> > del SubForm.fields['fields2']
>>> >
>>> >
>>> > On Fri, Feb 20, 2009 at 6:15 PM, David Zhou  wrote:
>>> >>
>>> >> Suppose I had this form:
>>> >>
>>> >> class BaseForm(forms.Form):
>>> >>field1 = forms.CharField(...)
>>> >>field2 = forms.Charfield(...)
>>> >>
>>> >> And then in a subclass, I had:
>>> >>
>>> >> class SubForm(BaseForm):
>>> >>field1 = forms.EmailField(...)
>>> >>
>>> >> What's a good way to remove field2 in SubForm?  Setting field2 = None
>>> >> didn't work.  I've been resorting to a custom widget that doesn't
>>> >> display any HTML, but there must be a better way?
>>> >>
>>> >> I guess I could write an __init__ method that checks for the existence
>>> >> of field2 and removes it as an attribute, but that doesn't feel very
>>> >> clean.
>>> >>
>>> >> -- dz
>>> >>
>>> >>
>>> >
>>> >
>>> > >
>>> >
>>>
>>>
>>
>
>
> >
>

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



Re: Removing fields in a form subclass

2009-02-20 Thread David Zhou

I would, but in this case, I want to remove a field in an external app
(specifiaclly, django-registration).  I suppose I could extract all
the relevant parts out of the form class in django-registration and
paste it into my own form, but that seems really redundant.

Basically, the user's name is autogenerated from the email field, so I
want to remove the username field from the django-registration form.

Though I suppose if there's no good way of doing it, I'll just have to
copy out the relevant bits into a new form.

-- dz



On Fri, Feb 20, 2009 at 7:20 PM, Malcolm Tredinnick
 wrote:
>
> On Fri, 2009-02-20 at 10:15 -0500, David Zhou wrote:
>> Suppose I had this form:
>>
>> class BaseForm(forms.Form):
>> field1 = forms.CharField(...)
>> field2 = forms.Charfield(...)
>>
>> And then in a subclass, I had:
>>
>> class SubForm(BaseForm):
>> field1 = forms.EmailField(...)
>>
>> What's a good way to remove field2 in SubForm?
>
> Wrong question. Reconsider your class structure. Inheritance says that
> SubForm "is-a" version of BaseForm. However, your question is asking how
> you can actually break that constraint by removing one of the necessary
> parts of BaseForm. So it isn't really a subclass after all.
>
> If there are common elements between BaseForm and SubForm, then factor
> out those common bits into a true base class that both BaseForm and
> SubForm inherit from.
>
> Regards.
> Malcolm
>
>
>
>
> >
>

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



Re: Why won't my form validate?

2009-03-24 Thread David Zhou

If it's not valid, then something likely threw a validation error.
What does the error say?

-- dz



On Tue, Mar 24, 2009 at 3:11 PM, Theme Park Photo, LLC
 wrote:
>
> It has data! It was created from an existing instance...and all the
> fields have values
>
> 'body': u'hello there', 'allow_comments':
>                        1, 'author': 10L, 'tease': u'hello there p>',
>                        'publish': datetime.datetime(2009, 3, 23, 15,
> 3,
>                        36), 'score': -93L, 'categories': [1L],
> 'title':
>                        u'Hello', 'slug': u'hello-0', 'tags':
> u'hello'}
>
>
> On Mar 24, 12:06 pm, Alex Gaynor  wrote:
>> On Tue, Mar 24, 2009 at 3:02 PM, Theme Park Photo, LLC 
>> wrote:
>>
>>
>>
>>
>>
>> > Im trying to get code to edit an existing record in a table working.
>> > For some reason, form.is_valid is returning false (and I can't save it
>> > because there's no cleaned data). Even reduced to this (below) where
>> > I'm simply getting an existing "Post" object, creating a ModelForm,
>> > and validating it, fails!
>>
>> > Any suggestions?
>>
>> >        post = Post.objects.get(id=postId)
>> >        form = PostForm(instance=post)
>> >        if form.is_valid(): # All validation rules pass
>> >                        form.save()
>> >        else:
>> >               # at this point, non_field_errors and _get_errors
>> > return null. _errors is defined as none(), yet form.is_valid
>> >               # is returning false
>>
>> A form without data is never considered valid.  You probably want your
>> workflow to be more like:
>>
>> obj = Model.objects.get()
>> if request.method == 'POST':
>>     form = Form(request.POST, isntance=obj)
>>     if form.is_valid():
>>        form.save()
>> else:
>>      form = Form(instance=obj)
>> return render_to_response()
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your right to
>> say it." --Voltaire
>> "The people's good is the highest law."--Cicero
> >
>

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



Re: Why won't my form validate?

2009-03-24 Thread David Zhou

It builds up on the things mentioned in the documentation for normal
forms.  Also, the documentation for ModelForm's save instance has
pretty explicit examples of creating form instances:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

-- dz



On Tue, Mar 24, 2009 at 3:21 PM, Theme Park Photo, LLC
 wrote:
>
> Error fields were all empty. I checked methods non_field_errors and
> _get_errors; _errors was None.
>
> But Alex Gaynor was right! When I added the form "POST" data in, the
> form validated. I assumed that creating a ModelForm from an existing
> instance would give it valid data, but that's not the case. (Though
> the Django Documentation doesn't say this:
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ )
>
>
> On Mar 24, 12:15 pm, David Zhou  wrote:
>> If it's not valid, then something likely threw a validation error.
>> What does the error say?
>>
>> -- dz
>>
>> On Tue, Mar 24, 2009 at 3:11 PM, Theme Park Photo, LLC
>>
>>  wrote:
>>
>> > It has data! It was created from an existing instance...and all the
>> > fields have values
>>
>> > 'body': u'hello there', 'allow_comments':
>> >                        1, 'author': 10L, 'tease': u'hello there> > p>',
>> >                        'publish': datetime.datetime(2009, 3, 23, 15,
>> > 3,
>> >                        36), 'score': -93L, 'categories': [1L],
>> > 'title':
>> >                        u'Hello', 'slug': u'hello-0', 'tags':
>> > u'hello'}
>>
>> > On Mar 24, 12:06 pm, Alex Gaynor  wrote:
>> >> On Tue, Mar 24, 2009 at 3:02 PM, Theme Park Photo, LLC 
>> >> wrote:
>>
>> >> > Im trying to get code to edit an existing record in a table working.
>> >> > For some reason, form.is_valid is returning false (and I can't save it
>> >> > because there's no cleaned data). Even reduced to this (below) where
>> >> > I'm simply getting an existing "Post" object, creating a ModelForm,
>> >> > and validating it, fails!
>>
>> >> > Any suggestions?
>>
>> >> >        post = Post.objects.get(id=postId)
>> >> >        form = PostForm(instance=post)
>> >> >        if form.is_valid(): # All validation rules pass
>> >> >                        form.save()
>> >> >        else:
>> >> >               # at this point, non_field_errors and _get_errors
>> >> > return null. _errors is defined as none(), yet form.is_valid
>> >> >               # is returning false
>>
>> >> A form without data is never considered valid.  You probably want your
>> >> workflow to be more like:
>>
>> >> obj = Model.objects.get()
>> >> if request.method == 'POST':
>> >>     form = Form(request.POST, isntance=obj)
>> >>     if form.is_valid():
>> >>        form.save()
>> >> else:
>> >>      form = Form(instance=obj)
>> >> return render_to_response()
>>
>> >> --
>> >> "I disapprove of what you say, but I will defend to the death your right 
>> >> to
>> >> say it." --Voltaire
>> >> "The people's good is the highest law."--Cicero
> >
>

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



Re: marrying django to twitter

2009-06-30 Thread David Zhou

On Tue, Jun 30, 2009 at 11:21 PM, Kenneth Gonsalves
 wrote:
>
> has anyone succeeded in marrying django to twitter - that is broadcasting
> updates in the django db to twitter? I did see one post on the subject in the
> archives, but there was no information as to whether the operation was
> successful.

I haven't tried it, but it shouldn't be hard.  Subscribe to the
relevant signals for whatever you want to track, and use a Python
Twitter library to post to the Twitter account.

I've used Mike's module at: http://mike.verdone.ca/twitter/ previously
to great success.   To post something an account with that module:

import twitter
t = twitter.api.Twitter('username', 'password')
t.statuses.update(status="This is the tweet.")

-- dz

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



Re: How to get rid of the 'u'? Seems to be everyhere :)

2009-08-08 Thread David Zhou

See:

http://diveintopython.org/xml_processing/unicode.html

-- dz



On Sat, Aug 8, 2009 at 11:27 PM, Joshua Partogi wrote:
> u' stands for Python unicode.
>
> On Sun, Aug 9, 2009 at 12:03 PM, strotos  wrote:
>>
>> Hey all,
>>
>> I am very new to Django and am having a bit of trouble with something
>> and I'm hoping I can get some help from you all.
>>
>> I was just wondering how do I share say a list or dictionary between
>> views?
>>
>> What I have at the moment is.
>>
>> from django.shortcuts import render_to_response
>> from django.http import HttpResponse
>>
>> myList = ["http://localhost:1";, "http://localhost:2";]
>>
>> def index(request):
>>        head = "Viewer"
>>
>>        thelist = ""
>>
>>        for i in myList:
>>                thelist = ('%s  Test ') % (thelist,
>> i)
>>
>>        body ="%s" % thelist
>>        tail = ""
>>        print thelist
>>        html = head,body,tail
>>
>>        return HttpResponse(html)
>>
>> def update(request):
>>
>>        query = request.GET.get('t', '')
>>        print query
>>        myList.append(query)
>>        html ="UploadUpload OK %s> body>
>>        return HttpResponse(html)
>>
>>
>> In my update the "query" variable is added to the list myList, but a u
>> is appended which seams to be the url of the app, is there a way to
>> remove this u, or is there a better way to share data like a dict or
>> list between views?
>>
>
> --
> http://blog.scrum8.com
> http://twitter.com/scrum8
>
> >
>

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



Re: logic in templates

2009-08-12 Thread David Zhou

The easiest way is probably moving that list to the view.  For example

customers = Customer.objects...
sellers = Seller.objects...

filtered_list = [pair for pair in zip(sellers, customers) if
pair[0].customer_id == pair[1].id]

Then pass filtered_list into the template context.  Inside the
template, you could do:

(Assuming Django >= 1.1)

{% for seller, customer in filtered_list %}
{{ seller.name }} {{ customer.name }} 
{% empty %}
No customers.
{% endfor %}


-- dz



On Wed, Aug 12, 2009 at 5:06 AM, elminio wrote:
>
> Hello,
>
> Common task in template is doing for loop end inserting into html some
> elements.
>
> for example
>
> 1: {% for  seller in sellers %}
> 2:    {% for customer in customers %}
> 3:        {% ifequal seller.customer_id customer.id %}
> 4:            {{ seller.name }} {{ customer.name }} 
> 5:        {% endifequal %}
> 6:    {% endfor %}
> 7: {% endfor %}
>
>
> Thats clear.
>
> Now I would like to know when the loop is over and system didnt't find
> customer for seller (line 3). And in this case insert no customers p>.
>
> If it shouldnt be done in template how can I inject logic from python
> file ?
>
> thanks for 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: digg style pagination

2009-08-14 Thread David Zhou

http://tinyurl.com/mj29fw

-- dz



On Fri, Aug 14, 2009 at 2:54 PM, sniper wrote:
>
> I am trying to do pagination. Just wanted to know if there is a
> shortcut to show digg style pagination or i have to write my own?
> I am asking this because in the admin page, the list page uses digg
> style paging.
>
>
> >
>

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



Re: Using glovar vars

2009-08-17 Thread David Zhou

For what you describe, you're not looking for "global" variables in
the sense that you want some value persisted in the same process.
You're looking at session variables, which are variables persisted for
a specific user session.

See:

http://docs.djangoproject.com/en/dev/topics/http/sessions/

Honestly though, the easiest way that I can think of is just to use
separate URLs.  That way, a user could easily use the PC version if he
desires.

-- dz



On Mon, Aug 17, 2009 at 3:28 AM, Steve
Patrick wrote:
>
> I`ve got an application developed for PCs and I want to make it
> available for mobile devices. There are only some slight differences
> between booth two versions, so I think is not worth while to develope
> different applications. Instead, I've decided to develope an only
> application in which I need a "global" variable that helps me to
> remember if the user is using a mobile device or a PC (I know it on my
> firts page, looking at the user agent). How can I store that
> variable?? Of course, if different users connect to the application
> they would have different user agents and thus, different values for
> that "global" variable I want to use.
> Thanks for your time
> >
>

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



Re: django template language issue

2009-08-17 Thread David Zhou

On Mon, Aug 17, 2009 at 6:39 AM, Adonis wrote:

> My problem is that even if the 'projects' queryset is empty, it still
> includes the projects.html
> Is there another way to do it?

If you're using at least Django 1.1, you can use the empty tag:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for-empty

For example:

{% for item in projects %}

   {% include projects.html %}

{% empty %}

   There are no items in the project.

{% endfor %}

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



Re: a bit like permission, but...

2009-08-21 Thread David Zhou

On Aug 21, 2009, at 9:54 AM, MIL wrote:

> this works fine but I dont want to repeat it in all my views:
> def my_profile(request):
>   gotta_go_through = request.user.get_profile
> ().gotta_go_through_this_url()
>   if gotta_go_through and gotta_go_through != request.path:
>   return HttpResponseRedirect(gotta_go_through)
>   ...
> Or  maybe you can give me a better solution for this.

Take a look at middleware. Specifically, process_request():

http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-request


-- dz

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



Re: How I can add new functionality in homepage of admin site??

2009-08-24 Thread David Zhou

On Mon, Aug 24, 2009 at 3:29 PM, sandravigo wrote:
>
> Hi, friends. I have a problem.
> I created a function (main) that displays a list on the first page
> (index.html) of site administration. The problem is that for example,
> if I put in URLConf: (r '^ admin /(.*)',' myproject.views.main '),
>  I get this list as I want, but don't shows the view by default of
> Django admin (r '^ admin /(.*)', admin.sites.root'), which shows all
> app and the managing of users and groups. Do you know what I mean?

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_urls

-- dz

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



Re: Django scalability with files

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 6:13 AM, Lewis
Taylor wrote:
>
> I have an imagefield that i want to create a thumbnail for on approval
> of the image. The problem is (setup is 2 django instances, load
> balancer and DB) if the image is stored on one machine it's not the
> cleanest solution to have to get the image from the other server and

We ran into a similar issue in a past project, and if you have
scalability concerns, setting up a proper queue system is pretty much
the only practical method we thought of.  For every image uploaded,
add a new task to the queue detailing where the image is located. Then
have a separate image processing service running somewhere, ping the
queue for new tasks, and sync the processed image to your static
server(s).

If you really want to store uploaded images directly to the database
in blobs, look into writing a custom storage backend:

http://docs.djangoproject.com/en/dev/howto/custom-file-storage/

That will lessen syncing issues without needing a task queue, but will
make your db server work harder.

-- dz

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



Re: How to check which form was submitted?

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 7:09 AM, Maksymus007 wrote:
>
> I've got two different form on the same page, under the same URL.
> When I send one of them, the second one gets validated too.
> I set prefixes but no change.
>
> Is there any way to distinguish between two forms, choosing one that
> have been submited?

Prefixes are for using the same form multiple times on a page,
avoiding name collisions.

Post the part of your view that handles your forms.

-- dz

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



Re: get an object's model name

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 7:08 AM, Léon Dignòn wrote:
>
 from django.contrib.auth.models import User
 u = User.objects.get(id=1)
 u
> 
 print u
> leon
 type(u)
> 

Alternatively:

>>> u.__class__.__name__
'User'

-- dz

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



Re: redirect in django

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 6:58 AM, Matthias
Kestenholz wrote:
>
>> On Thu, Aug 27, 2009 at 2:59 PM, ankit  wrote:
>>>
>>> I am new to django.I having to app in my admin.Know I want to know
>>> that how can i redirect user to one app listpage if clicks save on
>>> second app.say from app2 to app1
>>>
>
> You can do this by overriding the ModelAdmin response_change or
> response_add method (or both, depending on your needs) you are
> registering your model with.

The easiest way I can think of is to capture the response, and check
that.  For example:

class MyModelAdmin(admin.ModelAdmin):
   def response_change(self, *args, **kwargs):
  response = super(MyModelAdmin, self).response_change(*args, **kwargs)
  if 'Location' in response and response['Location'] == "../":
 #generate your own HttpResponseRedirect
  else:
 return response

Really though, jumping around the admin like that is potentially
really confusing.

-- dz

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



Re: How to check which form was submitted?

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 7:33 AM, Maksymus007 wrote:
>
> On Thu, Aug 27, 2009 at 1:22 PM, David Zhou wrote:
>> Post the part of your view that handles your forms.
>
> Nothing special
>
>    if request.method == 'POST':
>        form = RegisterForm(request.POST)
>        if form.is_valid():
>             pass
>
> And second one is handled by middleware, in similar way

Put in a hidden inputs in your fields to distinguish the two.  For example:

if request.method == 'POST' and '_hiddenname' in request.POST:
 ...

-- dz

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



Re: Problem building data structure for Archive page

2009-08-27 Thread David Zhou

On Thu, Aug 27, 2009 at 10:10 AM, gnijholt wrote:
> Or is there a better way to generate a full archive page (per year,
> per month)?

You'll need to test this, but you should be able to do that with {%
ifchanged %}:

#view:
posts = Posts.objects.order_by('-pub_date')

#template

{% for post in posts %}
{% ifchanged post.pub_date.year %}
{{post.pub_date.year}}
{% endifchanged %}
{% ifchanged post.pub_date.month %}
{{post.pub_date.month}}
{% endifchanged %}
{{ post.title }}
{% endfor %}

-- dz

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



Re: Avoiding Accidental Overwrite In Admin Interface

2009-03-25 Thread David Zhou

It shouldn't be too hard to add a last-updated timestamp to a model,
and compare it to a hidden field in the form validation.

-- dz



On Wed, Mar 25, 2009 at 11:49 AM, Daniel Watkins
 wrote:
>
> Hello all,
>
> We recently ran into an issue when two people were editing a record via
> the admin interface simultaneously.  Both opened the record, made
> changes and hit Save.  Person A pressed Save after Person B, and so only
> Person A's changes were reflected in the database.
>
> What is a good way of ensuring that this doesn't happen again?
>
> I would expect Person A to receive a warning about what they were about
> to do, so they could open up Person B's changes in a different tab and
> compare.  An alternative solution would be to only allow one person to
> be editing a page at a given time (where they are 'editing' between
> opening the page and hitting 'Save', 'Save and add another' or logging
> out).  Perhaps a 'Cancel' button would also be in order.
>
>
> Thanks,
>
> Dan
>
>
> >
>

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



Re: Design Issue / forward referencing

2009-03-28 Thread David Zhou

Also see:

http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.symmetrical

-- dz



On Sat, Mar 28, 2009 at 11:57 AM, Alex Gaynor  wrote:
>
>
> On Sat, Mar 28, 2009 at 10:55 AM, mahesh  wrote:
>>
>> I am working on a (College) course manager project. Here is a
>> situation where any course have 0 (Zero) or More Prerequisites, anyone
>> who register for a course should satisfy dependency.
>>
>> /course_modue/model.py hash this..
>>
>> Here how my model looks like ..
>>
>> class CourseRelation(models.Model):
>>    course = models.CharField(max_length=64)
>>    prereq = models.ManyToManyField(CourseRelation)
>>    instructor = models.ForeignKey(User)
>>    is_active = models.BooleanField(default=False)
>>
>> Command - python manage.py sqlall course_module error out saying
>>  File "/course_module/models.py", line 27, in CourseRelation
>>    prereq = models.ManyToManyField(CourseRelation)
>> NameError: name 'CourseRelation' is not defined
>>
>> Is this a case of forward referencing ? how do I solve it ?
>>
>> Thx/Mahesh.
>>
>>
>>
>
> To do references to the same model you do ManyToManyField('self').
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

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



Re: Best Convension for dealing with variables needed in every view.

2009-03-29 Thread David Zhou

On Sun, Mar 29, 2009 at 7:14 PM, IanR  wrote:

> I'm trying to stay a close to the suggested Django conventions as
> possible.  I have a few variables that I need to render any page.

Check out context processors:
http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors

> base_media_url, this is the url of where I store all my static files
> and media, images, javascript, css

This is actually already available if you use the RequestContext, as
by default, the list of context processors include the media url:

http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media

-- dz

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



Re: What hash algorithm does django auth use?

2009-03-29 Thread David Zhou

On Sun, Mar 29, 2009 at 9:50 PM, Joshua Partogi  wrote:
>
> I thought we're to use hexdigest ?
>
> Did I miss something here?

You need to salt it:

http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L20

-- dz

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



  1   2   >