Re: using ajax in django

2009-05-14 Thread veasna bunhor
Thanks for your shearing a good knowledge.

I'll do it.

Veasna,

On Thu, May 14, 2009 at 9:42 PM, zayatzz  wrote:

>
> Im also a django beginner, but i have bit more advanced knowledge
> about js/jquery
>
> Here's what ive learned so far: All js events happen in browser and
> are all related/attached to some DOM elements.
>
> Basic (model)form flow works like that:
> You create a model
> You create a modelform (in apps forms.py for example)
> You pass it to a template in a view
> You load it in template with {{ from }}
>
> Check django forms documentation for more specific stuff.
>
> If you want to run some events related to form fields or when
> submitting a form, then you must know how the form will look like in
> markup and you can do it on template level writing stuff directly into
> template or create js file that is started on jquery domready event.
> That js file will catch formfield events.
>
> You can also create formwidgets. Not sure how to use/create them
> beause so far, ive only used tinyMCE pluggable and havent created any
> of my own.
>
> Basically i do not think django is an issue here. Just create html
> file with form and then create jquery some jquery events. Adding
> django into the mix changes not a thing especially if you want to use
> onchange events.
>
> Alan
> On May 14, 9:34 am, newbie  wrote:
> > hi,
> >
> >   I'm new to django and dont know much of javascript either. I
> > would like to start working on them. Could someone help me write a
> > simple form which can provide any functionality using ajax, preferably
> > using jquery libraries. It would be great if any event other  than the
> > submit event is recognised using ajax, something which connects to the
> > database would be preferable.
> >
> > I've used ajax in web2py. But here in django I'm not able to
> > understand the flow of a form. Here in django, forms are created by
> > declaring a class in a seperate file. In web2py, it was clear and
> > obvious of how to recognize a input or click or onchange event for a
> > particular input field. But here I dont understand where to catch the
> > event. Do i need to write the code in template file or in view file.
> > If i write it in template file(which i'm thinking is the way), how to
> > send the input entered(before the user submits the form) to the view
> > file.
> >
> >   All i want to do is, to capture a change/input event on a form
> > before the user submits and dynamically create an extra field in the
> > form/change the options of a field already present in the form, based
> > on the input
> >
> >   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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Limiting the queryset for a foreign key field in the admin change_list view

2009-05-14 Thread Colin Bean

On Thu, May 14, 2009 at 5:26 PM, Margie  wrote:
>
> Sorry for the length of this - I hope someone knowledgable about ajax
> has a minute to take a look, I've been working on it for awhile.
> George - if you are reading this - this is my attempt to do the jquery/
> ajax that you recommended a few days back when I posted a more general
> question.
>
> Ok - here's the high level: I have a Task model that contains an owner
> field.  In the admin change_list view for the task, I am am trying to
> create a jquery ajax request that will override the queryset for the
> task's owner  field so that it contains the users returned by a GET
> request to  http://mysite.com/admin/taskmanager/task/get_owner_queryse
> /.
>
> In other words, I don't want the queryset for owner to contain all
> Users in the system, I want it to just contain the users that are
> specified in the task's 'resources' field, which is a ManyToMany
> field.
>
> Note: all code is also at http://dpaste.com/44241 - more readable
> there.
>
> I'm trying hard to leverage the admin interface, which I think will
> work for me if I can just figure out how to configure it with some
> spiffy jquery/ajax.
>
> I'm doing this by overriding formfield_for_foreignkey () so that it
> uses a special OwnerSelectWidget for the 'owner' field, like this:
>
>
>
>    def formfield_for_foreignkey(self, db_field, request, **kwargs):
>        if db_field.name == "owner":
>            kwargs["widget"] = OwnerSelectWidget()
>            return db_field.formfield(**kwargs)
>        return super(TaskAdmin, self).formfield_for_foreignkey
> (db_field, request, **kwargs)
>
> My OwnerSelectWidget looks like this:
>
> class OwnerSelectWidget(widgets.Select):
>
>    class Media:
>        css = {}
>        js = (
>            'js/jquery.js',
>        )
>
>    def render(self, name, value, attrs=None):
>        rendered = super(OwnerSelectWidget, self).render(name, value,
> attrs)
>        return rendered + mark_safe(u'''
>            
>                $('#id_%(name)s').mousedown(function() {
>                            $.getJSON("get_owner_queryset/
> NEED_TASK_ID_HERE",
>                                      function(data) {
>                                        var options = '';
>                                        for (var i = 0; i <
> data.length; i++) {
>                                           /* set options based on
> data - not quite sure how */
>                                        $('#id_%(name)s').html
> (options);
>                                      })
>                            })
>            
>            ''' % {'name': name, })
>
> My code that services the GET is in my admin.py file and looks like
> this:
>
> class TaskAdmin(admin.ModelAdmin):
>
>    def __call__(self, request, url):
>        if url is None:
>            pass
>        else:
>            match = re.search('get_owner_queryset/(\d+)', url)
>            if  match:
>                return self.getOwnerQuerySet(match.group(0))
>            else:
>                return super(TaskAdmin, self).__call__(request, url)
>
>    def getOwnerQuerySet(self, taskId):
>        task = Task.objects.get(taskId)
>        resourcesToReturn = task.resources.all() # resources are users
>        return HttpResponse(simplejson.dumps(resourcesToReturn),
> mimetype='application/json')
>
>
> I have a couple problems (so far that I know of).
>
> 1. In line 8 of the render() method, where I have NEED_TASK_ID_HERE,
> I'm trying to figure out how I get the task id.  It seems like at
> this  point in the code  I don't have access to that.  The id is
> output as part of the change_list  form, but it doesn't have an id
> associated with it.  What is the best approach to take?
>
> 2. In getOwnerQuerySet(), I don't think what I'm returning is
> correct.  When I play around in pdb and create a User queryset and
> then try to call simplejson.dumps() on it:
>   resources = User.objects.all()
>   return HttpResponse(simplejson.dumps(resourcesToReturn),
> mimtype='application/json')
> I get the error:
>
>  *** TypeError: [, ] is not JSON serializable
>
> So I think I am not really returning the data correctly.  And when I
> run the app
> this way, I get a 500 INTERNAL SERVER ERROR.
>
> 3. Once I do manage to return whatever it is that I'm supposed to
> return (ie,  question 2), I'm not quite sure what it is going to look
> like when it gets back to the jquery callback function.  I have a
> little for loop in there, but I think I need to come up name/value
> pairs.  If the GET is returning a list of user names, where does the
> value come from?
>
>
> Ok - sorry for the length of this but I've been working for awhile now
> on it and could really use some pointers from someone knowledgable out
> there.  I know there is doc on this simplejson stuff, but the first
> time around, it's just hard to make sense of it all.
>
> Margie
> >
>

Re: your second question, you'll want to use django's built in 

Re: disable django cache

2009-05-14 Thread online

Thanks, this kind of design is interesting, not what i expected
though.

I thought the server is running whatever my script i want to use
return render_to_response('home.html')
or
return render_to_response('index.html')



On May 14, 7:55 pm, David Zhou  wrote:
> On Thu, May 14, 2009 at 9:53 PM, online  wrote:
>
> > Whatever i changed 'home.html' to other page i always get the same
> > result.
>
> Are you restarting your serving?  If by "changed home.html to other
> page" you mean you modified your view function to return a different
> template, then make sure you restart your server.
>
> -- dz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple 404.html pages

2009-05-14 Thread James Bennett

On Thu, May 14, 2009 at 10:56 PM, Lee Hinde  wrote:
> Because I would be using different base.html files, I'm wondering if
> there is a work around to having a single 404.html file. For instance,
> can I determine at run time where to find my base.html file?

Write a view which chooses and uses the correct template. Set that
view as the value of the variable 'handler404' in your root URLConf
(as documented).


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Multiple 404.html pages

2009-05-14 Thread Lee Hinde

Hi;

The site I'm working on will have two groups of users, the public and
staff. The 404.html page that the public sees needs to look different
than what the staff will see. Primarily because the staff is stuck
with the look and feel that I come up with, but the public side will
be skinned to match the rest of the client's public site.

Currently I have the public html files in their own directory with
their own base.html document.
/templates
  /public
  base.html
  /staff
  base.html

Because I would be using different base.html files, I'm wondering if
there is a work around to having a single 404.html file. For instance,
can I determine at run time where to find my base.html file?

I understand I can use {% extends variable %}, but I'm not clear a) if
this is a good use case for that and b) where in a get_object_or_404
process I set the base document...

tia.

 - Lee

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



Re: disable django cache

2009-05-14 Thread David Zhou

On Thu, May 14, 2009 at 9:53 PM, online  wrote:
>
> Whatever i changed 'home.html' to other page i always get the same
> result.

Are you restarting your serving?  If by "changed home.html to other
page" you mean you modified your view function to return a different
template, then make sure you restart your server.

-- dz

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



Re: disable django cache

2009-05-14 Thread Colin Bean

On Thu, May 14, 2009 at 6:53 PM, online  wrote:
>
> This is my code
>
>
> from django.http import HttpResponse
> from django.template import Context, loader
> from django.shortcuts import render_to_response
> from django.views.decorators.cache import cache_control
> @cache_control(no_cache=True)
> def index(request):
>        #t = loader.get_template('home.html')
>        return render_to_response('home.html')
>
>
> i don't think it was browser cache. I have tried both IE and firefox.
>
>
> Whatever i changed 'home.html' to other page i always get the same
> result.
>
>
> Thanks
>

What are the TEMPLATE_DIRS that you're using in your settings file? Do
they point to the same file you're editing?  Any chance you copied the
project from somewhere else and it's loading the templates from the
original location?

Colin

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



Re: disable django cache

2009-05-14 Thread online

This is my code


from django.http import HttpResponse
from django.template import Context, loader
from django.shortcuts import render_to_response
from django.views.decorators.cache import cache_control
@cache_control(no_cache=True)
def index(request):
#t = loader.get_template('home.html')
return render_to_response('home.html')


i don't think it was browser cache. I have tried both IE and firefox.


Whatever i changed 'home.html' to other page i always get the same
result.


Thanks



On May 14, 2:49 pm, John M  wrote:
> Are you sure it isn't your browser?  have you tried testing your
> concern with curl?
>
> On May 14, 12:19 pm, online  wrote:
>
> > Hi all,
>
> > I have a small project still under development. I don't set any cache
> > stuff yet. But for somehow django still cache all web pages.
>
> > Why django default uses cache?  How can i disable the all level
> > caches?
>
> > I tried
>
> > from django.views.decorators.cache import cache_control
>
> > @cache_control(private=True)
>
> > and
>
> > from django.views.decorators.cache import never_cache
>
> > @never_cache
>
> > on views.py but not working
>
> > Thanks for any help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Gravatar django apps

2009-05-14 Thread Joshua Partogi

Thanks Rama.

I will try this out too and I will see which one fits best. I didn't
know it was this simple :-)

Cheers.

On May 14, 11:08 pm, Rama Vadakattu  wrote:
> Integrating with Gravatar is very easy
>
> 1) Get MD5 hash of user's email id
>  import hashlib
>
>    def getMD5(self):
>           m = hashlib.md5()
>           m.update(self.user.email)
>          return m.hexdigest()
>
> 2) and prepare image url as below
>      http://www.gravatar.com/avatar/{{user-email-MD5-
> hash}}.jpg" alt="" />
>
> that's it the image shows the gravatar of respective user.
>
> --rama
>
> On May 14, 4:30 pm, Joshua Partogi  wrote:
>
> > Dear all
>
> > Does anybody know a good django application for gravatar 
> > (http://gravatar.com) ?
>
> > Thank you very much for the redirection.

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



Re: Gravatar django apps

2009-05-14 Thread Joshua Partogi

Thanks for the redirection Erreon.

I will try it out. :-)

Best regards,

On May 15, 5:00 am, Erreon  wrote:
> If you don't want to implement your own solution you could 
> use.http://code.google.com/p/django-gravatar/
>
> On May 14, 6:30 am, Joshua Partogi  wrote:
>
> > Dear all
>
> > Does anybody know a good django application for gravatar 
> > (http://gravatar.com) ?
>
> > Thank you very much for the redirection.
>
> > :-)
>
> > --
> > If you can't believe in God the chances are your God is too small.
>
> > Read my blog:http://joshuajava.wordpress.com/
> > Follow us on twitter:http://twitter.com/scrum8
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Limiting Choices of a ForeignKey with 'self'.

2009-05-14 Thread Margie

I am working on this.  I think it is not simple.  The queryset for the
forms in the change_list view are created at a point in the code where
there is no info on what the actual object associated with that form
is.  There is no simple way (ie, an arg or callback) to make a foreign
key field in the change_list view have a queryset that is specific to
that item. I think you have to use an ajax request to modify the
queryset on the fly.  The approach I am trying to take is that when
the user does a mouse-down on the foreign key field, it sends a
request to the server to get the possible values for the foreign key.
I'm not yet sure what to do about the initial value.  For example, if
I start with a queryset that is empty, then the selected value (in the
case where the object already has a value) does not show up.
Alternately, I don't want my queryset to start out with all objects,
because in my case that number is too large (would be all users in the
system).  So perhaps I will need a special ajax get that sets all
intial values for the query set ... I am not sure.  Anyway, I don't
have code working yet, but I just posted a long question with the code
that I have, at:

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

