Re: when deploying a real site django says i dont have access to python eggs cache

2008-10-27 Thread Graham Dumpleton



On Oct 28, 3:05 pm, geezer <[EMAIL PROTECTED]> wrote:
> hi,
>
> when deploying to a real site, django says i dont have writable access
> to a python eggs cache, when i redirect the python eggs cache, placing
> it into a new writable directory the browser crashes, exactly what are
> the steps to satisfying django requirements for the python eggs cache
> in this situation?

Depends on the hosting mechanism you use, something you don't say. So,
please provide more information about how you are running Django and
how you are configuring that specific hosting mechanism.

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



when deploying a real site django says i dont have access to python eggs cache

2008-10-27 Thread geezer

hi,

when deploying to a real site, django says i dont have writable access
to a python eggs cache, when i redirect the python eggs cache, placing
it into a new writable directory the browser crashes, exactly what are
the steps to satisfying django requirements for the python eggs cache
in this situation?

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



Easiest way to pass django documentation from rest to HTML?

2008-10-27 Thread Mr. Z

Which is the easiest way to pass the new django documentation from
rest to HTML?

Thank you,

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



How can I use captchar in django admin site

2008-10-27 Thread Alan

I want to add captchar to login django admin interface.
And now I hacked the staff_member_required in
django.contrib.admin.views.decorators
Is there a more graceful way to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Donation Application

2008-10-27 Thread [EMAIL PROTECTED]

I don't know of any applications for this specifically, however you
can probably steal various parts of Satchmo, specifically all the
payment stuff.

On Oct 27, 9:03 pm, unklbeemer <[EMAIL PROTECTED]> wrote:
> I did some searching and found nothing. I was wondering if anyone knew
> of any django applications out there for receiving donations and/or
> tracking those donations (capital campaign progress, pledges donated,
> etc.)
>
> 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
-~--~~~~--~~--~--~---



Donation Application

2008-10-27 Thread unklbeemer

I did some searching and found nothing. I was wondering if anyone knew
of any django applications out there for receiving donations and/or
tracking those donations (capital campaign progress, pledges donated,
etc.)

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: Triggering a custom signal

2008-10-27 Thread Matías Costa
On Mon, Oct 27, 2008 at 5:52 PM, redmonkey <[EMAIL PROTECTED]>wrote:

>
> h. Yeah, That's pretty simple.
>
> I could even get a reference to the Job number using -v with at,
> storing that in the DB and then removing and recreating another at-job
> if the user changes the time.
>

Do you mean some kind of shell scripting embed with os.system or
process.call?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ifequal and numbers

2008-10-27 Thread R. Gorman

You would probably be better off writing a custom template tag (http://
docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-
template-tags).

R.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Model that calls a function in another model

2008-10-27 Thread Karen Tracey
On Mon, Oct 27, 2008 at 7:19 PM, Michael Meier <[EMAIL PROTECTED]>wrote:

>
> Hello
>
> I'm relatively new to Django and I was able to set up a small
> application without any problems, BUT:
>
> How can I access data inside a model that comes from another model. As
> an example, I have a model Person, which has a One-To-Many-
> relationship to Skills. So each person can have multiple skills.
>
> Now my idea is that the Skills model has one function that returns the
> number of skills a person has.
>
> I tried this for several hours now :-(, including searching the
> documentation, but I can't find that information. Maybe I just need a
> push into the right direction.
>
>
You might want to read this section of the docs:

http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects

It's a little hard to be sure since you did not give specifics on your
model, but assuming you have a model named Person and one named Skill, and
Skill has a ForeignKey field to a Person, then the number of Skills for a
Person instance p would be obtained by:

p.skill_set.count()

So, you don't come at it from the Skill model but rather from an instance of
a Person model.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Model that calls a function in another model

2008-10-27 Thread Michael Meier

Hello

I'm relatively new to Django and I was able to set up a small
application without any problems, BUT:

How can I access data inside a model that comes from another model. As
an example, I have a model Person, which has a One-To-Many-
relationship to Skills. So each person can have multiple skills.

Now my idea is that the Skills model has one function that returns the
number of skills a person has.

I tried this for several hours now :-(, including searching the
documentation, but I can't find that information. Maybe I just need a
push into the right direction.

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: Exception thrown from django.test.client.Client

2008-10-27 Thread [EMAIL PROTECTED]

Thank you, that seems to have done it. I didn't know you could set
REMOTE_ADDR explicitly in the constructor.

On Oct 23, 12:16 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 23, 2008 at 11:41 AM, [EMAIL PROTECTED] <
>
> [EMAIL PROTECTED]> wrote:
>
> > By using pdb post mortem, I found out that the request.META dictionary
> > doesn't actually have 'REMOTE_ADDR' in it. Settings.INTERNAL_IPS is
> > '127.0.0.1'. So then get() returns None, and the error comes from
> > python trying to evaluate None in '127.0.0.1'. Should the test client
> > be setting this value? Is there something in my code or configuration
> > that needs to change to set that?
>
> I'm a little puzzled because I cannot recreate the error you see.  From your
> traceback it appears like it might be resulting from having DEBUG set to
> True when running the test, but even using a settings file where DEBUG is
> True, I do not see that error:
>
> >>> from django.conf import settings
> >>> settings.DEBUG
> True
> >>> from django.test.client import Client
> >>> c = Client()
> >>> c.get('/')
>
> 
>
>
>
> So I am not sure why you see it.  However, the lack of a REMOTE_ADDR setting
> in the test client environment has been reported in a ticket:
>
> http://code.djangoproject.com/ticket/8551
>
> so you could probably either use the workaround mentioned there or try
> running with the little patch in the ticket and see if it fixes your case.
>
> Karen
>
>
>
> > On Oct 23, 9:17 am, "[EMAIL PROTECTED]"
> > <[EMAIL PROTECTED]> wrote:
> > > I found this problem while trying out the django test client:
>
> > > $ ./manage.py shell>>> from django.test.client import Client
> > > >>> c = Client()
> > > >>> c.get('/')
>
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > >   File "/var/lib/python-support/python2.5/django/test/client.py", line
> > > 265, in get
> > >     return self.request(**r)
> > >   File "/var/lib/python-support/python2.5/django/core/handlers/
> > > base.py", line 86, in get_response
> > >     response = callback(request, *callback_args, **callback_kwargs)
> > >   File "/path/to/website/views.py", line 12, in index
> > >     context_instance=RequestContext(request))
> > >   File "/var/lib/python-support/python2.5/django/template/context.py",
> > > line 105, in __init__
> > >     self.update(processor(request))
> > >   File "/var/lib/python-support/python2.5/django/core/
> > > context_processors.py", line 34, in debug
> > >     if settings.DEBUG and request.META.get('REMOTE_ADDR') in
> > > settings.INTERNAL_IPS:
> > > TypeError: 'in ' requires string as left operand
>
> > > This is probably a mistake in my configuration, but it may be a bug.
> > > It throws the same error regardless of which path I try to get, or if
> > > I use c.post instead. Can anyone figure this out?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread bobhaugen

Some followup, in case some other poor soul searches for this topic:

I found some better doc for get-absolute-url() here:

http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#get-absolute-url

Including a better example:

@models.permalink
def get_absolute_url(self):
return ('archive_view', (), {
'year': self.created.year,
'month': self.created.month,
'day': self.created.day})

So I changed my method like this:

@models.permalink
def get_absolute_url(self):
return ('organization', (), {
"type_slug": self.type.slug,
"org_slug": self.slug})

...which works!

However, the permalink decorator still doesn't work.  Get error:
AttributeError: 'Org' object has no attribute 'permalink'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 along with PHP - avoiding Apache crashes

2008-10-27 Thread Graham Dumpleton

On Oct 28, 4:01 am, Giles Thomas <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> We're implementing some new stuff for our website in Django;
> unfortunately our site currently uses PHP quite heavily (for MediaWiki,
> Wordpress, phpBB and the like), and when we tried deploying the first
> cut of the solution, Apache segfaulted - best guess is that this is a
> result of PHP's problems with a statically linked version of the mysql
> library, which are known to interact badly with mod_python and mysql [1]
>
> Unfortunately, although the problem is with PHP, I have to work around
> it in order to get my Django app working, at least until I can budget
> the time to remove PHP from the site entirely :-)
>
> I guess quite a lot of people out there have had similar problems, so I
> was wondering what the most popular workaround is?  Here are the options
> I've found or been told about so far:
>
>     * Use mod_wsgi so that all of the Django stuff is kept in a separate
>       process.  (A bit ugly.)

Separate processes are provided by daemon mode of mod_wsgi, embedded
mode works the same as mod_python. Either way, it will not help in
this case as PHP preloads everything in the Apache parent process and
thus it infects even the mod_wsgi daemon mode processes as they are
forked from Apache parent process just like Apache child worker
processes.

>     * Run a separate server (Apache, lighthttpd, or whatever) just for
>       Django.  (Even uglier.)

But if the option of recompiling code is not realistic, the easiest to
do.

>     * Recompile PHP with the appropriate flags to make it use a shared
>       mysql library.  (Scary!)

But the preferred option.

Do not though that it isn't an issue with a static MySQL client
library being used, but that the shared library it uses is a different
version, or different variant, ie., not thread safe or reentrant.

This specific issue is talked about in mod_wsgi documentation at:

  
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#MySQL_Shared_Library_Conflicts

You should perhaps run 'ldd' as shown in example there and work out
what versions/variants of shared libraries are being used by PHP,
Python and Apache as appropriate. Post the details here as then can
tell you better what you may be able to do about it.

BTW, another option which would work is to use Postgresql for Django
instead. Some would argue this is a better database anyway. ;-)

Graham

> Any thoughts would be much appreciated.
>
> Regards,
>
> Giles
>
> [1]http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...http://modpython.org/FAQ/faqw.py?req=show=faq02.013.htp
>
> --
> Giles Thomas
> MD & CTO, Resolver Systems Ltd.
> [EMAIL PROTECTED]
> +44 (0) 20 7253 6372
>
> Try out Resolver One! 
>
> 17a Clerkenwell Road, London EC1M 5RD, UK
> VAT No.: GB 893 5643 79
> Registered in England and Wales as company number 5467329.
> Registered address: 843 Finchley Road, London NW11 8NA, UK
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Template syntax question

2008-10-27 Thread Robocop

So i'm looking to have an admin controlled news list, and one thing in
particular i'd like them to be able to control is how many headlines
are shown on the front page, and my current code is not doing that.

