Re: Pass context vars to django-registration

2009-05-07 Thread Stephen Cheng

No bother, I have found the solution. Simply use the ContextProcessor.

On May 7, 10:27 pm, Stephen Cheng  wrote:
> I have got a case like this: I have a drop down list of value of 8
> cities which requires a db query every time when every page loads. The
> problem is when the url is diverted to django-registration module,
> then I don't know how to properly pass the citylist as a context value
> to django-registration.
>
> I have got two solutions here:
> 1) For the view directly in registration module, I can just invoke my
> post-processed response,
> eg: in stead of using:
> return render_to_response(template_name,
>   { 'form': 
> form },
>   
> context_instance=context)
>I will hack it to:
> return mysiteresp(request,template_name,
>   { 'form': form },
>   
> context_instance=context)
>
> then in mysiteresp: I will add the context varible:cityList to the
> dictionary.
>
> I really don't like to intrude to third party's module, but this is a
> way to do it.
>
> However when the url is login, then it requires to use django's auth
> view
>
>url(r'^login/$',
>auth_views.login,
>{'template_name': 'registration/
> login.html'},
>name='auth_login'),
>
> then I can't do anything at all, I can't touch the system level
> functions. So how do I do? Any suggestion.
>
> 2) The other thought I got is to just hard code the city list in to
> the base.html template. eg:
>
> 
> 
>  
> value="10">AAA
> 
>  
> value="11">BBB
>
> ..
> 
>
> but I know that I am hesitated to do this.
>
> Any suggestion is appreciated.
>
> Stephen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: QuerySet.values() for single object?

2009-05-07 Thread George Song

On 5/7/2009 9:23 PM, Shadow wrote:
> If i get a model object with Model.objects.get()
> 
> Is their a way to turn that into a dictionary?

Why not just filter for it and use values()?

-- 
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: limiting choices for foreign key choices in the admin view

2009-05-07 Thread George Song

On 5/7/2009 9:19 PM, Margie wrote:
> Thanks much George, that was a big help.  I have some "proof of
> concept code below" that simply limits choices to the first four
> users, and I have verified that that works.
> 
> class TaskAdmin(admin.ModelAdmin):
> 
> def formfield_for_dbfield(self, db_field, **kwargs):
> if db_field.name == "owner":
> kwargs["queryset"] = User.objects.all()[0:3]
> formField = super(TaskAdmin, self).formfield_for_dbfield
> (db_field, **kwargs)
> return formField
> 
> I think that at the time formfield_for_dbfield is called we are
> creating the class for the form, ie, in this case, the class
> TaskForm.  It seems to me that I don't have any info at this time
> about what the actual values of the manyToMany field 'resources' is.
> In fact, it may be different for each line in the admin display.   IE,
> for each  line in the admin display, resources may point to different
> users and it is the value of resources hat I would really like to have
> for my choices for the owner field.  I have a feeling this isn't going
> to be possible ...
> 
> It seems like I would need to be setting the queryset for owner at a
> much later point in the code to really be able to set it to the
> 'resources' field for that same task.

If you can't predict ahead of time what the choice set is, then you will 
have to use some AJAX magic to accomplish what you want. The nice thing 
is you can attach JS to the fields you want.

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



Django Apache configuration Help !

2009-05-07 Thread veeravendhan

Hi,

I was trying to host 2 site in the one domain, the following was done
by me I coudn't get the two site.
NameVirtualHost domani

   ServerName domain/site
   DocumentRoot /home/somePath/
   ServerPath /path/
   SetHandler python-program
   PythonHandler django.core.handlers.modpython
   PythonDebug On
   SetEnv DJANGO_SETTINGS_MODULE site.settings
   PythonPath "['/home/somePath', '/usr/lib/python2.5/site-
packages/django'] + sys.path"



   ServerName domain/site1
   DocumentRoot /home/somePath/
   ServerPath /path/
   SetHandler python-program
   PythonHandler django.core.handlers.modpython
   PythonDebug On
   SetEnv DJANGO_SETTINGS_MODULE site.settings
   PythonPath "['/home/somePath', '/usr/lib/python2.5/site-
packages/django'] + sys.path"


for this how will i set the apache configuration.

Thanks,
Veeravendhan S
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 setting problem on windows

2009-05-07 Thread Phil Mocek

On Thu, May 07, 2009 at 10:16:44PM -0700, online wrote:
> Thanks, i tried changing
> 
> 
> to
>   or 

Your third attempt is not even valid syntax.  Doesn't it seem a
little strange that in the other cases you had quotes enclosing a
string but then in the third, you did not?

Your problem is completely unrelated to with Django, so it's a bit
out of place on this list.  As Malcom said previously, you need to
go read about Apache configuration.  It seems that you either
didn't read or misunderstood what you read.  Given that you
haven't asked any questions in an attempt to fill in the parts you
don't understand, it seems likely that you didn't even read any
relevant Apache docs.

Maybe if you cite the page that you're using as a reference in
your attempts to use Apache's location directive, and also explain
your present understanding of it, someone can help guide you to
whatever part you're missing or misunderstanding.

-- 
Phil Mocek

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

2009-05-07 Thread zayatzz

If you look at the example i pointed at on django page, then then you
notice that it says path/to/project in pythonpath.

your pythonpath is : PythonPath "['C:/depot/projects/web/'] +
sys.path"

Which seems to me is like path/with/project and should be /depot/
projects as far as i can tell.

If you fix that then change django root to /web/ and leave location to
"/web/"

Check the example on djagopage too, just in case. im writing this by
heart and i am known by simple mistakes that i make :)'

Alan

On May 8, 8:16 am, online  wrote:
> Thanks, i tried changing
y>
> 
> to
>   or 
>
> still no luck
>
> On May 4, 7:49 am, zayatzz  wrote:
>
> > Posting because i just set up httpd.conf on linux computer few days
> > ago and it took me a while to get it working as i wanted to.
>
> > If i just compare the way how i set it up and how you did it Then the
> > difference is that you have no pythonpath like Malcolm said and
> > location should be either "/web/" or "/"
>
> > Take a look at 2nd example here :http://docs.djangoproject.com/en/dev/
> > howto/deployment/modpython/
>
> > Thats the one i used to get it working.
>
> > Alan
>
> > On May 3, 8:24 am, online  wrote:
>
> > > I have mod_python set working fine with apache.
>
> > > I have django setting as following at apache
> > > 
> > > 
> > >     ServerAdmin webmas...@dummy-host2.li
> > >     DocumentRoot "C:/depot/projects/web/"
> > >     ServerName web
> > >     ServerAlias *.web
> > >     ErrorLog "logs/dummy-host2.li-error_log"
> > >     CustomLog "logs/dummy-host2.li-access_log" common
>
> > > 
> > >     SetHandler python-program
> > >     PythonHandler django.core.handlers.modpython
> > >     SetEnv DJANGO_SETTINGS_MODULE web.settings
> > >     PythonOption django.root "C:/depot/projects/web/"
> > >     PythonDebug On
> > > 
>
> > >   
> > >     SetHandler None
> > >   
>
> > >   
> > >     SetHandler None
> > >   
>
> > > 
> > > -
>
> > > But I always got error
>
> > > "ImportError: Settings cannot be imported, because environment
> > > variable DJANGO_SETTINGS_MODULE is undefined.
> > > "
>
> > > 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: django setting problem on windows

2009-05-07 Thread online

Thanks, i tried changing


to
  or 


still no luck


On May 4, 7:49 am, zayatzz  wrote:
> Posting because i just set up httpd.conf on linux computer few days
> ago and it took me a while to get it working as i wanted to.
>
> If i just compare the way how i set it up and how you did it Then the
> difference is that you have no pythonpath like Malcolm said and
> location should be either "/web/" or "/"
>
> Take a look at 2nd example here :http://docs.djangoproject.com/en/dev/
> howto/deployment/modpython/
>
> Thats the one i used to get it working.
>
> Alan
>
> On May 3, 8:24 am, online  wrote:
>
> > I have mod_python set working fine with apache.
>
> > I have django setting as following at apache
> > 
> > 
> >     ServerAdmin webmas...@dummy-host2.li
> >     DocumentRoot "C:/depot/projects/web/"
> >     ServerName web
> >     ServerAlias *.web
> >     ErrorLog "logs/dummy-host2.li-error_log"
> >     CustomLog "logs/dummy-host2.li-access_log" common
>
> > 
> >     SetHandler python-program
> >     PythonHandler django.core.handlers.modpython
> >     SetEnv DJANGO_SETTINGS_MODULE web.settings
> >     PythonOption django.root "C:/depot/projects/web/"
> >     PythonDebug On
> > 
>
> >   
> >     SetHandler None
> >   
>
> >   
> >     SetHandler None
> >   
>
> > 
> > -
>
> > But I always got error
>
> > "ImportError: Settings cannot be imported, because environment
> > variable DJANGO_SETTINGS_MODULE is undefined.
> > "
>
> > 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: django apache on windows setting problem

2009-05-07 Thread zayatzz

Several people answered to your question here:
http://groups.google.com/group/django-users/browse_thread/thread/2f98dfb324b86747/884e9a5477deb6ca?q=#884e9a5477deb6ca

Alan

On May 8, 7:54 am, online  wrote:
> forgot to mention the error message:
>
> ---
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined
>
> ---
>
> On May 7, 9:49 pm, online  wrote:
>
> > django is realy cool. But it is so frustrated to get django work on my
> > windows machine.
>
> > here is my setting/configures
>
> > python setting at httpd.conf:
> > --
>
> > 
> >     Options Indexes FollowSymLinks MultiViews
> >     AllowOverride All
> >     Order allow,deny
> >     allow from all
> >     AddHandler python-program .py
> >     PythonHandler mod_python.publisher
> >     PythonPath "['C:/Python25/Lib/site-packages/mod_python/',]
> > +sys.path"
> >     PythonDebug On
> > 
> > --
>
> > django setting at vhosts.conf:
>
> > -
> >         
> >     ServerAdmin webmas...@dummy-host2.li
> >     DocumentRoot "C:/depot/projects/web/"
> >     ServerName web
> >     ServerAlias *.web
> >     ErrorLog "logs/dummy-host2.li-error_log"
> >     CustomLog "logs/dummy-host2.li-access_log" common
>
> > 
> >     SetHandler python-program
> >     PythonHandler django.core.handlers.modpython
> >     PythonOption django.root "C:/depot/projects/web/"
> >     SetEnv DJANGO_SETTINGS_MODULE web.settings
> >     PythonPath "['C:/depot/projects/web/'] + sys.path"
> >     PythonDebug On
> > 
>
> >   
> >     SetHandler None
> >   
>
> >   
> >     SetHandler None
> >   
>
> > 
> > -
> > or you can see from this link:
>
> >http://stackoverflow.com/questions/823458/django-apache-on-windows-se...
>
> > Any help is much appreciated!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 apache on windows setting problem

2009-05-07 Thread online

forgot to mention the error message:

---
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined

---


On May 7, 9:49 pm, online  wrote:
> django is realy cool. But it is so frustrated to get django work on my
> windows machine.
>
> here is my setting/configures
>
> python setting at httpd.conf:
> --
>
> 
>     Options Indexes FollowSymLinks MultiViews
>     AllowOverride All
>     Order allow,deny
>     allow from all
>     AddHandler python-program .py
>     PythonHandler mod_python.publisher
>     PythonPath "['C:/Python25/Lib/site-packages/mod_python/',]
> +sys.path"
>     PythonDebug On
> 
> --
>
> django setting at vhosts.conf:
>
> -
>         
>     ServerAdmin webmas...@dummy-host2.li
>     DocumentRoot "C:/depot/projects/web/"
>     ServerName web
>     ServerAlias *.web
>     ErrorLog "logs/dummy-host2.li-error_log"
>     CustomLog "logs/dummy-host2.li-access_log" common
>
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     PythonOption django.root "C:/depot/projects/web/"
>     SetEnv DJANGO_SETTINGS_MODULE web.settings
>     PythonPath "['C:/depot/projects/web/'] + sys.path"
>     PythonDebug On
> 
>
>   
>     SetHandler None
>   
>
>   
>     SetHandler None
>   
>
> 
> -
> or you can see from this link:
>
> http://stackoverflow.com/questions/823458/django-apache-on-windows-se...
>
> Any help is much appreciated!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 apache on windows setting problem

2009-05-07 Thread online

django is realy cool. But it is so frustrated to get django work on my
windows machine.

here is my setting/configures

python setting at httpd.conf:
--


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AddHandler python-program .py
PythonHandler mod_python.publisher
PythonPath "['C:/Python25/Lib/site-packages/mod_python/',]
+sys.path"
PythonDebug On

--

django setting at vhosts.conf:

-

ServerAdmin webmas...@dummy-host2.li
DocumentRoot "C:/depot/projects/web/"
ServerName web
ServerAlias *.web
ErrorLog "logs/dummy-host2.li-error_log"
CustomLog "logs/dummy-host2.li-access_log" common



SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonOption django.root "C:/depot/projects/web/"
SetEnv DJANGO_SETTINGS_MODULE web.settings
PythonPath "['C:/depot/projects/web/'] + sys.path"
PythonDebug On


  
SetHandler None
  

  
SetHandler None
  


-
or you can see from this link:

http://stackoverflow.com/questions/823458/django-apache-on-windows-setting-problem


Any help is much appreciated!



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



QuerySet.values() for single object?

2009-05-07 Thread Shadow

Hi,

If i get a model object with Model.objects.get()

Is their a way to turn that into a dictionary?

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: limiting choices for foreign key choices in the admin view

2009-05-07 Thread Margie

Thanks much George, that was a big help.  I have some "proof of
concept code below" that simply limits choices to the first four
users, and I have verified that that works.

class TaskAdmin(admin.ModelAdmin):

def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == "owner":
kwargs["queryset"] = User.objects.all()[0:3]
formField = super(TaskAdmin, self).formfield_for_dbfield
(db_field, **kwargs)
return formField

I think that at the time formfield_for_dbfield is called we are
creating the class for the form, ie, in this case, the class
TaskForm.  It seems to me that I don't have any info at this time
about what the actual values of the manyToMany field 'resources' is.
In fact, it may be different for each line in the admin display.   IE,
for each  line in the admin display, resources may point to different
users and it is the value of resources hat I would really like to have
for my choices for the owner field.  I have a feeling this isn't going
to be possible ...

It seems like I would need to be setting the queryset for owner at a
much later point in the code to really be able to set it to the
'resources' field for that same task.

Margie



On May 7, 6:36 pm, George Song  wrote:
> On 5/7/2009 6:29 PM, Margie wrote:
>
>
>
> > I know this question has been pondered in a bunch of posts, and I'm
> > sorry to repeat it, but I just can't figure out what is the right
> > direction to take.
>
> > Let's say I have a model for a Task:
>
> > class Task(models.Model):
> >     owner = models.ForeignKey('auth.User')
> >     resources = models.ManyToManyField('auth.User')
>
> > The resources field identifies the set of possible owners for the
> > task.  I would like to have the admin change_list view show the
> > resources as the choices for the owner field, rather than showing all
> > Users.
>
> > Has anyone had success doing this?  Can someone point me in the right
> > direction?  Am happy to do some coding or override internal methods.
> > I see some people talking about using jquery to do this, but if there
> > is a way of overriding an internal method, that seems preferable to
> > me.
>
> I'll point you in the right direction: `django.contrib.admin.options`.
>
> Look specifically at `formfield_for_dbfield()` and the various flavors
> of related "hooks." I'll bet you can figure out what to do in your admin
> definition.
>
> --
> 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
-~--~~~~--~~--~--~---



GUCCI bags ( paypal payment )( www.315store.com )

2009-05-07 Thread dddddddddddd

GUCCI bags ( paypal payment )(  www.315store.com )
CHLOE bags
CHANEL bags
CLOTHES
COACH bags ( paypal payment )(  www.315store.com )
DOLCE&GABBANA bags
FENDI bags
GUESS bags
JIMMY CHOO bags ( paypal payment )(  www.315store.com )
JUICY bags
LV bags
PRADA bags ( paypal payment )(  www.315store.com )
BAPE bags
PAUL SMITH bags
AF bags ( paypal payment )(  www.315store.com )










GUCCI bags ( paypal payment )(  www.315store.com )
CHLOE bags
CHANEL bags
CLOTHES
COACH bags ( paypal payment )(  www.315store.com )
DOLCE&GABBANA bags
FENDI bags
GUESS bags
JIMMY CHOO bags ( paypal payment )(  www.315store.com )
JUICY bags
LV bags
PRADA bags ( paypal payment )(  www.315store.com )
BAPE bags
PAUL SMITH bags
AF bags ( paypal payment )(  www.315store.com )










GUCCI bags ( paypal payment )(  www.315store.com )
CHLOE bags
CHANEL bags
CLOTHES
COACH bags ( paypal payment )(  www.315store.com )
DOLCE&GABBANA bags
FENDI bags
GUESS bags
JIMMY CHOO bags ( paypal payment )(  www.315store.com )
JUICY bags
LV bags
PRADA bags ( paypal payment )(  www.315store.com )
BAPE bags
PAUL SMITH bags
AF bags ( paypal payment )(  www.315store.com )