Maybe I'm heading down the wrong path, it seems complex, I really am
not sure...

Margie

On May 14, 4:54 pm, Jamie  wrote:
> Have you found a solution for this? I'm surprised no one has at least
> responded that it is or is not possible.
>
> On Apr 9, 1:09 pm, Nicky Bulthuis  wrote:
>
> > Hello Django Users,
>
> > I'm trying to learn Django as best as i can, however i've come to  
> > problem which i hope someone can help me with.
>
> > I have two models, Release and OTAP.
>
> > A Release is a reference to a file and linked to an OTAP. An OTAP can  
> > have a Release for each of the 4 environments. I've modeled this as  
> > below:
>
> > class Release(models.Model):
>
> >         name = models.CharField(max_length=128, unique=True, )
> >         path = models.CharField(max_length=512, )
>
> >         otap = models.ForeignKey('OTAP')
>
> > class OTAP(models.Model):
>
> >         name = models.CharField(max_length=128, unique=True, )
>
> >         o_release = models.ForeignKey(Release, 
> > verbose_name="O-Environment",  
> > related_name='o_release', null=True, blank=True)
> >         t_release = models.ForeignKey(Release, 
> > verbose_name="T-Environment",  
> > related_name='t_release', null=True, blank=True)
> >         a_release = models.ForeignKey(Release, 
> > verbose_name="A-Environment",  
> > related_name='a_release', null=True, blank=True)
> >         p_release = models.ForeignKey(Release, 
> > verbose_name="P-Environment",  
> > related_name='p_release', null=True, blank=True)
>
> > This all works in the admin interface, i can select Releases for each  
> > OTAP i have for each of the 4 environments. However i would like to  
> > limit the choices of the environments to just those releases that  
> > belong to that OTAP. I've tried to work with the 'limit_choices_to'  
> > from the ForeignKey, but i've had no luck so far. I've tried to limit  
> > the Release to the otap field but i can't seem to figured out how to  
> > select the 'self' of OTAP.
>
> > So my question is: how do i limit the choices for each environment to  
> > just those release belonging to the OTAP?
>
> > I hope someone can point me in the right direction.
>
> > Regards,
> > Nick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Limiting the queryset for a foreign key field in the admin change_list view

2009-05-14 Thread Margie

Sorry for the length of this - I hope someone knowledgable about ajax
has a minute to take a look, I've been working on it for awhile.
George - if you are reading this - this is my attempt to do the jquery/
ajax that you recommended a few days back when I posted a more general
question.

Ok - here's the high level: I have a Task model that contains an owner
field.  In the admin change_list view for the task, I am am trying to
create a jquery ajax request that will override the queryset for the
task's owner  field so that it contains the users returned by a GET
request to  http://mysite.com/admin/taskmanager/task/get_owner_queryse
/.

In other words, I don't want the queryset for owner to contain all
Users in the system, I want it to just contain the users that are
specified in the task's 'resources' field, which is a ManyToMany
field.

Note: all code is also at http://dpaste.com/44241 - more readable
there.

I'm trying hard to leverage the admin interface, which I think will
work for me if I can just figure out how to configure it with some
spiffy jquery/ajax.

I'm doing this by overriding formfield_for_foreignkey () so that it
uses a special OwnerSelectWidget for the 'owner' field, like this:



def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "owner":
kwargs["widget"] = OwnerSelectWidget()
return db_field.formfield(**kwargs)
return super(TaskAdmin, self).formfield_for_foreignkey
(db_field, request, **kwargs)

My OwnerSelectWidget looks like this:

class OwnerSelectWidget(widgets.Select):

class Media:
css = {}
js = (
'js/jquery.js',
)

def render(self, name, value, attrs=None):
rendered = super(OwnerSelectWidget, self).render(name, value,
attrs)
return rendered + mark_safe(u'''

$('#id_%(name)s').mousedown(function() {
$.getJSON("get_owner_queryset/
NEED_TASK_ID_HERE",
  function(data) {
var options = '';
for (var i = 0; i <
data.length; i++) {
   /* set options based on
data - not quite sure how */
$('#id_%(name)s').html
(options);
  })
})

''' % {'name': name, })

My code that services the GET is in my admin.py file and looks like
this:

class TaskAdmin(admin.ModelAdmin):

def __call__(self, request, url):
if url is None:
pass
else:
match = re.search('get_owner_queryset/(\d+)', url)
if  match:
return self.getOwnerQuerySet(match.group(0))
else:
return super(TaskAdmin, self).__call__(request, url)

def getOwnerQuerySet(self, taskId):
task = Task.objects.get(taskId)
resourcesToReturn = task.resources.all() # resources are users
return HttpResponse(simplejson.dumps(resourcesToReturn),
mimetype='application/json')


I have a couple problems (so far that I know of).

1. In line 8 of the render() method, where I have NEED_TASK_ID_HERE,
I'm trying to figure out how I get the task id.  It seems like at
this  point in the code  I don't have access to that.  The id is
output as part of the change_list  form, but it doesn't have an id
associated with it.  What is the best approach to take?

2. In getOwnerQuerySet(), I don't think what I'm returning is
correct.  When I play around in pdb and create a User queryset and
then try to call simplejson.dumps() on it:
   resources = User.objects.all()
   return HttpResponse(simplejson.dumps(resourcesToReturn),
mimtype='application/json')
I get the error:

  *** TypeError: [, ] is not JSON serializable

So I think I am not really returning the data correctly.  And when I
run the app
this way, I get a 500 INTERNAL SERVER ERROR.

3. Once I do manage to return whatever it is that I'm supposed to
return (ie,  question 2), I'm not quite sure what it is going to look
like when it gets back to the jquery callback function.  I have a
little for loop in there, but I think I need to come up name/value
pairs.  If the GET is returning a list of user names, where does the
value come from?


Ok - sorry for the length of this but I've been working for awhile now
on it and could really use some pointers from someone knowledgable out
there.  I know there is doc on this simplejson stuff, but the first
time around, it's just hard to make sense of it all.

Margie
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this 

Re: Troubles after switching to WSGI: lost apache processes, multiple view func calls per HTTP request

2009-05-14 Thread Graham Dumpleton



On May 14, 11:08 pm, Valery  wrote:
> By the way, regarding the 30 func calls per HTTP request you'd mean
> it is a bare conflict WSGI vs mod_python?

That is likely to be a Django issue, you will have to explain that one
better and maybe someone else can help.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Limiting Choices of a ForeignKey with 'self'.

2009-05-14 Thread Jamie

Have you found a solution for this? I'm surprised no one has at least
responded that it is or is not possible.

On Apr 9, 1:09 pm, Nicky Bulthuis  wrote:
> Hello Django Users,
>
> I'm trying to learn Django as best as i can, however i've come to  
> problem which i hope someone can help me with.
>
> I have two models, Release and OTAP.
>
> A Release is a reference to a file and linked to an OTAP. An OTAP can  
> have a Release for each of the 4 environments. I've modeled this as  
> below:
>
> class Release(models.Model):
>
>         name = models.CharField(max_length=128, unique=True, )
>         path = models.CharField(max_length=512, )
>
>         otap = models.ForeignKey('OTAP')
>
> class OTAP(models.Model):
>
>         name = models.CharField(max_length=128, unique=True, )
>
>         o_release = models.ForeignKey(Release, verbose_name="O-Environment",  
> related_name='o_release', null=True, blank=True)
>         t_release = models.ForeignKey(Release, verbose_name="T-Environment",  
> related_name='t_release', null=True, blank=True)
>         a_release = models.ForeignKey(Release, verbose_name="A-Environment",  
> related_name='a_release', null=True, blank=True)
>         p_release = models.ForeignKey(Release, verbose_name="P-Environment",  
> related_name='p_release', null=True, blank=True)
>
> This all works in the admin interface, i can select Releases for each  
> OTAP i have for each of the 4 environments. However i would like to  
> limit the choices of the environments to just those releases that  
> belong to that OTAP. I've tried to work with the 'limit_choices_to'  
> from the ForeignKey, but i've had no luck so far. I've tried to limit  
> the Release to the otap field but i can't seem to figured out how to  
> select the 'self' of OTAP.
>
> So my question is: how do i limit the choices for each environment to  
> just those release belonging to the OTAP?
>
> I hope someone can point me in the right direction.
>
> Regards,
> Nick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Save() method doesn't update until an item has been saved twice

2009-05-14 Thread Jamie

I'm running into a problem with the save() method in which I need
Django to update items in Model_B when an item from Model_A is saved.
The problem is that I save Model_A but Model_B is not updated.
However, if I save Model_A a second time (without changing anything)
then Model_B is updated.

Here's the setup:

Model_A is ARTICLES and Model_B is PHOTOS. ARTICLES contains a many-to-
many field for PHOTOS so that multiple photos can be attached to each
article. PHOTOS are attached to ARTICLES via an intermediary table
that is an inline table in the ARTICLES admin page.

When I save an article, I need the following to happen:

1) PHOTOS needs to be updated with info from ARTICLES, such as
publish_datetime. This is necessary to make sure that the photo's
publish_datetime is synced to the article. Photos do not have
publish_datetime set until they are attached to an article. In other
words, orphaned photos will not be published.

2) In the event that a photo is removed from an article, I need that
orphaned article to have its publish_datetime set to None. In order to
accomplish this, I wrote a function called clean_orphaned_photos that
queries PHOTOS for all photos with a publish_datetime and then queries
the intermediary model for each of the results to see if they also
exist there (which means they are attached to an article). If not,
they are wiped.

If #1 takes place in both the ARTICLES and the intermediary model's
save() then this works. #2, however, only takes place when an article
is saved twice. It's as if the intermediary table isn't updated before
#2 executes.

So, my questions are:

1) Should I put the functions for #1 and #2 in the ARTICLES save() or
in the intermediary model's save()?

2) Why would these functions require that I save an article two times
before they update the data?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Allow only superusers to log into admin

2009-05-14 Thread ringemup


Thanks, that looks like a good place to start.

I'm literally setting up two separate admin sites -- I need to prevent
the "staff" from even accessing the site for the superusers, as it
presents a lot of options I don't want to even be visible to them,
displays different inlines, etc.


On May 14, 7:31 pm, Michael  wrote:
> On Thu, May 14, 2009 at 6:10 PM, ringemup  wrote:
>
> > Is there a way to limit admin login to superusers?  I'd like to set up
> > multiple admin areas -- one for regular users and one for superusers.
>
> > Thanks!
>
> You can subclass the AdminSite Class and just overide the has_permission
> function to require a user to be a 
> super_user:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm...
>
> Although I would ask why would you want to. is_staff is the boolean that is
> used for this and then you can refine controls a little more between a
> superuser and a 'staff' member. You might be better off creating a staff
> group and putting all the people you are trying to have as staff there and
> then use the is_staff boolean for whether or not they can log into the
> admin, as it was supposed to do.
>
> I hope that helps,
>
> Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Allow only superusers to log into admin

2009-05-14 Thread Michael
On Thu, May 14, 2009 at 6:10 PM, ringemup  wrote:

>
> Is there a way to limit admin login to superusers?  I'd like to set up
> multiple admin areas -- one for regular users and one for superusers.
>
> Thanks!


You can subclass the AdminSite Class and just overide the has_permission
function to require a user to be a super_user:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L138

Although I would ask why would you want to. is_staff is the boolean that is
used for this and then you can refine controls a little more between a
superuser and a 'staff' member. You might be better off creating a staff
group and putting all the people you are trying to have as staff there and
then use the is_staff boolean for whether or not they can log into the
admin, as it was supposed to do.

I hope that helps,

Michael

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



Re: how to work with web service in django

2009-05-14 Thread Michael
On Thu, May 14, 2009 at 5:20 PM, lperk  wrote:

>
> hello everyone!
>
> I'm trying to make application in wich you will search some product
> and  for
> response my application will list you products from other pages(for
> example
> amazon or some e-shop).. I want to do it with web service and I have
> no idea
> where to start..does someone know how to do it? Or give me some link
> where I
> can see how to work with web services in django?! What do you think
> that
> will be best choice for this problem?
>

Django has a lot of awesome reusable apps that can help out with this. One I
would recommend for webshop type stuff is Satchmo:
http://www.satchmoproject.com/

There is a lot of experience there. I recommend just starting with
Django/Satchmo, see how far you get and you can fill in the gaps with your
own code and other apps as needed. You will have a better feel after a few
hours of hacking around than sitting here waiting for people to respond.

Hope this helps,

Michael

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



Re: django-admin.py not working...HELP!

2009-05-14 Thread Karen Tracey
On Thu, May 14, 2009 at 6:20 PM, Karen Tracey  wrote:

> Nothing that does from django.whatever will match, since Python will then
> be looking for


Nothing that does 'from django.whatever import something'

is what I meant to type there.

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



Re: django-admin.py not working...HELP!

2009-05-14 Thread Karen Tracey
On Thu, May 14, 2009 at 8:46 AM, bsisco  wrote:

>
> Ok.  I updated to the latest trunk release this morning and now when I
> run django-admin.py startapp  I get the following: (specs:
> Python 2.5, Win XP Pro, Django trunk release 10781)
>

What did you update from? How did you update?  Where did you put the latest
Django code?