The line i care about is:

{% for New in news_list|slice:":{{limit}}"%}

where limit is some admin controlled variable that i'm certain is an
integer.  Is this possible?  Or is there just some error in my code
somewhere  that i have not seen?  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
-~--~~~~--~~--~--~---



ifequal and numbers

2008-10-27 Thread Alfredo Alessandrini

There is a method for write this, without write a loop:

{%  ifequal  apple.number <20  %}
..
{%  endifequal  %}


Alfredo

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



Re: How can I make WS in Django

2008-10-27 Thread Karen Tracey
On Mon, Oct 27, 2008 at 4:13 PM, Abdel Bolanos Martinez <
[EMAIL PROTECTED]> wrote:

>  Anyone has make WS (WebServices) inDjango???
>

This is the 2nd time you've asked essentially the same question in the space
of a few hours.  Your original question did get a few answers:

http://groups.google.com/group/django-users/browse_thread/thread/479933259b9784df?hl=en#

Did you not get receive/see the responses?  If they do not answer your
question, why not expand on your question with a few more details
(particularly since the vagueness of the question was noted in the responses
as creating a problem in providing meaningful answers)? Why do you think you
will get better answers on a new thread on the topic?  You won't.  You
might, however, get better answers if you spend a few more bytes on your
actual question and a few fewer on sig graphics.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: web 2.0 apps with django

2008-10-27 Thread RaviKondamuru

I am looking for some apps/ tutorials to understand comet/ bosch
models for web application development.
I understand that web 2.0 applications use these models.
thanks,
Ravi.