GUCCI bags ( paypal payment )(  www.315store.com )
CHLOE bags
CHANEL bags
CLOTHES
COACH bags ( paypal payment )(  www.315store.com )
DOLCE&GABBANA bags
FENDI bags
GUESS bags
JIMMY CHOO bags ( paypal payment )(  www.315store.com )
JUICY bags
LV bags
PRADA bags ( paypal payment )(  www.315store.com )
BAPE bags
PAUL SMITH bags
AF bags ( paypal payment )(  www.315store.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
-~--~~~~--~~--~--~---



new style CHD(www.518store.com

2009-05-07 Thread dddddddddddd

cheap GHD (www.518store.com)

hot sale CHD(www.518store.com)


wholesale CHD(www.518store.com)


good CHD(www.518store.com)

new style CHD(www.518store.com






cheap GHD (www.518store.com)

hot sale CHD(www.518store.com)


wholesale CHD(www.518store.com)


good CHD(www.518store.com)

new style CHD(www.518store.com







cheap GHD (www.518store.com)

hot sale CHD(www.518store.com)


wholesale CHD(www.518store.com)


good CHD(www.518store.com)

new style CHD(www.518store.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
-~--~~~~--~~--~--~---



cheap GHD Straightener,(www.518store.com)

2009-05-07 Thread dddddddddddd

cheap GHD Straightener,(www.518store.com)

Cheap GHD Iron,(www.518store.com)

Cheap GHD iv styler(www.518store.com)

,Cheap ghd stylers,(www.518store.com)

Cheap pink ghd,(www.518store.com)

Cheap ghd ceramic iron,(www.518store.com)

Cheap ghd flat iron,Cheap ghd (www.518store.com)

mk5,cheap ghd hair straightener wholesale

 Cheap ghd flat iron,Cheap ghd mk5,cheap ghd hair straightener (www.
518store.com)
wholesale NEW 2009 PINK EDITION GHD MK4 FLAT IRON HAIR STYLER(www.
518store.com)






cheap GHD Straightener,(www.518store.com)

Cheap GHD Iron,(www.518store.com)

Cheap GHD iv styler(www.518store.com)

,Cheap ghd stylers,(www.518store.com)

Cheap pink ghd,(www.518store.com)

Cheap ghd ceramic iron,(www.518store.com)

Cheap ghd flat iron,Cheap ghd (www.518store.com)

mk5,cheap ghd hair straightener wholesale

 Cheap ghd flat iron,Cheap ghd mk5,cheap ghd hair straightener (www.
518store.com)
wholesale NEW 2009 PINK EDITION GHD MK4 FLAT IRON HAIR STYLER(www.
518store.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
-~--~~~~--~~--~--~---



( paypal payment )( www.315store.com )Air Jordans Air Jordans 1 Air Jordans 2 Air Jordans 3 Air Jordans 3.5 Air Jordans 4 Air Jordans 4.5 Air Jordans 5 Air Jordans 6 ( paypal payment )( www.315store

2009-05-07 Thread dddddddddddd

( paypal payment )( www.315store.com )Air Jordans Air Jordans 1 Air
Jordans 2 Air Jordans 3 Air Jordans 3.5 Air Jordans 4 Air Jordans 4.5
Air Jordans 5 Air Jordans 6 ( paypal payment )( www.315store.com )Air
Jordans 7 Air Jordans 8 Air Jordans 9 Air Jordans 10 Air Jordans 11
Air Jordans 12 Air Jordans 13 Air Jordans 14 Air Jordans 16 ( paypal
payment )( www.315store.com )Air Jordans 17 Air Jordans 18 Air Jordans
23 Air Jordans DMP Air Jordans Kids Air Jordans 15.5 Air Jordans 23
women Air Jordans 5 ( paypal payment )( www.315store.com )women Air
Jordans 3.5 women Air Jordans 13 & Air Jordans 23 Air Jordans 13 & Air
Jordans 11
( paypal payment )( www.315store.com )Air Force Jordan Fusion AF&J1
AF&J3 AF&J5 AF&J12 AF&J23 AF&J5 women AF&J23 women AF&J20 AF&J7 AF&J12
women
Air Max Air Max 90 man Air Max 90 women Air Max LTD man Air Max LTD
women Air Max TN ( paypal payment )( www.315store.com )man Air Max TN
women Air Max 87 man Air Max 87 women Air Max 88 man Air Max 89 man
Air Max 91 man Air Max 95 man Air Max 95 women Air Max 97 man Air Max
97 women Air Max 360 man Air Max 360 women Air Max 180 man Air
( paypal payment )( www.315store.com )Max 180 women Air Max 2003 man
Air Max 2003 women Air Max 95 360 man
DUNK DUNK man DUNK women DUNK High man DUNK High women











( paypal payment )( www.315store.com )Air Jordans Air Jordans 1 Air
Jordans 2 Air Jordans 3 Air Jordans 3.5 Air Jordans 4 Air Jordans 4.5
Air Jordans 5 Air Jordans 6 ( paypal payment )( www.315store.com )Air
Jordans 7 Air Jordans 8 Air Jordans 9 Air Jordans 10 Air Jordans 11
Air Jordans 12 Air Jordans 13 Air Jordans 14 Air Jordans 16 ( paypal
payment )( www.315store.com )Air Jordans 17 Air Jordans 18 Air Jordans
23 Air Jordans DMP Air Jordans Kids Air Jordans 15.5 Air Jordans 23
women Air Jordans 5 ( paypal payment )( www.315store.com )women Air
Jordans 3.5 women Air Jordans 13 & Air Jordans 23 Air Jordans 13 & Air
Jordans 11
( paypal payment )( www.315store.com )Air Force Jordan Fusion AF&J1
AF&J3 AF&J5 AF&J12 AF&J23 AF&J5 women AF&J23 women AF&J20 AF&J7 AF&J12
women
Air Max Air Max 90 man Air Max 90 women Air Max LTD man Air Max LTD
women Air Max TN ( paypal payment )( www.315store.com )man Air Max TN
women Air Max 87 man Air Max 87 women Air Max 88 man Air Max 89 man
Air Max 91 man Air Max 95 man Air Max 95 women Air Max 97 man Air Max
97 women Air Max 360 man Air Max 360 women Air Max 180 man Air
( paypal payment )( www.315store.com )Max 180 women Air Max 2003 man
Air Max 2003 women Air Max 95 360 man
DUNK DUNK man DUNK women DUNK High man DUNK High women










( paypal payment )( www.315store.com )Air Jordans Air Jordans 1 Air
Jordans 2 Air Jordans 3 Air Jordans 3.5 Air Jordans 4 Air Jordans 4.5
Air Jordans 5 Air Jordans 6 ( paypal payment )( www.315store.com )Air
Jordans 7 Air Jordans 8 Air Jordans 9 Air Jordans 10 Air Jordans 11
Air Jordans 12 Air Jordans 13 Air Jordans 14 Air Jordans 16 ( paypal
payment )( www.315store.com )Air Jordans 17 Air Jordans 18 Air Jordans
23 Air Jordans DMP Air Jordans Kids Air Jordans 15.5 Air Jordans 23
women Air Jordans 5 ( paypal payment )( www.315store.com )women Air
Jordans 3.5 women Air Jordans 13 & Air Jordans 23 Air Jordans 13 & Air
Jordans 11
( paypal payment )( www.315store.com )Air Force Jordan Fusion AF&J1
AF&J3 AF&J5 AF&J12 AF&J23 AF&J5 women AF&J23 women AF&J20 AF&J7 AF&J12
women
Air Max Air Max 90 man Air Max 90 women Air Max LTD man Air Max LTD
women Air Max TN ( paypal payment )( www.315store.com )man Air Max TN
women Air Max 87 man Air Max 87 women Air Max 88 man Air Max 89 man
Air Max 91 man Air Max 95 man Air Max 95 women Air Max 97 man Air Max
97 women Air Max 360 man Air Max 360 women Air Max 180 man Air
( paypal payment )( www.315store.com )Max 180 women Air Max 2003 man
Air Max 2003 women Air Max 95 360 man
DUNK DUNK man DUNK women DUNK High man DUNK High women

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Can't visit any url but the root?

2009-05-07 Thread Shadow

For anyone that finds this:

I had the following in my apache config:

PythonOption django.root /

which stripped the initial slash.

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



dev server hangs on admin pages over remote port

2009-05-07 Thread jfenton

Hi,

I'm having a problem with admin pages hanging when running the dev
server on an off-port that seems to be similar to the one described
here:

http://groups.google.com/group/django-users/browse_thread/thread/3450e2c2585a8e82/c04d9a6d4c803bd7?lnk=gst&q=admin+server+hangs#c04d9a6d4c803bd7

I'm running this from a remote server and attempting to view the pages
over a variety of browsers. I'm running django 1.0.2 on Centos 5.2
with modpython and apache 2.something, python 2.4 and postgresql 8.3.

The dev server serves non-admin pages just fine over the same port;
and when I run the production server with the same configuration the
admin (and regular) pages are served no problem. ( If I had more
energy I might try to run the prod server over the same port and see
if the admin works, but... )

Anyway, when I try to load an admin page the dev server console shows
a 200 response code and no errors--but my browser just churns
endlessly.

Once the dev server chokes trying to send an admin page, it stops
responding to requests. If I restart it, though, it serves non-admin
pages fine over the same off-port.

I am able to get an admin page response when running the dev server
from localhost (I'm hitting the admin login page with wget), though I
confess I haven't bothered to try to log in that way and don't see
that as a useful alternative. The dev server doesn't hang when serving
pages to localhost this way though.

Has anyone seen this behavior before and fixed it? It seems weird that
there aren't any errors. I recall that when I moved servers a few
months ago that dev admin pages took a really unreasonable time to
load, but I couldn't say when this actually started happening--
probably because I was too lazy to do anything about it.

I thought maybe it was some sort of port/cookie weirdness--but I don't
see why that would make the dev server become unresponsive. Any hints
much appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Annotations

2009-05-07 Thread George Song

On 5/7/2009 4:28 PM, Andy Lei wrote:
> I have 3 models.  Something like this:
> 
> Writer:
>  content = ManyToMany(Content)
> Content
>  tags = ManyToMany(Tag)
> Tag
> 
> Now suppose I have a Tag, call it "tag1".  The idea of the query is
> that I want the Writers that have the most pieces of Content tagged
> with tag1.
> 
> Theoretically, it'd be something like
> Writer.objects.annotate(content_count=Count
> ("content__tags=tag1")).order_by('content_count")
> 
> Obviously, that doesn't work.  Any help would be greatly appreciated.

Hmm. I'm not sure if this is possible through the ORM. If it is, it's 
beyond me.

The closest thing I can think of is:
{{{
Writer.objects.filter(content__in=Content.objects.filter(tags=tag))
}}}

Which will yield a QuerySet with each Writer repeated n times (once for 
each Content associated with that writer, tagged with `tag`).

You should be able to do something in Python to get the Writer:count() 
mapping that you want.

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



Help with Querying Related Models, Please!

2009-05-07 Thread andre

"""
Background:

As described on the "User Authentication in Django" manual, I am using
an additional model to store extra information about users. This
additional model (J2User) model uses a ForeignKey to the User model
and is specified below.

Problems (all related):

1) Accessing the J2User model, how do I retrieve only one User field
for ALL records? I tried something like J2User.objects.all().username
but it didnt work.

2) Accessing the J2User model, how do I retrieve ALL User fields for
ALL records?

3) How do I write a J2User method that would return one field of the
User model? I need the implementation for something like
J2User.get_auth_user_usernames().

4) How do I write a J2User method that would return ALL User fields
for ALL records? The implementation for something like
J2User.get_auth_user_fields()

Suggestion:

Add the answers to the above question to the documentation.

This post also at http://dpaste.com/hold/41999/
"""

# models.py

from django.db import models
from django.contrib.auth.models import User

class J2UserType(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(unique=True, max_length=128)

class J2User(models.Model):
id = models.AutoField(primary_key=True)
user = models.ForeignKey(User, unique=True)
user_type = models.ForeignKey(J2UserType)
   def get_auth_user_usernames(self):
  # ???
  pass
   def get_auth_user_all_fields(self):
 # ???
 pass

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



Re: limiting choices for foreign key choices in the admin view

2009-05-07 Thread George Song

On 5/7/2009 6:29 PM, Margie wrote:
> I know this question has been pondered in a bunch of posts, and I'm
> sorry to repeat it, but I just can't figure out what is the right
> direction to take.
> 
> Let's say I have a model for a Task:
> 
> class Task(models.Model):
> owner = models.ForeignKey('auth.User')
> resources = models.ManyToManyField('auth.User')
> 
> The resources field identifies the set of possible owners for the
> task.  I would like to have the admin change_list view show the
> resources as the choices for the owner field, rather than showing all
> Users.
> 
> Has anyone had success doing this?  Can someone point me in the right
> direction?  Am happy to do some coding or override internal methods.
> I see some people talking about using jquery to do this, but if there
> is a way of overriding an internal method, that seems preferable to
> me.

I'll point you in the right direction: `django.contrib.admin.options`.

Look specifically at `formfield_for_dbfield()` and the various flavors 
of related "hooks." I'll bet you can figure out what to do in your admin 
definition.

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



limiting choices for foreign key choices in the admin view

2009-05-07 Thread Margie

I know this question has been pondered in a bunch of posts, and I'm
sorry to repeat it, but I just can't figure out what is the right
direction to take.

Let's say I have a model for a Task:

class Task(models.Model):
owner = models.ForeignKey('auth.User')
resources = models.ManyToManyField('auth.User')

The resources field identifies the set of possible owners for the
task.  I would like to have the admin change_list view show the
resources as the choices for the owner field, rather than showing all
Users.

Has anyone had success doing this?  Can someone point me in the right
direction?  Am happy to do some coding or override internal methods.
I see some people talking about using jquery to do this, but if there
is a way of overriding an internal method, that seems preferable to
me.

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



Re: TIME_ZONE problem

2009-05-07 Thread George Song

On 5/7/2009 5:00 PM, Graham Dumpleton wrote:
> 
> 
> On May 7, 2:41 am, George Song  wrote:
>> On 5/6/2009 4:02 AM, Graham Dumpleton wrote:
>>
>>
>>
>>
>>
>>> On May 6, 4:38 am, George Song  wrote:
 On 5/5/2009 6:48 AM, Michel Thadeu Sabchuk wrote:
> Hi guys,
> I'm having a weird problem with TIME_ZONE settings. Some view list
> objects based on the time, future time objects are not shown.
> The problem is that sometimes all objects that need to be shown appear
> normally, sometimes the latest objects are not shown.
> Digging on the problem I found that sometimes my os.environ['TZ'] are
> set to 'America/Sao_Paulo' (the correct one) and sometimes it is the
> default 'America/Chicago'. I can't see any reason to this problem.
> I using python2.5 with django1.1-beta installed on a vps with ubuntu
> hardy. My django settings module have the following line:
> TIME_ZONE = 'America/Sao_Paulo'
> And my apache virtual host configuration has the following:
> 
> SetHandler python-program
> PythonPath "['/path-to-my-project/'] + sys.path"
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE portal.settings
> PythonDebug Off
> 
> Does someone facing the same problem? Does anyone has a suggestion?
 That is very odd indeed. Are there other Django instances within the
 same virtual host?
>>> It doesn't strictly have to be other Django instances, it can be PHP
>>> or mod_perl as well. Basically anything that runs embedded in Apache
>>> processes and which expects a different timezone setting.
>>> For case where only running Python applications, formod_wsgithis
>>> problem is described in:
>>>  http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Timezone_and_...
>>> Same thing with mod_python, but with mod_python no way around it.
>> With mod_python, can you just use multiple interpreters?
>> 
> 
> No you can't. Those multiple interpreters are in the same process
> exactly as described from mod_wsgi case. The problem is because
> application in each interpreter is changing a value which is shared
> across all interpreters. This value being sorted at C library level
> outside of context of specific Python sub interpreter.

Gotcha, that makes sense.

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

2009-05-07 Thread Graham Dumpleton



On May 7, 2:41 am, George Song  wrote:
> On 5/6/2009 4:02 AM, Graham Dumpleton wrote:
>
>
>
>
>
> > On May 6, 4:38 am, George Song  wrote:
> >> On 5/5/2009 6:48 AM, Michel Thadeu Sabchuk wrote:
>
> >>> Hi guys,
> >>> I'm having a weird problem with TIME_ZONE settings. Some view list
> >>> objects based on the time, future time objects are not shown.
> >>> The problem is that sometimes all objects that need to be shown appear
> >>> normally, sometimes the latest objects are not shown.
> >>> Digging on the problem I found that sometimes my os.environ['TZ'] are
> >>> set to 'America/Sao_Paulo' (the correct one) and sometimes it is the
> >>> default 'America/Chicago'. I can't see any reason to this problem.
> >>> I using python2.5 with django1.1-beta installed on a vps with ubuntu
> >>> hardy. My django settings module have the following line:
> >>> TIME_ZONE = 'America/Sao_Paulo'
> >>> And my apache virtual host configuration has the following:
> >>> 
> >>>     SetHandler python-program
> >>>     PythonPath "['/path-to-my-project/'] + sys.path"
> >>>     PythonHandler django.core.handlers.modpython
> >>>     SetEnv DJANGO_SETTINGS_MODULE portal.settings
> >>>     PythonDebug Off
> >>> 
> >>> Does someone facing the same problem? Does anyone has a suggestion?
> >> That is very odd indeed. Are there other Django instances within the
> >> same virtual host?
>
> > It doesn't strictly have to be other Django instances, it can be PHP
> > or mod_perl as well. Basically anything that runs embedded in Apache
> > processes and which expects a different timezone setting.
>
> > For case where only running Python applications, formod_wsgithis
> > problem is described in:
>
> >  http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Timezone_and_...
>
> > Same thing with mod_python, but with mod_python no way around it.
>
> With mod_python, can you just use multiple interpreters?
> 

No you can't. Those multiple interpreters are in the same process
exactly as described from mod_wsgi case. The problem is because
application in each interpreter is changing a value which is shared
across all interpreters. This value being sorted at C library level
outside of context of specific Python sub interpreter.

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



Annotations

2009-05-07 Thread Andy Lei

I have 3 models.  Something like this:

Writer:
 content = ManyToMany(Content)
Content
 tags = ManyToMany(Tag)
Tag

Now suppose I have a Tag, call it "tag1".  The idea of the query is
that I want the Writers that have the most pieces of Content tagged
with tag1.

Theoretically, it'd be something like
Writer.objects.annotate(content_count=Count
("content__tags=tag1")).order_by('content_count")

Obviously, that doesn't work.  Any help would be greatly appreciated.

Thanks!

-Andy



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



Gathering related objects for a set of objects, across a many-to-many relationship

2009-05-07 Thread Steve Howard

Hi,

I'm wondering what the best/canonical way is to gather the set of
related objects for each of a number of objects, going across a
Many-to-Many relationship.  Here's an example, since that probably
didn't make sense by itself:

class Label(Model):
  name = CharField(...)

class Email(Model):
  sender = CharField(...)
  body = CharField(...)
  labels = ManyToManyField(Label)

Now I want to retrieve all emails sent by "showard" along with all the
labels applied to each email.  I want to do it with a *constant*
number of database queries.  How do I do it?

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: Trouble Starting Up with runserver

2009-05-07 Thread Chris DPS



On May 7, 11:23 am, Phil Mocek 
wrote:
> On Thu, May 07, 2009 at 12:49:28PM -0500, Tim Chase wrote:
> > > was searching for "interface" or "IP address" but the tutorial
> > > says -- incorrectly or colloqially, depending on how you see
> > > things -- "So to listen on all public IPs (useful if you want
> > > to show off your work on other computers), use:".  There's no
> > > such thing as a "public IP".
>
> > I suspect the intent is "external IP" compared to an internal IP
> > (localhost/127.0.0.1).
>
> I agree.
>
> What makes the tutorial technically incorrect, and what prevents
> someone who seeks information about using the 0.0.0.0 IP address
> from finding that passage using reasonable search terms, is its
> omission of the word "address".  The subject at hand is an
> address, not a protocol, yet what was written is "public IP" not
> "public IP address".  This is fine for casual conversation, but --
> for reasons including that which was discovered in this discussion
> -- not for a technical tutorial whose target audience is software
> developers.
>
> --
> Phil Mocek

Sorry for the confusion.
I have definitely tried it listening only to localhost (i.e. running
python manage.py runserver without additional arguments)

My question is mainly about reasons why the very basic python
manage.py runserver doesn't work
and creates the error 10104 getaddrinfo failed

I only mentioned 0.0.0.0:8000 because this was suggested on a separate
thread as a solution (and it worked for the guy asking). It does not
work for me.

It is something wrong with my computer (and I really don't think I
have any Firewall active - not entirely certain, but pretty sure). I
just did the same setup on a different computer and it is working, but
I need it to work on my own.

Any ideas?
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: Need help optimizing a view, too many queries

2009-05-07 Thread Daniel Roseman

On May 7, 5:56 pm, Eric Chamberlain  wrote:
> Our view is taking too long to render, can anyone offer suggestions to  
> improve its speed?
>
> There are 5830 profiles.
>
> Total query count: 23809
> Total duplicate query count: 493
> Total SQL execution time: 66.003
> Total Request execution time: 142.931



>
> profiles =  
> Profile
> .objects
> .filter(partner=request.partner,user__is_active=True).order_by('-
> user__date_joined')
> for p in profiles:
>        p.provider_list = list(
>            account.provider for account in  
> ProviderAccount
> .objects
> .filter(user=p.user,provider__provider_partners=request.partner))
>        p.call_count = p.call_records.filter().count()
> return PartnerResponse(request, {'profiles': profiles})
>
> PartnerResponse returns the view to the user, the template uses a for  
> loop to iterate through the profiles.


As it happens, reducing query counts is something of an obsession of
mine at the moment - just gave a talk at EuroDjangoCon on this very
subject.

In your case, the first thing to do is take that ProviderAccount query
out of the loop. What I would do is first get a list of all provider
user_ids, then query all ProviderAccounts with those users. You can
then put them into a dictionary keyed by user_id and then loop through
to re-associate them with the profile.

Something like this (untested):

profiles = Profile.objects.filter(partner=request.partner,
user__is_active=True).order_by('-user__date_joined')
user_ids = [p.user_id for p in profiles]

accounts = ProviderAccount.objects.filter(user__in=user_ids,
provider__provider_partners=request.partner)
account_dict = dict([(pa.user_id, pa) for pa in accounts])

for p in profiles:
p.provider_list = account_dict[p.user_id]

You will probably need to tweak this - it doesn't take account of the
fact that a user might be associated with multiple ProviderAccounts -
but hopefully you get the idea, you should try and get all your
accounts in one big query and *then* associate them with the relevant
profiles.

The other thing to look at is the proper use of select_related. You
might find that doing Profile.objects.select_related().filter
(whatever) has a big impact on reducing the count.

Finally, you have not stated what call_records is, it doesn't appear
to come from anywhere in this code, so I don't know if that's also the
cause of some big queries.

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



Filtering the admin change list on relatedmodel__isnull

2009-05-07 Thread Kai Groner

I am trying to figure out how to do isnull lookups with the admin
change list filter.  I am using the django master branch (off of
github), updated to 4/28.

I have a couple models with a simple relation:

from django.db import models

class ModelOne(models.Model):
  pass

class ModelTwo(models.Model):
  one = models.ForeignKey(ModelOne)

I can filter on `two_set__isnull=True` to find ModelOne not referenced
by any ModelTwo and `two_set__isnull=False` to find ModelOne that is
referenced by any ModelTwo.  That works well enough in python.

I can't find a way to do this with the admin change list filter.  The
ChangeList class does recognize and accept querystrings like the
following:

/admin/foo/modelone/?two_set__isnull=True
/admin/foo/modelone/?two_set__isnull=
/admin/foo/modelone/?two_set__isnull

The problem is that the parameters are all strings.  It seems the
behavior of isnull lookups is not useful for non boolean values.
Perhaps that is sensible.

I have a couple ideas toward making this work.

One idea involves the ChangeList class that does the work of
converting the request.GET parameters to a QuerySet.  This could do
the conversion to a boolean value.  There is presently a branch to
specially handle in lookups there.

My other idea is to make isnull lookups work for non-boolean types.
This is actually already done to generate the IS NULL / IS NOT NULL
sql, but there is also a test to change the join type so NULL values
or returned for rows where the join fails (instead of no row).

Is this an issue for anyone else?  Am I barking up the wrong tree?
I'm fairly new to django, so I could just be missing something here.


Kai


Patch to make the admin ChangeList class coerce isnull lookups to use
bool.
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -185,6 +185,10 @@ class ChangeList(object):
 if key.endswith('__in'):
 lookup_params[key] = value.split(',')

+   # if key ends with __isnull, convert the value to a boolean
+   elif key.endswith('__isnull'):
+   lookup_params[key] = bool(value)
+
 # Apply lookup parameters from the query string.
 try:
 qs = qs.filter(**lookup_params)


Patch to make BaseQuery use a more relaxed test for truthiness.
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1536,7 +1536,7 @@ class BaseQuery(object):
 can_reuse)
 return

-if (lookup_type == 'isnull' and value is True and not negate
and
+if (lookup_type == 'isnull' and value and not negate and
 len(join_list) > 1):
 # If the comparison is against NULL, we may need to use
some left
 # outer joins when creating the join chain. This is only
done when


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

2009-05-07 Thread varikin



On May 6, 11:23 am, joshuamckenty  wrote:
> I'm using Fabric for deployment of my django apps, and I quite like
> it. It's still probably not as feature-rich as capistrano, but it's
> written in python, has a *very* active community right now, and solves
> the problems that I have, anyway. YMMV.http://www.nongnu.org/fab/
>

I second Fabric. I found it very nice to do anything I needed. And all
actions are just python functions (might be callables, I don't know)
so you can make it do almost anything.

You also mentioned SQL and migrations. Are you using a migration
application? I know there are a couple that get a lot of buzz, like
South. From what I hear, it is very good.

Regards,
John
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: please help with FileField(upload_to='foo')

2009-05-07 Thread varikin



On May 6, 9:30 am, djangomax  wrote:
> Thanks! So I just need to replace "forms" with "models and it'll work?

Are you defining a model or are you creating a form? To really be able
to answer that, the code around that one line would be helpful.

The easy answer (but not necessarily correct answer) is if this is in
models.py, it is a model. If this is in another file such as forms.py
or views.py, it is a form and you don't need to specify upload_to. But
that easy answer can be wrong in certain cases.

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



Re: Problem with overriding save() method

2009-05-07 Thread George Song

On 5/7/2009 8:05 AM, Lee Hinde wrote:
> On Wed, May 6, 2009 at 11:37 PM, George Song  wrote:
>> On 5/6/2009 11:18 PM, Lee Hinde wrote:
>>> On Wed, May 6, 2009 at 11:15 PM, Lee Hinde  wrote:
 On Wed, May 6, 2009 at 10:54 PM, George Song  wrote:
> On 5/6/2009 10:34 PM, Lee Hinde wrote:
>> On Wed, May 6, 2009 at 10:22 PM, George Song  wrote:
>>> On 5/6/2009 9:57 PM, Lee Hinde wrote:
 I have this as part of the model for a class called "Class"


 def save(self, force_insert=False, force_update=False):
 start = defaultfilters.slugify(self.Name)
 count = Class.objects.filter(Slug__equal=start).count()
 if count != 0:
 filterme = "%s_%d" % (self.Name, count)
 self.Slug = defaultfilters.slugify(filterme)
 else:
 self.Slug = start


 The reason is, it's ok to have duplicate Names,  and I want to use a
 Slug as the canonical url.

 I have a bunch of data to import and so , in shell I run

  c = Class.objects.all()
 for o in c:
 o.save()


 My goal would be to see something like:

 yoga-for-kids
 yoga-for-kids_1
 yoga-for-kids_2

 What's weird is I'm getting:

 yoga-for-kids
 yoga-for-kids
 yoga-for-kids_2

 i.e., I get dupes and then not.
 hasn't
 I've played with it most of the evening and now I'm hoping someone
 with a fresh pair of eyes might have a suggestion.

 Thanks in advance.
>>> I'm not sure why you're getting yoga-for-kids_2, what I expect is
>>> yoga-for-kids, yoga-for-kids_1, then more yoga-for-kids_1 if your slug
>>> field is not unique=True.
>>>
>>> In any case, your logic will keep generating yoga-for-kids_1 because
>>> there will only ever be one count for yoga-for-kids in your DB.
>>>
>> Well, depends on when it's run, right? yoga-for-kids_1 would be the
>> correct response for the 2nd record.
>>
>>  In this case I'm updating imported data, so there's a pre-existing
>> match. If it's a new record, it should come back zero, sine the record
>> hasn't been saved yet?
>>
>> Thanks for looking at it.
> Well, I imagine your Class.Name for your test case is "Yoga For Kids",
> right?
>
> So your `start` is always going to be "yoga-for-kids" no matter what.
>
> Since you're search on that slug, you should only ever have one record
> since your slugs are supposed to be unique. So your re-generated slug
> will always be "yoga-for-kids_1".
>
> --
> George
>
 Yes, I see what you're saying and it means I've left out a step.
 Before I run the model.save() loop, I clear the existing slug data, so
 it starts clean each run.

>>> But still should always leave me with 1... So, how did I end up with 2
>>> blanks and one 2?
>>>
>>> Assuming I start off with blanks.
>>>
>>> First time - no match, save as is
>>> Second time - one match save as X_1
>>> third time, still one match (this is what you described), should save
>>> again as x_1 (I'd tried 'startedwith' but that had other problems.)
>> I can't be sure what your exact conditions are, but in my test, the
>> result is exactly as I described:
>>
>> {{{
>> from django.db import models
>> from django.template.defaultfilters import slugify
>>
>> class Class(models.Model):
>> name = models.CharField(max_length=50)
>> slug = models.SlugField()
>>
>> def save(self, force_insert=False, force_update=False):
>> self.slug = slugify(self.name)
>> count = self.__class__.objects.filter(slug=self.slug).count()
>> if count:
>> self.slug = '%s_%d' %(self.slug, count)
>> super(Class, self).save(force_insert, force_update)
>>
>>  >>> from yoga.models import Class
>>  >>> c1 = Class.objects.create(name='Yoga For Kids')
>>  >>> c2 = Class.objects.create(name='Yoga For Kids')
>>  >>> c3 = Class.objects.create(name='Yoga For Kids')
>>  >>> c1.slug
>> u'yoga-for-kids'
>>  >>> c2.slug
>> u'yoga-for-kids_1'
>>  >>> c3.slug
>> u'yoga-for-kids_1'
>> }}}
>>
>> --
>> George
> 
> 
> George, thanks very much for the effort.
> 
> I'd appreciate any suggestions on the right way to code this.

I would probably define a utility function that generically accepts a 
list of current slugs and the slug that you want, and returns a unique slug.

In the function body would be whatever logic you want to use to make 
that slug unique, among all the slugs for a specific model.

{{{
def make_unique_slug(all_slugs, slug):
 if slug in all_slugs:
 # Do your magic here to make it unique
 return slug
}}}

-- 
George

--~--~-~--~~~---~--~~
You received this message because you are

Re: Wrapping object_detail generic view in another view

2009-05-07 Thread George Song

On 5/7/2009 1:01 PM, Jamie Pittock wrote:
> Basically, am I doing things right, and if so which is the best
> solution from the above?

Yup, you are doing things correctly as far as I can tell.

As for creating a custom method or not, it's up to you, it's just a 
convenience wrapper, after all. I don't see much value in this specific 
instance, unless you think the meaning of "get_by_author" may change at 
some point.

p.s. Use spaces instead of tabs in your code. It was extremely hard to read.

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



Wrapping object_detail generic view in another view

2009-05-07 Thread Jamie Pittock

Hi all -

As the subject suggests, I've wrapped the generic view
date_based.object_detail in another view, and while my solution seem
to be working, as I'm still new to Django, I'd like to check I'm doing
things right with the experts (you!).

I'm creating a blog that has multiple authors.  The url for posts is
date based but also includes the author's username, like:

domain.com/username/blog/2009/may/02/blog-post/

The view I've created consists of the following...

def post_detail(request, username, year, month, day, slug):
return date_based.object_detail(request,
year,
month,
day,

Post.objects.filter(author__username__exact=username),

date_field='pub_date',

slug=slug,

slug_field='slug',

extra_context={},

template_name='blog/post_detail.html')

It seems to work but as I say I'm still new to Django and I'm not sure
if this the right way to go around it.

As an alternative I could create a method (get_by_author) in my
manager that does the filtering which I'd be able to reuse in the
object_list view, such as:

def post_detail(request, username, year, month, day, slug):
user = get_object_or_404(User, username__exact=username)
return date_based.object_detail(request,
year,
month,
day,

Post.objects.get_by_author(user.username),

date_field='pub_date',

slug=slug,

slug_field='slug',

extra_context={'user': user},

template_name='blog/post_detail.html')

Basically, am I doing things right, and if so which is the best
solution from the above?

Thanks in advance,
Jamie

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Internationalization (i18n) of model: request.LANGUAGE_CODE in __unicode__ and ordering?

2009-05-07 Thread Tom Evans

On Thu, 2009-05-07 at 07:55 -0700, Wouter van der Graaf wrote:
> Hi there,
> 
> Spent hours trying to find the solution, but no luck. So here goes...
> 
> Please consider simplified code below:
> 
> {{{
> class Country(models.Model):
> ...
> label_en = models.CharField(max_length = 128, blank=True,
> null=True)
> label_nl = models.CharField(max_length = 128, blank=True,
> null=True)
> 
> class Meta:
> ordering = ('label_en',)
> 
> def __unicode__(self):
> if hasattr(settings, 'LANGUAGE_CODE'):
> field = 'label_%s' % settings.LANGUAGE_CODE.lower()
> if hasattr(self, field):
> return getattr(self, field)
> return self.label_en
> }}}
> 
> Other models use Country with a ForeignKey relationship. The
> __unicode__ function works for displaying localized country names. If
> LANGUAGE_CODE is 'nl' then the drop down selectbox for Country in the
> admin shows Dutch country names, otherwise all country names are
> English.
> 
> But it's not exactly what you'd want. Now I want to be able to do two
> things:
> 
>  1. Change __unicode__ to use request.LANGUAGE_CODE, the user
> preference.
>  2. Change ordering to the chosen language field. You don't want a
> list in Dutch, ordered by English translations.
> 
> All this is happening runtime, of course. Users in a admin edit page,
> using a drop down for the foreign key Country, should see the country
> names and ordering change when they select another language.
> 
> Possible? Other ways to achieve a runtime language dependent model?
> 
> Thanks in advance,
> 
> Wouter
> 

IMHO, that is very definitely the wrong way to do i18n! I say this from
a position of authority, as I have had to maintain systems like this in
the past, and it is just Plain Wrong :)

i18n is a very tricky topic, fortunately very smart people have spent a
long long time to come up with the best solution - gettext. It is
builtin to python, and is well supported by django. Read more about it
here:

http://docs.djangoproject.com/en/dev/topics/i18n/#topics-i18n

Your scenario is slightly more complicated than the examples shown
there, but the principle is the same. Instead of having separate fields
for each language translation, your field holds the key phrase which is
then used to lookup the correct translation in a gettext catalog.

Your change to your model would look like this:

class Country(models.Model):
description = models.CharField(...)

def __unicode__(self):
return ugettext_lazy(self.description)

I'm afraid this isn't a magic bullet though, for two reasons:

1) Your main aim seems to be to allow natural language ordering? I'm not
entirely sure how one could achieve that, as the ordering is done as
part of the DB query, which would not have access to the gettext catalog
- any ideas anyone?

2) As you add more instances of your model, you would need to be able to
add the translation of the description to the gettext catalog. This
might be fine in this specific case (how many countries will be
dynamically added later?), but wouldn't be for something slightly more
dynamic, like tag names. Again, any ideas anyone?

i18n, l10n and collation are pet peeves of mine, I am still yet to find
excellent solutions to all of these problems :)

Cheers

Tom


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-cms and flatpages with tiny_mce path problem

2009-05-07 Thread Jesse

Hello,

The thread link didn't go through.

On May 7, 12:25 pm, branesks  wrote:
> Follow this thread.
>
> Sent from my iPhone
>
> On May 7, 2009, at 12:09, Jesse  wrote:
>
>
>
> > Hello,
>
> > I've implemented both django-cms and flatpages, but can not get
> > tiny_mce to display in either.  My
>
> > URLs.py file:
> >    (r'^tinymce/', include('tinymce.urls')),
>
> > from django.conf import settings
> > if settings.DEBUG:
> >    urlpatterns += patterns('',
> >    (r'^site_media/(?P.*)$', 'django.views.static.serve',
> >            {'document_root': settings.MEDIA_ROOT}),
> > )
>
> > SETTINGS.py
>
> > TINYMCE_JS_URL = 'http://127.0.0.1:8000/site_media/js/tiny_mce/
> > tiny_mce.js'
> > TINYMCE_JS_ROOT = 'http://127.0.0.1:8000/site_media/js/tinymce/'
> > TINYMCE_DEFAULT_CONFIG = {
> >   'plugins': "table,spellchecker,paste,searchreplace",
> >   'theme': "advanced",
> >    'cleanup_on_startup': True,
> >    'custom_undo_redo_levels': 10,
> > }
> > TINYMCE_SPELLCHECKER = False
> > TINYMCE_COMPRESSOR = False
> > TINYMCE_FILEBROWSER = True
> > CMS_USE_TINYMCE = True
>
> > ADMIN.py
> > from django.contrib.flatpages.models import FlatPage
> > from django.contrib.flatpages.admin import FlatPageAdmin
> > #Flatpages
> > class FlatPageAdmin(FlatPageAdmin):
> >    class Media:
> >        js = ('http://127.0.0.1:8000/js/tiny_mce/tiny_mce.js',
> >              'http://127.0.0.1:8000/js/tiny_mce/textareas.js',)
>
> > # We have to unregister it, and then reregister
> > admin.site.unregister(FlatPage)
> > admin.site.register(FlatPage, FlatPageAdmin)
> > #django-cms
> > from myprograms.cms.models import Page
> > class PageOptions(admin.ModelAdmin):
> >    class Media:
> >        js = ('http://127.0.0.1:8000/site_media/js/tiny_mce/
> > tiny_mce.js', 'http://127.0.0.1:8000/site_media/js/tiny_mce/
> > textareas.js')
> > #admin.site.register(Page, PageOptions)
>
> > In the base.html file
> > 
> > 

Re: django-cms and flatpages with tiny_mce path problem

2009-05-07 Thread branesks

Follow this thread.

Sent from my iPhone

On May 7, 2009, at 12:09, Jesse  wrote:

>
> Hello,
>
> I've implemented both django-cms and flatpages, but can not get
> tiny_mce to display in either.  My
>
> URLs.py file:
>(r'^tinymce/', include('tinymce.urls')),
>
> from django.conf import settings
> if settings.DEBUG:
>urlpatterns += patterns('',
>(r'^site_media/(?P.*)$', 'django.views.static.serve',
>{'document_root': settings.MEDIA_ROOT}),
> )
>
> SETTINGS.py
>
> TINYMCE_JS_URL = 'http://127.0.0.1:8000/site_media/js/tiny_mce/
> tiny_mce.js'
> TINYMCE_JS_ROOT = 'http://127.0.0.1:8000/site_media/js/tinymce/'
> TINYMCE_DEFAULT_CONFIG = {
>   'plugins': "table,spellchecker,paste,searchreplace",
>   'theme': "advanced",
>'cleanup_on_startup': True,
>'custom_undo_redo_levels': 10,
> }
> TINYMCE_SPELLCHECKER = False
> TINYMCE_COMPRESSOR = False
> TINYMCE_FILEBROWSER = True
> CMS_USE_TINYMCE = True
>
> ADMIN.py
> from django.contrib.flatpages.models import FlatPage
> from django.contrib.flatpages.admin import FlatPageAdmin
> #Flatpages
> class FlatPageAdmin(FlatPageAdmin):
>class Media:
>js = ('http://127.0.0.1:8000/js/tiny_mce/tiny_mce.js',
>  'http://127.0.0.1:8000/js/tiny_mce/textareas.js',)
>
> # We have to unregister it, and then reregister
> admin.site.unregister(FlatPage)
> admin.site.register(FlatPage, FlatPageAdmin)
> #django-cms
> from myprograms.cms.models import Page
> class PageOptions(admin.ModelAdmin):
>class Media:
>js = ('http://127.0.0.1:8000/site_media/js/tiny_mce/
> tiny_mce.js', 'http://127.0.0.1:8000/site_media/js/tiny_mce/
> textareas.js')
> #admin.site.register(Page, PageOptions)
>
> In the base.html file
> 
> 

Re: admin inlines saving empty objects

2009-05-07 Thread modelmike

I, also, am receiving inexplicable "Please correct the errors below"
messages within templates with inlines that contain fields with
'blank=True' and / or 'null=True'.

The messages appear about every third or fourth save attempt that
involves empty strings.  But I'm unsure.  The bug is difficult to
recreate.

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



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

2009-05-07 Thread Margie

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-admin-templates

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



Re: Trouble Starting Up with runserver

2009-05-07 Thread George Song

On 5/7/2009 11:23 AM, Phil Mocek wrote:
> On Thu, May 07, 2009 at 12:49:28PM -0500, Tim Chase wrote:
>>> was searching for "interface" or "IP address" but the tutorial
>>> says -- incorrectly or colloqially, depending on how you see
>>> things -- "So to listen on all public IPs (useful if you want
>>> to show off your work on other computers), use:".  There's no
>>> such thing as a "public IP".
>> I suspect the intent is "external IP" compared to an internal IP 
>> (localhost/127.0.0.1).
> 
> I agree.
> 
> What makes the tutorial technically incorrect, and what prevents
> someone who seeks information about using the 0.0.0.0 IP address
> from finding that passage using reasonable search terms, is its
> omission of the word "address".  The subject at hand is an
> address, not a protocol, yet what was written is "public IP" not
> "public IP address".  This is fine for casual conversation, but --
> for reasons including that which was discovered in this discussion
> -- not for a technical tutorial whose target audience is software
> developers.

This is good clarification. It would be great if one of you can open a 
ticket and supply a patch.

-- 
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: Need help optimizing a view, too many queries

2009-05-07 Thread George Song

On 5/7/2009 11:16 AM, Eric Chamberlain wrote:
> 
> On May 7, 2009, at 10:36 AM, George Song wrote:
> 
>> On 5/7/2009 8:56 AM, Eric Chamberlain wrote:
>>> Our view is taking too long to render, can anyone offer suggestions  
>>> to
>>> improve its speed?
>>>
>>> There are 5830 profiles.
>>>
>>> /Total query count:/ 23809
>>> /Total duplicate query count:/ 493
>>> /Total SQL execution time:/ 66.003
>>> /Total Request execution time:/ 142.931
>>>
>>> class Profile(Model):
>>>id = UUIDField(primary_key=True)
>>>user = ForeignKey(User, verbose_name=_('user'), unique=True,  
>>> null=True)
>>>partner = ForeignKey('Partner')
>>>call_records = ManyToManyField('CallRecord', verbose_name=_('call
>>> record'), null=True, blank=True, help_text='Calls made by the user')
>>>
>>> class Partner(Model):
>>>id = UUIDField(primary_key=True)
>>>name = CharField(max_length=255, help_text='The name for the  
>>> partner')
>>>users = ManyToManyField(User, related_name='partner_users',
>>> null=True, blank=True, help_text='Users signed up specifically  
>>> through
>>> this partner')
>>>providers = ManyToManyField('Provider',
>>> related_name='provider_partners', blank=True, null=True,
>>> help_text="Calling services owned by this provider.")
>>>calls = ManyToManyField('CallRecord',  
>>> related_name='call_partners',
>>> blank=True, null=True, help_text='Calls made through this calling  
>>> service.')
>>>
>>> class CallRecord(Model):
>>>id = UUIDField(primary_key=True)
>>>provider_account = ForeignKey('ProviderAccount', null=True,
>>> blank=True, help_text='The calling service, if any, the call was made
>>> through')
>>>provider = ForeignKey('Provider', blank=True, null=True,
>>> help_text='The calling service the call was made through')
>>>
>>> class Provider(Model):
>>>id = UUIDField(primary_key=True)
>>>name = CharField(max_length=255)
>>>
>>> class ProviderAccount(Model):
>>>provider = ForeignKey('Provider', help_text='The calling service
>>> this account works with')
>>>username = TextField()
>>>encrypted_password = TextField(db_column='password')
>>>user = ForeignKey(User, help_text='The user this calling service
>>> account belongs to')
>>>
>>>
>>> profiles =
>>> Profile 
>>> .objects 
>>> .filter(partner=request.partner,user__is_active=True).order_by('- 
>>> user__date_joined')
>>> for p in profiles:
>>>  p.provider_list = list(
>>>  account.provider for account in
>>> ProviderAccount 
>>> .objects 
>>> .filter(user=p.user,provider__provider_partners=request.partner))
>>>  p.call_count = p.call_records.filter().count()
>>> return PartnerResponse(request, {'profiles': profiles})
>>>
>>> PartnerResponse returns the view to the user, the template uses a for
>>> loop to iterate through the profiles.
>> Well, it seems like what you're really after is the ProviderAccount,  
>> right?
>>
>> So you can just pass this to your template:
>> {{{
>> accounts =
>> ProviderAccount 
>> .objects 
>> .filter(provider__provider_partners=request.partner).order_by('- 
>> user__date_joined')
>> }}}
>>
>> In your template you can regroup accounts by user and you should be  
>> good
>> to go, right?
>>
> 
> We are after user information and a user can have 0 or more  
> ProviderAccounts.
> 
> The template looks like:
> 
> {% for profile in profiles %}
>  
>  {{profile.user.email}}
>  {{profile.user.first_name}} {{profile.user.last_name}}
>  {{profile.user.date_joined|date:"Y M d H:i"  }}
>  
>  {% for calling_service in profile.provider_list %}
>  {{calling_service.name}} a>{% if not forloop.last %}{% endif %}
>  {% endfor %}
>  
>  
>  {% for sim in profile.sims.all %}
>  {{sim.caller_id}}{% if not forloop.last %}{% endif %}
>  {% endfor %}
>  
>  {{profile.call_count}}
>  
>  
> {% endfor %}

I'll have to look at this some more when I have time. But you can 
eliminate call_count right off the bat, right? Since that can be 
accessed directly via `profile.call_records.count` directly on the template.

-- 
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: Trouble Starting Up with runserver

2009-05-07 Thread Phil Mocek

On Thu, May 07, 2009 at 12:49:28PM -0500, Tim Chase wrote:
> > was searching for "interface" or "IP address" but the tutorial
> > says -- incorrectly or colloqially, depending on how you see
> > things -- "So to listen on all public IPs (useful if you want
> > to show off your work on other computers), use:".  There's no
> > such thing as a "public IP".
> 
> I suspect the intent is "external IP" compared to an internal IP 
> (localhost/127.0.0.1).

I agree.

What makes the tutorial technically incorrect, and what prevents
someone who seeks information about using the 0.0.0.0 IP address
from finding that passage using reasonable search terms, is its
omission of the word "address".  The subject at hand is an
address, not a protocol, yet what was written is "public IP" not
"public IP address".  This is fine for casual conversation, but --
for reasons including that which was discovered in this discussion
-- not for a technical tutorial whose target audience is software
developers.

-- 
Phil Mocek

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 optimizing a view, too many queries

2009-05-07 Thread Eric Chamberlain


On May 7, 2009, at 10:36 AM, George Song wrote:

>
> On 5/7/2009 8:56 AM, Eric Chamberlain wrote:
>> Our view is taking too long to render, can anyone offer suggestions  
>> to
>> improve its speed?
>>
>> There are 5830 profiles.
>>
>> /Total query count:/ 23809
>> /Total duplicate query count:/ 493
>> /Total SQL execution time:/ 66.003
>> /Total Request execution time:/ 142.931
>>
>> class Profile(Model):
>>id = UUIDField(primary_key=True)
>>user = ForeignKey(User, verbose_name=_('user'), unique=True,  
>> null=True)
>>partner = ForeignKey('Partner')
>>call_records = ManyToManyField('CallRecord', verbose_name=_('call
>> record'), null=True, blank=True, help_text='Calls made by the user')
>>
>> class Partner(Model):
>>id = UUIDField(primary_key=True)
>>name = CharField(max_length=255, help_text='The name for the  
>> partner')
>>users = ManyToManyField(User, related_name='partner_users',
>> null=True, blank=True, help_text='Users signed up specifically  
>> through
>> this partner')
>>providers = ManyToManyField('Provider',
>> related_name='provider_partners', blank=True, null=True,
>> help_text="Calling services owned by this provider.")
>>calls = ManyToManyField('CallRecord',  
>> related_name='call_partners',
>> blank=True, null=True, help_text='Calls made through this calling  
>> service.')
>>
>> class CallRecord(Model):
>>id = UUIDField(primary_key=True)
>>provider_account = ForeignKey('ProviderAccount', null=True,
>> blank=True, help_text='The calling service, if any, the call was made
>> through')
>>provider = ForeignKey('Provider', blank=True, null=True,
>> help_text='The calling service the call was made through')
>>
>> class Provider(Model):
>>id = UUIDField(primary_key=True)
>>name = CharField(max_length=255)
>>
>> class ProviderAccount(Model):
>>provider = ForeignKey('Provider', help_text='The calling service
>> this account works with')
>>username = TextField()
>>encrypted_password = TextField(db_column='password')
>>user = ForeignKey(User, help_text='The user this calling service
>> account belongs to')
>>
>>
>> profiles =
>> Profile 
>> .objects 
>> .filter(partner=request.partner,user__is_active=True).order_by('- 
>> user__date_joined')
>> for p in profiles:
>>  p.provider_list = list(
>>  account.provider for account in
>> ProviderAccount 
>> .objects 
>> .filter(user=p.user,provider__provider_partners=request.partner))
>>  p.call_count = p.call_records.filter().count()
>> return PartnerResponse(request, {'profiles': profiles})
>>
>> PartnerResponse returns the view to the user, the template uses a for
>> loop to iterate through the profiles.
>
> Well, it seems like what you're really after is the ProviderAccount,  
> right?
>
> So you can just pass this to your template:
> {{{
> accounts =
> ProviderAccount 
> .objects 
> .filter(provider__provider_partners=request.partner).order_by('- 
> user__date_joined')
> }}}
>
> In your template you can regroup accounts by user and you should be  
> good
> to go, right?
>

We are after user information and a user can have 0 or more  
ProviderAccounts.

The template looks like:

{% for profile in profiles %}
 
 {{profile.user.email}}
 {{profile.user.first_name}} {{profile.user.last_name}}
 {{profile.user.date_joined|date:"Y M d H:i"  }}
 
 {% for calling_service in profile.provider_list %}
 {{calling_service.name}}{% if not forloop.last %}{% endif %}
 {% endfor %}
 
 
 {% for sim in profile.sims.all %}
 {{sim.caller_id}}{% if not forloop.last %}{% endif %}
 {% endfor %}
 
 {{profile.call_count}}
 
 
{% endfor %}





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



django-cms and flatpages with tiny_mce path problem

2009-05-07 Thread Jesse

Hello,

I've implemented both django-cms and flatpages, but can not get
tiny_mce to display in either.  My

URLs.py file:
(r'^tinymce/', include('tinymce.urls')),

from django.conf import settings
if settings.DEBUG:
urlpatterns += patterns('',
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)

SETTINGS.py

TINYMCE_JS_URL = 'http://127.0.0.1:8000/site_media/js/tiny_mce/
tiny_mce.js'
TINYMCE_JS_ROOT = 'http://127.0.0.1:8000/site_media/js/tinymce/'
TINYMCE_DEFAULT_CONFIG = {
   'plugins': "table,spellchecker,paste,searchreplace",
   'theme': "advanced",
'cleanup_on_startup': True,
'custom_undo_redo_levels': 10,
}
TINYMCE_SPELLCHECKER = False
TINYMCE_COMPRESSOR = False
TINYMCE_FILEBROWSER = True
CMS_USE_TINYMCE = True

ADMIN.py
from django.contrib.flatpages.models import FlatPage
from django.contrib.flatpages.admin import FlatPageAdmin
#Flatpages
class FlatPageAdmin(FlatPageAdmin):
class Media:
js = ('http://127.0.0.1:8000/js/tiny_mce/tiny_mce.js',
  'http://127.0.0.1:8000/js/tiny_mce/textareas.js',)

# We have to unregister it, and then reregister
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageAdmin)
#django-cms
from myprograms.cms.models import Page
class PageOptions(admin.ModelAdmin):
class Media:
js = ('http://127.0.0.1:8000/site_media/js/tiny_mce/
tiny_mce.js', 'http://127.0.0.1:8000/site_media/js/tiny_mce/
textareas.js')
#admin.site.register(Page, PageOptions)

In the base.html file



There are so many different options when accessing the various user
groups, docs, etc.  I'm not sure what is the correct syntax.  The CMS
doesn't do me much good without some kind of text editor.
Thx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Aggregated Expression.

2009-05-07 Thread George Song

On 5/7/2009 10:42 AM, overgroove wrote:
> I have the following models:
> 
> Customer
> Order
> Lineitem
> 
> Customers have orders and orders have lineitems.  In lineitems there's
> a product price and a product quantity.  I would like to be able to,
> using django querysets and whatever magic I have to do, to annotate
> the multiplication of price and quantity in lineitem to the customer.
> I know I can do this with raw sql, however, I'd like to do it with
> querysets so that I can afterwards apply a filter.  I've tried a hack
> where I perform some trivial annotation to the customer based on a
> lineitem (which gives me the appropriate joins) and then add SUM(price
> * quantity) with extra() to the select.  However, this column also
> gets added to the group by clause, rendering the query useless.

There might be a fancy way to do this in QuerySet, but I don't know how.

I personally would just write a custom method on Customer or Order to do 
this for you, depending on what level of aggregation you need.

-- 
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: Template issue

2009-05-07 Thread Colin Bean

On Thu, May 7, 2009 at 2:13 AM, 83nini <83n...@gmail.com> wrote:
>
> Hi guys,
>
> I have a template.surf which i'm trying to style with CSS external
> file, but it's not working! any idea how to deal with .surf templates?
> and how to style them with the CSS external files?
> internally working, externally...NOT!
>
> cheers.
> >
>

I don't know what a .surf template is, but can you access the
stylesheet in your browser at the URL your template is using?  If you
want further help debugging that, you'll need to provide some
information about your setup and how you're serving static media.

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: Trouble Starting Up with runserver

2009-05-07 Thread Tim Chase

> was searching for "interface" or "IP address" but the tutorial
> says -- incorrectly or colloqially, depending on how you see
> things -- "So to listen on all public IPs (useful if you want
> to show off your work on other computers), use:".  There's no
> such thing as a "public IP".

I suspect the intent is "external IP" compared to an internal IP 
(localhost/127.0.0.1).  By default Django only listens on 
localhost ("private" or "internal").  If your machine is 
multi-homed (has multiple IP addresses such as a dialup, aircard, 
VPN, LAN, wireless, etc), you can specify that Django listens on 
a single address such as 192.168.1.99 (which should be bound to a 
single interface).  If you specify 0.0.0.0 Django will listen on 
any interfaces/IP-address.  These latter cases would be "public" 
or "external".

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



Aggregated Expression.

2009-05-07 Thread overgroove

I have the following models:

Customer
Order
Lineitem

Customers have orders and orders have lineitems.  In lineitems there's
a product price and a product quantity.  I would like to be able to,
using django querysets and whatever magic I have to do, to annotate
the multiplication of price and quantity in lineitem to the customer.
I know I can do this with raw sql, however, I'd like to do it with
querysets so that I can afterwards apply a filter.  I've tried a hack
where I perform some trivial annotation to the customer based on a
lineitem (which gives me the appropriate joins) and then add SUM(price
* quantity) with extra() to the select.  However, this column also
gets added to the group by clause, rendering the query useless.

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: Need help optimizing a view, too many queries

2009-05-07 Thread George Song

On 5/7/2009 8:56 AM, Eric Chamberlain wrote:
> Our view is taking too long to render, can anyone offer suggestions to 
> improve its speed?
> 
> There are 5830 profiles.
> 
> /Total query count:/ 23809
> /Total duplicate query count:/ 493
> /Total SQL execution time:/ 66.003
> /Total Request execution time:/ 142.931
> 
> class Profile(Model):
> id = UUIDField(primary_key=True)
> user = ForeignKey(User, verbose_name=_('user'), unique=True, null=True)
> partner = ForeignKey('Partner')
> call_records = ManyToManyField('CallRecord', verbose_name=_('call 
> record'), null=True, blank=True, help_text='Calls made by the user')
> 
> class Partner(Model):
> id = UUIDField(primary_key=True)
> name = CharField(max_length=255, help_text='The name for the partner')
> users = ManyToManyField(User, related_name='partner_users', 
> null=True, blank=True, help_text='Users signed up specifically through 
> this partner')
> providers = ManyToManyField('Provider', 
> related_name='provider_partners', blank=True, null=True, 
> help_text="Calling services owned by this provider.")
> calls = ManyToManyField('CallRecord', related_name='call_partners', 
> blank=True, null=True, help_text='Calls made through this calling service.')
> 
> class CallRecord(Model):
> id = UUIDField(primary_key=True)
> provider_account = ForeignKey('ProviderAccount', null=True, 
> blank=True, help_text='The calling service, if any, the call was made 
> through')
> provider = ForeignKey('Provider', blank=True, null=True, 
> help_text='The calling service the call was made through')
> 
> class Provider(Model):
> id = UUIDField(primary_key=True)
> name = CharField(max_length=255)
> 
> class ProviderAccount(Model):
> provider = ForeignKey('Provider', help_text='The calling service 
> this account works with')
> username = TextField()
> encrypted_password = TextField(db_column='password')
> user = ForeignKey(User, help_text='The user this calling service 
> account belongs to')
> 
> 
> profiles = 
> Profile.objects.filter(partner=request.partner,user__is_active=True).order_by('-user__date_joined')
> for p in profiles:
>   p.provider_list = list(
>   account.provider for account in 
> ProviderAccount.objects.filter(user=p.user,provider__provider_partners=request.partner))
>   p.call_count = p.call_records.filter().count()
> return PartnerResponse(request, {'profiles': profiles})
> 
> PartnerResponse returns the view to the user, the template uses a for 
> loop to iterate through the profiles.

Well, it seems like what you're really after is the ProviderAccount, right?

So you can just pass this to your template:
{{{
accounts = 
ProviderAccount.objects.filter(provider__provider_partners=request.partner).order_by('-user__date_joined')
}}}

In your template you can regroup accounts by user and you should be good 
to go, right?

-- 
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: Trouble Starting Up with runserver

2009-05-07 Thread Phil Mocek

On Thu, May 07, 2009 at 09:01:01AM -0700, donarb wrote:
> On May 7, 8:43 am, Phil Mocek wrote:
> > This, unfortunately, is not explained in the runserver
> > documentation [1] or the admin utility's built-in help.  The
> > only place I've found it documented is in chapter two of The
> > Django Book [2].
> 
> It is also documented in the tutorial:
> 
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-a-project

Thanks.  I plan to open a ticket for an update to the documentation
if one doesn't already exist.  I'll add this information.

I missed this mention of 0.0.0.0 because I was searching for
"interface" or "IP address" but the tutorial says -- incorrectly or
colloqially, depending on how you see things -- "So to listen on all
public IPs (useful if you want to show off your work on other
computers), use:".  There's no such thing as a "public IP".

-- 
Phil Mocek

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



Can't visit any url but the root?

2009-05-07 Thread Shadow

Hi, I'm not sure what I've done wrong but I get the following error if
I visit any url but "/".


Environment:

Request Method: GET
Request URL: http://fusion-gospel/test
Django Version: 1.1 beta 1 SVN-10658
Python Version: 2.5.2
Installed Applications:
['django.contrib.contenttypes', 'django.contrib.sites',
'fusion_gospel.fusion']
Installed Middleware:
('django.middleware.common.CommonMiddleware',)


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  83. request.path_info)

Exception Type: TypeError at test
Exception Value: 'NoneType' object is not iterable


and urls.py:

===
from django.conf.urls.defaults import *

urlpatterns = patterns('fusion_gospel.fusion.views',
(r'^$', 'main'),
(r'^swap/(?P[-\w]+)/(?P[-\w]+)/(?Pmt|mk|lk|jn)/
$', 'swap'),
)
===

I don't get 404s for other urls, just the above error message.

Any ideas?

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



running django as egg KeyError: 'startproject'

2009-05-07 Thread rich.al...@gmail.com

I've got django running fine and my app/project. I'm testing out a
deploy on a fresh machine and wanted to use django as a egg. Did the
following,and per the link on the django site, pulled out django-
admin.py (although won't need to run that on the deployed machines)

export PYTHONPATH=~/egg/Django-1.1_beta_1-py2.5.egg

(starting python and doing an import django works, with django.VERSION
reporting that eggs version)

$cd ~/mydjangoproject

Basically, any manage.py command gives the following error

$ python manage.py help
Usage: manage.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal
output, 2=all output
  --settings=SETTINGS   The Python path to a settings module, e.g.
"myproject.settings.main". If this
isn't provided, the DJANGO_SETTINGS_MODULE
environment variable will be used.
  --pythonpath=PYTHONPATH
A directory to add to the Python path, e.g. "/
home/djangoprojects/myproject".
  --traceback   Print traceback on exception
  --version show program's version number and exit
  -h, --helpshow this help message and exit
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/home/deploy/eggs/Django-1.1_beta_1-py2.5.egg/django/core/
management/__init__.py", line 359, in execute_manager

  File "/home/deploy/eggs/Django-1.1_beta_1-py2.5.egg/django/core/
management/__init__.py", line 293, in execute

  File "/home/deploy/eggs/Django-1.1_beta_1-py2.5.egg/django/core/
management/__init__.py", line 240, in main_help_text

  File "/home/deploy/eggs/Django-1.1_beta_1-py2.5.egg/django/core/
management/__init__.py", line 126, in get_commands

KeyError: 'startproject'

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

2009-05-07 Thread sggottlieb

For anyone else trying to figure this out, I think I found the
answer.

See InlineModelAdmin:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

To translate into my example...

class PersonPositionInline(admin.TabularInline):
model = PersonPosition

class PersonAdmin(admin.ModelAdmin):
inlines = [
PersonPositionInline,
]


On May 7, 7:31 am, sggottlieb  wrote:
> For some reason I can't reply to this thread about Many to One (http://
> groups.google.com/group/django-users/browse_thread/thread/
> 180feab07df9dfe6/17301e3fcaa92a33?lnk=gst&q=many+to
> +one#17301e3fcaa92a33) so I will re-open here.
>
> I am looking for an answer to  Puneet's question: "but if there's
> something like one-many it could implicitly tell Django to add objects
> inline with the parent object."  My model has a "Person" with multiple
> "PersonPosition" (AKA job) objects.  So, in my model, I have something
> like this:
>
> class PersonPosition(models.Model):
>         user = models.ForeignKey(Person)
>
> Users will only creating PersonPosition objects from the person.  They
> will not be creating a PersonPosition object and then picking a Person
> to relate to.
>
> Is the proper way to handle this to implement add and remove methods
> onto my Person class?  How would I expose those methods into the Admin
> UI?
>
> Thanks,
>
> Seth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Trouble Starting Up with runserver

2009-05-07 Thread donarb

On May 7, 8:43 am, Phil Mocek 
wrote:
> This, unfortunately, is not explained in the
> runserver documentation [1] or the admin utility's built-in help.
> The only place I've found it documented is in chapter two of The
> Django Book [2].

It is also documented in the tutorial:

http://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-a-project

Don



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 optimizing a view, too many queries

2009-05-07 Thread Eric Chamberlain
Our view is taking too long to render, can anyone offer suggestions to  
improve its speed?

There are 5830 profiles.

Total query count: 23809
Total duplicate query count: 493
Total SQL execution time: 66.003
Total Request execution time: 142.931

class Profile(Model):
 id = UUIDField(primary_key=True)
 user = ForeignKey(User, verbose_name=_('user'), unique=True,  
null=True)
 partner = ForeignKey('Partner')
 call_records = ManyToManyField('CallRecord', verbose_name=_('call  
record'), null=True, blank=True, help_text='Calls made by the user')

class Partner(Model):
 id = UUIDField(primary_key=True)
 name = CharField(max_length=255, help_text='The name for the  
partner')
 users = ManyToManyField(User, related_name='partner_users',  
null=True, blank=True, help_text='Users signed up specifically through  
this partner')
 providers = ManyToManyField('Provider',  
related_name='provider_partners', blank=True, null=True,  
help_text="Calling services owned by this provider.")
 calls = ManyToManyField('CallRecord',  
related_name='call_partners', blank=True, null=True, help_text='Calls  
made through this calling service.')

class CallRecord(Model):
 id = UUIDField(primary_key=True)
 provider_account = ForeignKey('ProviderAccount', null=True,  
blank=True, help_text='The calling service, if any, the call was made  
through')
 provider = ForeignKey('Provider', blank=True, null=True,  
help_text='The calling service the call was made through')

class Provider(Model):
 id = UUIDField(primary_key=True)
 name = CharField(max_length=255)

class ProviderAccount(Model):
 provider = ForeignKey('Provider', help_text='The calling service  
this account works with')
 username = TextField()
 encrypted_password = TextField(db_column='password')
 user = ForeignKey(User, help_text='The user this calling service  
account belongs to')


profiles =  
Profile 
.objects 
.filter(partner=request.partner,user__is_active=True).order_by('- 
user__date_joined')
for p in profiles:
   p.provider_list = list(
   account.provider for account in  
ProviderAccount 
.objects 
.filter(user=p.user,provider__provider_partners=request.partner))
   p.call_count = p.call_records.filter().count()
return PartnerResponse(request, {'profiles': profiles})

PartnerResponse returns the view to the user, the template uses a for  
loop to iterate through the profiles.



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



QuerySet in FormSets?

2009-05-07 Thread jason.t.stein

Is the initial querySet availble in a template rendering a formset? I
would like to display values from the querySet, along with the 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: Trouble Starting Up with runserver

2009-05-07 Thread Phil Mocek

On Thu, May 07, 2009 at 07:17:08AM -0700, John Crawford wrote:
> I'm not sure why your address is all zeros, did you give a
> specific host number parameter to runserver?

That causes the development server to listen on all available
network interfaces.  This, unfortunately, is not explained in the
runserver documentation [1] or the admin utility's built-in help.
The only place I've found it documented is in chapter two of The
Django Book [2].  This is not Django-specific, as RFC 3330
("Special-Use IPv4 Addresses") [3] defines addresses in the
0.0.0.0/8 block as referring to "source hosts on `this' network",
but it seems that it would be helpful to note this in the Django
docs for people who are unfamiliar with this convention.

> Generally 127.0.0.0:8000 would be your localhost

That would cause the development server to listen on port 8000 of
whatever interface uses 127.0.0.0.  The hostname "localhost" [4]
typically resolves to 127.0.0.1, the address of the loopback
interface [5].


References:

[1]: 
[2]: 
[3]: 
[4]: 
[5]: 

-- 
Phil Mocek

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



Internationalization (i18n) of model: request.LANGUAGE_CODE in __unicode__ and ordering?

2009-05-07 Thread Wouter van der Graaf

Hi there,

Spent hours trying to find the solution, but no luck. So here goes...

Please consider simplified code below:

{{{
class Country(models.Model):
...
label_en = models.CharField(max_length = 128, blank=True,
null=True)
label_nl = models.CharField(max_length = 128, blank=True,
null=True)

class Meta:
ordering = ('label_en',)

def __unicode__(self):
if hasattr(settings, 'LANGUAGE_CODE'):
field = 'label_%s' % settings.LANGUAGE_CODE.lower()
if hasattr(self, field):
return getattr(self, field)
return self.label_en
}}}

Other models use Country with a ForeignKey relationship. The
__unicode__ function works for displaying localized country names. If
LANGUAGE_CODE is 'nl' then the drop down selectbox for Country in the
admin shows Dutch country names, otherwise all country names are
English.

But it's not exactly what you'd want. Now I want to be able to do two
things:

 1. Change __unicode__ to use request.LANGUAGE_CODE, the user
preference.
 2. Change ordering to the chosen language field. You don't want a
list in Dutch, ordered by English translations.

All this is happening runtime, of course. Users in a admin edit page,
using a drop down for the foreign key Country, should see the country
names and ordering change when they select another language.

Possible? Other ways to achieve a runtime language dependent model?

Thanks in advance,

Wouter

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ManyToMany relationships in an object creation view

2009-05-07 Thread George Song

On 5/3/2009 12:59 AM, notcourage wrote:
> I'm interested in hearing how you cope w/ the problem of specifying
> ManyToMany relationships in an object creation view. Consider two
> models M1 & M2 and a creation view/form for M1. A technique I'm using
> is to specify M2 values as an unbound field in a ModelForm for M1.
> When the form validates:
> m1Form.save()
> I convert m1Form['m2'] into ManyToMany relationship chgs. This works
> but it defeats the purpose of ModelForm.
> 
> I'm making use of a scrolling  of checkboxes instead of a shuttle
> widget (takes up too much space) or a multi-select widget (easy to
> mess up the selection). I'm considering creating a custom widget for
> the MultipleChoiceField. Is this practical or a good idea?

I don't think you need to create a custom widget. There's already a 
`CheckboxSelectMultiple` widget that you can use.

{{{
from django.db import models
from django import forms

class Pizza(models.Model):
 name = models.CharField(max_length=50)
 toppings = models.ManyToManyField('Topping')

 def __unicode__(self):
 return self.name

class Topping(models.Model):
 name = models.CharField(max_length=50)

 def __unicode__(self):
 return self.name

class PizzaForm(forms.ModelForm):
 TOPPINGS_CHOICES = [(t.pk, t) for t in Topping.objects.all()]
 toppings = forms.MultipleChoiceField(
 choices=TOPPINGS_CHOICES, widget=forms.CheckboxSelectMultiple)

 class Meta:
 model = Pizza

 >>> from m2m.models import PizzaForm
 >>> f = PizzaForm()
 >>> print f['toppings']

 Pesto
 Garlic

}}}

-- 
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: environment variable DJANGO_SETTINGS_MODULE is undefined

2009-05-07 Thread bconnors


pubu...@pubuntu:~/django-trunk/build/lib/django/bin/myapp1
export DJANGO_SETTINGS_MODULE=myapp1.settings
export PYTHONPATH=/usr/lib/python2.5/site-packages
django-admin.py dumpdata
Error: Could not import settings 'myapp1.settings' (Is it on sys.path?
Does it h
ave syntax errors?): No module named myapp1.settings
pubu...@pubuntu:~/django-trunk/build/lib/django/bin/myapp1$

my settings.py has

)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'myapp1.person',
)
pubu...@pubuntu:~/django-trunk/build/lib/django/bin/myapp1$

I tried doing export DJANGO_SETTINGS_MODULE=myapp1.person as in
settings.py, but got same error.


On May 7, 10:30 am, Sieker Adi Jörg  wrote:
> Hi,
>
> On 07.05.2009, at 16:02, bconnors wrote:
>
>
>
>
>
>
>
> > I saw this chat related to DJANGO_SETTINGS_MODULE is undefined.
> > Hello I am new to Django.
> > I am trying to exercise "templates" through the interactive shell,
> > however I end up getting this error. Can anyone help?
> > here is the exact steps I follow:
> > 1) cd C:\Django\mysite
> > 2) set DJANGO_SETTINGS_MODULE=mysite.settings I've also tried set
> > DJANGO_SETTINGS_MODULE=settings.py
> > 3) python
> > 4) >>> from django.template import Template
>  t = Template("My name is {{ name }}.")
> > 5) ERROR: ImportError: Settings cannot be imported, because
> > environment variable DJANGO_SETTINGS_MODULE is undefined
>
> The above is for windows and not unix.
>
>
>
>
>
> > - Show quoted text -
>
> > Setting it to mysite.settings will work if c:\django is on your
> > PYTHONPATH.
> > Setting it to settings.py won't work at all because of the .py.
> > Assuming
> > you are running the python from c:\django\mysite, setting
> > DJANGO_SETTINGS_MODULE to just 'settings' will work.  Or, use 'python
> > manage.py shell', which assumes settings.py is in the current
> > directory and
> > sets the environment up for you.
> > Karen
>
> > So I did
>
> > 1
> > export PYTHONPATH=/usr/lib/python2.5/site-packages
>
> > 2
> > set DJANGO_SETTINGS_MODULE=myapp1.settings
>
> This should be: export not set.
> set is a window command and doesn't or does something different under  
> *nix.
>
>
>
> > 3
> > settings.py has :
>
> > INSTALLED_APPS = (
> >    'django.contrib.auth',
> >    'django.contrib.contenttypes',
> >    'django.contrib.sessions',
> >    'django.contrib.sites',
> >    'myapp1.person',
> > )
>
> > when I do
> > django-admin.py dumpdata
> > Error: Settings cannot be imported, because environment variable
> > DJANGO_SETTINGS
> > _MODULE is undefined.
> > pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite/myapp$
>
> > on the Django Congratulations screen it has myapp1
> > what am I doing wrong?- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with overriding save() method

2009-05-07 Thread Lee Hinde

On Wed, May 6, 2009 at 11:37 PM, George Song  wrote:
>
> On 5/6/2009 11:18 PM, Lee Hinde wrote:
>> On Wed, May 6, 2009 at 11:15 PM, Lee Hinde  wrote:
>>> On Wed, May 6, 2009 at 10:54 PM, George Song  wrote:
 On 5/6/2009 10:34 PM, Lee Hinde wrote:
> On Wed, May 6, 2009 at 10:22 PM, George Song  wrote:
>> On 5/6/2009 9:57 PM, Lee Hinde wrote:
>>> I have this as part of the model for a class called "Class"
>>>
>>>
>>>     def save(self, force_insert=False, force_update=False):
>>>         start = defaultfilters.slugify(self.Name)
>>>         count = Class.objects.filter(Slug__equal=start).count()
>>>         if count != 0:
>>>             filterme = "%s_%d" % (self.Name, count)
>>>             self.Slug = defaultfilters.slugify(filterme)
>>>         else:
>>>             self.Slug = start
>>>
>>>
>>> The reason is, it's ok to have duplicate Names,  and I want to use a
>>> Slug as the canonical url.
>>>
>>> I have a bunch of data to import and so , in shell I run
>>>
>>>  c = Class.objects.all()
>>> for o in c:
>>>     o.save()
>>>
>>>
>>> My goal would be to see something like:
>>>
>>> yoga-for-kids
>>> yoga-for-kids_1
>>> yoga-for-kids_2
>>>
>>> What's weird is I'm getting:
>>>
>>> yoga-for-kids
>>> yoga-for-kids
>>> yoga-for-kids_2
>>>
>>> i.e., I get dupes and then not.
>>> hasn't
>>> I've played with it most of the evening and now I'm hoping someone
>>> with a fresh pair of eyes might have a suggestion.
>>>
>>> Thanks in advance.
>> I'm not sure why you're getting yoga-for-kids_2, what I expect is
>> yoga-for-kids, yoga-for-kids_1, then more yoga-for-kids_1 if your slug
>> field is not unique=True.
>>
>> In any case, your logic will keep generating yoga-for-kids_1 because
>> there will only ever be one count for yoga-for-kids in your DB.
>>
> Well, depends on when it's run, right? yoga-for-kids_1 would be the
> correct response for the 2nd record.
>
>  In this case I'm updating imported data, so there's a pre-existing
> match. If it's a new record, it should come back zero, sine the record
> hasn't been saved yet?
>
> Thanks for looking at it.
 Well, I imagine your Class.Name for your test case is "Yoga For Kids",
 right?

 So your `start` is always going to be "yoga-for-kids" no matter what.

 Since you're search on that slug, you should only ever have one record
 since your slugs are supposed to be unique. So your re-generated slug
 will always be "yoga-for-kids_1".

 --
 George

>>>
>>> Yes, I see what you're saying and it means I've left out a step.
>>> Before I run the model.save() loop, I clear the existing slug data, so
>>> it starts clean each run.
>>>
>>
>> But still should always leave me with 1... So, how did I end up with 2
>> blanks and one 2?
>>
>> Assuming I start off with blanks.
>>
>> First time - no match, save as is
>> Second time - one match save as X_1
>> third time, still one match (this is what you described), should save
>> again as x_1 (I'd tried 'startedwith' but that had other problems.)
>
> I can't be sure what your exact conditions are, but in my test, the
> result is exactly as I described:
>
> {{{
> from django.db import models
> from django.template.defaultfilters import slugify
>
> class Class(models.Model):
>     name = models.CharField(max_length=50)
>     slug = models.SlugField()
>
>     def save(self, force_insert=False, force_update=False):
>         self.slug = slugify(self.name)
>         count = self.__class__.objects.filter(slug=self.slug).count()
>         if count:
>             self.slug = '%s_%d' %(self.slug, count)
>         super(Class, self).save(force_insert, force_update)
>
>  >>> from yoga.models import Class
>  >>> c1 = Class.objects.create(name='Yoga For Kids')
>  >>> c2 = Class.objects.create(name='Yoga For Kids')
>  >>> c3 = Class.objects.create(name='Yoga For Kids')
>  >>> c1.slug
> u'yoga-for-kids'
>  >>> c2.slug
> u'yoga-for-kids_1'
>  >>> c3.slug
> u'yoga-for-kids_1'
> }}}
>
> --
> George


George, thanks very much for the effort.

I'd appreciate any suggestions on the right way to code this.

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



Re: ManyToManyField and Manager.exclude()

2009-05-07 Thread Riccardo Pelizzi

duh, i forgot to say that i had 477 registered domain in the database
and 0 hosts before i run this code :-)

On 7 Mai, 15:40, Riccardo Pelizzi  wrote:
> Sorry for the delay. hosts__isnull works!
> But i can confirm exclude doesn't:
>
> h = Host.objects.create(ip="0.0.0.0")
> d = RegisteredDomain.objects.all()[0]
> d.hosts.add(h)
> RegisteredDomain.objects.count()
> --> 477L (total)
> RegisteredDomain.objects.filter(hosts=None).count()
> --> 476L (good!)
> RegisteredDomain.objects.exclude(hosts=None).count()
> --> 0 (not so good :-/)
> RegisteredDomain.objects.filter(hosts__isnull=False).count()
> --> 1L (good!)
>
> I will paste you both models to be sure:
>
> class Host(TimeStampedModel):
>     ip = models.IPAddressField(unique=True)
>
> class RegisteredDomain(TimeStampedModel):
>     domain = models.CharField(max_length=255, unique=True)
>     spam_time = models.DateTimeField(null=True)
>     hosts = models.ManyToManyField(Host,
> related_name="registered_domains")
>     random = models.BooleanField(null=True)
>
> Is this a bug or i just didn't get how models work? :-)
>
> Riccardo
>
> On 4 Mai, 21:22, Malcolm Tredinnick  wrote:
>
> > On Mon, 2009-05-04 at 09:18 -0700, Riccardo Pelizzi wrote:
> > > Hello,
>
> > > I have a model which looks kinda like this:
>
> > > class Host(model):
> > >   ip = IPAddressField()
>
> > > class Domain(model):
> > >   hosts = ManyToManyField(Host)
>
> > > If i want to get all the domains without hosts:
> > > Domain.objects.filter(hosts=None)
> > > works.
>
> > > Later on in my script i need to get the opposite, all the domains
> > > having one or more hosts associated. using exclude instead of filter
> > > with the same condition doesn't work as expected (at least as I
> > > expected :-P), it just returns an empty queryset. Is there a way to
> > > formulate thequeryusing the django api? or should i use custom sql?
>
> > That should work properly. It works for me using exactly your models
> > with a few different Host/Domain combinations.
>
> > The SQL we currently generate for Domain.objects.exclude(hosts=None) is
> > a little inefficient, but it's not fundamentally incorrect. It just uses
> > a couple more tables than it needs to be because the "NULL" case can
> > take advantage of one particular extra optimisation that isn't in the
> > code yet. I'm surprised it isn't returning the correct result.
>
> > Another to get the same answer, which generates simpler SQL but is
> > potentially a little less efficient on the database side is
>
> >         Domain.objects.filter(hosts__isnull=False).distinct()
>
> > That's essentially the only case where Django has a "not" filter
> > available: you can actually filter for "not NULL". The distinct() call
> > there is important, as for many-to-many fields, you would otherwise get
> > back one domain object for every host (so repetitions for domains with
> > multiple hosts), not just the set of domains that have at least one
> > host.
>
> > In any case, I suspect there's something else going on in your
> > particular case, as the SQL generated should be pulling back the results
> > you're after and it works with a small example using your models. If you
> > can use those models, as pasted, to generate an incorrect result, what
> > is the smallest amount of data (Host & Domain objects) you need to
> > create to demonstrate the problem. That would be interesting to see.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: environment variable DJANGO_SETTINGS_MODULE is undefined

2009-05-07 Thread Sieker Adi Jörg

Hi,

On 07.05.2009, at 16:02, bconnors wrote:

>
> I saw this chat related to DJANGO_SETTINGS_MODULE is undefined.
> Hello I am new to Django.
> I am trying to exercise "templates" through the interactive shell,
> however I end up getting this error. Can anyone help?
> here is the exact steps I follow:
> 1) cd C:\Django\mysite
> 2) set DJANGO_SETTINGS_MODULE=mysite.settings I've also tried set
> DJANGO_SETTINGS_MODULE=settings.py
> 3) python
> 4) >>> from django.template import Template
 t = Template("My name is {{ name }}.")
> 5) ERROR: ImportError: Settings cannot be imported, because
> environment variable DJANGO_SETTINGS_MODULE is undefined
>
>

The above is for windows and not unix.

> - Show quoted text -
>
> Setting it to mysite.settings will work if c:\django is on your
> PYTHONPATH.
> Setting it to settings.py won't work at all because of the .py.
> Assuming
> you are running the python from c:\django\mysite, setting
> DJANGO_SETTINGS_MODULE to just 'settings' will work.  Or, use 'python
> manage.py shell', which assumes settings.py is in the current
> directory and
> sets the environment up for you.
> Karen
>
>
>
> So I did
>
> 1
> export PYTHONPATH=/usr/lib/python2.5/site-packages
>
>
> 2
> set DJANGO_SETTINGS_MODULE=myapp1.settings
>
>
This should be: export not set.
set is a window command and doesn't or does something different under  
*nix.


> 3
> settings.py has :
>
> INSTALLED_APPS = (
>'django.contrib.auth',
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'myapp1.person',
> )
>
>
> when I do
> django-admin.py dumpdata
> Error: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS
> _MODULE is undefined.
> pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite/myapp$
>
>
>
>
>
> on the Django Congratulations screen it has myapp1
> what am I doing wrong?
>
>
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Ajax and non-ajax forms.

2009-05-07 Thread George Song

On 5/7/2009 1:43 AM, Chris Dew wrote:
> Do other developers consider it vital to support non-javascript
> browsers for accessibility reasons?  Or are people largely using ajax
> regardless of accessibility, to make their apps look shiny?

It depends on who the app is for. If it's in a corporate environment 
where you know the constraints you're working with, then by all means 
AJAX away w/o fallback.

Or in another extreme, maybe you can't use AJAX at all in that environment.

But if it's public facing, you're probably better off constructing the 
entire app w/o AJAX first and then selectively put in widgets where 
usability can be improved. This way you're not locking out some segment 
of your users.

Note this doesn't just apply to AJAX, but to JS in general. And more 
importantly, you should have valid semantic markup that can still be 
read w/o relying on styling if possible, if you want things like screen 
readers to work.

-- 
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: Trouble Starting Up with runserver

2009-05-07 Thread John Crawford

Arg - I meant 127.0.0.1:8000

Is there a way to edit messages that I dont see here? :)

John C>

On May 7, 10:17 am, John Crawford  wrote:
> I'm not sure why your address is all zeros, did you give a specific
> host number parameter to runserver?
>
> Generally 127.0.0.0:8000 would be your localhost, and that is the
> default for runserver. Use that instead (or don't give it any
> parameters), see what happens.
>
> John C>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Trouble Starting Up with runserver

2009-05-07 Thread John Crawford

I'm not sure why your address is all zeros, did you give a specific
host number parameter to runserver?

Generally 127.0.0.0:8000 would be your localhost, and that is the
default for runserver. Use that instead (or don't give it any
parameters), see what happens.

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



self unique symmetrical relation

2009-05-07 Thread Aldo

Hello,

I have a problem for a quite simple model.
I would like to model a person marriage relation.

example :

class Person(models.Model):
name=models.CharField(max_length=100)
married_to=models.OneToOneField('self',symmetrical=True) #
symmetrical not allowed
married_to=models.ForeignKey
('self',unique=True,symmetrical=True) # symmetrical not allowed
married_to=models.ManyToManyField
('self',unique=True,symmetrical=True) # unique not allowed

The relation I want has to be unique and symmetrical.
Someone can only be married to one other person (unique).
If Alice is married to Bob, then Bob is automatically married to Alice
(symmetrical).

How would you model this relation ?
Thanks.

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

2009-05-07 Thread 不提防
When LANG = C, os.stat(u'中文.txt') will make a error.

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5:
ordinal not in range(128)

os.environ['LANG']='utf8'
os.stat(u'中文.txt') also makes that error.

In my program, I tried SetEnv, adding export LANG='utf8' in envvars, but
they all were not usefull.
So I think os.stat() has nothing to do with os.environ['LANG'].

So it must be mod_python has bug.

I changed mod_python to mod_wsgi. That error didn't occur 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
-~--~~~~--~~--~--~---



environment variable DJANGO_SETTINGS_MODULE is undefined

2009-05-07 Thread bconnors

I saw this chat related to DJANGO_SETTINGS_MODULE is undefined.
Hello I am new to Django.
I am trying to exercise "templates" through the interactive shell,
however I end up getting this error. Can anyone help?
here is the exact steps I follow:
1) cd C:\Django\mysite
2) set DJANGO_SETTINGS_MODULE=mysite.settings I've also tried set
DJANGO_SETTINGS_MODULE=settings.py
3) python
4) >>> from django.template import Template
>>> t = Template("My name is {{ name }}.")
5) ERROR: ImportError: Settings cannot be imported, because
environment variable DJANGO_SETTINGS_MODULE is undefined


- Show quoted text -

Setting it to mysite.settings will work if c:\django is on your
PYTHONPATH.
Setting it to settings.py won't work at all because of the .py.
Assuming
you are running the python from c:\django\mysite, setting
DJANGO_SETTINGS_MODULE to just 'settings' will work.  Or, use 'python
manage.py shell', which assumes settings.py is in the current
directory and
sets the environment up for you.
Karen



So I did

1
export PYTHONPATH=/usr/lib/python2.5/site-packages


2
set DJANGO_SETTINGS_MODULE=myapp1.settings


3
settings.py has :

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'myapp1.person',
)


when I do
django-admin.py dumpdata
Error: Settings cannot be imported, because environment variable
DJANGO_SETTINGS
_MODULE is undefined.
pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite/myapp$





on the Django Congratulations screen it has myapp1
 what am I doing wrong?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ManyToManyField and Manager.exclude()

2009-05-07 Thread Riccardo Pelizzi

Sorry for the delay. hosts__isnull works!
But i can confirm exclude doesn't:

h = Host.objects.create(ip="0.0.0.0")
d = RegisteredDomain.objects.all()[0]
d.hosts.add(h)
RegisteredDomain.objects.count()
--> 477L (total)
RegisteredDomain.objects.filter(hosts=None).count()
--> 476L (good!)
RegisteredDomain.objects.exclude(hosts=None).count()
--> 0 (not so good :-/)
RegisteredDomain.objects.filter(hosts__isnull=False).count()
--> 1L (good!)

I will paste you both models to be sure:

class Host(TimeStampedModel):
ip = models.IPAddressField(unique=True)

class RegisteredDomain(TimeStampedModel):
domain = models.CharField(max_length=255, unique=True)
spam_time = models.DateTimeField(null=True)
hosts = models.ManyToManyField(Host,
related_name="registered_domains")
random = models.BooleanField(null=True)

Is this a bug or i just didn't get how models work? :-)

Riccardo

On 4 Mai, 21:22, Malcolm Tredinnick  wrote:
> On Mon, 2009-05-04 at 09:18 -0700, Riccardo Pelizzi wrote:
> > Hello,
>
> > I have a model which looks kinda like this:
>
> > class Host(model):
> >   ip = IPAddressField()
>
> > class Domain(model):
> >   hosts = ManyToManyField(Host)
>
> > If i want to get all the domains without hosts:
> > Domain.objects.filter(hosts=None)
> > works.
>
> > Later on in my script i need to get the opposite, all the domains
> > having one or more hosts associated. using exclude instead of filter
> > with the same condition doesn't work as expected (at least as I
> > expected :-P), it just returns an empty queryset. Is there a way to
> > formulate thequeryusing the django api? or should i use custom sql?
>
> That should work properly. It works for me using exactly your models
> with a few different Host/Domain combinations.
>
> The SQL we currently generate for Domain.objects.exclude(hosts=None) is
> a little inefficient, but it's not fundamentally incorrect. It just uses
> a couple more tables than it needs to be because the "NULL" case can
> take advantage of one particular extra optimisation that isn't in the
> code yet. I'm surprised it isn't returning the correct result.
>
> Another to get the same answer, which generates simpler SQL but is
> potentially a little less efficient on the database side is
>
>         Domain.objects.filter(hosts__isnull=False).distinct()
>
> That's essentially the only case where Django has a "not" filter
> available: you can actually filter for "not NULL". The distinct() call
> there is important, as for many-to-many fields, you would otherwise get
> back one domain object for every host (so repetitions for domains with
> multiple hosts), not just the set of domains that have at least one
> host.
>
> In any case, I suspect there's something else going on in your
> particular case, as the SQL generated should be pulling back the results
> you're after and it works with a small example using your models. If you
> can use those models, as pasted, to generate an incorrect result, what
> is the smallest amount of data (Host & Domain objects) you need to
> create to demonstrate the problem. That would be interesting to see.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin page with my own themes/skins

2009-05-07 Thread Michael
Hi Stephen;

On Thu, May 7, 2009 at 8:36 AM, Stephen Cheng wrote:

>
> I have thought this for quite a while and no idea so far. I like the
> forms/pages auto generated by Admin engine, but I also want to
> incorporate some of the forms/pages into my site with following
> expectations:
>
> 1. I can use my own template.

There is an entire section in the docs dedicated to overriding the default
templates.
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates


>
> 2. use my own template and also use the context variables from my apps

I would recommend using template tags to accomplish this. You could do it at
the view level or the context processor level, but I think that would be
more difficult.


>
> 3. possibly use nicer url instead of auto url
>

With the urls, you have a few options, and I have never needed to do this,
but if I did, I would probably look into the ABSOLUTE_URL_OVERRIDES setting.
Janis Leidel has a good write up here:
http://jannisleidel.com/2008/08/easy-overrides-absolute-urls-reusable-apps/.
Another way you can do this is by looking at the code in
django.contrib.admin.sites.site. There is a function names get_urls in 1.1
(now in Beta) that is assigned to the property urls. You could overide this
and create a a custom subclass admin that would have your custom urls. There
are probably a few gotchas in there, because the views in the sites require
all of the information that is passes in the auto url, so you would have to
make sure the signature is the same or the views are different, in which
case you are essentially just writing your own admin.

>
> Any thought? or this is silly?


The templating overiding will be extremely easy. Changing the URLs is going
to be an adventure. I don't really see the point, but I don't know your
project either. If you have the time, go for it! If your successful, a write
up or blog post about how you did it would be a very interesting read.

Good luck and I 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: You don't have permission to edit anything - new forms admin

2009-05-07 Thread omat * gezgin.com

Are you using a custom authentication backend?

Admin calls get_all_permissions() method on the logged-in user, which
tries to call get_all_permissions() method of each authentication
backend used.

The back-ends used should implement this method and definetely
http://docs.djangoproject.com/en/dev/topics/auth/#other-authentication-sources
should mention that.


Best,
oMat






On Mar 12, 4:28 pm, dave  wrote:
> Hi,
> I'm encountering exactly the same problem as yours. Didyoufinally
> find the solutions?
> Thanks,
> Dave
>
> On Feb 17, 1:25 pm, Tipan  wrote:
>
> > I'm having some problems with the New Forms Admin that are giving me
> > the error message "Youdon'thavepermissiontoeditanything." when
> > I log into the Admin. I also lose the admin-media so that the page
> > displays on a plain white background.
>
> > I'm using the latest django release from the trunk r9844.
>
> > Interestingly, Ihaveanother app that uses exactly the same database
> > and this delivers full access for the same user (a superuser).
>
> > I've checked through the urls/settings and admin.py files and both are
> > identical except for the app name.
>
> > On previous threads it suggests putting print statements in contrib
> > \admin\__init__.py to check the apps loaded by autodiscover and it
> > seems to be working as expected:
> > django.contrib.auth
> > django.contrib.contenttypes
> > django.contrib.sessions
> > django.contrib.admin
> > django.contrib.humanize
> > django.contrib.flatpages
> > hive.promotions
>
> > where hive is my app.
>
> > My urls.py looks like this:
> > 
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
>
> > admin.autodiscover()
>
> > js_info_dict = {
> >     'packages': ( 'hive.promotions',),}
>
> > urlpatterns = patterns('',
> >     # Example:
> >     (r'^', include('promotions.urls')),
>
> >     (r'^hive/', include('promotions.urls')),
> >     (r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
> > js_info_dict),
>
> >     # Admin:
> >     ('^hiveadmin/(.*)', admin.site.root),
> > )
> > --
> > My admin.py looks like this:
>
> > from django.contrib import admin
> > from promotions.models import *
>
> > class PointTypeAdmin(admin.ModelAdmin):
> >         list_display=
> > ('points_type','date_created','ranking','points_expire','description',
> > 'cash_validity_period')
> >         save_on_top=True
> >         pass
>
> > admin.site.register(PointType, PointTypeAdmin)
> > plus other model classes..
>
> > I seem to be going into blind alleys at the moment, can anyone suggest
> > a troubleshooting direction for me to pursue?
>
> > 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: admin permissions: all or nothing

2009-05-07 Thread omat * gezgin.com

Solved - was a custom authentication backend issue.

Looking into the get_all_permissions() method, I realized that it
calls the authentication backend's get_all_permissions() method.

I have been using a custom authentication back-end, developed
according to:
http://docs.djangoproject.com/en/dev/topics/auth/#other-authentication-sources

I think, this document should mention about admin / permissions issues
when using custom backends.


Best,
oMat


On May 7, 3:01 pm, "omat * gezgin.com"  wrote:
> While trying to track down the problem, I encountered this strange
> behavior that the permissions of the user are not returned with
> get_all_permissions():
>
> >>> u = User.objects.get(username='demo')
> >>> u.user_permissions.all()
>
> [,  | Can change site>, ]
>
> >>> u.get_all_permissions()
>
> set([])
>
> Am I missing something basic?
>
> Best,
> oMat
>
> On May 7, 1:25 pm, "omat * gezgin.com"  wrote:
>
> > Sure, otherwise I won't be able to login to admin with that user at
> > first place.
>
> > Best,
> > oMat
>
> > On May 7, 1:04 pm, Kenneth Gonsalves  wrote:
>
> > > On Thursday 07 May 2009 15:32:08 omat wrote:
>
> > > > "You don't have permission to edit anything."
>
> > > you have set is_staff?
> > > --
> > > regards
> > > kghttp://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Admin page with my own themes/skins

2009-05-07 Thread Stephen Cheng

I have thought this for quite a while and no idea so far. I like the
forms/pages auto generated by Admin engine, but I also want to
incorporate some of the forms/pages into my site with following
expectations:

1. I can use my own template.
2. use my own template and also use the context variables from my apps
3. possibly use nicer url instead of auto url

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



Re: Problem with importing widget media

2009-05-07 Thread David Jean Louis

Hi,

> I've set up my Media class for a widget as such:
> 
> class InternationalSlugWidget(forms.TextInput):
> class Media:
> js = ('js/international_slug.js')

Your js here is a string, you want a tuple:
js = ('js/international_slug.js',)

 >>> type(('foo'))

 >>> type(('foo',))


-- 
David

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



Many to one revisited

2009-05-07 Thread sggottlieb

For some reason I can't reply to this thread about Many to One (http://
groups.google.com/group/django-users/browse_thread/thread/
180feab07df9dfe6/17301e3fcaa92a33?lnk=gst&q=many+to
+one#17301e3fcaa92a33) so I will re-open here.

I am looking for an answer to  Puneet's question: "but if there's
something like one-many it could implicitly tell Django to add objects
inline with the parent object."  My model has a "Person" with multiple
"PersonPosition" (AKA job) objects.  So, in my model, I have something
like this:

class PersonPosition(models.Model):
user = models.ForeignKey(Person)

Users will only creating PersonPosition objects from the person.  They
will not be creating a PersonPosition object and then picking a Person
to relate to.

Is the proper way to handle this to implement add and remove methods
onto my Person class?  How would I expose those methods into the Admin
UI?

Thanks,

Seth




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



Pass context vars to django-registration

2009-05-07 Thread Stephen Cheng

I have got a case like this: I have a drop down list of value of 8
cities which requires a db query every time when every page loads. The
problem is when the url is diverted to django-registration module,
then I don't know how to properly pass the citylist as a context value
to django-registration.

I have got two solutions here:
1) For the view directly in registration module, I can just invoke my
post-processed response,
eg: in stead of using:
return render_to_response(template_name,
  { 'form': 
form },
  
context_instance=context)
   I will hack it to:
return mysiteresp(request,template_name,
  { 'form': form },
  
context_instance=context)

then in mysiteresp: I will add the context varible:cityList to the
dictionary.

I really don't like to intrude to third party's module, but this is a
way to do it.

However when the url is login, then it requires to use django's auth
view

   url(r'^login/$',
   auth_views.login,
   {'template_name': 'registration/
login.html'},
   name='auth_login'),

then I can't do anything at all, I can't touch the system level
functions. So how do I do? Any suggestion.

2) The other thought I got is to just hard code the city list in to
the base.html template. eg:


AAA
BBB
   
..


but I know that I am hesitated to do this.

Any suggestion is appreciated.

Stephen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: admin permissions: all or nothing

2009-05-07 Thread omat * gezgin.com

While trying to track down the problem, I encountered this strange
behavior that the permissions of the user are not returned with
get_all_permissions():

>>> u = User.objects.get(username='demo')
>>> u.user_permissions.all()
[, , ]

>>> u.get_all_permissions()
set([])


Am I missing something basic?


Best,
oMat



On May 7, 1:25 pm, "omat * gezgin.com"  wrote:
> Sure, otherwise I won't be able to login to admin with that user at
> first place.
>
> Best,
> oMat
>
> On May 7, 1:04 pm, Kenneth Gonsalves  wrote:
>
> > On Thursday 07 May 2009 15:32:08 omat wrote:
>
> > > "You don't have permission to edit anything."
>
> > you have set is_staff?
> > --
> > regards
> > kghttp://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Re: cannot save in the admin site

2009-05-07 Thread Lame Spirale

I guess we won't find the answer, wait and see if other face the same
thing

Because my firefox install is new, shipped with the last ubuntu in a
fresh install
In plugins i have 'ubuntu firefox modification' and 'flashblock'. Of
course some others for video

Add to that the fact that it worked some time before. I was really
sudden. Nearly like :
-Works
-Deleted my db
-Didn't work any more
I could be wrong about the db being the main factor but you see the
point, i was working on my app

I was wondering if it has anything to do with language, i think the
guy who faced this problem was french too ...

Well never mind, it works for me in opera.
I would be glad to check, if you have another idea, though.

Thank you for your help.
Lame Spirale

On 6 mai, 01:19, Russell Keith-Magee  wrote:
> On Tue, May 5, 2009 at 7:58 PM, Lame Spirale  wrote:
>
> > When i turn firebug on, and press "enregistrer" absolutely nothing
> > happens
>
> > When i access the page the (development) server tells
> > [05/May/2009 13:28:38] "GET /admin/sites/site/add/ HTTP/1.1" 200 3093
> > [05/May/2009 13:28:38] "GET /admin/jsi18n/ HTTP/1.1" 200 1918
> > but when i press "enregistrer" absolutely nothing happens
>
> > No way of reproducing the error, i only found 1 guy on the net for
> > which that happened (i lost the adress but i could search if you like)
> > and he wrote that it solved automagically while he was going to show
> > how that wasn't suppose to work (kind of a reverse demo effect i
> > guess).
>
> > The javascript seems loaded, here's the resulting code source that i
> > copied and pasted in a html file :
> >http://www.lame-spirale.net/adminsite.html
>
> > I tripled checked every setting (but i don't underestimate my ability
> > to not see a possible mistake of course)
> > from django.contrib import admin
> > admin.autodiscover()
> >    (r'^admin/', include(admin.site.urls)),
>
> > I downloded opera and it works fine (well at least the admin, not my
> > app)
> > i guess i will be able to at least use django after all, playing with
> > 2 browser
> > but shouldn't we try and resolve that ?
>
> Ok - so what you are telling us is that Opera can render the Django
> admin fine - it's only Firefox that has a problem. This means that the
> problem is one of two things:
>
>  1) The Django admin has a rendering problem with Firefox.
>  2) Your Firefox install is borked in some way.
>
> Given the volume of people that use Firefox for Django development,
> option (1) seems unlikely, unless it is an intersection with a Firefox
> plugin. I would suggest trying a clean Firefox install, and/or a clean
> Firefox install on a different machine, and see if the problem
> persists.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Hidden field in Admin without label

2009-05-07 Thread Andy

Hello Pierre.

I recently came across the exact same problem (and for the exact same
reason)

I don't think my solution was any less ugly that yours. I modified
fieldset.html to look for a specific fieldset name. Anything in that
fieldset is displayed in a manner which honors the hidden field
property.

(so still a hack!)

Andy

On May 7, 10:01 am, PierreR  wrote:
> Thanks for your reply.
>
> My intention is to use this field as a version/timestamp to implement
> a form of optimistic locking. I need to receive it back from the user
> through a form and check it against the current version/timestamp of
> the updated record.
>
> I don't think "exclude" will work for me.
>
>
>
> > Hmm. Does the field need to be in the form at all? You could just add
> > it to the 'exclude' tuple in the ModelAdmin declaration, then it won't
> > show up.
> > --
> > 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: admin permissions: all or nothing

2009-05-07 Thread omat * gezgin.com

Sure, otherwise I won't be able to login to admin with that user at
first place.


Best,
oMat


On May 7, 1:04 pm, Kenneth Gonsalves  wrote:
> On Thursday 07 May 2009 15:32:08 omat wrote:
>
> > "You don't have permission to edit anything."
>
> you have set is_staff?
> --
> regards
> kghttp://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Re: admin permissions: all or nothing

2009-05-07 Thread Kenneth Gonsalves

On Thursday 07 May 2009 15:32:08 omat wrote:
> "You don't have permission to edit anything."

you have set is_staff?
-- 
regards
kg
http://lawgon.livejournal.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
-~--~~~~--~~--~--~---



admin permissions: all or nothing

2009-05-07 Thread omat

Hi,

I have set up the admin, and works as expected when logged in as a
super user.

When I log in with a user that have limited permissions (either when
permissions were assigned directly to the user or through a group
membership), the admin site says:

"You don't have permission to edit anything."

I checked the user's permissions via django shell, and made sure the
user has the given permissions.

What can be going wrong?

Thanks...

ps: I am using a recent svn version of django

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Separate Admin for each Site

2009-05-07 Thread Russell Keith-Magee

On Thu, May 7, 2009 at 4:49 PM, Russell Keith-Magee
 wrote:
> On Thu, May 7, 2009 at 11:31 AM, Steve R  wrote:
>>
>> I’m looking to create an Admin so that when a user from one Site logs
>> into the admin they will not be able to see or modify entries for
>> other sites.
> ...
>> Do I need to subclass AdminSite in contrib.admin.sites.py?  Or modify
>> the Admin views?
>>
> The second part is to allow different admin 'instances' for each of
> your site. This is the bit I haven't really played with, but I can
> think of two ways you might be able to do this:
...

Thinking about this a little more, you may not even need this bit,
depending on how you deploy your application. If all you are looking
for is for each site to have it's own admin, then you may not need to
do any  modifications to the admin; as long as each site has its own
settings file and site ID, you may be able to use a standard admin
deployment, with content filtered as James described.

Yours,
Russ Magee %-)

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



Re: Separate Admin for each Site

2009-05-07 Thread Russell Keith-Magee

On Thu, May 7, 2009 at 5:38 PM, modelmike  wrote:
>
> Hi,
>
> How do I instantiate AdminSite for my app and then subclass
> ModelAdmin?

Like I said in my original email, if you interested in this problem,
you're going to need to do a little digging of your own. This
particular problem wasn't a specific design consideration for the
admin, but it is something you should be able to put together from the
pieces that have been provided. However, in order to do this, you're
going to have to understand what the pieces can do, and this means
looking into the code, stretching your Python coding muscles, and
being a little creative.

Yours,
Russ Magee %-)

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



Re: Separate Admin for each Site

2009-05-07 Thread modelmike

Hi,

How do I instantiate AdminSite for my app and then subclass
ModelAdmin?

my_site.py...

 from django.contrib.admin import sites

 class my_admin_instance(sites.AdminSite)
 pass

admin.py...

 from my_django_project.my_django_app.my_site import
my_admin_instance

 class AuthorAdmin(my_admin_instance.ModelAdmin):
  pass

 my_admin_instance.site.register(Author, AuthorAdmin)

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: Separate Admin for each Site

2009-05-07 Thread modelmike

Hi,

How do I instantiate AdminSite for my app and then subclass
ModelAdmin?

my_site.py...

 from django.contrib.admin import sites

class my_admin_instance(sites.AdminSite)
 pass


admin.py...

 from my_django_project.my_django_dpp.my_site import
my_admin_instance

 class AuthorAdmin(my_admin_instance.ModelAdmin):
  pass

 my_admin_instance.site.register(Author, AuthorAdmin)



Thanks,
Mike









On May 6, 11:31 pm, Steve R  wrote:
> I’m looking to create an Admin so that when a user from one Site logs
> into the admin they will not be able to see or modify entries for
> other sites.
>
> An example might help.  Say you have a blog application and you use
> the django.contrib.site framework so that you can run multiple blogs,
> each with its own domain.
>
> from django.db import models
> from django.contrib.sites.models import Site
>
> class BlogEntry(models.Model):
>         title = models.CharField()
>         article = models.TextField()
>         site = models.ForeignKey(Site)
>
> I want each Blog owner to appear have their own Admin that will only
> display their blog entries.  So if a user goes to foo.com/admin and
> login they get access to only the Example.com blog entries.  Not the
> bar.com blog entries.  Similarly, when a user logs in at bar.com/admin
> they get just the bar.com entries.
>
> I tried using a site specific object manager for BlogEntry above by
> adding "objects = CurrentSiteManager()", as suggested in the docs:
>
> "Also, note that certain parts of Django -- namely, the Django admin
> site and generic views -- use whichever manager is defined first in
> the model, so if you want your admin site to have access to all
> objects (not just site-specific ones), put objects = models.Manager()
> in your model, before you define CurrentSiteManager." (http://
> docs.djangoproject.com/en/dev/ref/contrib/sites/)
>
> However, it didn't seem to make any difference and entries were
> visible regardless of which domain I used to create them.
>
> Do I need to subclass AdminSite in contrib.admin.sites.py?  Or modify
> the Admin views?
>
> I’ve read all the documentation on django.contrib.admin and
> django.contrib.sites, but I haven’t found a solution.  It seems like
> this should be possible, but I’m just not sure how to go about it.
> Any suggestions you can offer would be greatly appreciated.
>
> I'm using django version 1.0.2 final and Python 2.6.1.  If it makes
> any difference I'm using the builtin django test server ("manage.py
> runserver").
>
> Cheers,
> 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: Problem with importing widget media

2009-05-07 Thread kRON

Problem solved, my fault - just noticed it was expecting to traverse a
tuple;
js = ('js/international_slug.js',)  fixed the problem

On May 7, 10:16 am, kRON  wrote:
> Sorry for the repost, somehow I've submitted the form.
>
> I just wanted to add that my media url looks as MEDIA_URL = '/media/'
>
> Can anyone steer me the right way for fixing this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Template issue

2009-05-07 Thread 83nini

Hi guys,

I have a template.surf which i'm trying to style with CSS external
file, but it's not working! any idea how to deal with .surf templates?
and how to style them with the CSS external files?
internally working, externally...NOT!

cheers.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Hidden field in Admin without label

2009-05-07 Thread PierreR

Thanks for your reply.

My intention is to use this field as a version/timestamp to implement
a form of optimistic locking. I need to receive it back from the user
through a form and check it against the current version/timestamp of
the updated record.

I don't think "exclude" will work for me.


>
> Hmm. Does the field need to be in the form at all? You could just add
> it to the 'exclude' tuple in the ModelAdmin declaration, then it won't
> show up.
> --
> 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: Separate Admin for each Site

2009-05-07 Thread Russell Keith-Magee

On Thu, May 7, 2009 at 11:31 AM, Steve R  wrote:
>
> I’m looking to create an Admin so that when a user from one Site logs
> into the admin they will not be able to see or modify entries for
> other sites.
...
> Do I need to subclass AdminSite in contrib.admin.sites.py?  Or modify
> the Admin views?
>
> I’ve read all the documentation on django.contrib.admin and
> django.contrib.sites, but I haven’t found a solution.  It seems like
> this should be possible, but I’m just not sure how to go about it.
> Any suggestions you can offer would be greatly appreciated.

I haven't worked through all the details, but what you are doing
certainly sounds possible, and shouldn't require too much heavy
lifting.

The first part is to build an admin site that limits access to
objects. James Bennett described how to do this in lots of detail in
his blog late last year:

http://www.b-list.org/weblog/2008/dec/24/admin/

The second part is to allow different admin 'instances' for each of
your site. This is the bit I haven't really played with, but I can
think of two ways you might be able to do this:

Firstly, you could actually create lots of admin.site instances, and
deploy them using a wrapper to dispatch urls. To do this completely
dynamically, you will need to do a little bit of programming to build
a class that can wrap the admin instances, and dispatch requests to
the right admin site per request. The good news is that this becomes a
lot easier if you use Django trunk, rather than v1.0.X. In trunk,
urlresolvers have been updated so that any object with a get_urls()
method can be included into an urlresolver. The recommended syntax for
including admin sites has been updated to reflect this change (the old
syntax still works, but will eventually be deprecated). If you do a
bit of code digging into the admin Site, you should hopefully be able
to see how this could work.

The second approach is to subclass admin.site so that the get_urls()
method on site takes the sites.Site model as an argument in the URL.
This essentially means you would have a single site, but individual
requests on the admin site would be aware of the site for which they
are operating (the use of the term site is getting a bit ambiguous
here, but hopefully you grok my point)

Neither of these two approaches are particularly well documented; I'm
relying on your adventurous spirit here to dig into how the get_urls()
approach works in Django trunk, and to see how this could be used to
your advantage.

Yours,
Russ Magee %-)

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



Re: Ajax and non-ajax forms.

2009-05-07 Thread Chris Dew

Thanks for the advice, that's very useful.

Do other developers consider it vital to support non-javascript
browsers for accessibility reasons?  Or are people largely using ajax
regardless of accessibility, to make their apps look shiny?

Regards,

Chris.

On 6 May, 16:07, Matthias Kestenholz 
wrote:
> Hey,
>
>
>
> On Wed, May 6, 2009 at 3:27 PM, Chris Dew  wrote:
>
> > I'd like to develop a Django application with the following
> > properties:
>
> > A page (list of items) will have a link to a page with a form to add a
> > new item.
>
> > If there is no javascript, the link will take the user to the new page
> > and let the user submit the form, then return them to the initial page
> > when the form successfully validates.
>
> > If there is javascript, the link will open the form *within* the
> > current page (via ajax, perhaps as thickbox or greybox).  Submission/
> > validation errors of/on the form will take place entirely within the
> > current page.  When the for is submitted and valid, the form's div
> > will disappear/close.
>
> > At the moment, I think that I need to have ajax and non-ajax views for
> > *each form* within the application.
>
> > I also need to code form template snippets (for ajax) for *each form*
> > which are included by the templates for the non-ajax pages.
>
> > Has anyone developed a Django extension which makes this easier - some
> > form of 'unajax for non javascript-capable browsers'.
>
> > I realise that I'll probably need to do this myself, by hand, but I
> > thought I'd ask the question, just in case.
>
> Just to give you some ideas (it really is not that hard):
>
> def your_view(request):
>     # your processing code
>
>     if request.is_ajax():
>         return render_to_response('_form.html', {}...)
>     else:
>         return render_to_response('form.html', {}...)
>
> Your form.html template should contain not much more than the following code:
>
> {% extends "base.html" %}
>
> {% block content %}
> 
> {% include "_form.html" %}
> 
> {% endblock %}
>
> If you use the jQuery form plugin (it's what I know, not what I want
> to advertize -- I'm sure every javascript library has the bestest way
> to do it), you can prepare your form like this:
>
> $('#form form').ajaxForm({'target': '#form'})
>
> So in closing, you'll need several templates which are only used if
> the client does not support javascript; there is still some code
> duplication around, but not too much anymore, because you can reuse
> the view code and the _form.html template.
>
> I hope this'll put you on track.
> Matthias
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Hidden field in Admin without label

2009-05-07 Thread Daniel Roseman

On May 7, 9:23 am, PierreR  wrote:
> That is what I do !
> (another way is to define a custom model field and override the
> "formfield" method).
>
> But ... I cannot get rid off the label in the admin console. That is
> my problem.
>
> Any easy way to remove the label of an hidden field in the admin
> console ?
>
> Thanks.
>

Hmm. Does the field need to be in the form at all? You could just add
it to the 'exclude' tuple in the ModelAdmin declaration, then it won't
show up.
--
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: Hidden field in Admin without label

2009-05-07 Thread PierreR

Well so far the only "not so ugly way" (in the sense that it is only
one line of code) I have found to do this is to change the css
directly (in my case admin.css):
/* Hacky way to remove hidden field lavel in the Admin console */
div.form-row.last_modified { display: none;}

On 7 mai, 09:23, PierreR  wrote:
> That is what I do !
> (another way is to define a custom model field and override the
> "formfield" method).
>
> But ... I cannot get rid off the label in the admin console. That is
> my problem.
>
> Any easy way to remove the label of an hidden field in the admin
> console ?
>
> Thanks.
>
> On 6 mai, 17:24, Daniel Roseman  wrote:
>
> > On May 6, 4:48 pm, PierreR  wrote:
>
> > > I don't seem to find a good way to have a hidden field in the admin
> > > console. I can of course get the hidden field easily but the label is
> > > still showing up. This problem is really related to the Admin app.
>
> > > I have been trying to "hack" the "fieldset.html" but it is not that
> > > easy. "is_hidden" is only available on field.field ...
>
> > > The best solution is probably to get the hidden fields to go in a
> > > different fieldset (admin wise) so I can apply a style on the fieldset
> > > level, not on the fieldlevel.
>
> > > The following solution will not work if I need to mark as hidden a
> > > field of a base class:
>
> > >http://groups.google.com/group/django-users/browse_thread/thread/10fd...
>
> > > Any idea ? Thanks very much.
>
> > The best way to do this is to define a custom modelform for your admin
> > class, and override the definition of your field there to make it use
> > a  HiddenInput widget.
>
> > class MyForm(forms.ModelForm):
> >     myfield = forms.CharField(widget=forms.HiddenInput)
> >     class Meta:
> >         model = MyModel
>
> > class MyAdmin(admin.ModelAdmin):
> >     form = MyForm
>
> > admin.site.register(MyModel, MyAdmin)
> > --
> > 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: Problem with importing widget media

2009-05-07 Thread kRON

Sorry for the repost, somehow I've submitted the form.

I just wanted to add that my media url looks as MEDIA_URL = '/media/'

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



Problem with importing widget media

2009-05-07 Thread kRON

I've set up my Media class for a widget as such:

class InternationalSlugWidget(forms.TextInput):
class Media:
js = ('js/international_slug.js')

The problem is Django keeps pumping out the following import
statements:







...etc

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



Trouble Starting Up with runserver

2009-05-07 Thread Chris DPS

I am new to Django.

When I try to execute: python manage.py runserver, I get the following
error

Error: [Errno 10104] getaddrinfo failed

What is going on and what should I do?
I have tried with 0.0.0.0:8000.

I am running Django Version 1.0.2-final and Python 2.6


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Hidden field in Admin without label

2009-05-07 Thread PierreR

That is what I do !
(another way is to define a custom model field and override the
"formfield" method).

But ... I cannot get rid off the label in the admin console. That is
my problem.

Any easy way to remove the label of an hidden field in the admin
console ?

Thanks.

On 6 mai, 17:24, Daniel Roseman  wrote:
> On May 6, 4:48 pm, PierreR  wrote:
>
>
>
> > I don't seem to find a good way to have a hidden field in the admin
> > console. I can of course get the hidden field easily but the label is
> > still showing up. This problem is really related to the Admin app.
>
> > I have been trying to "hack" the "fieldset.html" but it is not that
> > easy. "is_hidden" is only available on field.field ...
>
> > The best solution is probably to get the hidden fields to go in a
> > different fieldset (admin wise) so I can apply a style on the fieldset
> > level, not on the fieldlevel.
>
> > The following solution will not work if I need to mark as hidden a
> > field of a base class:
>
> >http://groups.google.com/group/django-users/browse_thread/thread/10fd...
>
> > Any idea ? Thanks very much.
>
> The best way to do this is to define a custom modelform for your admin
> class, and override the definition of your field there to make it use
> a  HiddenInput widget.
>
> class MyForm(forms.ModelForm):
>     myfield = forms.CharField(widget=forms.HiddenInput)
>     class Meta:
>         model = MyModel
>
> class MyAdmin(admin.ModelAdmin):
>     form = MyForm
>
> admin.site.register(MyModel, MyAdmin)
> --
> 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: Run context processor conditionally?

2009-05-07 Thread James Bennett

On Thu, May 7, 2009 at 2:44 AM, Jani Tiainen  wrote:
> How you do that? Everywhere I look, documentation states that view is a
> "function" (well there is few places where is mentioned "callable").

You may want to consult some Python documentation; writing a class
whose instances are callable is not particularly hard one you get a
grasp on some of the things the language lets you do.


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