> >django-admin.py startapp rd
> Traceback (most recent call last):
>  File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
> line 2, in 
>from django.core import management
> ImportError: No module named django.core
>

So you have django-admin.py in C:\Python25\Lib\site-packages\django\bin.
What else is under C:\Python25\Lib\site-packages\django?  Is there a
C:\Python25\Lib\site-packages\django\core directory with an __init__.py file
in it?  Python is seeming to say not, yet that is where it would be expected
to be given where you have django-admin.py.


>
> My python path is as follows:
> >echo %pythonpath% >> out.txt
> C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
>

Note having C:\Python25\Lib\site-packages\django in your PYTHONPATH is
incorrect.  Nothing that does from django.whatever will match, since Python
will then be looking for
C:\Python25\Lib\site-packages\django\django\whatever -- there's one too many
django's in there.  So, you don't want the 'django' part when you specify it
in PYTHONPATH.  But if you take django off of what you have you are left
with your site-packages directory, which is automatically searched.  So
you'd best just take that part out of your PYTHONPATH setting.

(It's also odd to have C:\Python25 in your PYTHONPATH.  Anything installed
under your Python directory, ought to be under site-packages, and therefore
automatically found.  If you've got Python packages installed directly under
C:\Python25 that's non-standard.)

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Allow only superusers to log into admin

2009-05-14 Thread ringemup

Is there a way to limit admin login to superusers?  I'd like to set up
multiple admin areas -- one for regular users and one for superusers.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django superusers

2009-05-14 Thread Karen Tracey
On Thu, May 14, 2009 at 4:06 PM, Mike Driscoll  wrote:

>
> Hi,
>
> I am working my way through the Django 1.0 book by Ayman Hourieh from
> Packt and I just reached the Admin Interface chapter (which is number
> 8 if you have the book). Anyway, when I login to my site's admin, I'm
> told that I don't have permission to edit anything. I loaded up the
> shell and did a user.is_superuser and it returned True.
>
> I then tried user.get_all_permissions() and that returned an empty set
> object, so something's messed up. Can someone tell me how to add the
> proper permissions that the superuser should have?
>
> I am running on Windows XP with Python 2.5 and Django 1.0.2 (final).
> Thanks!
>

I am not familiar with that book.  Does it instruct you to include
admin.autodiscover() in your urls.py file as is described here:

http://docs.djangoproject.com/en/1.0/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf

?

The usual reason for that message is not that the user's permissions are
missing, but rather that nothing has been registered to the admin, so no
user has permission to edit anything, as there is nothing to edit.  And the
usual reason for nothing being registered is that admin.autodiscover() isn't
being called.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



modelling question / many-to-many / intermediary

2009-05-14 Thread chris

Hi,

I'm working with Django since a few weeks and I really *love* it!

I came across a problem I didn't find any help so I thought it might
be a good idea to ask the pros.

I need to model persons and each person should have a list of other
persons (a 'collaborates-with'-property).

I have to save some meta-data about the connection, so I need a
intermediary table (let's call it "PersonCollaboration").

In normal SQL I would do it with a simple join table: person1_id |
person2_id | meta-stuff...

I'm not sure how to handle this in django.

How would you do that?

I read http://heather.koyuk.net/refractions/?p=151  - is this the only
way to go?

What about a symmetric approach?

Here is what I got so far (inspired from 
http://heather.koyuk.net/refractions/?p=151):

class PersonCollaboration (models.Model):
  person1 = models.ManyToManyField('Person',
related_name='person1')
  person2 = models.ManyToManyField('Person',
related_name='person2)
  ...

class Person (models.Model):
   name = models.CharField(max_length=250, unique=True)
   collaborates_with = models.ManyToManyField('self',
through='AuthorCollaboration', symmetrical=False

This is not symmetric - I could try to create two PersonCollaboration-
objects, but this is not really clean...

Thanks a lot for your support,

chris

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



Re: disable django cache

2009-05-14 Thread John M

Are you sure it isn't your browser?  have you tried testing your
concern with curl?

On May 14, 12:19 pm, online  wrote:
> Hi all,
>
> I have a small project still under development. I don't set any cache
> stuff yet. But for somehow django still cache all web pages.
>
> Why django default uses cache?  How can i disable the all level
> caches?
>
> I tried
>
> from django.views.decorators.cache import cache_control
>
> @cache_control(private=True)
>
> and
>
> from django.views.decorators.cache import never_cache
>
> @never_cache
>
> on views.py but not working
>
> Thanks for any help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to work with web service in django

2009-05-14 Thread lperk

hello everyone!

I'm trying to make application in wich you will search some product
and  for
response my application will list you products from other pages(for
example
amazon or some e-shop).. I want to do it with web service and I have
no idea
where to start..does someone know how to do it? Or give me some link
where I
can see how to work with web services in django?! What do you think
that
will be best choice for this problem?

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



Re: creating objects in views

2009-05-14 Thread Gene

You may still be able to use the built-in django-comments, as it's
easy to customize (especially if your just adding extra fields). You
can read about it here: 
http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#ref-contrib-comments-custom

Gene

On May 14, 12:59 pm, Oleg Oltar  wrote:
> Well, the problem with built in comments framework is that I need few more
> fields in comments.
>
> What I created is:
>
> MODEL:
>
> class Comment(models.Model):
>     name = models.CharField(max_length = 30)
>     body = models.CharField(max_length = 2000)
>     article = models.ForeignKey(Article)
>
>     def __unicode__(self):
>         return u"%s" %(self.name)
>
> FORM:
>
> class CommentForm(forms.Form):
>     '''
>     The Register form is created to deal with registration process
>     check if data is clean and passwords match each other
>     '''
>     username = forms.CharField(label='Name', max_length=30)
>     body = forms.CharField(required = True,
>                             label = 'Comment Body',
>                             widget=forms.Textarea)
>
>     def clean_body(self):
>         if 'body' in self.cleaned_data:
>             body = self.cleaned_data['body']
>             if not re.search(r'^\w+$', username):
>                 raise forms.ValidationError('Error: body can contains \
> only alphanumeric characters')
>
> VIEW:
>
> def article_page(request, page_name):
>     article = get_object_or_404(models.Article, url = page_name)
>     articles_list =
> models.Article.objects.exclude(is_published__exact="0").order_by("-pub_date")
>
>     if request.method == 'POST':
>         form = CommentForm(request.POST)
>         # Creating a comment
>         if form.is_valid():
>             comment = Comment(
>                 name = from.cleaned_data['name'],
>                 body = form.cleaned_data['body'],
>                 article = 
>                 )
>
>     return render_to_response('article.html',
>                               {'section': article.title,
>                                'article' : article,
>                                'articles' : articles_list}
>                               )
>
> Not sure how to fill the article field :(
>
> Thanks in advance,
> Oleg
>
> On Tue, May 12, 2009 at 1:01 PM, Daniel Roseman <
>
> roseman.dan...@googlemail.com> wrote:
>
> > On May 12, 10:51 am, Oleg Oltar  wrote:
> > > Hi!
> > > I am running small blog-styled information site. Which contains articles
> > > added via admin application
> > > Now I am trying to add possibility to add comments, so I defined a
> > comment
> > > Model (which contains Foreign Key to article object, and few text
> > fields),
> > > also defined forms.
>
> > > Can you please explain how should I create a comment object in view?
> > (After
> > > processing data from form). I don't understand where can I get, the
> > article
> > > name (id, guid or something) to link article and comment
>
> > > Thanks in advance,
> > > Oleg
>
> > Firstly, have you investigated the built-in comment app? It's quite
> > full-featured, and may do everything you want.
>
> > Assuming you've decided that your own model is the way to go, the
> > answer to your question will depend on the way you've defined your
> > form and view. Presumably the comment form is displayed at the bottom
> > of an article page, so you'll already have the ID of the article - so
> > I don't really understand what your issue is. Perhaps you could post
> > the code you have so far?
> > --
> > DR.

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



Re: disable django cache

2009-05-14 Thread Daniel Roseman

On May 14, 8:19 pm, online  wrote:
> Hi all,
>
> I have a small project still under development. I don't set any cache
> stuff yet. But for somehow django still cache all web pages.
>
> Why django default uses cache?  How can i disable the all level
> caches?
>
> I tried
>
> from django.views.decorators.cache import cache_control
>
> @cache_control(private=True)
>
> and
>
> from django.views.decorators.cache import never_cache
>
> @never_cache
>
> on views.py but not working
>
> Thanks for any help.

Django doesn't cache anything unless you tell it to. What makes you
think your pages are being cached? You will need to give us some
details of your setup before we can help.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: I/O operation on closed file

2009-05-14 Thread Tim Sawyer

On Tuesday 12 May 2009 21:28:35 Alex Gaynor wrote:
> On Tue, May 12, 2009 at 3:27 PM, Tim Sawyer wrote:
> > ValueError: I/O operation on closed file
>
> This is probably a symptom of http://code.djangoproject.com/ticket/11084 .
>

Thanks Alex.

I've just updated to 10784 (without a fix for that bug) and it seems fine now!

Cheers,

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: has date template filter been fixed?

2009-05-14 Thread Mr. T

Thanks!

On May 14, 1:28 pm, Alex Gaynor  wrote:
> On Thu, May 14, 2009 at 3:20 PM, Mr. T  wrote:
>
> > Pretty big WTF moment for me to debug what went wrong, eventually
> > discovering DJango's |date:"U" tempate filter is nonsense. It renders
> > to bogus values. Eventually found this:
>
> >http://tinyurl.com/rbop9g
>
> > Using 1.0. Has this been fixed?
>
> This was fixed in the 1.1 development branch and the 1.0.X devel branch.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: has date template filter been fixed?

2009-05-14 Thread Alex Gaynor
On Thu, May 14, 2009 at 3:20 PM, Mr. T  wrote:

>
> Pretty big WTF moment for me to debug what went wrong, eventually
> discovering DJango's |date:"U" tempate filter is nonsense. It renders
> to bogus values. Eventually found this:
>
> http://tinyurl.com/rbop9g
>
> Using 1.0. Has this been fixed?
> >
>
This was fixed in the 1.1 development branch and the 1.0.X devel branch.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



has date template filter been fixed?

2009-05-14 Thread Mr. T

Pretty big WTF moment for me to debug what went wrong, eventually
discovering DJango's |date:"U" tempate filter is nonsense. It renders
to bogus values. Eventually found this:

http://tinyurl.com/rbop9g

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



Re: django-admin.py not working...HELP!

2009-05-14 Thread Laszlo Antal
On Thu, May 14, 2009 at 11:45 AM, Blake M. Sisco wrote:

> Laszlo,
> django/bin is in my pathnot sure why gmail decided to format that so
> oddly but it's four lines up from the bottom of the quote in my last
> post.:-)  I made sure that it was there just now as well even went as
> far as rebooting the machine and still no joy...
>
>
> Blake M. Sisco
> LOR Manufacturing Co., Inc
> Web Presence • Graphic Design
> www.lormfg.com
> (866) 644-8622
> (888) 524-6292 FAX
>
> The information transmitted by Blake Sisco herewith is intended only for
> the person or entity to which it is addressed and may contain confidential
> and/or privileged material.  Any review, retransmission, dissemination or
> other use of, or taking of any action in reliance upon, this information by
> persons or entities other than the intended recipient is prohibited.  If you
> received this in error, please contact the sender and delete the material
> from any computer
>
>
>
> On Thu, May 14, 2009 at 2:38 PM, Laszlo Antal  wrote:
>
>>
>>
>> On Thu, May 14, 2009 at 11:02 AM, Blake M. Sisco 
>> wrote:
>>
>>> import django works fine.  i posted the results of >echo %pythonpath% and
>>> echo %path% in my first message but here it is again:
>>>
>>> *>echo %pythonpath%
 C:\Python25;C:\Python25\Lib\
 **site-packages\django;C:\**django_projects;

 and my win path is :
 >echo %path%
 C:\Program Files\PHP\;C:\Perl\site\bin;C:
 **\Perl\bin;C:\WINDOWS
 \system32;C:\WINDOWS;C:\**WINDOWS\System32\Wbem;C:\**Program Files
 \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-
 **Static;C:
 \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
 \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
 \Autodesk\DWG TrueView\;C:\ctags57;C:\
 **Program Files\GnuWin32\bin;C:
 \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\
 **MinGW\bin
 \;C:\WINDOWS\system32\**WindowsPowerShell\v1.0;C:\**Python25\Lib\site-
 packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\
 **Program Files
 \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
 Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
 *

>>>
>>> It's to the point of pulling my hair out :-\...
>>>
>>> Regards,
>>>
>>>
>>> Blake M. Sisco
>>> LOR Manufacturing Co., Inc
>>> Web Presence • Graphic Design
>>> www.lormfg.com
>>> (866) 644-8622
>>> (888) 524-6292 FAX
>>>
>>> The information transmitted by Blake Sisco herewith is intended only for
>>> the person or entity to which it is addressed and may contain confidential
>>> and/or privileged material.  Any review, retransmission, dissemination or
>>> other use of, or taking of any action in reliance upon, this information by
>>> persons or entities other than the intended recipient is prohibited.  If you
>>> received this in error, please contact the sender and delete the material
>>> from any computer
>>>
>>>
>>>
>>>
>>> On Thu, May 14, 2009 at 1:49 PM, Bruno Tikami wrote:
>>>


 On Thu, May 14, 2009 at 2:41 PM, bsisco  wrote:

>
> I've uninstalled and reinstalled django and I still can't get this to
> work.  Any help would be greatly appreciated...
>
> On May 14, 8:46 am, bsisco  wrote:
> > Ok.  I updated to the latest trunk release this morning and now when
> I
> > run django-admin.py startapp  I get the following: (specs:
> > Python 2.5, Win XP Pro, Django trunk release 10781)
> >
> > >django-admin.py startapp rd
> >
> > Traceback (most recent call last):
> >   File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
> > line 2, in 
> > from django.core import management
> > ImportError: No module named django.core
> >
> > My python path is as follows:>echo %pythonpath% >> out.txt
> >
> > C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
> >
> > and my win path is :>echo %path% >> out.txt
> >
> > C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
> > \system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
> > \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
> > \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
> > \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
> > \Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
> > \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
> > \;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
> > packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
> > \SecureCRT;C:\Documents and Settings\bsisco\Local
> Settings\Application
> > Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
>
>
 Hi 

Django superusers

2009-05-14 Thread Mike Driscoll

Hi,

I am working my way through the Django 1.0 book by Ayman Hourieh from
Packt and I just reached the Admin Interface chapter (which is number
8 if you have the book). Anyway, when I login to my site's admin, I'm
told that I don't have permission to edit anything. I loaded up the
shell and did a user.is_superuser and it returned True.

I then tried user.get_all_permissions() and that returned an empty set
object, so something's messed up. Can someone tell me how to add the
proper permissions that the superuser should have?

I am running on Windows XP with Python 2.5 and Django 1.0.2 (final).
Thanks!

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



Re: file upload docs obsolete?

2009-05-14 Thread msoulier

On May 14, 3:51 pm, msoulier  wrote:
> I looked here
>
> http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>
> and it mentions request.FILES being a dictionary, but the 1.0 porting
> guide here
>
> http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/
>
> says otherwise.
>
> Was this overlooked? I think the page needs an update.

Oh, I misread. FILES is still a dictionary, but it no longer returns
dictionaries, but UploadedFile objects.

Gotcha.

Is it Friday yet?

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



file upload docs obsolete?

2009-05-14 Thread msoulier

I looked here

http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

and it mentions request.FILES being a dictionary, but the 1.0 porting
guide here

http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/

says otherwise.

Was this overlooked? I think the page needs an update.

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



App command line args for degugging in IDLE?

2009-05-14 Thread Joshua Russo

Is there a way to specify arguments for your app when debugging in
IDLE? Like manage.py runserver. I can't figure out how to add the
runserver to the command to start debugging.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with map widget on admin change page (GIS / OpenLayers)

2009-05-14 Thread intrepidweb

Hi there,

I have a model called Locality that has a coordinates field. When I
view the admin change form for the model, the mapping widget appears,
but the actual map is grayed out.

For example, for Atlanta, GA, the coordinates are 33.69132,
-84.40137.  When the OpenLayers map widget is rendered, the individual
boxes that make up the map are all blank (gray), although the controls
are visible. Here is the URL for one of the boxes that comprise the
map:

http://labs.metacarta.com/wms/vmap0?LAYERS=basic=WMS=1.1.1=GetMap==application%2Fvnd.ogc.se_inimage=image%2Fjpeg=EPSG%3A4326=33.75,-84.375,33.837890625,-84.287109375=256=256

Does anyone know why the map is not being rendered? Do I need an API
key?

I am using GeoModelAdmin as the base class for the model admin class;
the only options I've specified so far are search_fields, ordering and
fields.

Thanks for the help!

Leif

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



disable django cache

2009-05-14 Thread online

Hi all,

I have a small project still under development. I don't set any cache
stuff yet. But for somehow django still cache all web pages.

Why django default uses cache?  How can i disable the all level
caches?

I tried

from django.views.decorators.cache import cache_control

@cache_control(private=True)

and

from django.views.decorators.cache import never_cache

@never_cache

on views.py but not working




Thanks for any help.




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



Re: temporarily log in as another user

2009-05-14 Thread Sam Chuparkoff

On Wed, 2009-05-13 at 05:21 -0700, Dave Brueck wrote:
> Has anyone in this group implemented any sort of login-as-another-user
> functionality with Django?

I implemented "sticky superuser logins" about a year ago (the last
time I worked with django until now), so I can attest it is a neat
trick, at least for demos. But I probably don't undertand it
anymore. And unfortunately, a brief look at the code shows some
changes since django-gis r7229, which I was using then.

I was working under the premise that the only special priviledge the
superuser retains after changing effective id to another user is the
ability to login as another user without a password. But nothing
prevents granting other special powers. Anyhow I too suspect someone
else has thought about this, no?

My approach was to hack a new SUPERUSER_SESSION_KEY and
SUPERUSER_BACKEND_SESSION_KEY into contrib/auth/__init__.py , and add
a new 'superuser' attribute in AuthenticationMiddleware. I guessed
this wasn't the most clever way but didn't want to confuse myself too
much, because I still had a logical consequences to deal with. If
you're interested in seeing some of this code, reply directly.

sdc



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



Re: Gravatar django apps

2009-05-14 Thread Erreon

If you don't want to implement your own solution you could use.
http://code.google.com/p/django-gravatar/

On May 14, 6:30 am, Joshua Partogi  wrote:
> Dear all
>
> Does anybody know a good django application for gravatar 
> (http://gravatar.com) ?
>
> Thank you very much for the redirection.
>
> :-)
>
> --
> If you can't believe in God the chances are your God is too small.
>
> Read my blog:http://joshuajava.wordpress.com/
> Follow us on twitter:http://twitter.com/scrum8

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



Re: django-admin.py not working...HELP!

2009-05-14 Thread Blake M. Sisco
Laszlo,
django/bin is in my pathnot sure why gmail decided to format that so
oddly but it's four lines up from the bottom of the quote in my last
post.:-)  I made sure that it was there just now as well even went as
far as rebooting the machine and still no joy...


Blake M. Sisco
LOR Manufacturing Co., Inc
Web Presence • Graphic Design
www.lormfg.com
(866) 644-8622
(888) 524-6292 FAX

The information transmitted by Blake Sisco herewith is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.  If you
received this in error, please contact the sender and delete the material
from any computer



On Thu, May 14, 2009 at 2:38 PM, Laszlo Antal  wrote:

>
>
> On Thu, May 14, 2009 at 11:02 AM, Blake M. Sisco wrote:
>
>> import django works fine.  i posted the results of >echo %pythonpath% and
>> echo %path% in my first message but here it is again:
>>
>> *>echo %pythonpath%
>>> C:\Python25;C:\Python25\Lib\
>>> **site-packages\django;C:\**django_projects;
>>>
>>> and my win path is :
>>> >echo %path%
>>> C:\Program Files\PHP\;C:\Perl\site\bin;C:
>>> **\Perl\bin;C:\WINDOWS
>>> \system32;C:\WINDOWS;C:\**WINDOWS\System32\Wbem;C:\**Program Files
>>> \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-
>>> **Static;C:
>>> \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
>>> \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
>>> \Autodesk\DWG TrueView\;C:\ctags57;C:\
>>> **Program Files\GnuWin32\bin;C:
>>> \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\
>>> **MinGW\bin
>>> \;C:\WINDOWS\system32\**WindowsPowerShell\v1.0;C:\**Python25\Lib\site-
>>> packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\
>>> **Program Files
>>> \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
>>> Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
>>> *
>>>
>>
>> It's to the point of pulling my hair out :-\...
>>
>> Regards,
>>
>>
>> Blake M. Sisco
>> LOR Manufacturing Co., Inc
>> Web Presence • Graphic Design
>> www.lormfg.com
>> (866) 644-8622
>> (888) 524-6292 FAX
>>
>> The information transmitted by Blake Sisco herewith is intended only for
>> the person or entity to which it is addressed and may contain confidential
>> and/or privileged material.  Any review, retransmission, dissemination or
>> other use of, or taking of any action in reliance upon, this information by
>> persons or entities other than the intended recipient is prohibited.  If you
>> received this in error, please contact the sender and delete the material
>> from any computer
>>
>>
>>
>>
>> On Thu, May 14, 2009 at 1:49 PM, Bruno Tikami wrote:
>>
>>>
>>>
>>> On Thu, May 14, 2009 at 2:41 PM, bsisco  wrote:
>>>

 I've uninstalled and reinstalled django and I still can't get this to
 work.  Any help would be greatly appreciated...

 On May 14, 8:46 am, bsisco  wrote:
 > Ok.  I updated to the latest trunk release this morning and now when I
 > run django-admin.py startapp  I get the following: (specs:
 > Python 2.5, Win XP Pro, Django trunk release 10781)
 >
 > >django-admin.py startapp rd
 >
 > Traceback (most recent call last):
 >   File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
 > line 2, in 
 > from django.core import management
 > ImportError: No module named django.core
 >
 > My python path is as follows:>echo %pythonpath% >> out.txt
 >
 > C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
 >
 > and my win path is :>echo %path% >> out.txt
 >
 > C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
 > \system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
 > \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
 > \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
 > \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
 > \Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
 > \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
 > \;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
 > packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
 > \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
 > Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap


>>> Hi bsisco,
>>>
>>> are you shure that django is in your PYTHONPATH ? Try this:
>>>
>>> open a python terminal
>>> try to import django.
>>>
>>> If it gives you an error, you should assure that your PYTHONPATH points
>>> to the right directory.

Re: django-admin.py not working...HELP!

2009-05-14 Thread Laszlo Antal
On Thu, May 14, 2009 at 11:02 AM, Blake M. Sisco wrote:

> import django works fine.  i posted the results of >echo %pythonpath% and
> echo %path% in my first message but here it is again:
>
> *>echo %pythonpath%
>> C:\Python25;C:\Python25\Lib\
>> **site-packages\django;C:\**django_projects;
>>
>> and my win path is :
>> >echo %path%
>> C:\Program Files\PHP\;C:\Perl\site\bin;C:
>> **\Perl\bin;C:\WINDOWS
>> \system32;C:\WINDOWS;C:\**WINDOWS\System32\Wbem;C:\**Program Files
>> \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-
>> **Static;C:
>> \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
>> \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
>> \Autodesk\DWG TrueView\;C:\ctags57;C:\
>> **Program Files\GnuWin32\bin;C:
>> \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\
>> **MinGW\bin
>> \;C:\WINDOWS\system32\**WindowsPowerShell\v1.0;C:\**Python25\Lib\site-
>> packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\
>> **Program Files
>> \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
>> Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
>> *
>>
>
> It's to the point of pulling my hair out :-\...
>
> Regards,
>
>
> Blake M. Sisco
> LOR Manufacturing Co., Inc
> Web Presence • Graphic Design
> www.lormfg.com
> (866) 644-8622
> (888) 524-6292 FAX
>
> The information transmitted by Blake Sisco herewith is intended only for
> the person or entity to which it is addressed and may contain confidential
> and/or privileged material.  Any review, retransmission, dissemination or
> other use of, or taking of any action in reliance upon, this information by
> persons or entities other than the intended recipient is prohibited.  If you
> received this in error, please contact the sender and delete the material
> from any computer
>
>
>
>
> On Thu, May 14, 2009 at 1:49 PM, Bruno Tikami wrote:
>
>>
>>
>> On Thu, May 14, 2009 at 2:41 PM, bsisco  wrote:
>>
>>>
>>> I've uninstalled and reinstalled django and I still can't get this to
>>> work.  Any help would be greatly appreciated...
>>>
>>> On May 14, 8:46 am, bsisco  wrote:
>>> > Ok.  I updated to the latest trunk release this morning and now when I
>>> > run django-admin.py startapp  I get the following: (specs:
>>> > Python 2.5, Win XP Pro, Django trunk release 10781)
>>> >
>>> > >django-admin.py startapp rd
>>> >
>>> > Traceback (most recent call last):
>>> >   File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
>>> > line 2, in 
>>> > from django.core import management
>>> > ImportError: No module named django.core
>>> >
>>> > My python path is as follows:>echo %pythonpath% >> out.txt
>>> >
>>> > C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
>>> >
>>> > and my win path is :>echo %path% >> out.txt
>>> >
>>> > C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
>>> > \system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
>>> > \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
>>> > \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
>>> > \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
>>> > \Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
>>> > \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
>>> > \;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
>>> > packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
>>> > \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
>>> > Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
>>>
>>>
>> Hi bsisco,
>>
>> are you shure that django is in your PYTHONPATH ? Try this:
>>
>> open a python terminal
>> try to import django.
>>
>> If it gives you an error, you should assure that your PYTHONPATH points to
>> the right directory.
>>
>> Let us know what happened.
>>
>> Tkm
>>
>>
>>
>>
> Hi,
It does not look like django/bin is in your path.
Try adding it and make sure you close down cmd and open a new one.
I had to do that on my install on XP to work.

lzantal
-
Laszlo Antal

>
> >
>

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



Re: Signals giving: global name 'MyModel' is not defined

2009-05-14 Thread Colin Bean

On Thu, May 14, 2009 at 6:48 AM, phoebebright  wrote:
>
> Have been at this now for some hours and still can't see the wood for
> the trees.  Failed to get two signals working - one called on pre_save
> to keep an audit trail of one field on a model (didn't implemenet the
> Audit.py version in the wiki as more complex than I needed).  The
> other to create some default records in a related table.  Both are
> failing with the same error and I suspect I am going to kick myself
> when someone points out the obvious, but here goes.
>
> Model.py
>
> (simplified)
>
> class Version(models.Model):
>
>        version_no = models.CharField(_('ver'), max_length=10, unique=True)
>        name = models.CharField(_('name'), max_length=50, unique=True)
>
> class VersionDocs(models.Model):
>
>        version = models.ForeignKey('Version')
>        doc_content = models.TextField(_('content'))
>
>
> class VersionDocsVer(models.Model):
>
>        doc = models.ForeignKey('VersionDocs')
>        doc_content = models.TextField(_('content'))
>
>
> pre_save.connect(keep_version, sender=VersionDocs)
> post_save.connect(default_docs, sender=Version)
>
>
>
> signals.py
>
> (simplified)
>
> from devcycle.models import *
>
> def default_docs(instance, **kwards):
>
>        try:
>                doc = VersionDocs.objects.filter(version=instance.id)
>
>        except:
>
>            
>
> def keep_version(instance, **kwargs):
>
>        print 'version instance =',instance.id
>        original = VersionDocs.objects.get(id=instance.id)
>
>        
>
>
>
> Using Django version 1.1 beta 1,
>
>
>
>
>
> >
>


What error were you getting?

Those signals both take a "sender" argument as the first instance, so
you might try something like:

def keep_version(sender, instance, **kwargs):


"Sender" will be class of the model that's being saved.

Colin

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



Re: django-admin.py not working...HELP!

2009-05-14 Thread Blake M. Sisco
import django works fine.  i posted the results of >echo %pythonpath% and
echo %path% in my first message but here it is again:

*>echo %pythonpath%
> C:\Python25;C:\Python25\Lib\**site-packages\django;C:\**django_projects;
>
> and my win path is :
> >echo %path%
> C:\Program Files\PHP\;C:\Perl\site\bin;C:**\Perl\bin;C:\WINDOWS
> \system32;C:\WINDOWS;C:\**WINDOWS\System32\Wbem;C:\**Program Files
> \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-**Static;C:
> \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
> \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
> \Autodesk\DWG TrueView\;C:\ctags57;C:\**Program Files\GnuWin32\bin;C:
> \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\**MinGW\bin
> \;C:\WINDOWS\system32\**WindowsPowerShell\v1.0;C:\**Python25\Lib\site-
> packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\**Program Files
> \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
> Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
> *
>

It's to the point of pulling my hair out :-\...

Regards,


Blake M. Sisco
LOR Manufacturing Co., Inc
Web Presence • Graphic Design
www.lormfg.com
(866) 644-8622
(888) 524-6292 FAX

The information transmitted by Blake Sisco herewith is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.  If you
received this in error, please contact the sender and delete the material
from any computer



On Thu, May 14, 2009 at 1:49 PM, Bruno Tikami  wrote:

>
>
> On Thu, May 14, 2009 at 2:41 PM, bsisco  wrote:
>
>>
>> I've uninstalled and reinstalled django and I still can't get this to
>> work.  Any help would be greatly appreciated...
>>
>> On May 14, 8:46 am, bsisco  wrote:
>> > Ok.  I updated to the latest trunk release this morning and now when I
>> > run django-admin.py startapp  I get the following: (specs:
>> > Python 2.5, Win XP Pro, Django trunk release 10781)
>> >
>> > >django-admin.py startapp rd
>> >
>> > Traceback (most recent call last):
>> >   File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
>> > line 2, in 
>> > from django.core import management
>> > ImportError: No module named django.core
>> >
>> > My python path is as follows:>echo %pythonpath% >> out.txt
>> >
>> > C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
>> >
>> > and my win path is :>echo %path% >> out.txt
>> >
>> > C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
>> > \system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
>> > \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
>> > \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
>> > \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
>> > \Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
>> > \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
>> > \;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
>> > packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
>> > \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
>> > Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
>>
>>
> Hi bsisco,
>
> are you shure that django is in your PYTHONPATH ? Try this:
>
> open a python terminal
> try to import django.
>
> If it gives you an error, you should assure that your PYTHONPATH points to
> the right directory.
>
> Let us know what happened.
>
> Tkm
>
>
> >
>

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



Re: django-admin.py not working...HELP!

2009-05-14 Thread bsisco

I've uninstalled and reinstalled django and I still can't get this to
work.  Any help would be greatly appreciated...

On May 14, 8:46 am, bsisco  wrote:
> Ok.  I updated to the latest trunk release this morning and now when I
> run django-admin.py startapp  I get the following: (specs:
> Python 2.5, Win XP Pro, Django trunk release 10781)
>
> >django-admin.py startapp rd
>
> Traceback (most recent call last):
>   File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
> line 2, in 
>     from django.core import management
> ImportError: No module named django.core
>
> My python path is as follows:>echo %pythonpath% >> out.txt
>
> C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
>
> and my win path is :>echo %path% >> out.txt
>
> C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
> \system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
> \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
> \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
> \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
> \Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
> \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
> \;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
> packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
> \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
> Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-admin.py not working...HELP!

2009-05-14 Thread Bruno Tikami
On Thu, May 14, 2009 at 2:41 PM, bsisco  wrote:

>
> I've uninstalled and reinstalled django and I still can't get this to
> work.  Any help would be greatly appreciated...
>
> On May 14, 8:46 am, bsisco  wrote:
> > Ok.  I updated to the latest trunk release this morning and now when I
> > run django-admin.py startapp  I get the following: (specs:
> > Python 2.5, Win XP Pro, Django trunk release 10781)
> >
> > >django-admin.py startapp rd
> >
> > Traceback (most recent call last):
> >   File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
> > line 2, in 
> > from django.core import management
> > ImportError: No module named django.core
> >
> > My python path is as follows:>echo %pythonpath% >> out.txt
> >
> > C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;
> >
> > and my win path is :>echo %path% >> out.txt
> >
> > C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
> > \system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
> > \SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
> > \Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
> > \;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
> > \Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
> > \Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
> > \;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
> > packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
> > \SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
> > Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
> >
>
Hi bsisco,

are you shure that django is in your PYTHONPATH ? Try this:

open a python terminal
try to import django.

If it gives you an error, you should assure that your PYTHONPATH points to
the right directory.

Let us know what happened.

Tkm

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



Re: creating objects in views

2009-05-14 Thread Daniel Roseman

On May 14, 5:59 pm, Oleg Oltar  wrote:
> Well, the problem with built in comments framework is that I need few more
> fields in comments.
>
> What I created is:
>
> MODEL:
>
> class Comment(models.Model):
>     name = models.CharField(max_length = 30)
>     body = models.CharField(max_length = 2000)
>     article = models.ForeignKey(Article)
>
>     def __unicode__(self):
>         return u"%s" %(self.name)
>
> FORM:
>
> class CommentForm(forms.Form):
>     '''
>     The Register form is created to deal with registration process
>     check if data is clean and passwords match each other
>     '''
>     username = forms.CharField(label='Name', max_length=30)
>     body = forms.CharField(required = True,
>                             label = 'Comment Body',
>                             widget=forms.Textarea)
>
>     def clean_body(self):
>         if 'body' in self.cleaned_data:
>             body = self.cleaned_data['body']
>             if not re.search(r'^\w+$', username):
>                 raise forms.ValidationError('Error: body can contains \
> only alphanumeric characters')
>
> VIEW:
>
> def article_page(request, page_name):
>     article = get_object_or_404(models.Article, url = page_name)
>     articles_list =
> models.Article.objects.exclude(is_published__exact="0").order_by("-pub_date ")
>
>     if request.method == 'POST':
>         form = CommentForm(request.POST)
>         # Creating a comment
>         if form.is_valid():
>             comment = Comment(
>                 name = from.cleaned_data['name'],
>                 body = form.cleaned_data['body'],
>                 article = 
>                 )
>
>     return render_to_response('article.html',
>                               {'section': article.title,
>                                'article' : article,
>                                'articles' : articles_list}
>                               )
>
> Not sure how to fill the article field :(
>
> Thanks in advance,
> Oleg

But you have the article already, from when you did get_object_or_404.
Why can't you just use that?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: creating objects in views

2009-05-14 Thread Oleg Oltar
Well, the problem with built in comments framework is that I need few more
fields in comments.

What I created is:

MODEL:

class Comment(models.Model):
name = models.CharField(max_length = 30)
body = models.CharField(max_length = 2000)
article = models.ForeignKey(Article)

def __unicode__(self):
return u"%s" %(self.name)


FORM:

class CommentForm(forms.Form):
'''
The Register form is created to deal with registration process
check if data is clean and passwords match each other
'''
username = forms.CharField(label='Name', max_length=30)
body = forms.CharField(required = True,
label = 'Comment Body',
widget=forms.Textarea)

def clean_body(self):
if 'body' in self.cleaned_data:
body = self.cleaned_data['body']
if not re.search(r'^\w+$', username):
raise forms.ValidationError('Error: body can contains \
only alphanumeric characters')


VIEW:


def article_page(request, page_name):
article = get_object_or_404(models.Article, url = page_name)
articles_list =
models.Article.objects.exclude(is_published__exact="0").order_by("-pub_date")

if request.method == 'POST':
form = CommentForm(request.POST)
# Creating a comment
if form.is_valid():
comment = Comment(
name = from.cleaned_data['name'],
body = form.cleaned_data['body'],
article = 
)

return render_to_response('article.html',
  {'section': article.title,
   'article' : article,
   'articles' : articles_list}
  )


Not sure how to fill the article field :(

Thanks in advance,
Oleg

On Tue, May 12, 2009 at 1:01 PM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
> On May 12, 10:51 am, Oleg Oltar  wrote:
> > Hi!
> > I am running small blog-styled information site. Which contains articles
> > added via admin application
> > Now I am trying to add possibility to add comments, so I defined a
> comment
> > Model (which contains Foreign Key to article object, and few text
> fields),
> > also defined forms.
> >
> > Can you please explain how should I create a comment object in view?
> (After
> > processing data from form). I don't understand where can I get, the
> article
> > name (id, guid or something) to link article and comment
> >
> > Thanks in advance,
> > Oleg
>
> Firstly, have you investigated the built-in comment app? It's quite
> full-featured, and may do everything you want.
>
> Assuming you've decided that your own model is the way to go, the
> answer to your question will depend on the way you've defined your
> form and view. Presumably the comment form is displayed at the bottom
> of an article page, so you'll already have the ID of the article - so
> I don't really understand what your issue is. Perhaps you could post
> the code you have so far?
> --
> DR.
> >
>

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



Re: New Project - want advice

2009-05-14 Thread Lee Hinde

On Wed, May 13, 2009 at 6:30 PM, Technicalbard  wrote:
>
> Hi,
>
> I'm planning a new project, and I want the following feature set
> (eventually).  It will of course be rolled out in parts as apps are
> completed.  The purpose of this is to manage knowledge in various
> domains.
>
>  - wiki-type knowledge-base with full audit trail
>  - threaded forum
>  - embedding pdf / svg / png images in wiki/forum
>  - attaching and safely storing native format files associate with
> wiki/forum items.
>  - task manager to identify and assign issues that need resolving in
> the knowledgebase.
>  - need to have ACL-type user access, editing and moderating levels
> and granular permissions on wiki articles / forum messages that are
> assignable by a moderator from a web-interface.
>  - email alerts to users
>  - ideally, login authentication will use existing Active Directory.
>
> So my request for advice is:
> What django-apps are available that could use to provide some of this
> functionality, or at least use as a starting point to develop the
> functionality?  Can anyone point me to demos/examples of similar
> functionality?
>

http://pinaxproject.com/

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



how to import variable from view to form

2009-05-14 Thread Yang

Hello,

I'd like to import the variables from view to form, but after trying
several ways, I failed.

For example: user01 inputs his username/password(apache
authentication) to login, then based on this username, function,
get_list_from_ldap, will get a relative list from LDAP. Different
username will have different lists. Then I'd variable_from_view
can be used as choices of ChoiceField.

Anyone knows how I can do it?

Any comments will be welcome

In from.py

from django import forms

class ContactForm(forms.Form):
email = forms.ChoiceField(choices=variable_from_views)


views.py
from django.shortcuts import render_to_response
from mysite.contact.forms import ContactForm

def contact(request):
variable_from_views=get_list_from_ldap(user_input_variable)
form = ContactForm()
return render_to_response('contact_form.html', {'form': form})


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



Re: login decorator losing POST data

2009-05-14 Thread aa56280

Tim,

Thanks for the fantastic insight into the browser issues with 307
redirects. I'll explore this a bit further and see which route I want
to take.

Given that the form in question is simply a button that says "Join
network," I may be inclined to just let the user login, come back to
the page and submit the form again. An annoying experience (IMHO), but
one that eliminates all this hassle.

Thanks again.

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



Re: login decorator losing POST data

2009-05-14 Thread aa56280

On May 14, 8:29 am, TiNo  wrote:

> Isn't it possible to force the user to login before filling out the form?
> That eliminates all the issues with redirecting the POST data.

How ironic. I clicked on the Reply link and Google told me I need to
sign in in order to reply. I was then brought back and had to click
Reply again.

So to answer your question TiNo, yes I could but the page I'm building
is very similar to this Google Groups page. It can be viewed by
anyone, but in order to perform certain actions, one needs to be
logged in.

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



Re: Production install 'admin' failing with 500 internal server error

2009-05-14 Thread Vincent

Ccorrection: The names and paths in WSGIScriptAlias and Directory were
inconsistent. The sample config file should read as follows:


httpd/conf.d/python.conf


LoadModule wsgi_module modules/mod_wsgi.so

WSGIDaemonProcess myapp
WSGIProcessGroup %{GLOBAL}
WSGIReloadMechanism Process

Alias /media/ /usr/local/www/media/


Order allow,deny
Allow from all


Alias /site_media/ /usr/local/www/site_media/


Order allow,deny
Allow from all


WSGIScriptAlias /myapp /usr/local/django-apps/myapp/apache/django.wsgi


Order allow,deny
Allow from all





On May 14, 11:11 am, Vincent  wrote:

> Hi Dan,
>
> Thanks for the tips. I think I've figured out what went wrong.
>
> First up: no, I am not using a virtualenv. I was able to serve the
> site using "./manage.py runserver" albeit a bit slow (due to load
> issues I believe). So the problem ultimately was my mod_wsgi setup.
>
> The fix:
>
> For starters, my httpd.conf file was poorly configured. I had defined
> the wrong user and group under the "WSGIDaemonProcess" directive.
> Ultimately, what I should've done was used the defaults instead of
> defining things. The documentation on the mod_wsgi wiki lead me to
> think otherwise.
>
> So my current config is as follows:
>
> 
> httpd/conf.d/python.conf
> 
>
> LoadModule wsgi_module modules/mod_wsgi.so
>
> WSGIDaemonProcess myapp
> WSGIProcessGroup %{GLOBAL}
> WSGIReloadMechanism Process
>
> Alias /media/ /usr/local/www/media/
>
> 
>     Order allow,deny
>     Allow from all
> 
>
> Alias /site_media/ /usr/local/www/site_media/
>
> 
>     Order allow,deny
>     Allow from all
> 
>
> WSGIScriptAlias /snufkin /usr/local/django-apps/snufkin/apache/
> django.wsgi
>
> 
>     Order allow,deny
>     Allow from all
> 
>
> 
>
> My second issue was related to the first, I had the wrong user & group
> for my django application. Chown-ing things to apache:apache did the
> trick. I realize that all of these things are most likely trivial
> issues and silly mistakes but my hope is that this post here may act
> as an example should someone else make the same mistakes as I did.
>
> ~Vincent
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Production install 'admin' failing with 500 internal server error

2009-05-14 Thread Vincent

Hi Dan,

Thanks for the tips. I think I've figured out what went wrong.

First up: no, I am not using a virtualenv. I was able to serve the
site using "./manage.py runserver" albeit a bit slow (due to load
issues I believe). So the problem ultimately was my mod_wsgi setup.

The fix:

For starters, my httpd.conf file was poorly configured. I had defined
the wrong user and group under the "WSGIDaemonProcess" directive.
Ultimately, what I should've done was used the defaults instead of
defining things. The documentation on the mod_wsgi wiki lead me to
think otherwise.

So my current config is as follows:


httpd/conf.d/python.conf


LoadModule wsgi_module modules/mod_wsgi.so

WSGIDaemonProcess myapp
WSGIProcessGroup %{GLOBAL}
WSGIReloadMechanism Process

Alias /media/ /usr/local/www/media/


Order allow,deny
Allow from all


Alias /site_media/ /usr/local/www/site_media/


Order allow,deny
Allow from all


WSGIScriptAlias /snufkin /usr/local/django-apps/snufkin/apache/
django.wsgi


Order allow,deny
Allow from all




My second issue was related to the first, I had the wrong user & group
for my django application. Chown-ing things to apache:apache did the
trick. I realize that all of these things are most likely trivial
issues and silly mistakes but my hope is that this post here may act
as an example should someone else make the same mistakes as I did.

~Vincent


On May 13, 6:13 pm, Daniel Hilton  wrote:

> Are you using a virtualenv?
>
> Can you serve the site using ./manage.py runserver example.com:8080 ?
>
> If you can serve it using the in-built server then it's likely a
> problem with your mod_wsgi setup.
>
> If you can't serve it using the in-built server try comparing the
> versions of packages installed on the server verses your local
> machine.
>
> HTH
> Dan
> --
> Dan Hilton
> 
> DanHilton.co.uk
> 
>
>
> 2009/5/13 Vincent :
>
>> Additional information:
>
>> I am running Django 1.0.2 and the web host I am attempting to do this
>> all on is Media Temple, in one of their Dedicated Virtual (DV)
>> accounts. I followed the general guidelines for mod_wsgi setup from
>> here:
>
>>http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
>> None of my media, templates or app code reside in the standard MT
>> httpd path:
>
>> /var/www/vhosts/example.com/httpdocs
>
>> I am using /usr/local/django-apps along with the suggested mod_wsgi
>> script path of:
>
>> /usr/local/django-apps/myapp/apache/django.wsgi
>
>> My templates and media directories appear to load correctly, in
>> particular, my 404 template loads just fine.
>
>> There's no shortage of configurations and settings to list but I am
>> not sure what else to post.
>
>
>> On May 13, 4:19 pm, Vincent  wrote:
>
>>> Hi all:
>
>>> I have loaded my application on our production server but I am unable
>>> to load the supplied admin interface. What's really odd is that
>>> everything else seems to work fine. Databrowse works along with the
>>> django 'configuration success' page. When using databrowse, I can view
>>> all of my database just as I would on the dev server. My database is
>>> currently a SQLite3 db and I am using the latest release version of
>>> mod_wsgi all running with Python 2.4.3. When I get the "500 Internal
>>> Server Error" page, it is the one generated by Apache and not django.
>>> I also do not get any errors in logs/httpd/error_log. Everything runs
>>> swimmingly when run locally from the built-in development server.
>
>>> If any other configuration info is needed, please ask. Any help would
>>> be greatly appreciated. I've spent so much time working on my app,
>>> it's no fun having things break at this stage.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using ajax in django

2009-05-14 Thread zayatzz

Im also a django beginner, but i have bit more advanced knowledge
about js/jquery

Here's what ive learned so far: All js events happen in browser and
are all related/attached to some DOM elements.

Basic (model)form flow works like that:
You create a model
You create a modelform (in apps forms.py for example)
You pass it to a template in a view
You load it in template with {{ from }}

Check django forms documentation for more specific stuff.

If you want to run some events related to form fields or when
submitting a form, then you must know how the form will look like in
markup and you can do it on template level writing stuff directly into
template or create js file that is started on jquery domready event.
That js file will catch formfield events.

You can also create formwidgets. Not sure how to use/create them
beause so far, ive only used tinyMCE pluggable and havent created any
of my own.

Basically i do not think django is an issue here. Just create html
file with form and then create jquery some jquery events. Adding
django into the mix changes not a thing especially if you want to use
onchange events.

Alan
On May 14, 9:34 am, newbie  wrote:
> hi,
>
>           I'm new to django and dont know much of javascript either. I
> would like to start working on them. Could someone help me write a
> simple form which can provide any functionality using ajax, preferably
> using jquery libraries. It would be great if any event other  than the
> submit event is recognised using ajax, something which connects to the
> database would be preferable.
>
> I've used ajax in web2py. But here in django I'm not able to
> understand the flow of a form. Here in django, forms are created by
> declaring a class in a seperate file. In web2py, it was clear and
> obvious of how to recognize a input or click or onchange event for a
> particular input field. But here I dont understand where to catch the
> event. Do i need to write the code in template file or in view file.
> If i write it in template file(which i'm thinking is the way), how to
> send the input entered(before the user submits the form) to the view
> file.
>
>       All i want to do is, to capture a change/input event on a form
> before the user submits and dynamically create an extra field in the
> form/change the options of a field already present in the form, based
> on the input
>
>           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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django.contrib.auth tests fail

2009-05-14 Thread Kegan Gan

This could be related to ticket #10521 
http://code.djangoproject.com/ticket/10521,
which has been fixed. It's currently in the trunk already, since
changeset http://code.djangoproject.com/changeset/10674 .

~KEGan

On May 14, 12:36 am, Sean Brant  wrote:
> I am also having a issue with contrib.auth test errors. They errors
> seem to be caused by url tags in my base.html template. When I comment
> out all of those tags the tests pass. The url tags seem to work when i
> look at the site im my browser.
>
> ==
> ERROR: test_confirm_complete
> (django.contrib.auth.tests.views.PasswordResetTest)
> --
> Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/django/contrib/auth/tests/
> views.py", line 81, in test_confirm_complete
>     response = self.client.get(path)
>   File "/usr/lib/python2.5/site-packages/django/test/client.py", line
> 278, in get
>     return self.request(**r)
>   File "/usr/lib/python2.5/site-packages/django/test/client.py", line
> 222, in request
>     response = self.handler(environ)
>   File "/usr/lib/python2.5/site-packages/django/test/client.py", line
> 66, in __call__
>     response = self.get_response(request)
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 128, in get_response
>     return self.handle_uncaught_exception(request, resolver, exc_info)
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 160, in handle_uncaught_exception
>     return callback(request, **param_dict)
>   File "/usr/lib/python2.5/site-packages/django/views/defaults.py",
> line 24, in server_error
>     return http.HttpResponseServerError(t.render(Context({})))
>   File "/usr/lib/python2.5/site-packages/django/test/utils.py", line
> 15, in instrumented_test_render
>     return self.nodelist.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
> line 768, in render
>     bits.append(self.render_node(node, context))
>   File "/usr/lib/python2.5/site-packages/django/template/debug.py",
> line 71, in render_node
>     result = node.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/
> loader_tags.py", line 97, in render
>     return compiled_parent.render(context)
>   File "/usr/lib/python2.5/site-packages/django/test/utils.py", line
> 15, in instrumented_test_render
>     return self.nodelist.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
> line 768, in render
>     bits.append(self.render_node(node, context))
>   File "/usr/lib/python2.5/site-packages/django/template/debug.py",
> line 71, in render_node
>     result = node.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/
> loader_tags.py", line 24, in render
>     result = self.nodelist.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
> line 768, in render
>     bits.append(self.render_node(node, context))
>   File "/usr/lib/python2.5/site-packages/django/template/debug.py",
> line 81, in render_node
>     raise wrapped
> TemplateSyntaxError: Caught an exception while rendering: Reverse for
> 'crowdSPRING.contact_us' with arguments '()' and keyword arguments
> '{}' not found.
>
> Original Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/django/template/debug.py",
> line 71, in render_node
>     result = node.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/
> defaulttags.py", line 387, in render
>     args=args, kwargs=kwargs)
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 262, in reverse
>     *args, **kwargs)))
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 251, in reverse
>     "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for 'MySite.contact_us' with arguments '()'
> and keyword arguments '{}' not found.
>
> On May 13, 10:55 am, Michael  wrote:
>
>
>
> > On Wed, May 13, 2009 at 9:42 AM, Luc Saffre  wrote:
>
> > > Hello,
>
> > > when I run ``manage.py test`` to test my Django applications, then I
> > > also get a lot of test failures for django.contrib.auth.
>
> > > Is that normal? What can I do to get rid of these errors?
>
> > Auth leans on some templates in django.contrib.admin for the tests. This is
> > known, though not ideal. If you added django.contrib.admin to your installed
> > apps, the failures should go away.
>
> > I hope that helps,
> > Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 

Re: Return multiple counts from the same table in one query?

2009-05-14 Thread Up2L8

Yeah, I've used count() before but I didn't see how to do 2 counts in
the same query.

I thought maybe the new annotate or aggregate stuff might help, but it
wasn't obvious to me.

Thanks,
Eric

On May 13, 8:30 pm, raman  wrote:
> This is a "count()" method for querysets:
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#count
>
> However, for this, it may be easiest to use raw sql within Django:
>
> http://docs.djangoproject.com/en/dev/topics/db/sql/
>
> -Raman
>
> On May 13, 6:43 pm, Up2L8  wrote:
>
> > Is there a way to do something like this in django?
>
> > SELEC COUNT(t1.id), COUNT(t2.id)
> > FROM Test_testrun t1
> > LEFT JOIN Test_testrun t2 ON t2.id = t1.id AND t2.passed=True
>
> > Sorry for my newbness, I've been searching for awhile now with no
> > luck.
>
> > Eric
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Query by date + offset

2009-05-14 Thread TiNo
On Wed, May 13, 2009 at 5:00 PM, eric.frederich wrote:

>
> I have a model called Offering which has a start date and a duration
> in days.
> I want to do a query and get instances where the end date (not
> modeled) is in the past.
> I know that I can add a non-editable field end-date that is computed
> in the save method, but this seems denormalized.
> I'm curious to see if this is possible using only a start date,
> duration, and queries.


You might be able to do so with the field reference function F():
http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model

Maybe this works (untested):
Offering.objects.filter(date__lt=datetime.today() + F('duration'))

TiNo


> >
>

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



Signals giving: global name 'MyModel' is not defined

2009-05-14 Thread phoebebright

Have been at this now for some hours and still can't see the wood for
the trees.  Failed to get two signals working - one called on pre_save
to keep an audit trail of one field on a model (didn't implemenet the
Audit.py version in the wiki as more complex than I needed).  The
other to create some default records in a related table.  Both are
failing with the same error and I suspect I am going to kick myself
when someone points out the obvious, but here goes.

Model.py

(simplified)

class Version(models.Model):

version_no = models.CharField(_('ver'), max_length=10, unique=True)
name = models.CharField(_('name'), max_length=50, unique=True)

class VersionDocs(models.Model):

version = models.ForeignKey('Version')
doc_content = models.TextField(_('content'))


class VersionDocsVer(models.Model):

doc = models.ForeignKey('VersionDocs')
doc_content = models.TextField(_('content'))


pre_save.connect(keep_version, sender=VersionDocs)
post_save.connect(default_docs, sender=Version)



signals.py

(simplified)

from devcycle.models import *

def default_docs(instance, **kwards):

try:
doc = VersionDocs.objects.filter(version=instance.id)

except:



def keep_version(instance, **kwargs):

print 'version instance =',instance.id
original = VersionDocs.objects.get(id=instance.id)





Using Django version 1.1 beta 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: uneditable fields

2009-05-14 Thread Rama Vadakattu

So you need dynamic form as below


Class MyForm(forms.ModelForm):
  fields
   ...

 def __init__(self, user,*args , **kwargs):
   super(MyForm,self).__init__(*args,**kwargs)
   if user is not  superuser :
self.fields['title'].widget.attrs['readonly']
= True


i hope the code will work.

On May 14, 5:56 pm, duikboot  wrote:
> Hi, is there a way to have a field editable by the superuser but not
> by another logged in user, in the admin area?
> The rest of the model should be editable by the logged in user.
>
> example:
>
> class Test(models.Model):
>     title = models.CharField(max_length=150)
>     page = models.TextField()
>
> So page should be editable for the logged in user, but title should
> only be editable by the superuser.
>
> Any ideas? Thanks,
>
> Duikboot
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



python manage.py dbshell throws error

2009-05-14 Thread bvemu

Hi  All

I am executing the command  "python manage.py dbshell" and it throws
the following error
"Profiling timer expired"


I have an alias in my .bashrc  of
alias mysql='mysql -u subramanyam -pxxx'
Tried unaliasing mysql but didnt work whereas it works fine from
command line

Any pointers on this would be helpful

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



Re: login decorator losing POST data

2009-05-14 Thread TiNo
On Wed, May 13, 2009 at 11:56 PM, aa56280  wrote:

>
> Hello there,
>
> I have a form. Once it's submitted (method=POST) the view handling the
> submit uses the @login_required decorator.\


Isn't it possible to force the user to login before filling out the form?
That eliminates all the issues with redirecting the POST data.

TiNo

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



swingtime keyerror

2009-05-14 Thread gl330k

Hey all,

I'm using an app called swingtime that I installed for event
management.

In the admin interface I'm trying to add events. It works great on my
local development setup but when I've uploaded to the web server I'm
unable to save events through the admin. It comes up with

KeyError at /admin/swingtime/event/add/

'event'

Request Method: GET
Request URL:
http://nvymca-dev.5qcommunications.com/admin/swingtime/event/add/
Exception Type: KeyError
Exception Value:'event'

Now the strange thing is that we are able to add events through a
clunky front-end interface on the web server. But we can't add events
when trying to do it via the backend interface.

Thoughts?

Do I need to post further notes for debugging?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Gravatar django apps

2009-05-14 Thread Rama Vadakattu

Integrating with Gravatar is very easy

1) Get MD5 hash of user's email id
 import hashlib

   def getMD5(self):
  m = hashlib.md5()
  m.update(self.user.email)
 return m.hexdigest()

2) and prepare image url as below
 http://www.gravatar.com/avatar/{{user-email-MD5-
hash}}.jpg" alt="" />