On Oct 27, 12:44 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Wiadomość napisana w dniu 2008-10-27, o godz. 20:36, przez Ravi  
> Kondamuru:
>
> > Is there any simple app/ tutorial to understand web 2.0 application  
> > development with django?
> > thanks,
>
> With exception of vagueness of all this web-two-dot-oh-thing, Django  
> has some very good tutorials that will teach you writing applications.  
> Could you evaluate what are your objectives?
>
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R, Redefine
> [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: database API from external tools?

2008-10-27 Thread Andrew Chapman





James Bennett wrote:

  On Sun, Oct 26, 2008 at 9:19 PM, Steve Holden <[EMAIL PROTECTED]> wrote:
  
  
Here's a specific example of a piece of code that uses a web app's
models. It should get you started - just dive in and write some code!
The tricky bit is providing the settings without using a "settings"
module. I can't remember who I got this code from, but the kudos belongs
to them, not me. Enjoy.

  
  
I'm late to the party on this, but here's my writeup from last year
(IIRC all this stuff is in the official docs, too):

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/
  


Thanks guys, that's a great help. 
That settings hack along with my models.py file (and django installed)
seems to be all I need for the moment.

AC.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: web 2.0 apps with django

2008-10-27 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-10-27, o godz. 20:36, przez Ravi  
Kondamuru:

> Is there any simple app/ tutorial to understand web 2.0 application  
> development with django?
> thanks,

With exception of vagueness of all this web-two-dot-oh-thing, Django  
has some very good tutorials that will teach you writing applications.  
Could you evaluate what are your objectives?

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[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
-~--~~~~--~~--~--~---



web 2.0 apps with django

2008-10-27 Thread Ravi Kondamuru
Hi,Is there any simple app/ tutorial to understand web 2.0 application
development with django?thanks,
Ravi.

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



Re: trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread bobhaugen

Got the url tag version working this way:

Changed the url pattern to:

url(r'^org/(?P[-\w]+)/(?P[-\w]+)/$',
'orgs.views.org', name='organization'),

And the template to:

{% url organization type_slug=org.type.slug, org_slug=org.slug %}

And added the new keyword to the view.

But I'm still a long ways from understanding this stuff enuf to do a
new one with any confidence.

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



Re: trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread bobhaugen

Tried going about this another way:
In the template:

{% url orgs.views.org org.type.slug, org_slug=org.slug %}

That gets me this error message:

Don't mix *args and **kwargs in call to reverse()!

But how is that different from this example in the Django doc?

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url

{% url path.to.some_view arg1,arg2,name1=value1 %}

"The first argument is a path to a view function in the format
package.package.module.function. Additional arguments are optional and
should be comma-separated values that will be used as positional and
keyword arguments in the URL. All arguments required by the URLconf
should be present."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Noon Help

2008-10-27 Thread Peter Herndon

I might also suggest django-registration
(http://code.google.com/p/django-registration) to handle your user
registration needs.

On Mon, Oct 27, 2008 at 2:34 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> Johnny Utah wrote:
>> Thanks for the input.
>>
>> When you say Django.admin would be useful, do you mean users would
>> access the admin interface?
>>
> Please respond to the list when asking further questions.
>
> That being said: no-- users shouldn't access the admin interface. Admins
> should. It's there to make your life much easier, and it does that very
> well. You'll still need to build views for your app, but if you need to
> go in and change something manually, the admin interface is way better
> than dropping to SQL.
>
> Jeff Anderson
>
>

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



Re: trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread bobhaugen

Shabda,

Thanks for trying, but:

>  return ('orgs.views.org', [self.type.slug, self.slug])

In the shell, that gets me:
TypeError: reverse() argument after ** must be a dictionary

But do I understand correctly that the first argument shd be a view?

And that what gets returned from get_absolute_url goes into reverse()?
Looking at the code for urlresolvers.revers() now.  If I read
correctly, it wants either a view or an URL pattern name.

That's a start at getting more understanding.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 along with PHP - avoiding Apache crashes

2008-10-27 Thread Giles Thomas

vivek,

Thanks for the reply.  You're right - having spent a bit of time looking 
at it, I've come to realise that I was wrong in thinking mod_wsgi was 
inelegant.  I'll give it a go. 


Regards,

Giles






vivek wrote:
> I  think mod_wsgi should not be considered "bit ugly", it is quite
> elegant option. In daemon mode, it will probably provide a better
> memory utilization as compared to mod_php + mod_python apache
> processes. I have not faced such problem so cant give an exact
> solution but you should definitely try mod_wsgi.
>
>
> vp
> >
>   

-- 
Giles Thomas
MD & CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! 

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 
Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 along with PHP - avoiding Apache crashes

2008-10-27 Thread Giles Thomas

Heh - looks like I spoke too soon.  When I try to get mod_wsgi running 
with my PHP-infested Apache instance, it crashes anyway.  Looks like the 
same problem as with mod_python/Django.  If anyone else has got this 
running, I'd love to hear from you... 

In the meantime, I'll keep plugging at it and if I discover anything 
interesting I'll post it to the list.


Regards,

Giles

-- 
Giles Thomas
MD & CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! 

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 
Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Noon Help

2008-10-27 Thread Jeff Anderson
Johnny Utah wrote:
> Thanks for the input.
>
> When you say Django.admin would be useful, do you mean users would
> access the admin interface?
>   
Please respond to the list when asking further questions.

That being said: no-- users shouldn't access the admin interface. Admins
should. It's there to make your life much easier, and it does that very
well. You'll still need to build views for your app, but if you need to
go in and change something manually, the admin interface is way better
than dropping to SQL.

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: customize TimeField

2008-10-27 Thread Lars Stavholm

Arash wrote:
> Hi Everybody,
> Could you tell me please how can I customize TimeField. I need to get
> ride of the seconds. I don't want seconds to appear on admin interface

settings.py: TIME_FORMAT maybe.

/L


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 along with PHP - avoiding Apache crashes

2008-10-27 Thread vivek

I  think mod_wsgi should not be considered "bit ugly", it is quite
elegant option. In daemon mode, it will probably provide a better
memory utilization as compared to mod_php + mod_python apache
processes. I have not faced such problem so cant give an exact
solution but you should definitely try mod_wsgi.


vp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: about WebServices

2008-10-27 Thread Tim Chase

> maybe you can do a question more explicit ;-) like how i can make WS

For anybody to be more explicit, you'd have to be more explicit 
yourself in what you want from a webservice.  I tend to make my 
web-services RESTful, which makes them no different from any 
other HTML or XML response that my views return.  I just create a 
template that produces the data that I want to return (whether 
XML or JSON).  My WS consumer simply requests the URL (possibly 
adding credentials) with a GET if it's to retrieve data, or a 
POST (I just use get/post but some folks use get/post/delete/put) 
if the intent is to update data.  This also allows for 
intelligent caching of read-only objects that get returned.

I have no idea about SOAP web-services, as I find them ugly, 
unweildy and neither Pythonic nor adhering to "the web way".

-tim

PS:  You may want to omit all the attachments/images you include 
in your emails.  Your actual content was only a handful of 
bytes...your spam-images (no matter how much I myself am a 
Debian/Ubuntu Vista-hating sorta guy) clocked in at nearly 200k 
flagging my "it's big with attachments and came unsolicited, so 
is therefore likely spam" filters by about 150kb.





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: reusing generic settings dependent on the project folder

2008-10-27 Thread Frank Malina @ vizualbod.com

Hi Matias,
It return's an empty string on my machine (Ubuntu Linux).

This is not in fact what I am looking for. I would want to do
something like:

###generic.py

set_generic(folder):
path = "/sites/" + folder
url = "http://; + folder + ".localhost/"

DATABASE_NAME = folder
SITE_NAME = folder
CACHE_PREFIX = folder
TEMPLATE_DIRS = (path + "/templates", "/source/apps/templates")
MEDIA_ROOT = path + "/static"
MEDIA_URL = url + "static/"
ADMIN_MEDIA_PREFIX = url + "media/"

LOCAL_DEV = False
DEBUG = False
TEMPLATE_DEBUG = False
USE_I18N = True
SEND_BROKEN_LINK_EMAILS = True
TIME_ZONE = 'Europe/London'
LANGUAGE_CODE = 'en-gb'
DATABASE_ENGINE = 'postgresql_psycopg2'
CACHE_BACKEND = "file:///var/tmp/django_cache"
...

###settings.py (settings for the project)

import os
from generic import *
folder = os.path.dirname(__file__).split(os.path.sep)[-1]
set_generic(folder)
# Done! Happy Day.

The above doesn't work because:

1. The function set_generic needs to return all those variables
somehow.
What is the best way how to do it?

2. os.path.dirname(__file__).split(os.path.sep)[-1] returns an empty
string. This is probably because
It would be best to wrap it some function because it is ugly in itself
in itself in every config file.
Is there such function to get a current working directory of a
__file__?

The ideal syntax of the settings files would "look" like.
This is what a good programmer could make it look like:
---
from generic import *
set generic_settings.for_current_project

... some optional settings
---

I could probably put together something ugly like

---
from generic import *
set_generic_settings(for_current_project(__file__))
... optional settigns
---

---
### generic.py
...
def for_current_project(getfile):
return os.path.dirname(getfile).split(os.path.sep)[-1]
...
---

I really care about how the settings file look like because it is all
python my users are mostly going to see.
I am hungry to learn what is the cleanest way to do it.





On Oct 27, 1:00 pm, "Matías Costa" <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 27, 2008 at 1:07 PM, Frank Malina @ vizualbod.com <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi all,
> > in my projects I use a set of settings conventions that are the same
> > from project to project. I want to separate them because I don't want
> > to repeat myself.
>
> > I am also reusing a big deal of my applications throughout the
> > projects/sites, so it makes sense to give it a clear order and
> > generalize the project_folder dependent settings.
>
> > E.g. My database is always called the same as the project folder,
> > Initial SITE_NAME is always the same as project folder until I set one
> > in the sites application model.
> > CACHE_PREFIX  I use is always the same as the project folder name for
> > consistency
>
> > DATABASE_NAME = folder
> > SITE_NAME = folder
> > CACHE_PREFIX = folder
>
> > TEMPLATE_DIRS = ("/webs/" + folder + "/templates", "/django_apps/
> > templates")
> > MEDIA_ROOT = "/webs/" + folder + "/static"
> > MEDIA_URL = "http://; + folder + ".vizualbod.com/static/"
> > ADMIN_MEDIA_PREFIX = "http://; + folder + ".localhost/media/"
>
> > It would make sense to put this boilerplate stuff in my
> > generic_settings.py instead of repeating it in every setting.py, but
> > *how do I pass it the project folder name*?
>
> folder = os.path.dirname(__file__).split(os.path.sep)[-1]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread shabda

You want something like this

@models.permalink
def get_absolute_url(self):
 return ('orgs.views.org', [self.type.slug, self.slug])

Essentially, you code would be doing something like reverse('/org/
hoa/', kwargs={..}) which fails. Templates supress Exceptions so you
do not see them.


On Oct 27, 9:48 pm, bobhaugen <[EMAIL PROTECTED]> wrote:
> Altho I have read alot of the relevant documentation, and searched
> this group and the Web, I remain confused about these topics and their
> relationships.  Something is not sticking in my brain.
>
> I usually get something working by blind cut and paste.  Looking for a
> more conceptual explanation, or even some pointers to where to look
> next.
>
> Here's my current problem:
>
> in models.py:
>
>     def get_absolute_url(self):
>         prefix = "/org/%s/" % self.type.slug
>         return (prefix, None, {"org_slug": iri_to_uri(self.slug)})
>
> in urls.py:
>
>     url(r'^org/(\w)+/(?P[-\w]+)/$', 'orgs.views.org',
> name='org'),
>
> in a template:
>
>     {{ org.get_absolute_url }}
>
> returns nothing.  No error message.
>
> Error message from the shell:
>
> >>>org,get_absolute_url()
>
> [...]
> NoReverseMatch: Reverse for '/org/hoa/' with arguments '()' and
> keyword arguments '{'org_slug': 'cp'}' not found.
>
> If I enter the urlhttp://127.0.0.1:8000/org/hoa/cp/in the address
> bar, it works fine.
>
> Using current trunk and the Django dev server.
>
> What am I missing?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: about WebServices

2008-10-27 Thread Tim Chase

> Has anyone made Webservices in Django  ???

yes

-tim




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



customize TimeField

2008-10-27 Thread Arash

Hi Everybody,
Could you tell me please how can I customize TimeField. I need to get
ride of the seconds. I don't want seconds to appear on admin interface

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: create objects from custom SQL

2008-10-27 Thread Roboto

hmm.. I don't think you linked the right item?
Rory

This is what I use to process custom sql statements

def process_sql(query):
from django.db import connection
cursor = connection.cursor()
cursor.execute(query)
results = [dict(zip([item[0] for item in cursor.description],row))
for row in cursor.fetchall()]
return results



On Oct 25, 2:30 am, "DULMANDAKH Sukhbaatar" <[EMAIL PROTECTED]>
wrote:
> http://docs.djangoproject.com/en/dev/howto/legacy-databases/#howto-le...
>
> Here is a guide that will help you to build model from current
> database structure. maybe you need to do some optimizations on it.
>
> --
> Regards
> Dulmandakh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Triggering a custom signal

2008-10-27 Thread Steve Holden

redmonkey wrote:
> h. Yeah, That's pretty simple.
>
> I could even get a reference to the Job number using -v with at,
> storing that in the DB and then removing and recreating another at-job
> if the user changes the time.
>
> Brilliant, thank you.
>
> On Oct 27, 4:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>   
>> I believe you are over-thinking this one. Why not just have a program
>> access a known URL (with authentication, because you don't want just
>> *any* user to be able to do this) to bring a catalog off-line? You can
>> then use the Linux "at" utility to schedule each catalog's off-lining
>> when you create it.
>>
>> regards
>>  Steve
>> 
A pleasure. Sometimes more technology isn;t the answer, just the
technology we've had so long we've forgotten about it ;-)

regards
 Steve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Active Directory Authentication Backend Using SSL

2008-10-27 Thread Jashugan

Hello,

I have been using a Django snippet (http://www.djangosnippets.org/
snippets/901/) to authenticate over LDAP with our Active Directory.
It's been working fine without SSL, but I am having some problems
getting it up and running with SSL. I have the SSL certificate (base
64 encoded) for our domain, and I have OPT_X_TLS_CACERTFILE set to the
path the file is in. However, I get the following error when I use
SSL:

SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I'm not sure whether the certificate that I'm using is encoded
incorrectly or whether I need the actual server's own public
certificate versus the domain's public certificate. The ldap
documentation is pretty sparse. Any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django along with PHP - avoiding Apache crashes

2008-10-27 Thread Giles Thomas
Hi all,

We're implementing some new stuff for our website in Django; 
unfortunately our site currently uses PHP quite heavily (for MediaWiki, 
Wordpress, phpBB and the like), and when we tried deploying the first 
cut of the solution, Apache segfaulted - best guess is that this is a 
result of PHP's problems with a statically linked version of the mysql 
library, which are known to interact badly with mod_python and mysql [1]

Unfortunately, although the problem is with PHP, I have to work around 
it in order to get my Django app working, at least until I can budget 
the time to remove PHP from the site entirely :-)

I guess quite a lot of people out there have had similar problems, so I 
was wondering what the most popular workaround is?  Here are the options 
I've found or been told about so far:

* Use mod_wsgi so that all of the Django stuff is kept in a separate
  process.  (A bit ugly.)
* Run a separate server (Apache, lighthttpd, or whatever) just for
  Django.  (Even uglier.)
* Recompile PHP with the appropriate flags to make it use a shared
  mysql library.  (Scary!)

Any thoughts would be much appreciated.


Regards,

Giles

[1]
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-segmentation-fault
http://modpython.org/FAQ/faqw.py?req=show=faq02.013.htp

-- 
Giles Thomas
MD & CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! 

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 
Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Triggering a custom signal

2008-10-27 Thread redmonkey

h. Yeah, That's pretty simple.

I could even get a reference to the Job number using -v with at,
storing that in the DB and then removing and recreating another at-job
if the user changes the time.

Brilliant, thank you.

On Oct 27, 4:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> redmonkey wrote:
> > Thanks Matías, you've come up with a good solution, but unfortunately
> > this won't really work for my situation.
>
> > For my client, online bidding ends immediately before they open
> > bidding on the shop floor. The catalogue for that sale must go offline
> > at that point. I can't expect my client to postpone things while they
> > wait for my cron job to decide to close the catalogue down. Thanks for
> > posting the save method though, it's quite neat.
>
> > I'm finding it hard to believe there isn't an easy way to do this, not
> > even with the full Python Library behind it. I understand what signals
> > are, and I know that you can create http://code.google.com/p/
> > django-cron/source/browse/trunk/cron/signals.py" title"Django-cron:
> > Signals">custom ones. I'd like to know how I can send my custom
> > signal at the DateTimeField value.
>
> > On Oct 27, 12:14 pm, "Matías Costa" <[EMAIL PROTECTED]> wrote:
>
> >> BTW this is the save method for the model with the rounding function:
>
> >>     def save(self):
> >>         def roundminute(d,  r):
> >>             """Rounds the datetime d to the nearer r multiple
> >>             If r == 15 =>
> >>             3:00 -> 3:00
> >>             3:05 -> 3:00
> >>             3:27 -> 3:30
> >>             3:55 -> 4:00
>
> >>             Adds hours correctly
> >>             """
> >>             from datetime import datetime,  timedelta
> >>             m = d.minute
> >>             if m > (60 - r/2):
> >>                 m = 0
> >>                 d += timedelta(60*60)
> >>             else:
> >>                 m = m - (m%r) if (m%r)<(r/2) else m+(r-(m%r))
> >>             return d.replace(minute=m,  second=0, microsecond=0)
>
> >>         if self.price == None:
> >>             self.price = self.start_price
> >>         self.start_date = roundminute(self.start_date,  15)
> >>         self.end_date = roundminute(self.end_date,  15)
> >>         super(Auction, self).save()
>
> >> On Mon, Oct 27, 2008 at 1:06 PM, Matías Costa <[EMAIL PROTECTED]> wrote:
>
> >>> I have the exact problem. I round end and start dates to 15 minutes. I
> >>> mean, user enters 12:10, I write 12:15. So each 15 minutes cron runs a
> >>> script with django-commands-extensions runscript. Is a balance between
> >>> accuracy and load.
>
> >>> The perfect should be finding the next success to happen (easy) and 
> >>> program
> >>> django-cron or anything else to run at that time (I don't know how)
>
> >>> I am very interested in the solutions people have found for this
>
> >>> On Mon, Oct 27, 2008 at 12:45 PM, redmonkey <[EMAIL PROTECTED]
>
>  wrote:
>
>  Hi,
>
>  I'm working on a simple auctioneer's website. My Catalogue app
>  consists of a list of Lots arranged into Catalogues. Each catalogue
>  has an auction_data field which stores a status and a date and time of
>  the sale:
>
>  class Catalogue(models.Model):
>     DRAFT_STATUS = 1
>     LIVE_STATUS = 2
>     CATALOGUE_CHOICES = (
>         (DRAFT_STATUS, 'Draft'),
>         (LIVE_STATUS, 'Live'),
>     )
>     status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
>         default=DRAFT_STATUS)
>     auction_date = models.DateTimeField("Date of Auction")
>     ...
>
>  class Lot(models.Model):
>     catalogue = models.ForeignKey(Catalogue, related_name="lots")
>     ...
>
>  Pretty simple stuff. My problem is that I need to run a function at
>  the auction_date of the catalogue that will do a few things like
>  change the status of the catalogue, and send an email out to some
>  admins.
>
>  I've done some brief research, and found django-cron,
>  and I imagine I could write something that checked each hour to see if
>  any catalogues had expried recently, but that seems mad.
>
>  Another solution I came up with involved checking for the expiry date
>  every time a record is pulled up from the database. But this add's a
>  hit to user responsiveness (even if it is tiny) and still doesn't
>  allow me to send out the email.
>
>  Finally, I read up on Django's signals to decide if I could use that
>  mechanism to do other things. Signals sounds ideal, but I don't know
>  how to trigger at the right time.
>
>  Can anyone help me with this? How do I trigger a custom signal based
>  on a DateTimeField value?
>
>  Thanks,
>
> I believe you are over-thinking this one. Why not just have a program
> access a known URL (with authentication, because you don't want just
> *any* user to be able to do this) to bring a catalog off-line? You can
> then use the Linux "at" utility to 

trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread bobhaugen

Altho I have read alot of the relevant documentation, and searched
this group and the Web, I remain confused about these topics and their
relationships.  Something is not sticking in my brain.

I usually get something working by blind cut and paste.  Looking for a
more conceptual explanation, or even some pointers to where to look
next.

Here's my current problem:

in models.py:

def get_absolute_url(self):
prefix = "/org/%s/" % self.type.slug
return (prefix, None, {"org_slug": iri_to_uri(self.slug)})

in urls.py:

url(r'^org/(\w)+/(?P[-\w]+)/$', 'orgs.views.org',
name='org'),

in a template:

{{ org.get_absolute_url }}

returns nothing.  No error message.

Error message from the shell:

>>>org,get_absolute_url()
[...]
NoReverseMatch: Reverse for '/org/hoa/' with arguments '()' and
keyword arguments '{'org_slug': 'cp'}' not found.

If I enter the url http://127.0.0.1:8000/org/hoa/cp/ in the address
bar, it works fine.

Using current trunk and the Django dev server.

What am I missing?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 get site's root path in Django

2008-10-27 Thread Steve Holden

yuanyun.ken wrote:
> Hi, all great Django users and developers, I have a little problem.
> To make @login_required work,
> I have to configure those in settings.py:
> root_url = '/root_url/'
> LOGIN_URL = root_url + '/login/'
> LOGOUT_URL =  root_url + '/logout/'
>
> But this is obviously not a good idea, as it couples with project's
> root url.
>
>   
But in Django your project's root URL is "/", which is why the default
settings.LOGIN_URL is "/accounts/login/".
> I tried to use:
> LOGIN_URL = '/login/'
> or
> LOGIN_URL = 'login/'
>
> the first can not work, apache would try to access http://localhost/login/,
> not http://localhost/root_url/login/
>   
So what you are saying is that you aren't running Django mapped to the
root of your server's web address space?
> the second option would not work, when access 
> http://localhost/root_url/dira/pageb,
> this would lead to access http://localhost/root_url/dira/login
>
> urls.py
> (r'^login/$', 'django.contrib.auth.views.login'),
> (r'^logout/$', 'django.contrib.auth.views.logout')
>
> The following are my configuration in apache's httpd.conf
> Alias /root_url/ D:/ws/django/myproject/
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE Regrroot_url.settings
> PythonOption django.root /root_url
> PythonDebug On
> PythonPath "['D:/ws/django/myproject/'] + sys.path"
> Options ExecCGI
> Options +Indexes
> Order allow,deny
> Allow from all
> 
>
> Any help is appreciated, and Thanks in advance.
If you don't want Django at the root of your web space then you will
have to take special pains to remap it. What's the reason you want your
project to appear at "/root_url/" rather than "/"?

regards
 Steve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: URL handling and porting from 0.96 to 1.0

2008-10-27 Thread Philippe Raoult

Thanks for the tip, it indeed worked. I'm now trying to figure out how
to use exotic characters in my url regex and so far I'm failing.

My 0.96 url file looked like this:

accents = "áâàäãéêèëíîìïóôòöõúûùüçøñÁÂÀÄÉÊÈËÍÎÌÏÓÔÒÖÚÛÙÜÇØÑ¡¿"
REGEX_FICHIER = "[\w/\-+_,@!%'°&\.#$\[\](} "+accents+']*'

(r'^fichier_numerique/(?P\d+)/(?P'+REGEX_FICHIER
+')/$', 'vue_fichier_dossier'),

So far it worked in 0.96, so now i'm just adding 'u' in front of
accents and REGEX_FICHIER strings but no luck:
NoReverseMatch: Reverse for '' with arguments '(56650L, u'blah/blih')' and keyword
arguments '{}' not found.

Has anyone managed to use accented caracters in urls with 1.0.X ?

Regards,
Philippe

On Oct 18, 1:58 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Sat, Oct 18, 2008 at 6:10 PM, Philippe Raoult
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > Hello all,
>
> > I've startingportingmy little app (20k loc) from 0.96 to 1.0 and
> > I've been hitting a wall of reverse/urlerrors. I haven't seen
> > anything in theportingwiki page so I'm wondering if anyone has
> > already encountered similar issues ?
>
> > I'm seeing stuff like: Reverse for ' > 0x1ae55f0>' with arguments '(34L,)' and keyword arguments '{}' not
> > found.
> > Obviously since the reverse has a function object it imported it
> > correctly (I provided the view path as a reverse argument). Is there
> > any change in theurlpatterns not mentionned in theportingwiki page
> > and worth knowing about ?
>
> > I'm going to be fiddling with this a bit, if I don't figure it out
> > I'll post a detailedurlfile...
>
> It sounds like you may have found a version of ticket #9038. This
> ticket was fixed in changeset [9087]; if you use a current trunk
> checkout (or a checkout from the v1.0.X branch), the issue should be
> resolved.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Triggering a custom signal

2008-10-27 Thread Steve Holden

redmonkey wrote:
> Thanks Matías, you've come up with a good solution, but unfortunately
> this won't really work for my situation.
>
> For my client, online bidding ends immediately before they open
> bidding on the shop floor. The catalogue for that sale must go offline
> at that point. I can't expect my client to postpone things while they
> wait for my cron job to decide to close the catalogue down. Thanks for
> posting the save method though, it's quite neat.
>
> I'm finding it hard to believe there isn't an easy way to do this, not
> even with the full Python Library behind it. I understand what signals
> are, and I know that you can create http://code.google.com/p/
> django-cron/source/browse/trunk/cron/signals.py" title"Django-cron:
> Signals">custom ones. I'd like to know how I can send my custom
> signal at the DateTimeField value.
>
> On Oct 27, 12:14 pm, "Matías Costa" <[EMAIL PROTECTED]> wrote:
>   
>> BTW this is the save method for the model with the rounding function:
>>
>> def save(self):
>> def roundminute(d,  r):
>> """Rounds the datetime d to the nearer r multiple
>> If r == 15 =>
>> 3:00 -> 3:00
>> 3:05 -> 3:00
>> 3:27 -> 3:30
>> 3:55 -> 4:00
>>
>> Adds hours correctly
>> """
>> from datetime import datetime,  timedelta
>> m = d.minute
>> if m > (60 - r/2):
>> m = 0
>> d += timedelta(60*60)
>> else:
>> m = m - (m%r) if (m%r)<(r/2) else m+(r-(m%r))
>> return d.replace(minute=m,  second=0, microsecond=0)
>>
>> if self.price == None:
>> self.price = self.start_price
>> self.start_date = roundminute(self.start_date,  15)
>> self.end_date = roundminute(self.end_date,  15)
>> super(Auction, self).save()
>>
>> On Mon, Oct 27, 2008 at 1:06 PM, Matías Costa <[EMAIL PROTECTED]> wrote:
>> 
>>> I have the exact problem. I round end and start dates to 15 minutes. I
>>> mean, user enters 12:10, I write 12:15. So each 15 minutes cron runs a
>>> script with django-commands-extensions runscript. Is a balance between
>>> accuracy and load.
>>>   
>>> The perfect should be finding the next success to happen (easy) and program
>>> django-cron or anything else to run at that time (I don't know how)
>>>   
>>> I am very interested in the solutions people have found for this
>>>   
>>> On Mon, Oct 27, 2008 at 12:45 PM, redmonkey <[EMAIL PROTECTED]
>>>   
 wrote:
 
 Hi,
 
 I'm working on a simple auctioneer's website. My Catalogue app
 consists of a list of Lots arranged into Catalogues. Each catalogue
 has an auction_data field which stores a status and a date and time of
 the sale:
 
 class Catalogue(models.Model):
DRAFT_STATUS = 1
LIVE_STATUS = 2
CATALOGUE_CHOICES = (
(DRAFT_STATUS, 'Draft'),
(LIVE_STATUS, 'Live'),
)
status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
default=DRAFT_STATUS)
auction_date = models.DateTimeField("Date of Auction")
...
 
 class Lot(models.Model):
catalogue = models.ForeignKey(Catalogue, related_name="lots")
...
 
 Pretty simple stuff. My problem is that I need to run a function at
 the auction_date of the catalogue that will do a few things like
 change the status of the catalogue, and send an email out to some
 admins.
 
 I've done some brief research, and found django-cron,
 and I imagine I could write something that checked each hour to see if
 any catalogues had expried recently, but that seems mad.
 
 Another solution I came up with involved checking for the expiry date
 every time a record is pulled up from the database. But this add's a
 hit to user responsiveness (even if it is tiny) and still doesn't
 allow me to send out the email.
 
 Finally, I read up on Django's signals to decide if I could use that
 mechanism to do other things. Signals sounds ideal, but I don't know
 how to trigger at the right time.
 
 Can anyone help me with this? How do I trigger a custom signal based
 on a DateTimeField value?
 
 Thanks,
 

I believe you are over-thinking this one. Why not just have a program
access a known URL (with authentication, because you don't want just
*any* user to be able to do this) to bring a catalog off-line? You can
then use the Linux "at" utility to schedule each catalog's off-lining
when you create it.

regards
 Steve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To 

Re: Triggering a custom signal

2008-10-27 Thread redmonkey

Thanks Matías, you've come up with a good solution, but unfortunately
this won't really work for my situation.

For my client, online bidding ends immediately before they open
bidding on the shop floor. The catalogue for that sale must go offline
at that point. I can't expect my client to postpone things while they
wait for my cron job to decide to close the catalogue down. Thanks for
posting the save method though, it's quite neat.

I'm finding it hard to believe there isn't an easy way to do this, not
even with the full Python Library behind it. I understand what signals
are, and I know that you can create http://code.google.com/p/
django-cron/source/browse/trunk/cron/signals.py" title"Django-cron:
Signals">custom ones. I'd like to know how I can send my custom
signal at the DateTimeField value.

On Oct 27, 12:14 pm, "Matías Costa" <[EMAIL PROTECTED]> wrote:
> BTW this is the save method for the model with the rounding function:
>
>     def save(self):
>         def roundminute(d,  r):
>             """Rounds the datetime d to the nearer r multiple
>             If r == 15 =>
>             3:00 -> 3:00
>             3:05 -> 3:00
>             3:27 -> 3:30
>             3:55 -> 4:00
>
>             Adds hours correctly
>             """
>             from datetime import datetime,  timedelta
>             m = d.minute
>             if m > (60 - r/2):
>                 m = 0
>                 d += timedelta(60*60)
>             else:
>                 m = m - (m%r) if (m%r)<(r/2) else m+(r-(m%r))
>             return d.replace(minute=m,  second=0, microsecond=0)
>
>         if self.price == None:
>             self.price = self.start_price
>         self.start_date = roundminute(self.start_date,  15)
>         self.end_date = roundminute(self.end_date,  15)
>         super(Auction, self).save()
>
> On Mon, Oct 27, 2008 at 1:06 PM, Matías Costa <[EMAIL PROTECTED]> wrote:
> > I have the exact problem. I round end and start dates to 15 minutes. I
> > mean, user enters 12:10, I write 12:15. So each 15 minutes cron runs a
> > script with django-commands-extensions runscript. Is a balance between
> > accuracy and load.
>
> > The perfect should be finding the next success to happen (easy) and program
> > django-cron or anything else to run at that time (I don't know how)
>
> > I am very interested in the solutions people have found for this
>
> > On Mon, Oct 27, 2008 at 12:45 PM, redmonkey <[EMAIL PROTECTED]
> > > wrote:
>
> >> Hi,
>
> >> I'm working on a simple auctioneer's website. My Catalogue app
> >> consists of a list of Lots arranged into Catalogues. Each catalogue
> >> has an auction_data field which stores a status and a date and time of
> >> the sale:
>
> >> class Catalogue(models.Model):
> >>    DRAFT_STATUS = 1
> >>    LIVE_STATUS = 2
> >>    CATALOGUE_CHOICES = (
> >>        (DRAFT_STATUS, 'Draft'),
> >>        (LIVE_STATUS, 'Live'),
> >>    )
> >>    status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
> >>        default=DRAFT_STATUS)
> >>    auction_date = models.DateTimeField("Date of Auction")
> >>    ...
>
> >> class Lot(models.Model):
> >>    catalogue = models.ForeignKey(Catalogue, related_name="lots")
> >>    ...
>
> >> Pretty simple stuff. My problem is that I need to run a function at
> >> the auction_date of the catalogue that will do a few things like
> >> change the status of the catalogue, and send an email out to some
> >> admins.
>
> >> I've done some brief research, and found django-cron,
> >> and I imagine I could write something that checked each hour to see if
> >> any catalogues had expried recently, but that seems mad.
>
> >> Another solution I came up with involved checking for the expiry date
> >> every time a record is pulled up from the database. But this add's a
> >> hit to user responsiveness (even if it is tiny) and still doesn't
> >> allow me to send out the email.
>
> >> Finally, I read up on Django's signals to decide if I could use that
> >> mechanism to do other things. Signals sounds ideal, but I don't know
> >> how to trigger at the right time.
>
> >> Can anyone help me with this? How do I trigger a custom signal based
> >> on a DateTimeField value?
>
> >> 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
-~--~~~~--~~--~--~---



How to get site's root path in Django

2008-10-27 Thread yuanyun.ken

Hi, all great Django users and developers, I have a little problem.
To make @login_required work,
I have to configure those in settings.py:
root_url = '/root_url/'
LOGIN_URL = root_url + '/login/'
LOGOUT_URL =  root_url + '/logout/'

But this is obviously not a good idea, as it couples with project's
root url.

I tried to use:
LOGIN_URL = '/login/'
or
LOGIN_URL = 'login/'

the first can not work, apache would try to access http://localhost/login/,
not http://localhost/root_url/login/
the second option would not work, when access 
http://localhost/root_url/dira/pageb,
this would lead to access http://localhost/root_url/dira/login

urls.py
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', 'django.contrib.auth.views.logout')

The following are my configuration in apache's httpd.conf
Alias /root_url/ D:/ws/django/myproject/

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE Regrroot_url.settings
PythonOption django.root /root_url
PythonDebug On
PythonPath "['D:/ws/django/myproject/'] + sys.path"
Options ExecCGI
Options +Indexes
Order allow,deny
Allow from all


Any help is appreciated, and Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: customize auth.users

2008-10-27 Thread Alfredo Alessandrini

How can I change the admin class?

Alfredo

2008/10/27 Erik Allik <[EMAIL PROTECTED]>:
>
> I'd suggest maybe inheriting your custom User admin class from the
> original one and only override stuff you need so you can automatically
> take advantage of future changes in contrib.auth.
>
> Erik
>
>
> On 27.10.2008, at 12:52, Alfredo Alessandrini wrote:
>
>>
>> I've solve whit this:
>>
>> http://wolfram.kriesing.de/blog/index.php/2008/customize-admin-for-user-model
>>
>>
>> Alfredo
>>
>> 2008/10/27 Alfredo Alessandrini <[EMAIL PROTECTED]>:
>>> Can I customize the auth.users list of the site administration? I
>>> need
>>> to display also the active status in the list.
>>>
>>> Thanks,
>>>
>>> Alfredo
>>>
>>
>> >
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



FileField issues

2008-10-27 Thread Karantir

Hi guys.

Could you help me please with understanding of FileField behaviour.
I'm slightly confused.

For test purposes i use this simple model


class Test(models.Model):
name = models.CharField(max_length=255)
template = models.FileField(upload_to='upload')


Then i'm trying to test this functionality in console on local windows
machine and here is the output:


...
>>> f = open('Z:/home/django/media/upload/test.xls', 'rb')
>>> f = File(f)
>>> t = Test.objects.create(name='test', template=f)
>>> t.template

>>> t.template.url
Traceback (most recent call last):
  File "", line 1, in 
  File "d:\webservers\usr\local\python\lib\site-packages\django\db
\models\fields\files.py", line 54, in _get_url
return self.storage.url(self.name)
  File "d:\webservers\usr\local\python\lib\site-packages\django\core
\files\storage.py", line 213, in url
return urlparse.urljoin(self.base_url, name).replace('\\', '/')
  File "d:\webservers\usr\local\python\lib\urlparse.py", line 254, in
urljoin
urlparse(url, bscheme, allow_fragments)
  File "d:\webservers\usr\local\python\lib\urlparse.py", line 154, in
urlparse
tuple = urlsplit(url, scheme, allow_fragments)
  File "d:\webservers\usr\local\python\lib\urlparse.py", line 194, in
urlsplit
i = url.find(':')
AttributeError: 'File' object has no attribute 'find'


The main question is what should i pass in this field on object
creation? As you can see i've tried to pass django.core.files.File
object, but in this case it seems that upload_to parameter is totally
ignored and 'template' field writes uncorretly. May be someone can
share a simple snippet of how to handle this field type.

Thanks in advance :))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



multiselect populated by another app

2008-10-27 Thread webcomm

Hi,

I have created a simple categories app, and now I want to be able to
categorize my articles, which are handled by a different app.  I'd
like to create a multiselect categories field in my articles admin
that is populated by the category entries from my categories app.

In my categories app, I have to ability to create category groups.
This is the models.py for the categories app...

from django.db import models

class Group(models.Model):
name = models.CharField(max_length=200)

def __str__(self):
return self.name

class Category(models.Model):
group = models.ForeignKey(Group)
name = models.CharField(max_length=200)

def __str__(self):
return self.name

class Meta:
verbose_name_plural = 'categories'

I want to set up my articles admin interface so there is a different
multiselect box for each category group, or one large multiselect with
the categories organized in groups.

I am not quite sure what to do in articles/admin.py and/or elsewhere
to achieve this.

Any ideas?

Thanks,
Ryan


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Can python/django match the features of php/zend framework?

2008-10-27 Thread walterbyrd

On Oct 26, 8:45 pm, Nick Lo <[EMAIL PROTECTED]> wrote:

> > 2) There is a fairly good library of php routines to connect on online
> > php app with quickbooks. I am not sure if python has anything like
> > that.
>
> That isn't really a ZF thing of course.

No, but I would I think that a php library would not be too difficult
to incorporate in ZF. Then again, in spite of the php libraries, a lot
of people find it difficult to sync online php apps with qb. I know
the developers of the magento ecommerce package (built on ZF) have not
been able to do that, at least not yet.