that's it the image shows the gravatar of respective user.


--rama




On May 14, 4:30 pm, Joshua Partogi  wrote:
> Dear all
>
> Does anybody know a good django application for gravatar 
> (http://gravatar.com) ?
>
> Thank you very much for the redirection.
>
> :-)
>
> --
> If you can't believe in God the chances are your God is too small.
>
> Read my blog:http://joshuajava.wordpress.com/
> Follow us on twitter:http://twitter.com/scrum8
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Troubles after switching to WSGI: lost apache processes, multiple view func calls per HTTP request

2009-05-14 Thread Valery

Hi Graham,

many thanks for your quick and very helpful reply!

> You need to ascertain whether they were Apache parent process, Apache
> server child worker processes, or mod_wsgi daemon mode processes.

OK i'd check next time, i've seen your hint on how to do it, thanks!


> > a. both issues appeared after I've switsched to WSGI dipatching model.
>
> Did you disable mod_python out of Apache when you switched. Loading
> both at same time is not recommended as can cause some problems.

mod_python is indeed *not* disabled because of other project running
on
the same server in mod_python. OK, great, I see, am going to change
this.


> > b. I use wsgi-based dispatching for apache prefork (unfortunatelly I am
> > restricted for prefork currently) as descreibed here right in the beginning
> > of the document:http://pinaxproject.com/docs/dev/deployment.html
>
> Be aware of the dangers of prefork. Read:
>
>  http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usa...