Here are the php libraries:

http://idnforums.intuit.com/messageview.aspx?catid=56=9164

I am not sure why this is so difficult. I guess nothing with SOAP is
all that easy.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: When should I do my imports, in views.py?

2008-10-27 Thread Horst Gutmann

According to the Python Coding Guidelines you should always put the
imports at the top of a file simply because it makes the file more
readable. Performance-wise there are AFAIK some small
speed-ramifications (negative ones) when putting imports into a
function instead of having them at the module level. My guess would
be, that this has something to do with the compile-time vs. runtime
issue, not to mention that the import-statement isn't really free. On
the other hand memory usage should be lower if you only import
something if it's really needed (say: inside of a view-function). I
haven't really run any benchmarks, though.

You might want to take a look at
http://www.szgti.bmf.hu/harp/python/fastpython.html :-)

- Horst

On Mon, Oct 27, 2008 at 3:06 PM, 7timesTom <[EMAIL PROTECTED]> wrote:
> I have a large number of view functions which require various python,
> django and other import statements.
>
> My question is: is it ok to put ALL my import statements at the top of
> views.py and then not have to worry about which view fuction uses
> what. Or must I put my imports within the view fuctions that require
> them?
>
> Does it depend on how many functions require I certain import? And if
> so, how many imports justifies a global import at the top of the code?
>
> I'm interested on the effect this decision has on speed/memory usage
> etc.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: When should I do my imports, in views.py?