Oh, interesting, I keep on reading it to the end after end of my
answer.


> Why are you restricted to using prefork? Also, that documentation says
> to use daemon mode which makes the MPM irrelevant, because if you
> configure it properly the application runs in separate process like in
> fastcgi.

I am restricted to prefork because of a small PHP-contact form
currently used in other application running on the same server.
If there would be a slim way to kick it away, it would be nice.
However I see it as an overkill to create a Django project just to
implement a short contact form within a static web-site...


> What the documentation doesn't explain is to use the option:
> [...]
> http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDae...

great, it helps a lot, thanks!


> > c. Also, to restart my app I sometime use "touch my-dispatcher.wsgi" as it
> > was mentioned somewhere in django docs.
>
> Perhaps also read mod_wsgi documentation on source code reloading to
> find out what that is doing:
>
>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

hm, I am curious what I am doing wrong, gotta read it.


> You need to identify what role the process was doing. The display-name
> option can help with that. Also set LogLevel to at least 'info' as
> explained in:
>  http://code.google.com/p/modwsgi/wiki/DebuggingTechniques
> Then you need to work out what the process is perhaps hanging on.

OK, I'll do.

By the way, regarding the 30 func calls per HTTP request you'd mean
it is a bare conflict WSGI vs mod_python?

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



uneditable fields

2009-05-14 Thread duikboot

Hi, is there a way to have a field editable by the superuser but not
by another logged in user, in the admin area?
The rest of the model should be editable by the logged in user.

example:

class Test(models.Model):
title = models.CharField(max_length=150)
page = models.TextField()

So page should be editable for the logged in user, but title should
only be editable by the superuser.

Any ideas? Thanks,

Duikboot

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



Re: Include Forms in a Template

2009-05-14 Thread Rama Vadakattu


BY passing instance of form as context to the template and saying
{{form.as_table}}  in the template.

On May 14, 5:22 pm, aruns  wrote:
> Hi,
>
> i have included many static pages in my template using
>
> {% include staticpage.html %}
>
> i have started using views and forms, so i am tring to include a form
> in my template. I am not sure how to do this.
>
> Could any one please help on this..
>
> Thanks and Regards,
> A
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django-admin.py not working...HELP!

2009-05-14 Thread bsisco

Ok.  I updated to the latest trunk release this morning and now when I
run django-admin.py startapp  I get the following: (specs:
Python 2.5, Win XP Pro, Django trunk release 10781)

>django-admin.py startapp rd
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\django\bin\django-admin.py",
line 2, in 
from django.core import management
ImportError: No module named django.core

My python path is as follows:
>echo %pythonpath% >> out.txt
C:\Python25;C:\Python25\Lib\site-packages\django;C:\django_projects;

and my win path is :
>echo %path% >> out.txt
C:\Program Files\PHP\;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS
\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files
\SecureCRT\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:
\Python25;C:\Program Files\e\cmd;C:\Program Files\QuickTime\QTSystem
\;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files
\Autodesk\DWG TrueView\;C:\ctags57;C:\Program Files\GnuWin32\bin;C:
\Program Files\MySQL\MySQL Server 5.1\bin;C:\cygwin\bin\;C:\MinGW\bin
\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Python25\Lib\site-
packages\django\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files
\SecureCRT;C:\Documents and Settings\bsisco\Local Settings\Application
Data\VanDyke Software\SecureFX\;C:\Program Files\Nmap
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Seperate thread - best practices

2009-05-14 Thread Filip Gruszczyński

Ok, thanks. I'll give it a try :-)

W dniu 14 maja 2009 11:40 użytkownik Daniel Roseman
 napisał:
>
> On May 14, 10:03 am, Filip Gruszczyński  wrote:
>> > Best practice here would be to stop trying to use a webserver to do
>> > things it wasn't intended for.
>>
>> > If you need a separate process/thread to run regularly and perform
>> > some background processing, then put that code in a standalone script
>> > and use a crontab entry to invoke the script.
>>
>> Even if it's an integral part of an app? And I would like to be able
>> to access it easily from django testing framework, so it can be
>> automatically tested every time I need it.
>
> Neither of those things are contradicted by Russ's advice. It would
> still be Django code, and you could still keep it within the app and
> test it with the normal testing framework, but it would be a separate
> script run by cron.
> --
> DR.
> >
>



-- 
Filip Gruszczyński

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



Re: Dynamic queryset when instantiating a form with a ModelChoiceField within a formset

2009-05-14 Thread SteveB

Hi,
   well I have a solution, but it's not ideal.
It involves extending the BaseFormSet class, and passing an extra
parameter into the subclass's __init__ method, and saving this value
as an attribute to self. The subclass also had to override the
_construct_form method, copying all of the code of the BaseFormSet's
_construct_form method
(which is not good from a maintenance point of view, and definitely
violates the Do not Repeat Yourself (DRY) principle), and when it
instantiates the form, it passes in this extra parameter for the form
to correctly initialize the queryset for the ModelChoiceField.

   How could this be improved? I think a better solution would involve
the Django development team considering extending the BaseFormSet
class to handle this situation. It could include an optional parameter
(e.g. 'formConfig') in the BaseFormSet __init__ method, which would be
passed as a parameter to each form's instantiation. The Django
forms.BaseForm.__init__ would have to accept (though would ignore)
this argument.

Regards,
Steve

On May 14, 12:45 pm, SteveB  wrote:
> Hi,
> I have a form which has a ModelChoiceField, whose queryset has to be
> set dynamically (when the form is instantiated).
> I have read an earlier posting on how to do 
> this:http://groups.google.com/group/django-users/browse_thread/thread/847e...
>
> My problem, is that I don't directly instantiate this form. The form
> is used in a formset,
> so the actual instantiation is done within Django code.
> The above mentioned posting specifies that some extra parameter be
> added to the
> form's __init__ function argument list, and that it can be used to
> determine the queryset for the ModelChoiceField, but how can I do this
> with a formset?
>
> Thanks,
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Include Forms in a Template

2009-05-14 Thread aruns

Hi,

i have included many static pages in my template using

{% include staticpage.html %}

i have started using views and forms, so i am tring to include a form
in my template. I am not sure how to do this.

Could any one please help on this..

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



Re: need help in query set

2009-05-14 Thread Michael
On Thu, May 14, 2009 at 12:01 PM, Prabhjyot Singh  wrote:

>
> I am using
>resultset = queryset.get(status__in=['pending'])
> but it is giving me error which says:
>
> Exception Type: MultipleObjectsReturned
> Exception Value:
>
> get() returned more than one WapAd -- it returned 3! Lookup parameters were
> {'status__in': ['pending']}
>
> Exception Location:
> /usr/lib/python2.5/site-packages/django/db/models/query.py in get, line 277
>
>
> what should I do?
>

get tries to return only one item. If you want a queryset or multiple items
you want to use filter instead of get.

Hope that helps,
Michael

>
> >
>

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



Re: The beginner to develop website using DJANGO

2009-05-14 Thread veasna bunhor
 Thanks in advanced.

On Thu, May 14, 2009 at 6:37 PM, Tomas Zulberti  wrote:

>
> On Thu, May 14, 2009 at 6:56 AM, veasna.bunhor 
> wrote:
> >
> >
> >Dear all value Django team,
> >
> >I am a third-year student in IT field that focus on Computer
> > programming in Cambodia. I have known a little about Python. Now, i am
> > start to learn to develop website by using Python framework Django.
> > Could you please tell very step by step what do i need to install
> > before using Django and also a good tutorial for the beginner. If
> > possible please five me the link to that source.
> >
> >Thanks in advanced,
> >
> >BUNHOR Veasna,
> >
>
> Have you checked the docs?[0]
> There is shown how django is installed, and it also have a four step
> tutorial which gives an overview of how django works
>
>
> [0] http://docs.djangoproject.com/en/dev/
>
> >
>

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



Dynamic queryset when instantiating a form with a ModelChoiceField within a formset

2009-05-14 Thread SteveB

Hi,
I have a form which has a ModelChoiceField, whose queryset has to be
set dynamically (when the form is instantiated).
I have read an earlier posting on how to do this:
http://groups.google.com/group/django-users/browse_thread/thread/847ec83e26dd7846/f0b15945a01eafe2?lnk=gst=queryset+modelchoicefield#f0b15945a01eafe2

My problem, is that I don't directly instantiate this form. The form
is used in a formset,
so the actual instantiation is done within Django code.
The above mentioned posting specifies that some extra parameter be
added to the
form's __init__ function argument list, and that it can be used to
determine the queryset for the ModelChoiceField, but how can I do this
with a formset?

Thanks,
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: The beginner to develop website using DJANGO

2009-05-14 Thread Tomas Zulberti

On Thu, May 14, 2009 at 6:56 AM, veasna.bunhor  wrote:
>
>
>    Dear all value Django team,
>
>    I am a third-year student in IT field that focus on Computer
> programming in Cambodia. I have known a little about Python. Now, i am
> start to learn to develop website by using Python framework Django.
> Could you please tell very step by step what do i need to install
> before using Django and also a good tutorial for the beginner. If
> possible please five me the link to that source.
>
>    Thanks in advanced,
>
>    BUNHOR Veasna,
>

Have you checked the docs?[0]
There is shown how django is installed, and it also have a four step
tutorial which gives an overview of how django works


[0] http://docs.djangoproject.com/en/dev/

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



need help in query set

2009-05-14 Thread Prabhjyot Singh

I am using
resultset = queryset.get(status__in=['pending'])
but it is giving me error which says:
   
Exception Type: MultipleObjectsReturned
Exception Value:

get() returned more than one WapAd -- it returned 3! Lookup parameters were 
{'status__in': ['pending']}

Exception Location: 
/usr/lib/python2.5/site-packages/django/db/models/query.py in get, line 277


what should I do?

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



The beginner to develop website using DJANGO

2009-05-14 Thread veasna.bunhor


Dear all value Django team,

I am a third-year student in IT field that focus on Computer
programming in Cambodia. I have known a little about Python. Now, i am
start to learn to develop website by using Python framework Django.
Could you please tell very step by step what do i need to install
before using Django and also a good tutorial for the beginner. If
possible please five me the link to that source.

Thanks in advanced,

BUNHOR Veasna,

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



Re: using ajax in django

2009-05-14 Thread veasna bunhor
Dear newbie,

I am a fourth-year student in IT in cambodia. I just start to learn
Python, and now i just start to learn about how to develop the website by
using DJANGO. Could you please give to me any idea and  tell me about some
document for the very beginner programming.

Thanks in advanced,

BUNHOR Veasna,

On Thu, May 14, 2009 at 1:34 PM, newbie  wrote:

>
> hi,
>
>  I'm new to django and dont know much of javascript either. I
> would like to start working on them. Could someone help me write a
> simple form which can provide any functionality using ajax, preferably
> using jquery libraries. It would be great if any event other  than the
> submit event is recognised using ajax, something which connects to the
> database would be preferable.
>
> I've used ajax in web2py. But here in django I'm not able to
> understand the flow of a form. Here in django, forms are created by
> declaring a class in a seperate file. In web2py, it was clear and
> obvious of how to recognize a input or click or onchange event for a
> particular input field. But here I dont understand where to catch the
> event. Do i need to write the code in template file or in view file.
> If i write it in template file(which i'm thinking is the way), how to
> send the input entered(before the user submits the form) to the view
> file.
>
>  All i want to do is, to capture a change/input event on a form
> before the user submits and dynamically create an extra field in the
> form/change the options of a field already present in the form, based
> on the input
>
>
>  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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What debugger do you use?

2009-05-14 Thread Andy Mikhailenko

I mostly stick to defensive programming so rarely does the need to
debug appear; if it does, I use simple print commands to find the
stage on which the data is broken; then I fix the algo or add another
assert statement. This enables using Kate (or whatever text editor) +
manage.py for everything.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Gravatar django apps

2009-05-14 Thread Joshua Partogi
Dear all

Does anybody know a good django application for gravatar (
http://gravatar.com ) ?

Thank you very much for the redirection.

:-)

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow us on twitter: http://twitter.com/scrum8

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



Re: Troubles after switching to WSGI: lost apache processes, multiple view func calls per HTTP request

2009-05-14 Thread Graham Dumpleton



On May 14, 7:14 pm, Valery Khamenya  wrote:
> Hi,
>
> I have 2 issues that presumably could be related:
>
> 1. when I totally stop apache, I see that some apache processes remain
> running. When I repeat the stop operation, apache says that apache is not
> running, whereas the processes do exist. So, I have to kill them manually.

You need to ascertain whether they were Apache parent process, Apache
server child worker processes, or mod_wsgi daemon mode processes.

> 2. For a single HTTP request I see that multiple calls of the corresponding
> rendering function of a view.py are invoked. The overhead like 30 calls per
> single HTTP request is not acceptable neither from performance nor logic
> requirements.
>
> Details:
>
> a. both issues appeared after I've switsched to WSGI dipatching model.

Did you disable mod_python out of Apache when you switched. Loading
both at same time is not recommended as can cause some problems.

> b. I use wsgi-based dispatching for apache prefork (unfortunatelly I am
> restricted for prefork currently) as descreibed here right in the beginning
> of the document:http://pinaxproject.com/docs/dev/deployment.html

Be aware of the dangers of prefork. Read:

  http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

Why are you restricted to using prefork? Also, that documentation says
to use daemon mode which makes the MPM irrelevant, because if you
configure it properly the application runs in separate process like in
fastcgi.

What the documentation doesn't explain is to use the option:

  display-name=%{GLOBAL}

to WSGIDaemonProcess. This will allow you to use 'ps' to see whether
the Apache process is actually the Django process, ie., mod_wsgi
daemon process, or not. See the official mod_wsgi documentation for
more detail:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

> c. Also, to restart my app I sometime use "touch my-dispatcher.wsgi" as it
> was mentioned somewhere in django docs.

Perhaps also read mod_wsgi documentation on source code reloading to
find out what that is doing:

  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

> d. the file my-dispatcher.wsgi is basically like 
> this:http://github.com/pinax/pinax/blob/1f6d2d1216c5e8539639ef561349e4277f...
>
> Your input is very welcome, thanks in advance.
>
> P.S. I doubt that the troubles are purely Pinax-related, but if so, I am
> sorry.

You need to identify what role the process was doing. The display-name
option can help with that. Also set LogLevel to at least 'info' as
explained in:

  http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

Then you need to work out what the process is perhaps hanging on.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: modular django site: projects vs. apps

2009-05-14 Thread metge

I believe that's I choose the first option.
thx  for your answer!!



On May 12, 5:06 pm, George Song  wrote:
> On 5/12/2009 3:27 AM, mabuse wrote:
>
> > I am developing a django site and my aim is to obtain a site with a
> > core  application that would be the site basis and above it addons
> > that would upgrade the standard application ( like firefox and its
> > extensions).
>
> > My question is, how can I achieve that? My idea is to create two
> > projects:
> > 1. One project would be the "core project": with all basic apps.
> > 2. The other would be the "addons site project": including the addons
> > configured as apps.
>
> > Is it the best solution? Or it would be nicer to have only one project
> > and the addons configured as separate apps?
>
> It depends on if these "add-ons" are truly independent apps or not. If
> they can't be used outside of the context of your core project, then
> there's no need to separate them, really.
>
> If they are meant to be independent, then you'll need to take care that
> they have no dependences on *any* project whatsoever. And preferably not
> on other apps as well (except maybe django.contrib ones).
>
> --
> George
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Seperate thread - best practices

2009-05-14 Thread Daniel Roseman

On May 14, 10:03 am, Filip Gruszczyński  wrote:
> > Best practice here would be to stop trying to use a webserver to do
> > things it wasn't intended for.
>
> > If you need a separate process/thread to run regularly and perform
> > some background processing, then put that code in a standalone script
> > and use a crontab entry to invoke the script.
>
> Even if it's an integral part of an app? And I would like to be able
> to access it easily from django testing framework, so it can be
> automatically tested every time I need it.

Neither of those things are contradicted by Russ's advice. It would
still be Django code, and you could still keep it within the app and
test it with the normal testing framework, but it would be a separate
script run by cron.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: overriding change_list.html causes 'maximum recursion depth exceeded' exception

2009-05-14 Thread Margie

Thanks for confirming it Nick.  I saw it also on 1.0.2. I went ahead
and created a ticket, it's ticket 5.

Margie

On May 13, 1:32 pm, NickPresta  wrote:
> I can confirm this happens with 1.0.2 Final.
>
> On May 7, 2:44 pm, Margie  wrote:
>
> > I am trying to override the admin sites' change_list.html, following
> > the example at:
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad...
>
> > If I create templates/admin/myapp/change_list.html and just put this
> > in it (and nothing else):
>
> > {% extends "admin/change_list.html" %}
>
> > I get
>
> > Request Method:         GET
> > Request URL:    http://172.16.84.5:8042/admin/taskmanager/task/
> > Exception Type:         TemplateSyntaxError
> > Exception Value:
>
> > Caught an exception while rendering: maximum recursion depth exceeded
> > in cmp
>
> > Original Traceback (most recent call last):
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/template/debug.py", line 71, in render_node
> >     result = node.render(context)
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/template/loader_tags.py", line 71, in render
> >     compiled_parent = self.get_parent(context)
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/template/loader_tags.py", line 64, in get_parent
> >     source, origin = find_template_source(parent, self.template_dirs)
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/template/loader.py", line 70, in find_template_source
> >     source, display_name = loader(name, dirs)
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/template/loaders/filesystem.py", line 31, in
> > load_template_source
> >     for filepath in get_template_sources(template_name,
> > template_dirs):
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/template/loaders/filesystem.py", line 16, in
> > get_template_sources
> >     template_dirs = settings.TEMPLATE_DIRS
> >   File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
> > packages/django/utils/functional.py", line 270, in __getattr__
> >     if name == "__members__":
> > RuntimeError: maximum recursion depth exceeded in cmp
>
> > Exception Location:     /tools/aticad/1.0/external/python-2.5.1/lib/
> > python2.5/site-packages/django/template/debug.py in render_node, line
> > 81
>
> > I'm using the beta:>>> django.VERSION
>
> > (1, 1, 0, 'beta', 1)
>
> > Is this something I should post as a real bug?  If so, could someone
> > point me at the appropriate site for posting a bug?
>
> > Margie
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Troubles after switching to WSGI: lost apache processes, multiple view func calls per HTTP request

2009-05-14 Thread Valery Khamenya
Hi,

I have 2 issues that presumably could be related:

1. when I totally stop apache, I see that some apache processes remain
running. When I repeat the stop operation, apache says that apache is not
running, whereas the processes do exist. So, I have to kill them manually.

2. For a single HTTP request I see that multiple calls of the corresponding
rendering function of a view.py are invoked. The overhead like 30 calls per
single HTTP request is not acceptable neither from performance nor logic
requirements.

Details:

a. both issues appeared after I've switsched to WSGI dipatching model.

b. I use wsgi-based dispatching for apache prefork (unfortunatelly I am
restricted for prefork currently) as descreibed here right in the beginning
of the document: http://pinaxproject.com/docs/dev/deployment.html

c. Also, to restart my app I sometime use "touch my-dispatcher.wsgi" as it
was mentioned somewhere in django docs.

d. the file my-dispatcher.wsgi is basically like this:
http://github.com/pinax/pinax/blob/1f6d2d1216c5e8539639ef561349e4277f370b87/pinax/projects/basic_project/deploy/pinax.wsgi

Your input is very welcome, thanks in advance.

P.S. I doubt that the troubles are purely Pinax-related, but if so, I am
sorry.

Best regards
--
Valery A.Khamenya

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



Re: Seperate thread - best practices

2009-05-14 Thread Filip Gruszczyński

> Best practice here would be to stop trying to use a webserver to do
> things it wasn't intended for.
>
> If you need a separate process/thread to run regularly and perform
> some background processing, then put that code in a standalone script
> and use a crontab entry to invoke the script.

Even if it's an integral part of an app? And I would like to be able
to access it easily from django testing framework, so it can be
automatically tested every time I need it.

-- 
Filip Gruszczyński

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



Global date format in fields

2009-05-14 Thread Bastien

Hi,

I needed to change the date format the user sees in a field and I used
'input_formats'. But I was wondering if there was a setting to change
it for the whole project, kind of a locale for dates. I tried to add
DATE_FORMAT / DATETIME_FORMAT to the settings file but it did not
change the behavior of the DateFields or DateTimeFields of my forms.

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



using ajax in django

2009-05-14 Thread newbie

hi,

  I'm new to django and dont know much of javascript either. I
would like to start working on them. Could someone help me write a
simple form which can provide any functionality using ajax, preferably
using jquery libraries. It would be great if any event other  than the
submit event is recognised using ajax, something which connects to the
database would be preferable.

I've used ajax in web2py. But here in django I'm not able to
understand the flow of a form. Here in django, forms are created by
declaring a class in a seperate file. In web2py, it was clear and
obvious of how to recognize a input or click or onchange event for a
particular input field. But here I dont understand where to catch the
event. Do i need to write the code in template file or in view file.
If i write it in template file(which i'm thinking is the way), how to
send the input entered(before the user submits the form) to the view
file.

  All i want to do is, to capture a change/input event on a form
before the user submits and dynamically create an extra field in the
form/change the options of a field already present in the form, based
on the input


  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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---