2008-10-27 Thread Steve Holden

7timesTom wrote:
> I have a large number of view functions which require various python,
> django and other import statements.
>
> My question is: is it ok to put ALL my import statements at the top of
> views.py and then not have to worry about which view fuction uses
> what. Or must I put my imports within the view fuctions that require
> them?
>
>   
It's OK, and indeed that's the normal way of programming.
> Does it depend on how many functions require I certain import? And if
> so, how many imports justifies a global import at the top of the code?
>
>   
One.
> I'm interested on the effect this decision has on speed/memory usage
> etc.
>   
If you want to, you can do some timings with the "timeit" Python module,
but essentially the usual justifications for putting imports inside
functions are

a. The function is very rarely called: putting the import inside the
function means that the import may never have to be executed.

b. Lowering startup overhead: with the import inside the function it
needn't be performed until the function is called, so the program gets
started quicker.

Almost no impact on speed unless you are using a heavily-layered
approach to your programming with many function calls. The import
functionality checks the sys.modules dict first thing to see whether the
module has already been imported. If so then the value of the
sys.modules entry is immediately used to satisfy the import, so there
isn't much overhead.

regards
 Steve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Foreign key with tons of items

2008-10-27 Thread gearheart

maybe limit_choices_to is what you're looking for
i had similar problem and solved with ajax autocomplete widget.

On Oct 27, 1:47 pm, paolofdr <[EMAIL PROTECTED]> wrote:
> Hello everybody,
> I have a similar problem: a too long drop-down menu inside an inline
> element in the admin page.
> Is it possible to limit the items displayed in the drop-down list,
> filtering them by the value of other fields?
>
> Thank you
> Paolo
>
> On 23 Ott, 18:37, Fabio Natali <[EMAIL PROTECTED]> wrote:
>
> > Hi everybody.
>
> > In my admin page I have a field for a foreign key with hundreds of
> > items. That results in a drop down menu which is very difficult and
> > annoying to use.
>
> > This is my models.py:
>
> > class Prod2(models.Model):
> >     name = models.CharField(max_length=30)
>
> > class Prod1(models.Model):
> >     name = models.CharField(max_length=30)
> >     belongs_to = models.ForeignKey(Prod2)
>
> > class Prod0(models.Model):
> >     name = models.CharField(max_length=30)
> >     belongs_to = models.ForeignKey(Prod2)
> >     price = models.DecimalField(max_digits=10, decimal_places=2)
> >     #...some more details...
>
> > class Purchase(models.Model):
> >     product = models.ForeignKey(Prod0)
> >     amount = models.DecimalField(max_digits=10, decimal_places=2)
> >     #...some more details...
>
> > My drop-down-menu-excessive-lenght problem arises when you want to
> > create a new Purchase item via the admin page.
>
> > As you can see my products are organized in a hyerarchy, Prod0 being
> > the real products and Prod1 and Prod2 groups and super-groups of
> > products, respectively.
>
> > I wonder which is the best way to have a nice, friendly drop down
> > menu, possibly taking advantage of the product hyerarchy (with some
> > kind of multi level structure...).
>
> > Is there a way to customize the admin page without having to write the
> > whole page from scratch? Shall I have to add some Javascript?
>
> > Any tips will be really appreciated. Links to code, docs and whatever
> > are welcome.
>
> > All the best,
>
> > --
> > Fabio Natali
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Order of fields reset on Dynamically generated Forms.

2008-10-27 Thread shabda

I need to use DynamicForm(form generated using database values), so I
am using this method, 
http://uswaretech.com/blog/2008/10/dynamic-forms-with-django/

Now the order in which I define the fields is not the same as that for
the rendered Html. If I change the line like setattr(EmployeeForm,
field.name, copy(type_mapping[field.type])), to setattr(EmployeeForm,
field.name, forms.CharField()), the order is maintained. Any pointers?

[
Intially I though that return type('EmployeeForm', (forms.Form, ),
dict(EmployeeForm.__dict__)), messes up the order, as
dict(EmpForm.__dict__) would not keep order, as dicts are unordered,
but somehow the order is being maintained even with this line, but
setattr(EmployeeForm, field.name, forms.CharField())
]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Can python/django match the features of php/zend framework?

2008-10-27 Thread walterbyrd

On Oct 26, 4:37 pm, "Low Kian Seong" <[EMAIL PROTECTED]> wrote:
> guess it does:

Python will work with QB, as long as both are on the same windows box.
But, I was asking about using django on a remote website to sync with
QB - that might be different.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Foreign key with tons of items

2008-10-27 Thread paolofdr

Hello everybody,
I have a similar problem: a too long drop-down menu inside an inline
element in the admin page.
Is it possible to limit the items displayed in the drop-down list,
filtering them by the value of other fields?

Thank you
Paolo


On 23 Ott, 18:37, Fabio Natali <[EMAIL PROTECTED]> wrote:
> Hi everybody.
>
> In my admin page I have a field for a foreign key with hundreds of
> items. That results in a drop down menu which is very difficult and
> annoying to use.
>
> This is my models.py:
>
> class Prod2(models.Model):
>     name = models.CharField(max_length=30)
>
> class Prod1(models.Model):
>     name = models.CharField(max_length=30)
>     belongs_to = models.ForeignKey(Prod2)
>
> class Prod0(models.Model):
>     name = models.CharField(max_length=30)
>     belongs_to = models.ForeignKey(Prod2)
>     price = models.DecimalField(max_digits=10, decimal_places=2)
>     #...some more details...
>
> class Purchase(models.Model):
>     product = models.ForeignKey(Prod0)
>     amount = models.DecimalField(max_digits=10, decimal_places=2)
>     #...some more details...
>
> My drop-down-menu-excessive-lenght problem arises when you want to
> create a new Purchase item via the admin page.
>
> As you can see my products are organized in a hyerarchy, Prod0 being
> the real products and Prod1 and Prod2 groups and super-groups of
> products, respectively.
>
> I wonder which is the best way to have a nice, friendly drop down
> menu, possibly taking advantage of the product hyerarchy (with some
> kind of multi level structure...).
>
> Is there a way to customize the admin page without having to write the
> whole page from scratch? Shall I have to add some Javascript?
>
> Any tips will be really appreciated. Links to code, docs and whatever
> are welcome.
>
> All the best,
>
> --
> Fabio Natali

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: customize auth.users

2008-10-27 Thread Erik Allik

I'd suggest maybe inheriting your custom User admin class from the  
original one and only override stuff you need so you can automatically  
take advantage of future changes in contrib.auth.

Erik


On 27.10.2008, at 12:52, Alfredo Alessandrini wrote:

>
> I've solve whit this:
>
> http://wolfram.kriesing.de/blog/index.php/2008/customize-admin-for-user-model
>
>
> Alfredo
>
> 2008/10/27 Alfredo Alessandrini <[EMAIL PROTECTED]>:
>> Can I customize the auth.users list of the site administration? I  
>> need
>> to display also the active status in the list.
>>
>> Thanks,
>>
>> Alfredo
>>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: reusing generic settings dependent on the project folder

2008-10-27 Thread Matías Costa
On Mon, Oct 27, 2008 at 1:07 PM, Frank Malina @ vizualbod.com <
[EMAIL PROTECTED]> wrote:

>
> Hi all,
> in my projects I use a set of settings conventions that are the same
> from project to project. I want to separate them because I don't want
> to repeat myself.
>
> I am also reusing a big deal of my applications throughout the
> projects/sites, so it makes sense to give it a clear order and
> generalize the project_folder dependent settings.
>
> E.g. My database is always called the same as the project folder,
> Initial SITE_NAME is always the same as project folder until I set one
> in the sites application model.
> CACHE_PREFIX  I use is always the same as the project folder name for
> consistency
>
> DATABASE_NAME = folder
> SITE_NAME = folder
> CACHE_PREFIX = folder
>
> TEMPLATE_DIRS = ("/webs/" + folder + "/templates", "/django_apps/
> templates")
> MEDIA_ROOT = "/webs/" + folder + "/static"
> MEDIA_URL = "http://; + folder + ".vizualbod.com/static/"
> ADMIN_MEDIA_PREFIX = "http://; + folder + ".localhost/media/"
>
> It would make sense to put this boilerplate stuff in my
> generic_settings.py instead of repeating it in every setting.py, but
> *how do I pass it the project folder name*?
>

folder = os.path.dirname(__file__).split(os.path.sep)[-1]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



KeyError with cache

2008-10-27 Thread pihentagy

Hi all!

I'm getting KeyErrors on my site. The key seems much like a cache key,
and the stack trace verifies it. How can I avoid it?
Is there a maximum number or entries I can use? Or is it not thread-
safe?

CACHE_BACKEND = 'locmem:///?max_entries=3'

Trace comes:

Traceback (most recent call last):

  File "/home/profilia/.python/lib/python2.5/site-packages/django/core/
handlers/base.py", line 86, in get_response

  File "/var/www/profila.hu/www/profila-site-test/auction/frontend/
views.py", line 250, in toc_item_list
bookmark=False, request=request,

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
views/generic/list_detail.py", line 101, in object_list

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 176, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/loader_tags.py", line 97, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 176, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/loader_tags.py", line 24, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/loader_tags.py", line 111, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 176, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/defaulttags.py", line 334, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 925, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/defaulttags.py", line 148, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/defaulttags.py", line 255, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 768, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
template/__init__.py", line 781, in render_node

  File "/home/profilia/.python/lib/python2.5/site-packages/django/
templatetags/cache.py", line 27, in render

  File "/home/profilia/.python/lib/python2.5/site-packages/django/core/
cache/backends/locmem.py", line 61, in get

KeyError: u'auctionlot-row:hu:-3716231'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Access the current instance from limit_choices_to?

2008-10-27 Thread Alex Rades

Also discussed here:

http://groups.google.com/group/django-users/browse_thread/thread/51228899c5a9a6c/d49271983401e29e

"If my original post was not entirely clear, I'm interested in any
method available to limit_choices_to that lets you dynamically create
the list of available options as a function of the current model
instance. "

On Mon, Oct 27, 2008 at 1:16 PM, Alex Rades <[EMAIL PROTECTED]> wrote:
> Hi,
>  is there currently a way to have something like:
>
> class Mother(models.Model):
>firstborn = models.ForeignKey('Child',
> limit_choices_to={'mother':lambda me: me})
>
> class Child(models.Model):
>mother = models.ForeignKey('Mother', related_name='children')
>
> (taken from http://code.djangoproject.com/ticket/2445 )
>
> Basically I'd like to have access to the current instance of the
> class, when working with limit_choices_to. Of course we can't use self
> (we're still defining the class).
>
> Thank you!
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Access the current instance from limit_choices_to?

2008-10-27 Thread Alex Rades

Hi,
 is there currently a way to have something like:

class Mother(models.Model):
firstborn = models.ForeignKey('Child',
limit_choices_to={'mother':lambda me: me})

class Child(models.Model):
mother = models.ForeignKey('Mother', related_name='children')

(taken from http://code.djangoproject.com/ticket/2445 )

Basically I'd like to have access to the current instance of the
class, when working with limit_choices_to. Of course we can't use self
(we're still defining the class).

Thank you!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Triggering a custom signal

2008-10-27 Thread Matías Costa
BTW this is the save method for the model with the rounding function:

def save(self):
def roundminute(d,  r):
"""Rounds the datetime d to the nearer r multiple
If r == 15 =>
3:00 -> 3:00
3:05 -> 3:00
3:27 -> 3:30
3:55 -> 4:00

Adds hours correctly
"""
from datetime import datetime,  timedelta
m = d.minute
if m > (60 - r/2):
m = 0
d += timedelta(60*60)
else:
m = m - (m%r) if (m%r)<(r/2) else m+(r-(m%r))
return d.replace(minute=m,  second=0, microsecond=0)

if self.price == None:
self.price = self.start_price
self.start_date = roundminute(self.start_date,  15)
self.end_date = roundminute(self.end_date,  15)
super(Auction, self).save()


On Mon, Oct 27, 2008 at 1:06 PM, Matías Costa <[EMAIL PROTECTED]> wrote:

> I have the exact problem. I round end and start dates to 15 minutes. I
> mean, user enters 12:10, I write 12:15. So each 15 minutes cron runs a
> script with django-commands-extensions runscript. Is a balance between
> accuracy and load.
>
> The perfect should be finding the next success to happen (easy) and program
> django-cron or anything else to run at that time (I don't know how)
>
> I am very interested in the solutions people have found for this
>
>
> On Mon, Oct 27, 2008 at 12:45 PM, redmonkey <[EMAIL PROTECTED]
> > wrote:
>
>>
>> Hi,
>>
>> I'm working on a simple auctioneer's website. My Catalogue app
>> consists of a list of Lots arranged into Catalogues. Each catalogue
>> has an auction_data field which stores a status and a date and time of
>> the sale:
>>
>> class Catalogue(models.Model):
>>DRAFT_STATUS = 1
>>LIVE_STATUS = 2
>>CATALOGUE_CHOICES = (
>>(DRAFT_STATUS, 'Draft'),
>>(LIVE_STATUS, 'Live'),
>>)
>>status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
>>default=DRAFT_STATUS)
>>auction_date = models.DateTimeField("Date of Auction")
>>...
>>
>> class Lot(models.Model):
>>catalogue = models.ForeignKey(Catalogue, related_name="lots")
>>...
>>
>> Pretty simple stuff. My problem is that I need to run a function at
>> the auction_date of the catalogue that will do a few things like
>> change the status of the catalogue, and send an email out to some
>> admins.
>>
>> I've done some brief research, and found django-cron,
>> and I imagine I could write something that checked each hour to see if
>> any catalogues had expried recently, but that seems mad.
>>
>> Another solution I came up with involved checking for the expiry date
>> every time a record is pulled up from the database. But this add's a
>> hit to user responsiveness (even if it is tiny) and still doesn't
>> allow me to send out the email.
>>
>> Finally, I read up on Django's signals to decide if I could use that
>> mechanism to do other things. Signals sounds ideal, but I don't know
>> how to trigger at the right time.
>>
>> Can anyone help me with this? How do I trigger a custom signal based
>> on a DateTimeField value?
>>
>> 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
-~--~~~~--~~--~--~---



reusing generic settings dependent on the project folder

2008-10-27 Thread Frank Malina @ vizualbod.com

Hi all,
in my projects I use a set of settings conventions that are the same
from project to project. I want to separate them because I don't want
to repeat myself.

I am also reusing a big deal of my applications throughout the
projects/sites, so it makes sense to give it a clear order and
generalize the project_folder dependent settings.

E.g. My database is always called the same as the project folder,
Initial SITE_NAME is always the same as project folder until I set one
in the sites application model.
CACHE_PREFIX  I use is always the same as the project folder name for
consistency

DATABASE_NAME = folder
SITE_NAME = folder
CACHE_PREFIX = folder

TEMPLATE_DIRS = ("/webs/" + folder + "/templates", "/django_apps/
templates")
MEDIA_ROOT = "/webs/" + folder + "/static"
MEDIA_URL = "http://; + folder + ".vizualbod.com/static/"
ADMIN_MEDIA_PREFIX = "http://; + folder + ".localhost/media/"

It would make sense to put this boilerplate stuff in my
generic_settings.py instead of repeating it in every setting.py, but
*how do I pass it the project folder name*?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Triggering a custom signal

2008-10-27 Thread Matías Costa
I have the exact problem. I round end and start dates to 15 minutes. I mean,
user enters 12:10, I write 12:15. So each 15 minutes cron runs a script with
django-commands-extensions runscript. Is a balance between accuracy and
load.

The perfect should be finding the next success to happen (easy) and program
django-cron or anything else to run at that time (I don't know how)

I am very interested in the solutions people have found for this

On Mon, Oct 27, 2008 at 12:45 PM, redmonkey
<[EMAIL PROTECTED]>wrote:

>
> Hi,
>
> I'm working on a simple auctioneer's website. My Catalogue app
> consists of a list of Lots arranged into Catalogues. Each catalogue
> has an auction_data field which stores a status and a date and time of
> the sale:
>
> class Catalogue(models.Model):
>DRAFT_STATUS = 1
>LIVE_STATUS = 2
>CATALOGUE_CHOICES = (
>(DRAFT_STATUS, 'Draft'),
>(LIVE_STATUS, 'Live'),
>)
>status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
>default=DRAFT_STATUS)
>auction_date = models.DateTimeField("Date of Auction")
>...
>
> class Lot(models.Model):
>catalogue = models.ForeignKey(Catalogue, related_name="lots")
>...
>
> Pretty simple stuff. My problem is that I need to run a function at
> the auction_date of the catalogue that will do a few things like
> change the status of the catalogue, and send an email out to some
> admins.
>
> I've done some brief research, and found django-cron,
> and I imagine I could write something that checked each hour to see if
> any catalogues had expried recently, but that seems mad.
>
> Another solution I came up with involved checking for the expiry date
> every time a record is pulled up from the database. But this add's a
> hit to user responsiveness (even if it is tiny) and still doesn't
> allow me to send out the email.
>
> Finally, I read up on Django's signals to decide if I could use that
> mechanism to do other things. Signals sounds ideal, but I don't know
> how to trigger at the right time.
>
> Can anyone help me with this? How do I trigger a custom signal based
> on a DateTimeField value?
>
> 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: Triggering a custom signal

2008-10-27 Thread Adi Jörg Sieker

Hi,

On 27.10.2008 12:45 Uhr, redmonkey wrote:
> Pretty simple stuff. My problem is that I need to run a function at
> the auction_date of the catalogue that will do a few things like
> change the status of the catalogue, and send an email out to some
> admins.
>
> I've done some brief research, and founddjango-cron,
> and I imagine I could write something that checked each hour to see if
> any catalogues had expried recently, but that seems mad.
>
> Another solution I came up with involved checking for the expiry date
> every time a record is pulled up from the database. But this add's a
> hit to user responsiveness (even if it is tiny) and still doesn't
> allow me to send out the email.
>
> Finally, I read up on Django's signals to decide if I could use that
> mechanism to do other things. Signals sounds ideal, but I don't know
> how to trigger at the right time.
>
> Can anyone help me with this? How do I trigger a custom signal based
> on a DateTimeField value?
>
Django's signals are fired when certain events arise, like before save 
or after save of a model instance.
They don't fire at certain times.
So your best bet is actually going for a normal cron job. or using 
something like django-cron

adi

-- 
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   web:http://www.sieker.info/profile
SAP-Developer

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Triggering a custom signal

2008-10-27 Thread redmonkey

Hi,

I'm working on a simple auctioneer's website. My Catalogue app
consists of a list of Lots arranged into Catalogues. Each catalogue
has an auction_data field which stores a status and a date and time of
the sale:

class Catalogue(models.Model):
DRAFT_STATUS = 1
LIVE_STATUS = 2
CATALOGUE_CHOICES = (
(DRAFT_STATUS, 'Draft'),
(LIVE_STATUS, 'Live'),
)
status = models.IntegerField("Status", choices=CATALOGUE_CHOICES,
default=DRAFT_STATUS)
auction_date = models.DateTimeField("Date of Auction")
...

class Lot(models.Model):
catalogue = models.ForeignKey(Catalogue, related_name="lots")
...

Pretty simple stuff. My problem is that I need to run a function at
the auction_date of the catalogue that will do a few things like
change the status of the catalogue, and send an email out to some
admins.

I've done some brief research, and found django-cron,
and I imagine I could write something that checked each hour to see if
any catalogues had expried recently, but that seems mad.

Another solution I came up with involved checking for the expiry date
every time a record is pulled up from the database. But this add's a
hit to user responsiveness (even if it is tiny) and still doesn't
allow me to send out the email.

Finally, I read up on Django's signals to decide if I could use that
mechanism to do other things. Signals sounds ideal, but I don't know
how to trigger at the right time.

Can anyone help me with this? How do I trigger a custom signal based
on a DateTimeField value?

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: customize auth.users

2008-10-27 Thread Alfredo Alessandrini

I've solve whit this:

http://wolfram.kriesing.de/blog/index.php/2008/customize-admin-for-user-model


Alfredo

2008/10/27 Alfredo Alessandrini <[EMAIL PROTECTED]>:
> Can I customize the auth.users list of the site administration? I need
> to display also the active status in the list.
>
> Thanks,
>
> Alfredo
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Uploaded Files -> Don't appear in folder, but no errors

2008-10-27 Thread Kip Parker

To get a new object from a ModelForm you just save it, so the view
should be something like:

def uploadImage(request):

  if request.method == 'POST': #if submitted
form = UploadNewImageForm(request.POST, request.FILES)

if form.is_valid():
ir = form.save()
   rw = ResourceWrapper(name = form.cleaned_data['name'])
   rw.save()
   return HttpResponseRedirect('/Main_page/') # Redirect after
POST


form.save() will put the image in the right place.

Kip.

On Oct 26, 7:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello,
>
> I've been having some problems with FileField. I can create and save
> objects with the FileField file, but the file is never placed in any
> directory. Essentially, the database has the correct values, but no
> files are copied into the correct directory. I am using django-1.0.
>
> A temporary file is created in memory if the file is < 2.5M, and a
> temporary file is written to disk in /tmp/ if it is bigger. I have
> confirmed this. Do I have to specifically trigger the save to the hard
> disk to get the file to appear in my MEDIA_ROOT subfolder? From the
> documentation it appeared that this should be done automatically.
>
> Settings:
> MEDIA_ROOT = '/home/paul/proj/djangotest/uploads/'
>
> Model:
>
> class ImageResource(models.Model):
>   wrapper = models.ForeignKey(ResourceWrapper)
>   image = models.FileField(upload_to='images/')
>   notes = models.CharField(max_length=200)
>
> class ResourceWrapper(models.Model):
>   #incomplete class, for versioning later
>   name = models.CharField(max_length=200)
>   creationDate = models.DateField(auto_now_add=True)
>
> Form:
>
> class UploadNewImageForm(ModelForm):
>   name = forms.CharField(max_length=200)
>   class Meta:
>     model = ImageResource
>
> View:
>
> def uploadImage(request):
>
>   if request.method == 'POST': #if submitted
>     form = UploadNewImageForm(request.POST, request.FILES) # A form
> bound to the POST data
>
>     if form.is_valid(): # All validation rules pass
>
>       # Process the data in form.cleaned_data
>
>       #create a meta resource object
>       rw = ResourceWrapper(name = form.cleaned_data['name'])
>       rw.save()
>
>       #this is either a TemporaryFile or MemoryFile depending on its
> size when I debug
>       img = form.cleaned_data['image']
>
>       ir = ImageResource(wrapper=rw,
>                          notes = form.cleaned_data['notes'],
>                          image = img, ##maybe the problem is here???
>                          )
>       ir.save()
>
>       #redirect to the main page
>       return HttpResponseRedirect('/Main_page/') # Redirect after POST
>
> Any ideas? This is frustrating because there are no error messages to
> point me in the right direction, and everything else seems to work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



customize auth.users

2008-10-27 Thread Alfredo Alessandrini

Can I customize the auth.users list of the site administration? I need
to display also the active status in the list.

Thanks,

Alfredo

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ignore url

2008-10-27 Thread Niall Mccormack
Cool, thanks for the reply!

On 24 Oct 2008, at 15:01, Karen Tracey wrote:

> On Fri, Oct 24, 2008 at 6:56 AM, Niall Mccormack <[EMAIL PROTECTED] 
> > wrote:
>
> Is it possible to tell Django to ignore certain url's so that it
> resorts to showing what is on the server at that url.
>
> i.e. if I have a file at the url
> http://www.mywebsite.com/myfiles/image.jpg
>
> Can I instruct Django to ignore the /myfiles/ url so I can link
> directly to that file?
>
>
> The place to do this is in the web server configuration.  You  
> configure it so that such files are served directly rather than  
> sending the request through Django.  Unless you are talking about  
> the Djagno development server; there you can use the static server  
> to serve these files.  Search for "static files" in the docs for  
> details on how to do that.
>
> Karen
>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Where is my Django?

2008-10-27 Thread David Reynolds


On 23 Oct 2008, at 5:32 pm, leonel wrote:

> dpkg -l  python-django   shows  all the package contents ..


No, dpkg -l gives you a list of packages your system knows about it  
must be

dpkg -L python-django

as I noted before ;)

-- 
David Reynolds
[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: Handling Subdomain Requests

2008-10-27 Thread Graham Dumpleton



On Oct 27, 6:43 pm, Aljosa Mohorovic <[EMAIL PROTECTED]>
wrote:
> On Oct 27, 5:52 am, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
>
> > A single instance of the web application would then handle each
> > virtual host.
>
> is this something that is possible/stable to use in mod_wsgi/django
> combination?

Yes.

> concrete example, i'm building a site with a single admin interface
> and several frontends (different design, same content, different
> context), will be hosted at webfaction (although if necessary can be
> slicehost or something else).
> depending on domain i thought i'll configure several mod_wsgi/django
> projects (apps in webfaction configuration) but i'm very interested in
> option to handle all request from single django project/webfaction
> app.
> obviously i want to use less memory since every frontend will have
> 100-500 hits per month so there is no real need to have ~10x50mb if i
> can use 50-70mb.
> can you provide any suggestions for this situation?
> thanks

The preferred approach would be to use mod_wsgi daemon mode and have a
separate daemon process for each virtual host. Since the sites are so
infrequently used, you would set inactivity-timeout option for daemon
process so when site is idle it will effectively shutdown until
required again, at which point it will be reloaded automatically.

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



Re: Handling Subdomain Requests

2008-10-27 Thread haloween

>  i want to use less memory since every frontend will have
> 100-500 hits per month so there is no real need to have ~10x50mb if i
> can use 50-70mb.
> can you provide any suggestions for this situation?

A) use the sites framework

B)  dirtiest and probably most stupid

you can have discovery performed in the context_processor and
middleware:

ex:
hostname=request.META["SERVER_NAME"];
location = None;

if hostname=='foo.com' or hostname=='www.foo.com':
 location = 1;

if hostname=='boo.foo.com':
 location = 2;

then you can setup redirection templates wchich would include the
proper site templates.

for example in news.html

{%ifequal location 1%}
{%include "loc1/news.html"%}
{%endifequal%}

and so on . not a very elegant though

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Noon Help

2008-10-27 Thread Low Kian Seong

This sounds good. Keep me informed. I am currently writing a carpet
inventory based on django.

On Mon, Oct 27, 2008 at 2:27 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> Johnny Utah wrote:
>> Hi Guys,
>>
>> If I'm posting this on the wrong site, my apologies.
>>
>> I'm a beginner to both Python and Django and I would like to develop a
>> public site.  I'm not looking for help with code as much as with what
>> modules I will need (e.g. django.contrib.auth).  Any help is greatly
>> appreciated!
>>
> It sounds like Django is the right tool to do the job. The things that
> are in django.contrib that'll probably be most useful is auth and admin.
> These are documented at docs.djangoproject.com pretty well. If you have
> any specific questions that come up, this is the place to ask.
>
> It sounds like you're already headed in the right direction. Use
> Django's auth system, the admin site, and build your own app for reptile
> tracking. I'd use it, except I'm not a reptile owner– we only have a bird.
>
>
> Happy Coding!
>
> Jeff Anderson
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Handling Subdomain Requests

2008-10-27 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-10-27, o godz. 04:00, przez killer  
barney:

> I'm not too familiar with how to handle subdomain requests on django.
> If i have test.example.com, is this somethign I'm supposed to find in
> the urls.py?? Or is this done in the middleware?
>
> I'm really confused about this, so you may have to give me step by
> step instructions =)

It depends.

If the subdomain is supposed to handle part of your application  
functionality (eg. section for partners, admin application, some other  
management interface), it seems feasible to do the routing in  
middleware by changing request.urlconf, like:

class SubdomainsMiddleware(object):

 def process_request(self, request):
 parts = request.META['HTTP_HOST'].split('.')
 if parts[0] in settings.SUBDOMAINS_MAP:
 request.urlconf = settings.SUBDOMAINS_MAP[parts[0]]

The above example code requires that you maintain a mapping  
(dictionary) of subdomain names to urlconf modules.

In any other case I'd suggest configuring virtual host and serve it  
with another application.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[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: Handling Subdomain Requests

2008-10-27 Thread Aljosa Mohorovic

On Oct 27, 5:52 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> A single instance of the web application would then handle each
> virtual host.

is this something that is possible/stable to use in mod_wsgi/django
combination?
concrete example, i'm building a site with a single admin interface
and several frontends (different design, same content, different
context), will be hosted at webfaction (although if necessary can be
slicehost or something else).
depending on domain i thought i'll configure several mod_wsgi/django
projects (apps in webfaction configuration) but i'm very interested in
option to handle all request from single django project/webfaction
app.
obviously i want to use less memory since every frontend will have
100-500 hits per month so there is no real need to have ~10x50mb if i
can use 50-70mb.
can you provide any suggestions for this situation?
thanks

Aljosa Mohorovic
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Noon Help

2008-10-27 Thread Jeff Anderson
Johnny Utah wrote:
> Hi Guys,
>
> If I'm posting this on the wrong site, my apologies.
>
> I'm a beginner to both Python and Django and I would like to develop a
> public site.  I'm not looking for help with code as much as with what
> modules I will need (e.g. django.contrib.auth).  Any help is greatly
> appreciated!
>   
It sounds like Django is the right tool to do the job. The things that
are in django.contrib that'll probably be most useful is auth and admin.
These are documented at docs.djangoproject.com pretty well. If you have
any specific questions that come up, this is the place to ask.

It sounds like you're already headed in the right direction. Use
Django's auth system, the admin site, and build your own app for reptile
tracking. I'd use it, except I'm not a reptile owner– we only have a bird.


Happy Coding!

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Receiving emails via app

2008-10-27 Thread Jeff Anderson
James Bennett wrote:
> On Sat, Oct 25, 2008 at 2:09 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote:
>   
>> We have an alias set up in postfix that sends the e-mail to our script
>> via a pipe.
>>
>> The python script imports our Django models, and parses the e-mail
>> message with the email module, and does what it needs to.
>> 
>
> You can also use Python's built-in SMTP server module to set up a
> lightweight server process, and have your regular MTA forward messages
> to it. This lets the entire mail-processing routine happen in Python,
> which is often a bit easier to set up.
>
> See Doug Hellmann's recent PyMOTW article on this for some basic
> details: http://blog.doughellmann.com/2008/10/pymotw-smtpd.html
>   

This sounds like the best of both worlds option. One python process for
all e-mails without the overhead of having to check the e-mail
passively. A second server still needs to be run, but if you aren't
already running a mail server that "disadvantage" goes away. I may
consider switching to this.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature