Re: Uploadfile form and CSS Style

2014-11-17 Thread Russo
Hi James,

sorry I'm new on Django, can you give me some code example? I mean, hot to 
define the CLASS or ID into the html with elements like this {{ 
form.docfile }} ?

Regards
Russo


El jueves, 13 de noviembre de 2014 15:48:16 UTC-4:30, James Schneider 
escribió:
>
> If you are manually expressing the form, then you can add classes and ID's 
> to any or all elements in the form. Even if you are using something like 
> the {{ form.as_p }} method to display the form, you can still style it 
> using CSS styles at the tag level. Just include a custom CSS file with your 
> template.
>
> -James
> On Nov 13, 2014 12:13 PM, "Russo" <arus...@musicparticles.com 
> > wrote:
>
>>  Hi Kakar,
>>
>> but i tried and there is not way to change the bottom style, see the html 
>> code
>>
>> 
>> > enctype="multipart/form-data">
>> {% csrf_token %}
>>
>> {{ form.non_field_errors }}
>> {{ form.docfile.label_tag }} {{ form.docfile.help_text 
>> }}
>> 
>> {{ form.docfile.errors }}
>> {{ form.docfile }}
>> 
>> 
>> 
>>
>> as it is a form there is no way to change style ¿?
>>
>> Regards/AR
>>
>>
>> El 13/11/2014 a las 03:37 p.m., Kakar Nyori escribió:
>>  
>> Then you need to apply css to the form.
>>
>> On Fri, Nov 14, 2014 at 1:16 AM, Russo <arus...@musicparticles.com 
>> > wrote:
>>
>>> Hi,
>>>
>>> i just implemented the uploadfile form on Django, and everything goes 
>>> greate, but i would like to do if it is possible to apply CSS styles to the 
>>> upload botton on the forms, Anybody knows this?
>>>
>>> Regards
>>> Russo
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/54650A9B.8040004%40musicparticles.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/5465119E.2030707%40musicparticles.com
>>  
>> <https://groups.google.com/d/msgid/django-users/5465119E.2030707%40musicparticles.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c14d4df3-2eb8-401b-8e42-17eddbcad59d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Uploadfile form and CSS Style

2014-11-13 Thread Russo

Hi Kakar,

but i tried and there is not way to change the bottom style, see the 
html code



enctype="multipart/form-data">

{% csrf_token %}

{{ form.non_field_errors }}
{{ form.docfile.label_tag }} {{ form.docfile.help_text 
}}


{{ form.docfile.errors }}
{{ form.docfile }}




as it is a form there is no way to change style ¿?

Regards/AR


El 13/11/2014 a las 03:37 p.m., Kakar Nyori escribió:

Then you need to apply css to the form.

On Fri, Nov 14, 2014 at 1:16 AM, Russo <aruss...@musicparticles.com 
<mailto:aruss...@musicparticles.com>> wrote:


Hi,

i just implemented the uploadfile form on Django, and everything
goes greate, but i would like to do if it is possible to apply CSS
styles to the upload botton on the forms, Anybody knows this?

Regards
Russo

-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/54650A9B.8040004%40musicparticles.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto:django-users@googlegroups.com>.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com?utm_medium=email_source=footer>.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5465119E.2030707%40musicparticles.com.
For more options, visit https://groups.google.com/d/optout.


Uploadfile form and CSS Style

2014-11-13 Thread Russo

Hi,

i just implemented the uploadfile form on Django, and everything goes 
greate, but i would like to do if it is possible to apply CSS styles to 
the upload botton on the forms, Anybody knows this?


Regards
Russo

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54650A9B.8040004%40musicparticles.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble with VirtualEnv on Windows

2012-10-15 Thread Joshua Russo
Sweet! Thank you!

On Monday, October 15, 2012 12:56:37 AM UTC-4, Jani Tiainen wrote:
>
> Because the setup procedure used there is faulty. 
>
> This is what happens: 
>
> When installing Python install package will bind .PY(C) file execution 
> to use _always_ main installation. It won't follow any path settings 
> which virtualenv relies on. 
>
> I'm not sure can you even overcome that restriction easily on cmd. I 
> know that powershell can do it (don't know how though) or personally I 
> use TCC/LE. 
>
> Also psycopg2 is installed on main installation and virtualenv created 
> with --no-site-packages should disable it from virtualenv. 
>
> This is the battle tested procedure how I do set up my environment: 
>
> http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/ 
>
>
> 15.10.2012 5:45, Joshua Russo kirjoitti: 
> > I suppose I was a little light on the details of how I setup the 
> > environment. I don't often setup a new environment from scratch so I 
> > used this post as the basis: 
> > 
> http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/
>  
> > 
> > 
> > The versions of each program I used / ended up with were: 
> > Python 2.7.3 (32 bit) 
> > Postgres 9.2 (32 bit) 
> > Setuptools 0.6c11 for Python 2.7 
> > Psycopg2 2.4.5 for Python 2.7 (32 bit) 
> > VirtualEnv 1.8.2 
> > Django 1.4.1 
> > 
> > 
> > 
> > On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote: 
> > 
> > This is probably a VirturalEnv problem as opposed to a Django 
> > problem but I was wondering if someone here could point me in the 
> > right direction. 
> > 
> > I'm trying to setup clean environment for a demonstration of Django 
> > on Tuesday but I get the following when I try to setup the project 
> > within the virtual environment. You can see that if I just run 
> > python from within the virtual environment I do have access to the 
> > libraries, but if I try to use the django-admin.py script, the 
> > libraries aren't found. Any thoughts? 
> > 
> > (django-tutorial) 
> > C:\dev\venv\django-tutorial>Scripts\django-admin.py startproject 
> > testsite 
> > Traceback (most recent call last): 
> >File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line 
> > 2, in  
> >  from django.core import management 
> > ImportError: No module named django.core 
> > 
> > (django-tutorial) 
> > C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script 
> > s\python.exe 
> > Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit 
> > (Intel)] on win 
> > 32 
> > Type "help", "copyright", "credits" or "license" for more 
> information. 
> >  >>> from django.core import management 
> >  >>> management 
> >  > 'C:\dev\venv\django-tutorial\lib\site-pack 
> > ages\django\core\management\__init__.pyc'> 
> >  >>> 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/YuSLHUyt6xIJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>
>
> -- 
> Jani Tiainen 
>
> - Well planned is half done and a half done has been sufficient before... 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ahUGFdt6pEgJ.
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 with VirtualEnv on Windows

2012-10-14 Thread Joshua Russo
I suppose I was a little light on the details of how I setup the 
environment. I don't often setup a new environment from scratch so I used 
this post as the basis: 
http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/
 

The versions of each program I used / ended up with were:
   Python 2.7.3 (32 bit)
   Postgres 9.2 (32 bit)
   Setuptools 0.6c11 for Python 2.7 
   Psycopg2 2.4.5 for Python 2.7 (32 bit)
   VirtualEnv 1.8.2
   Django 1.4.1



On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote:
>
> This is probably a VirturalEnv problem as opposed to a Django problem but 
> I was wondering if someone here could point me in the right direction.
>
> I'm trying to setup clean environment for a demonstration of Django on 
> Tuesday but I get the following when I try to setup the project within the 
> virtual environment. You can see that if I just run python from within the 
> virtual environment I do have access to the libraries, but if I try to use 
> the django-admin.py script, the libraries aren't found. Any thoughts?
>
> (django-tutorial) C:\dev\venv\django-tutorial>Scripts\django-admin.py 
> startproject testsite
> Traceback (most recent call last):
>   File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line 2, in 
> 
> from django.core import management
> ImportError: No module named django.core
>
> (django-tutorial) 
> C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script
> s\python.exe
> Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] 
> on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from django.core import management
> >>> management
>  'C:\dev\venv\django-tutorial\lib\site-pack
> ages\django\core\management\__init__.pyc'>
> >>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YuSLHUyt6xIJ.
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 with VirtualEnv on Windows

2012-10-14 Thread Joshua Russo
This is probably a VirturalEnv problem as opposed to a Django problem but I 
was wondering if someone here could point me in the right direction.

I'm trying to setup clean environment for a demonstration of Django on 
Tuesday but I get the following when I try to setup the project within the 
virtual environment. You can see that if I just run python from within the 
virtual environment I do have access to the libraries, but if I try to use 
the django-admin.py script, the libraries aren't found. Any thoughts?

(django-tutorial) C:\dev\venv\django-tutorial>Scripts\django-admin.py 
startproject testsite
Traceback (most recent call last):
  File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line 2, in 

from django.core import management
ImportError: No module named django.core

(django-tutorial) 
C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script
s\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] 
on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core import management
>>> management

>>>

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



Re: Best practices for open sourcing a Django project?

2012-10-14 Thread Joshua Russo
Clifford, I have actually done this but the local settings files were 
merely used to override the production values. I think I like this way 
better for handling things like the database and the various path settings, 
though I'm not sure I will completely abandon the override mechanism either.

Thanks for the idea


On Sunday, October 14, 2012 4:56:59 PM UTC-4, CLIFFORD ILKAY wrote:
>
> On 10/14/2012 03:47 PM, Joshua Russo wrote: 
> > I have project that I have been working and I was contemplating open 
> > sourcing it but I ran into a little hang up. How to handle the 
> > database authentication. The settings file obviously needs to be 
> > included but I don't want to advertise the production database login. 
> > How is this generally handled? 
> > 
> > Also, are there procedures that need to be followed to "properly" open 
> > source a project, or is it really just choosing a licence and dubbing 
> > it so? 
>
> Hi Joshua, 
>
> You would have the same issue if you have a staging process where you go 
> from development, testing, and production. We handle that by having a 
> local_config.py that is not checked into the Mercurial repo. At the top 
> of settings.py, we have code that looks like this: 
>
> import local_settings as LOCAL_SETTINGS 
>
> # The following variables are defined in local_settings.py 
> ## 
>
> DEBUG = LOCAL_SETTINGS.DEBUG 
> ADMINS = LOCAL_SETTINGS.ADMINS 
>
> DATABASES = { 
>  'default': { 
> 'ENGINE': LOCAL_SETTINGS.DATABASES['default']['ENGINE'], 
>  'NAME': LOCAL_SETTINGS.DATABASES['default']['NAME'], 
>  'USER': LOCAL_SETTINGS.DATABASES['default']['USER'], 
>  'PASSWORD': LOCAL_SETTINGS.DATABASES['default']['PASSWORD'], 
>  'HOST': LOCAL_SETTINGS.DATABASES['default']['HOST'], 
>  'PORT': LOCAL_SETTINGS.DATABASES['default']['PORT'], 
>  } 
> } 
>
> TIME_ZONE = LOCAL_SETTINGS.TIME_ZONE 
> SECRET_KEY = LOCAL_SETTINGS.SECRET_KEY 
>
> DEFAULT_FROM_EMAIL = LOCAL_SETTINGS.DEFAULT_FROM_EMAIL 
> EMAIL_HOST = LOCAL_SETTINGS.EMAIL_HOST 
> EMAIL_PORT = LOCAL_SETTINGS.EMAIL_PORT 
> EMAIL_HOST_USER = LOCAL_SETTINGS.EMAIL_HOST_USER 
> EMAIL_HOST_PASSWORD = LOCAL_SETTINGS.EMAIL_HOST_PASSWORD 
> EMAIL_USE_TLS = LOCAL_SETTINGS.EMAIL_USE_TLS 
>
> CONTACT_EMAIL = LOCAL_SETTINGS.CONTACT_EMAIL 
>
> INTERNAL_IPS = LOCAL_SETTINGS.INTERNAL_IPS 
>
> # End of variables defined in local_settings.py ## 
>
> local_settings.py can vary from instance of the application to another 
> and those sensitive things like passwords are never kept under revision 
> control. settings.py is consistent regardless of whether it's a 
> development, testing, or production deployment. If you find yourself 
> having to change things in settings.py if you deploy onto another 
> server, chances are it should be factored out into local_settings.py and 
> imported into settings.py as above. 
>
> -- 
> Regards, 
>
> Clifford Ilkay 
> Dinamis 
> 1419-3230 Yonge St. 
> Toronto, ON 
> Canada  M4N 3P6 
>
> <http://dinamis.com> 
> +1 416-410-3326 
>
>

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



Re: Best practices for open sourcing a Django project?

2012-10-14 Thread Joshua Russo
It sounds like you're saying that the open sourced project should be 
different from the production project. Am I reading that right?


On Sunday, October 14, 2012 4:00:03 PM UTC-4, Cal Leeming [Simplicity Media 
Ltd] wrote:
>
> You could just include the necessary info in the README, or make a wrapper 
> script that does it for them - although I tend to stick with READMEs where 
> possible as they consume less time.
>
> If the code is coming straight out of production, there's a few tips I'd 
> recommended;
>
> * Ensure that you test the code outside of the production environment 
> against a test project, and make sure it works as expected.
> * Triple check that you haven't left any private info in the code
> * Provide a (reasonable) amount of documentation
>
> Personally, I tend to opt for this license;
> http://en.wikipedia.org/wiki/WTFPL
>
> There are many places you can put your code (GitHub, my most favourite), 
> and others such as BitBucket and Google Code - again it's down to personal 
> preference.
>
> Here is an example of a project I open sourced a while back... at the time 
> I thought it was done well, but I later realised it needed a serious amount 
> of re-writing and documentation - which I still haven't got around to doing;
> https://github.com/foxx/django-cutemodel
>
> Others may be able to offer a bit more advice, but the above is a head 
> start at least!
>
> Hope this helps!
>
> Cal
>
> On Sun, Oct 14, 2012 at 8:47 PM, Joshua Russo 
> <josh.r...@gmail.com
> > wrote:
>
>> I have project that I have been working and I was contemplating open 
>> sourcing it but I ran into a little hang up. How to handle the database 
>> authentication. The settings file obviously needs to be included but I 
>> don't want to advertise the production database login. How is this 
>> generally handled?
>>
>> Also, are there procedures that need to be followed to "properly" open 
>> source a project, or is it really just choosing a licence and dubbing it so?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/LJU31pYrcXgJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6nucbxbFRF8J.
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.



Best practices for open sourcing a Django project?

2012-10-14 Thread Joshua Russo
I have project that I have been working and I was contemplating open 
sourcing it but I ran into a little hang up. How to handle the database 
authentication. The settings file obviously needs to be included but I 
don't want to advertise the production database login. How is this 
generally handled?

Also, are there procedures that need to be followed to "properly" open 
source a project, or is it really just choosing a licence and dubbing it so?

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



How do determine which {% load %} item is missing?

2011-11-22 Thread Joshua Russo
I've noticed that instead of generating an error, if a filter or tag is 
used that is not found in a {% load %} item, the include that contains the 
error is just skipped. Is there anyway to debug which filter/tag is failing?

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



How to specify a group by field set?

2011-11-22 Thread Joshua Russo
Is there a way to select a list of group by columns? 
The aggregation methods seem only apply to a single model but I want to use 
fields from different models to group by. 

select org.id as organization_id,
   dep.id as department_id,
   cat."catId",
   max(cat.name) as name,
   max(cat."nameDisplay") as nameDisplay,
   count(depItem.id) as itemCount
  from communitynetwork_listcategory as cat 
   inner join communitynetwork_listitem as li on
 li.category_id = cat."catId"
   inner join communitynetwork_organizationdepartmentitem as depItem on
 depItem.item_id = li.id
   inner join communitynetwork_organizationdepartment as dep on
 dep.id = depItem.department_id
   inner join communitynetwork_organization as org on
 org.id = dep.organization_id and
 org.active = True  
 where cat.name like '%service%' 
or cat."nameDisplay" like '%service%' 
group by org.id, dep.id, cat."catId"
order by org.name, dep.name, cat.order

This is what I tried to do with a QuerySet that didn't work:

OrganizationDepartmentItem.objects.filter(
department__organization__active=True
).filter(Q(item__category__name=searchValue) | Q(
item__category__nameDisplay=searchValue)
).order_by('department__organization', 'department__name', 
'item__category__order'
).values('department__organization', 'department', 'item__category'
).aggregate(Max('item__category__name'), 
Max('item__category__nameDisplay'), Count('item'))


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



Re: Query exclude via model_set property?

2011-11-12 Thread Joshua Russo
it looks like this is the best way to tackle the problem. 

http://stackoverflow.com/questions/1724317/django-exclude-on-a-many-to-many-relationship-through-a-third-table

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Drr0HvurTM8J.
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.



Query exclude via model_set property?

2011-11-12 Thread Joshua Russo
I have a 3 table solution

class Organization(models.Model):
name = models.CharField("Organization's name", max_length=100)

class OrganizationDepartment(models.Model):
organization = models.ForeignKey(Organization)
name = models.CharField("Name", max_length=100)
contacts = models.ManyToManyField("Contact")

class Contact(models.Model):
organization = models.ForeignKey("Organization", blank=True, null=True)
name = models.CharField("Contact's name", max_length=100)

I want to create a list of contacts within an organization and not in a 
given department. The problem is that it looks like I can't use the 
contact.organzationdepartment_set in an exclude. Is that correct?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/irkjf3hcKrkJ.
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.



Is there any particular reason why it's assumed you won't be performing a Max on a CharField?

2011-09-21 Thread Joshua Russo
Is there any particular reason why it's assumed you won't be performing a 
Max on a CharField? 

I tried to create the following QuerySet:

Document.objects.filter(documentType=1, 
event__eventType=3).annotate(event_date=Max('event__start_date'), 
subcommittee=Max('event__subcommittee__name')).order_by('subcommittee', 
'event_date')

I enforce this particular documentType to occur only once per Event, but in 
reality the Document - Event relation is many to many. That is why I 
performed a Max on the to go from Document to a FK relation of Event.

I really only ask out of curiosity. As far as SQL goes, this is completely 
legit and I plan on modifying Django and submitting a patch. (Unless there's 
a compelling reason not to)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/nQfxnZlrOskJ.
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: Alter the list of fields returned by a queryset without turning them into strings?

2011-09-13 Thread Joshua Russo
I had previously typed (but obviously not sent) a thank you ... so, thank 
you. That was what I was looking for and did lead me to my ultimate 
solution.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/lRWXSr1eTUMJ.
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: Alter the list of fields returned by a queryset without turning them into strings?

2011-09-13 Thread Joshua Russo
So, how I actually solved it was even a bit different:

Document.objects.filter(documentType=1, 
event__eventType=1).annotate(Max('event__start_date')).order_by('event__start_date__max')

I had to use the Max function because the relationship is actually a many to 
many. Even if it was just a standard foreign key this is still an option, 
and it eliminates the problem of re-querying if you later decide to use 
other fields. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LJZowJhdGbkJ.
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.



Alter the list of fields returned by a queryset without turning them into strings?

2011-09-12 Thread Joshua Russo
I have 2 tables, document and event. I want to retrieve the document url and 
the event date but it seems like I can't do this in a single query set and 
that is then used directly in a template. This was my first thought:

context = {
'minutes': Document.objects.filter(documentType=1, 
event__eventType=1).values('documentFile', 
'event__start_date').order_by('event__start_date')
}

with the template looking like 

{% for scm in minutes %}
 {{ 
scm.event__start_date|optTimeShort }}
{% endfor %}

The problem is that the values() command turns the FileField into a string.

If I remove the values() command I can access the event through event_set 
but it's not clear to me how to access the one and only event in the set 
within the template.

Do I just need to do a little more pre-processing in the view or can I 
accomplish what I'm trying to do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kFEzUs3fmigJ.
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: When is it useful to run multiple admin sites?

2011-09-11 Thread Joshua Russo
That makes sense. Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Hz0DW_-dSwAJ.
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.



When is it useful to run multiple admin sites?

2011-09-11 Thread Joshua Russo
I know you can run multiple admin sites, but the only reason I can see for 
doing it is to have a full admin and other customized admin sites for 
different types of users. This is possibly even a stretch, and really just a 
guess. 

What are some of the use cases for multiple admin sites? 

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



Re: CSS question

2011-08-21 Thread Joshua Russo
Thanks for the help, CSS is always my gremlin 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/TmoW1R-DflQJ.
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.



CSS question

2011-08-21 Thread Joshua Russo
I know this is a bit off topic but I know this place is full of very 
helpful intelligent people. :o)

Ok so I have an html block (div, p, doesn't matter what kind), and I fill it 
with a label and an input text field. The input is always larger than the 
label (rightly so), but the label is always aligned to the top of the block. 
I want to center the label in the block but for the life of me, I can't 
figure out how.

Any ideas on how to fix it or where to go to get an answer?

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



Re: Best approach to handling different types of Users

2011-08-21 Thread Joshua Russo
Things will break in the sense that, if you add another app that accesses 
the User model they will only see the original implementation. They won't 
get your subclass. Other than that, other apps that use the User model 
should "work" just fine.

Unless I'm missing something, and in that case someone can kindly correct 
me. :o)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/qeQeHTmp_E8J.
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: DB based translations?

2011-08-21 Thread Joshua Russo
Ooo that looks like what I'm looking for. Thanks for the tip. 

Do you have any experience with it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BhN92mZ7W9oJ.
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.



DB based translations?

2011-08-20 Thread Joshua Russo
Ok, I've been looking into the different database based translation 
solutions out there and I can't find what I really had in mind. I need to 
have non-technical people easily update the translations. So I wanted a 
solution where I could create an interface to ease the process.

One problem is that none of the solutions seem to talk about translating 
static text. I'm thinking I need to create a site_content table to handle my 
static text translations and then use one of these solutions against it. 

If this is an appropriate solution, what are people's experience with the 
different database driven translation solutions? I tried 
django_multilingual, and django_multilingual_ng but they seemed to have 
issues with South. (Of course that was a few months back and I can't 
remember the exact problems I was having.) I'm now looking at 
django_modeltranslation, but none of these products really give the 
impression of being production worthy.

I'm willing to give them a shot because I need something and it's small 
enough project that I can take a little more risk. What are people's 
experience with them?

Thanks in advance
Josh

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



Re: I need help with reverse and url patterns

2011-08-20 Thread Joshua Russo
Never mind I got it. I changed my url patter to 

url(r'^events/(?P\d{4})/(?P\d{1,2})/$', events, 
name="eventsMonth")

I'm still not very sharp on my regex skills. I realized that {2} required a 
2 digit number

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/bZU9C0CBpTwJ.
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.



I need help with reverse and url patterns

2011-08-20 Thread Joshua Russo
I setup this patter in url.py

url(r'^events/(?P\d{4})/(?P\d{2})/$', events, 
name="eventsMonth")

in my template I have this tag

{% url eventsMonth year=month.prev.year month=month.prev.month %}

but I keep getting 

Caught NoReverseMatch while rendering: Reverse for 'eventsMonth' with 
arguments '()' and keyword arguments '{'month': 7, 'year': 2011}' not found.

I traced the problem into the reverse() code and the logic goes all the way 
to the end, when the following statement from line 325 of 
core/urlresolvers.py fails and I can't figure out why

if re.search(u'^%s' % pattern, candidate, re.UNICODE):

The pattern is 
'events/(?P\\d{4})/(?P\\d{2})/$'
and the candidate is 
u'events/2011/7/'

Why doesn't that regular expression match? What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/HexbsXNrkKAJ.
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: Splitting models.py results in table rename?

2011-08-19 Thread Joshua Russo
Perfect! Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NRyP256j0G4J.
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.



Splitting models.py results in table rename?

2011-08-19 Thread Joshua Russo
My models.py was getting too large so I tried to split it into

/models
  __init__.py
  someLogicalGroupOfModels.py
  andSoOn.py

in the __init__.py I have

from appName.models.someLogicalGroupOfModels import *
from appName.models.andSoOn import *

All of my imports still work but the queries are now looking for 
models_someTableName instead of appName_someTableName. 

I know I've done this before. Is there something I'm doing wrong?

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



Re: How to prevent model formset from saving the empty forms?

2011-08-09 Thread Joshua Russo
I just needed to retrieve the first pk value from the field's queryset in 
the init of the form and set the initial value there.

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



Re: How to prevent model formset from saving the empty forms?

2011-08-09 Thread Joshua Russo
Nm, I got it

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



Re: How to prevent model formset from saving the empty forms?

2011-08-09 Thread Joshua Russo
Ok, I figured out why, but I still don't know how to fix it. 

I set a dropdown to empty_label = None, which automatically selects the 
first element. I want that, but the form then thinks it has changed because 
the value in the list of initial values is empty for that field, and I can't 
see how to set the initial value for the forms in a model formset.

Any suggestions?

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



How to prevent model formset from saving the empty forms?

2011-08-09 Thread Joshua Russo
I have a model formset that's displaying an extra form, but when I save I 
always get that form saved as an empty entry. How do I tell it not to save 
the model forms that I don't edit? It doesn't happen this way in the admin, 
does it?

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



Re: How to test form values in a template? (simplified)

2011-08-07 Thread Joshua Russo
It's more that I want to have different ways of displaying the same form 
field. I want the text field to be on the same line as the checkbox when 
it's an input field and below it when it's displayed as a textarea. There's 
also the point of changing the required setting of the same field based on 
if the checkbox is selected or not. 

I guess what I'm trying to get at is, how should I access these values to 
determine the display and validation. If I don't use my method I will have 
to test for both the boolean value and the string value 'True' instead. 
That's what I'm trying to avoid.

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



How to test form values in a template? (simplified)

2011-08-07 Thread Joshua Russo
I realize that I went from too little information, to too much information 
in the previous post, so this is an attempt to find a middle ground.

What I'm building is the ability to have a list of checkable options, and 
depending on the setup for a give option it may have a text field to enter 
additional information. This text field can be either displayed as a single 
line text input or a multi-line textarea. 

My problem is that I want to have these different setup values available to 
control the validation and display of the form, but there doesn't seem a 
consistent way to test the values. When the form is POSTed back and isn't 
valid, the value out of the BoundField's value() metod for BooleanFields is 
a string, where it's a actual boolean on the initial creation of the page. I 
understand why this is, it's pulling from the POST data instead of the 
initial data. 

The way I over came this was to add a to_python() method to the BoundField 
class in django/forms/forms.py:

def to_python(self):
return self.field.to_python(self.value())

Below is what I'm doing. I'm using the new to_python() method are in the 
__init__ of the form, the save logic of the view, and the template at the 
end. I left out the CreateItemsSection() function that builds of the 
listItems dict because its convoluted. The listItems structure is in a form 
that's easily looped through in the template and the function creates (on 
the initial load) or inserts (on POST back) the forms of the formset. If it 
would be helpful I can post it but I think there should be enough 
information here.

Is there a better way to accomplish what I'm doing with the to_python() 
method? 

# Form class 

# I use the self["multiLineInfo"] pattern instead of 
self.fields["multiLineInfo"] 
# because the former gives a BoundField which merges the Field and the 
# post/initial data
class OrganizationItemForm(ModelForm):
selected  = forms.BooleanField(required=False)  
extraRequired = forms.BooleanField(required=False, 
widget=forms.HiddenInput)
multiLineInfo = forms.BooleanField(required=False, 
widget=forms.HiddenInput)

def __init__(self, *args, **kwargs):
super(AuditModelForm, self).__init__(*args, **kwargs)
if self["multiLineInfo"].to_python():
self.fields["descr"].widget = 
forms.Textarea(attrs={"class":"descriptionEdit"})
else:
self.fields["descr"].widget = 
forms.TextInput(attrs={"class":"itemDescrEdit"}) 
self.fields["descr"].required = self["extraRequired"].to_python() 
and self["selected"].to_python()

class Meta:
model = OrganizationItem

# Model classes

class OrganizationItem(models.Model):
organization = models.ForeignKey(Organization)
item   = models.ForeignKey(ListItem)
descr  = models.TextField("Description", blank=True)

# View 

def organizationAdd(request):

OrganizationItemFormSet = formset_factory(OrganizationItemForm)

if request.method == 'POST':
form = OrganizationForm(request.POST)
orgItemFormSet = OrganizationItemFormSet(request.POST)
if form.is_valid():
form.save() 
for itm in orgItemFormSet:
if itm["selected"].to_python():
itm.instance.organization = form.instance
if orgItemFormSet.is_valid():
SaveItems(form.instance, orgItemFormSet)
redirect("orgEdit", form.instance.pk)
else:
form.instance.delete()
listItems = CreateItemsSection(orgItemFormSet, 
category__organization=True)
else:
form = OrganizationForm()
orgItemFormSet = OrganizationItemFormSet() 
listItems = CreateItemsSection(orgItemFormSet, "organization", 
category__organization=True)

context = {
'title': 'New organization', 
'form': form, 
'listItems': listItems, 
'listItemsManagementForm': orgItemFormSet.management_form, 
'isNew': True}

return render_to_response('organizationEdit.html', context,
context_instance=RequestContext(request))

# Template

{{ listItemsManagementForm }}

{% for item in listItems %}

{{ item.form.descr.errors }}{% if item.form.descr.errors 
%}{% endif %}
{{ item.form.selected }} {{ item.label }}
{% if item.form.extraRequired.to_python or item.descrLabel %}
{% if item.form.multiLineInfo.to_python %}

{% else %}

{% endif %}
{{ item.descrLabel }}
{% if item.form.multiLineInfo.to_python %}

{% else %}

{% endif %}
{{ item.form.descr }}
{% else %}

Re: Best practice when testing form values in a template?

2011-08-05 Thread Joshua Russo
Ok, I apologize. Here is a fuller representation of what I'm doing. I had a 
hard time figuring out how much was enough versus too much. This is 
simplified, but I think it represents what I'm trying to do. For instance, 
don't pay too much attention to the save logic in the view, I haven't 
actually really worked on it much yet.

To restate my scenario, I want to carry information in hidden fields of a 
form that determine how the form is displayed and functions. I realize I do 
have access to the self.Initial values in the form itself but I don't think 
that there's easy access to those values in the template. The value that I 
want seems to be the value() method of the BoundField, but run through the 
to_python() method of the field. I actually solved this by adding a 
to_python() method to the BoundField that does just this, but I would like 
to solve this without modifying the Django code. The samples below do not 
reflect my added to_python() method.

# Form class (I use the self["multiLineInfo"] pattern instead of 
self.fields["multiLineInfo"] 
# because the former gives a BoundField which merges the Field and the 
post/initial data)
class OrganizationItemForm(ModelForm):
selected  = forms.BooleanField(required=False)  
extraRequired = forms.BooleanField(required=False, 
widget=forms.HiddenInput)
multiLineInfo = forms.BooleanField(required=False, 
widget=forms.HiddenInput)

def __init__(self, *args, **kwargs):
super(AuditModelForm, self).__init__(*args, **kwargs)
if self["multiLineInfo"].value():
self.fields["descr"].widget = 
forms.Textarea(attrs={"class":"descriptionEdit"})
else:
self.fields["descr"].widget = 
forms.TextInput(attrs={"class":"itemDescrEdit"}) 
self.fields["descr"].required = self["extraRequired"].value() and 
self["selected"].value()

class Meta:
model = OrganizationItem

# Model classes

class OrganizationItem(models.Model):
organization = models.ForeignKey(Organization)
item   = models.ForeignKey(ListItem)
descr  = models.TextField("Description", blank=True)

class ListItem(models.Model):
category = models.ForeignKey(ListCategory)
name = models.CharField("Name", max_length=200)
order= models.IntegerField("Order")
extraInfo = models.BooleanField("Requires extra information")
multiLineInfo = models.BooleanField("The display should use a multi-line 
edit box instead of a single line edit")
descrLabel= models.CharField("Extra information label", 
max_length=50,
blank=True)

class ListCategory(modelUtils.MyModelAudit):
catId = models.CharField("Category identifier", max_length=15,
primary_key=True)
name  = models.CharField("Name", max_length=100)
order = models.IntegerField("Order")
group = models.ForeignKey(ListGroup)
organization = models.BooleanField("Should this be associated with an 
organization?")
twoColumn= models.BooleanField("Should the current list span 2 
columns?")

class ListGroup(modelUtils.MyModelAudit):
name = models.CharField("Name", max_length=15)
descr = models.CharField("Description", max_length=100, blank=True)
order = models.IntegerField("Order")

# View example
def organizationAdd(request):

OrganizationItemFormSet = formset_factory(OrganizationItemForm)

if request.method == 'POST':
orgItemFormSet = OrganizationItemFormSet(request.POST)
orgItemFormSetIsValid = orgItemFormSet.is_valid()
if orgItemFormSetIsValid:
orgItemFormSet.save(commit=False)
else:
orgItemFormSet = OrganizationItemFormSet() 
listItems = CreateItemsSection(orgItemFormSet, "organization", 
category__organization=True)

context = {
'listItems': listItems, 
'listItemsManagementForm': orgItemFormSet.management_form}

return render_to_response('organizationEdit.html', context,
context_instance=RequestContext(request))


def CreateItemsSection(formset, idField="", objId=None, relation=None, 
**kwargs):
"""Construct the list of selectable items"""

qs = ListItem.objects.filter(**kwargs)

# Get the appliable list of groups
groups = qs.values(
"category__group", "category__group__descr"
).order_by(
"category__group__order"
).distinct()

# Convert the items relation into a dictionary of ListItem PK and 
XItems.descr
selectedData = {}
if relation is not None:
selectedData = dict([(item.item__id, item.descr) for item in 
relation])

retVal = []

# Track the current form to display when the formset is populated from a 
postback
formIndex = 0;
postedData = len(formset) > 0

# Assemble the information for each category group
for grp in groups:
# The current group's description
curGrpDescr = grp["category__group__descr"]
# 

Re: Best practice when testing form values in a template?

2011-08-03 Thread Joshua Russo
Really? Nothing? Do you need more information? From the lack of response I 
feel like I'm completely off the mark and nobody wants to tell me.

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



Re: Best practice when testing form values in a template?

2011-08-03 Thread Joshua Russo
Or am I not using these concepts as intended?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UvoTGqPzDBoJ.
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.



Best practice when testing form values in a template?

2011-08-02 Thread Joshua Russo
Ok, so I've created a fairly simple form:


class OrganizationItemForm(AuditModelForm):
selected  = forms.BooleanField()  
extraRequired = forms.BooleanField(widget=forms.HiddenInput)
multiLineInfo = forms.BooleanField(widget=forms.HiddenInput)

def __init__(self, *args, **kwargs):
super(AuditModelForm, self).__init__(*args, **kwargs)
if self["multiLineInfo"].value():
self.fields["descr"].widget = 
forms.Textarea(attrs={"class":"descriptionEdit"})
else:
self.fields["descr"].widget = 
forms.TextInput(attrs={"class":"itemDescrEdit"}) 
self.fields["descr"].required = self["extraRequired"].value()

class Meta:
model = OrganizationItem

I use this as a single checkbox entry that could optionally have either a 
single line edit, multi-line edit, or no text box at all

The applicable section of the template looks like this:



{% for item in cat.items %}
{{ item.form.selected }} {{ item.label }}
{% if item.form.extraRequired.value or item.descrLabel %}  
{% if item.form.multiLineInfo.value %}

{% else %}

{% endif %}
{{ item.descrLabel }}
{% if item.form.multiLineInfo.value %}

{% else %}

{% endif %}
{{ item.form.descr }}
{% else %}
{{ item.form.descr.as_hidden }}
{% endif %}
{{ item.form.extraRequired }}
{{ item.form.multiLineInfo }}

{% endfor %}
 

Keep in mind, this is a work in progress. I've not integrated the error 
output yet. Right now my problem is that if I simply click submit to test 
all of the error conditions, the value of the hidden fields is a string. 
This seems to be because to_python is only called for the cleaned value. The 
cleaned data is only available after the form passes validation.

What is the best practice for carrying data like this in a form and using it 
in the templates to govern conditionals?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/nvSquVbDnmMJ.
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: Extending the ManyToMany relation, maybe a bad idea

2011-07-28 Thread Joshua Russo
Ya, sorry, I was just getting frustrated because I was taking longer than I 
wanted to implement this. The formset is what I ended up with. The tricky 
part is still that I want a defined list of options in the formset, so I 
can't just make it a model formset. I haven't worked in Django in a while 
and it just takes a little bit to get my mind around what the options really 
are.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/g0dNryER_WoJ.
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: Extending the ManyToMany relation, maybe a bad idea

2011-07-27 Thread Joshua Russo
Ok, so I can retrieve this extra data in the __init__ of the model form, but 
it seems like I will need to skip all of the cleaning and automatic 
validation of the form; because the data, to be displayed with the 
associated checkbox will have to be included with the items field in the 
OrganizationForm and fields and form names need to have a one to one 
relationship. 

I keep thinking I'm doing something wrong here. From the lack of responses I 
feel like there is no real good way to handle a group of options with 
additional relational data.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dgChbxIsY24J.
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: Extending the ManyToMany relation, maybe a bad idea

2011-07-27 Thread Joshua Russo
My problem is that I have multiple values and I need to associate the list 
of extra fields with selected relations for the ManyToMany relation. Below 
is a simplified version of what my setup is. 

I want to create an edit form for Organization, but I'm struggling with how 
best to save (and re-retrieve for display) the descr field in 
OrganizationItem. I don't see how adding fields to the OrganizationForm will 
accomplish this.

# Models

class Organization(models.Model):
name  = models.CharField("Organization's name", max_length=100)
items = models.ManyToManyField(ListItem, through='OrganizationItem')

class OrganizationItem(models.Model):
organization = models.ForeignKey(Organization)
item   = models.ForeignKey(ListItem)
descr  = models.TextField("Description", blank=True)

class ListItem(models.Model):
name = models.CharField("Name", max_length=200)
order= models.IntegerField("Order")
extraInfo = models.BooleanField("Requires extra information")
multiLineInfo = models.BooleanField("The display should use a multi-line 
edit box instead of a single line edit")
descrLabel= models.CharField("Extra information label", 
max_length=50,
blank=True)

# ModelForm

class OrganizationForm(ModelForm):
class Meta:
model = Organization


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/i4f72wAdJqkJ.
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: Extending the ManyToMany relation, maybe a bad idea

2011-07-27 Thread Joshua Russo
Someone tell me where I'm going wrong conceptually here, I feel like I'm 
making this too hard.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/T5m8OIVMyusJ.
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: Extending the ManyToMany relation, maybe a bad idea

2011-07-27 Thread Joshua Russo
I am using the through keyword. I'm just trying to figure out the 
most efficient way to create a form field and widget to update the data.

What I'm struggling with is how a ManyToMany field with an intermediate 
table containing extra fields fits into the ModelForm saving. I'm just not 
sure where to save the extra field data, how best to collect it in the form, 
or how I would handle re-retrieving of the extra fields. The only  thing 
I've created so far is an extension of the ModelMultipleChoice field that 
creates a custom choices structure and an accompanying widget that extends 
CheckboxSelectMultiple. This will display the structure, but what's the best 
practice here for saving and re-displaying?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BcS0YvmaCjwJ.
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.



Extending the ManyToMany relation, maybe a bad idea

2011-07-24 Thread Joshua Russo
Ok, so I've created a structure of selectable properties, that for the most 
part is a straight forward many-to-many relationship. What I've added is a 
character field in the relationship table that should conditionally display 
based on the setup of the property being selected.

What I wanted to do was create a complex CheckboxSelectMany widget and 
supporting form and model fields, but once I got into the saving, deletion, and 
retrieval in the related field model fields, it looked like too much of a 
rewrite.

My current thought is to do each checkbox / conditional field combination as an 
individual form. Though I'm not sure if this is the best way to go about it 
either, because I don't see any real automated way to do this; short of 
retrieving all of the checkbox options and creating the form instances myself. 
I'm not opposed to this, I just want to make sure I'm not re-inventing the 
wheel. 

Any suggestions? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rkty0SwesqIJ.
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 overriding registration templates

2011-07-19 Thread Joshua Russo
btw, I was correct, it was the development settings causing the problem

On Wed, Jul 13, 2011 at 1:43 PM, Joshua Russo <josh.r.ru...@gmail.com>wrote:

> Correct
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/K5yKllF_gPcJ.
>
> 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.
>

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

2011-07-13 Thread Joshua Russo
Correct

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/K5yKllF_gPcJ.
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 overriding registration templates

2011-07-13 Thread Joshua Russo
*light bulb* I forgot about my development vs production settings. I was 
only changing the TEMPLATE_DIRS in the main settings.py that represents my 
production settings. I'm not in a place where I can test this but I'm almost 
certain that's what the problem is.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/eOkOKob7PMgJ.
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 overriding registration templates

2011-07-13 Thread Joshua Russo
Cool, thanks for the confirmation. 

I do have my template directories explicitly listed in TEMPLATE_DIRS. I even 
made sure that my app's templates came before the admin templates, but for 
some reason it's not picking up my /registration/logged_out.html and the 
others that show up in the admin's templates/registration directory. My 
/registration/login.html works just fine.

I'll try playing with the order of the installed apps and see if that makes 
any difference.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GJZkPFObtAIJ.
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 overriding registration templates

2011-07-13 Thread Joshua Russo
That's fine, but I was under the impression that the templates could be 
overridden just by creating the proper path in my template directories. Is 
that not true?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1wsAXZTaRvoJ.
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: AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Am I wrong about how templates work?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/FVBKI9qS2PQJ.
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: AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Sorry, auto correct strikes again. I was trying to reply quickly from my 
phone. I meant auth, not author views. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/CoqBYvTqp8UJ.
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.



AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
I do have a views that are basically just proxies for the author views, but I 
was under the impression that if I just wanted to replace the registration 
templates then all I needed was a registration directory in my templates 
directory with the right file names. From there it should just take the first 
template it finds in the list of template directories in settings.

Where is the default login.html template? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1QEreGVNwuMJ.
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 overriding registration templates

2011-07-12 Thread Joshua Russo
I want to use my own logout template but it doesn't want to pick it up. The 
login template worked just fine, but for anything that's already in the 
admin's template/registration folder, it only wants to use those. I tried 
putting my templates folder before the admin templates folder in the list of 
template folder in the settings file but that didn't do anything. Any 
suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VcsTSOx1iSoJ.
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: Which PostgreSQL driver do you use

2010-08-26 Thread Joshua Russo
On Thu, Aug 26, 2010 at 10:17 PM, Joshua Russo <josh.r.ru...@gmail.com>wrote:

> There are a lot of PostgreSQL drivers listed on the Python Wiki
> http://wiki.python.org/moin/PostgreSQL
>
> Has anyone found one to be better or even that different from another?
>

Nevermind, It helps to read the docs.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Which PostgreSQL driver do you use

2010-08-26 Thread Joshua Russo
There are a lot of PostgreSQL drivers listed on the Python Wiki
http://wiki.python.org/moin/PostgreSQL

Has anyone found one to be better or even that different from another?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout

2010-08-06 Thread Joshua Russo
On Fri, Aug 6, 2010 at 12:17 PM, Joshua Russo <josh.r.ru...@gmail.com>wrote:

> On Aug 6, 9:57 am, "J. Cliff Dyer" <j...@sdf.lonestar.org> wrote:
> > "Joshua Russo" <josh.r.ru...@gmail.com> wrote:
> > >On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden <holden...@gmail.com>
> wrote:
> >
> > >> On 8/5/2010 7:16 PM, Joshua Russo wrote:
> > >> > On Aug 4, 6:49 pm, Hassan <hsn.zam...@gmail.com> wrote:
> > >> >>> Ok, so it appears that (in Python 2.5 at least) there is no way to
> > >> capture
> > >> >>> the stdout of subprocess.Popen()
> >
> > >> >> just do this
> >
> > >> >> from subprocess import Popen, PIPE
> > >> >> p = Popen([cmd], stdout=PIPE)
> > >> >> p.stdout.readlines()
> >
> > >> >> thats it!
> >
> > >> > The problem is that it waits for the process to end to output
> > >> > anything. Unless I was doing something wrong, but I think I was
> doing
> > >> > just what you describe here.
> >
> > >> Well, readlines() inherently has to see the end of the data stream
> > >> before it can return a list of all the lines that the data stream
> > >> contains, so that's hardly surprising is it?
> >
> > >> Try using readline() in a loop and see if that gives you better
> results.
> > >> I don't guarantee it will, but at least you will have some chance if
> > >> subprocess.open() *isn't* buffering the whole stream.
> >
> > >> regards
> > >>  Steve
> >
> > >Tried that too and even putting the reading of them in their own thread
> as
> > >someone else suggested on Stackoverflow. I just can't find anyway to
> capture
> > >stdout in real-time from Popen. The problem is that everything uses
> > >readline() that buffers the output.
> >
> > >http://stackoverflow.com/questions/874815/how-do-i-get-real-time-info.
> ..
> > >http://stackoverflow.com/questions/2082850/real-time-subprocess-popen.
> ..
> >
> > >The way I got it to work with out Popen is to use a text box control as
> the
> > >stdout object. This works great, utilizing the object's write() method.
> >
> > >The problem with Popen is that it expects the stdout object to have a
> > >fileno() method also, which the text box control does not have. So I
> tried
> > >extending the text box to add the fileno() and had it return 1 like the
> > >standard stdout, but still no dice. I didn't let the process (unit
> tests)
> > >finish but it definitely was not giving real time output, through it did
> > >accept the control with the fileno() method added. It really seems like
> that
> > >should have worked and I may have been able to dig further into Popen to
> > >make it work but I figured that I had spent too much time on it as it
> was.
> >
> > >If anybody has more suggestions I'd love to hear them.
> >
> > >--
> > >You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > >To post to this group, send email to django-us...@googlegroups.com.
> > >To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> > >For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en.
> >
> > If I understand your issue correctly, in ran into something similar a
> while back. The problem is not in subprocess, but in how stdout works.  The
> output is buffered by default, so it only gets written on a line-by-line
> basis.
> >
> > If you want to catch it one character at a time, you have to explicitly
> flush the output after each character using sys.stdout.flush().  Then, of
> course, you'll also have to read it from subprocess one character at a time,
> too,
> > using .read(1) instead of .readline()
> >
> > I hope that addresses your issue.
> >
> > Cheers,
> > Cliff
>
> Thanks for the tip, I'll check it out.


Nope, still no dice. Below is what I did. I modified the worker() function
from one of the Stackoverflow examples. Let me know if I'm using flush
properly. Keep in mind that everything you see here is already running in a
separate thread from the wxPython GUI so I can update the GUI while all my
tests run in the background.

import threading
import subprocess as sp
import sys

class ThreadWorker(threading.Thread):
def __init__(self

Re: Python question about subprocess.Popen() and stdout

2010-08-06 Thread Joshua Russo
On Aug 6, 9:57 am, "J. Cliff Dyer" <j...@sdf.lonestar.org> wrote:
> "Joshua Russo" <josh.r.ru...@gmail.com> wrote:
> >On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden <holden...@gmail.com> wrote:
>
> >> On 8/5/2010 7:16 PM, Joshua Russo wrote:
> >> > On Aug 4, 6:49 pm, Hassan <hsn.zam...@gmail.com> wrote:
> >> >>> Ok, so it appears that (in Python 2.5 at least) there is no way to
> >> capture
> >> >>> the stdout of subprocess.Popen()
>
> >> >> just do this
>
> >> >> from subprocess import Popen, PIPE
> >> >> p = Popen([cmd], stdout=PIPE)
> >> >> p.stdout.readlines()
>
> >> >> thats it!
>
> >> > The problem is that it waits for the process to end to output
> >> > anything. Unless I was doing something wrong, but I think I was doing
> >> > just what you describe here.
>
> >> Well, readlines() inherently has to see the end of the data stream
> >> before it can return a list of all the lines that the data stream
> >> contains, so that's hardly surprising is it?
>
> >> Try using readline() in a loop and see if that gives you better results.
> >> I don't guarantee it will, but at least you will have some chance if
> >> subprocess.open() *isn't* buffering the whole stream.
>
> >> regards
> >>  Steve
>
> >Tried that too and even putting the reading of them in their own thread as
> >someone else suggested on Stackoverflow. I just can't find anyway to capture
> >stdout in real-time from Popen. The problem is that everything uses
> >readline() that buffers the output.
>
> >http://stackoverflow.com/questions/874815/how-do-i-get-real-time-info...
> >http://stackoverflow.com/questions/2082850/real-time-subprocess-popen...
>
> >The way I got it to work with out Popen is to use a text box control as the
> >stdout object. This works great, utilizing the object's write() method.
>
> >The problem with Popen is that it expects the stdout object to have a
> >fileno() method also, which the text box control does not have. So I tried
> >extending the text box to add the fileno() and had it return 1 like the
> >standard stdout, but still no dice. I didn't let the process (unit tests)
> >finish but it definitely was not giving real time output, through it did
> >accept the control with the fileno() method added. It really seems like that
> >should have worked and I may have been able to dig further into Popen to
> >make it work but I figured that I had spent too much time on it as it was.
>
> >If anybody has more suggestions I'd love to hear them.
>
> >--
> >You received this message because you are subscribed to the Google Groups 
> >"Django users" group.
> >To post to this group, send email to django-us...@googlegroups.com.
> >To unsubscribe from this group, send email to 
> >django-users+unsubscr...@googlegroups.com.
> >For more options, visit this group 
> >athttp://groups.google.com/group/django-users?hl=en.
>
> If I understand your issue correctly, in ran into something similar a while 
> back. The problem is not in subprocess, but in how stdout works.  The output 
> is buffered by default, so it only gets written on a line-by-line basis.
>
> If you want to catch it one character at a time, you have to explicitly flush 
> the output after each character using sys.stdout.flush().  Then, of course, 
> you'll also have to read it from subprocess one character at a time, too,
> using .read(1) instead of .readline()
>
> I hope that addresses your issue.
>
> Cheers,
> Cliff

Thanks for the tip, I'll check it out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout

2010-08-06 Thread Joshua Russo
On Thu, Aug 5, 2010 at 10:53 PM, Steve Holden <holden...@gmail.com> wrote:

> On 8/5/2010 7:16 PM, Joshua Russo wrote:
> > On Aug 4, 6:49 pm, Hassan <hsn.zam...@gmail.com> wrote:
> >>> Ok, so it appears that (in Python 2.5 at least) there is no way to
> capture
> >>> the stdout of subprocess.Popen()
> >>
> >> just do this
> >>
> >> from subprocess import Popen, PIPE
> >> p = Popen([cmd], stdout=PIPE)
> >> p.stdout.readlines()
> >>
> >> thats it!
> >
> > The problem is that it waits for the process to end to output
> > anything. Unless I was doing something wrong, but I think I was doing
> > just what you describe here.
> >
> Well, readlines() inherently has to see the end of the data stream
> before it can return a list of all the lines that the data stream
> contains, so that's hardly surprising is it?
>
> Try using readline() in a loop and see if that gives you better results.
> I don't guarantee it will, but at least you will have some chance if
> subprocess.open() *isn't* buffering the whole stream.
>
> regards
>  Steve


Tried that too and even putting the reading of them in their own thread as
someone else suggested on Stackoverflow. I just can't find anyway to capture
stdout in real-time from Popen. The problem is that everything uses
readline() that buffers the output.

http://stackoverflow.com/questions/874815/how-do-i-get-real-time-information-back-from-a-subprocess-popen-in-python-2-5
http://stackoverflow.com/questions/2082850/real-time-subprocess-popen-via-stdout-and-pipe

The way I got it to work with out Popen is to use a text box control as the
stdout object. This works great, utilizing the object's write() method.

The problem with Popen is that it expects the stdout object to have a
fileno() method also, which the text box control does not have. So I tried
extending the text box to add the fileno() and had it return 1 like the
standard stdout, but still no dice. I didn't let the process (unit tests)
finish but it definitely was not giving real time output, through it did
accept the control with the fileno() method added. It really seems like that
should have worked and I may have been able to dig further into Popen to
make it work but I figured that I had spent too much time on it as it was.

If anybody has more suggestions I'd love to hear them.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout

2010-08-05 Thread Joshua Russo
On Aug 4, 6:49 pm, Hassan  wrote:
> > Ok, so it appears that (in Python 2.5 at least) there is no way to capture
> > the stdout of subprocess.Popen()
>
> just do this
>
> from subprocess import Popen, PIPE
> p = Popen([cmd], stdout=PIPE)
> p.stdout.readlines()
>
> thats it!

The problem is that it waits for the process to end to output
anything. Unless I was doing something wrong, but I think I was doing
just what you describe here.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python question about subprocess.Popen() and stdout

2010-08-03 Thread Joshua Russo
On Mon, Aug 2, 2010 at 6:41 PM, Joshua Russo <josh.r.ru...@gmail.com> wrote:

> I'm creating a wxPython application that the client can run to make
> sure the installation stack is functioning properly. I want to include
> the unit test processing in this application but I've run into some
> difficulties. An additional wrinkle I threw in was that I am using
> py2exe so they don't also need to install wxPython, we'll see if that
> will actually work or not.
>
> It seems like the most appropriate thing to do is to use
> subprocess.Popen() to trigger "manage.py test --noinput". The problem
> I am trying to solve is that this runs for a while and I want to
> display the stdio output into a text box on the window.
>
> I had this working using django.core.management.call_command but
> creating the exe broke the pathing within Django and even some Python
> libraries (thus dumping py2exe could be what I need to do).
>
> The problem with switching to Popen is that it expects a file type
> object with a fileno() method. The file class cannot be extended in
> the stdio instance because you can't write back to the __class__
> property. I guess what I need to know is how do I mimic stdout? Stdout
> doesn't output to a file, but it still uses the file object. It seems
> like I want to open a file object onto a Nul output. Can this be
> done?
>
> Thanks
> Josh
>

Ok, so it appears that (in Python 2.5 at least) there is no way to capture
the stdout of subprocess.Popen(). I've tried many different suggestions from
questions that have already been posted to Stack Overflow and everything
either buffers until the end of processing or just plain doesn't work.

So I dumped Py2exe and went back to using
django.core.management.call_command() and everything works like a dream.

In case you care.

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



Python question about subprocess.Popen() and stdout

2010-08-02 Thread Joshua Russo
I'm creating a wxPython application that the client can run to make
sure the installation stack is functioning properly. I want to include
the unit test processing in this application but I've run into some
difficulties. An additional wrinkle I threw in was that I am using
py2exe so they don't also need to install wxPython, we'll see if that
will actually work or not.

It seems like the most appropriate thing to do is to use
subprocess.Popen() to trigger "manage.py test --noinput". The problem
I am trying to solve is that this runs for a while and I want to
display the stdio output into a text box on the window.

I had this working using django.core.management.call_command but
creating the exe broke the pathing within Django and even some Python
libraries (thus dumping py2exe could be what I need to do).

The problem with switching to Popen is that it expects a file type
object with a fileno() method. The file class cannot be extended in
the stdio instance because you can't write back to the __class__
property. I guess what I need to know is how do I mimic stdout? Stdout
doesn't output to a file, but it still uses the file object. It seems
like I want to open a file object onto a Nul output. Can this be
done?

Thanks
Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Generic web-dev question: Best way to do a processing page?

2010-05-01 Thread Joshua Russo
This is mainly just curiosity at the moment. How do you create a
"processing" intermediate page, like you see on travel sites when they are
looking for the rates? I would always avoid this if at all possible, but
sometimes you have a process that takes longer than usual.

I've been looking around the web and I am not coming up with many examples.
So far I have only found one.

http://blog.ysatech.com/post/2010/02/06/ASPNET-redirect-a-web-page-with-AJAX-loading-indicator-image.aspx

Is that pretty much how it's done?

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



Re: Django Admin: DateField (Year and Month) only

2009-10-19 Thread Joshua Russo
I don't have an example of a date field but here is an example of how I
extended the Decimal field in making a Currency field.
http://www.djangosnippets.org/snippets/1527/

<http://www.djangosnippets.org/snippets/1527/>In the description there are
also links to the entire series of objects, including an input widget. That
should get you started on the concept of extending fields and widgets.


On Mon, Oct 19, 2009 at 10:40 PM, The Danny Bos <danny...@gmail.com> wrote:

>
>
> APologies for my naivety, how would I do that.
> Any examples you can point me toward?
>
> Thanks for the fast reply,
>
>
> d
>
>
>
> On Oct 20, 10:38 am, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > On Mon, Oct 19, 2009 at 10:28 PM, The Danny Bos <danny...@gmail.com>
> wrote:
> >
> >
> >
> > > Hiya,
> >
> > > In the Django Admin for the DateField I only want to display the Year
> > > and Month as select lists. I'll default the day to the 1st every time.
> > > Is this possible?
> >
> > > I want to keep the dates very simple, as I'll be adding many items
> > > from 1900 to now. So using the current DateField calendar in Django
> > > Admin would be an absolute nightmare.
> >
> > > Any ideas?
> >
> > Your best bet is to extend the date form field and input widget.
> >
>

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



Re: Django Admin: DateField (Year and Month) only

2009-10-19 Thread Joshua Russo
On Mon, Oct 19, 2009 at 10:28 PM, The Danny Bos  wrote:

>
> Hiya,
>
> In the Django Admin for the DateField I only want to display the Year
> and Month as select lists. I'll default the day to the 1st every time.
> Is this possible?
>
> I want to keep the dates very simple, as I'll be adding many items
> from 1900 to now. So using the current DateField calendar in Django
> Admin would be an absolute nightmare.
>
> Any ideas?
>

Your best bet is to extend the date form field and input widget.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Help with splicing models to a legacy DB, please

2009-10-19 Thread Joshua Russo
On Mon, Oct 19, 2009 at 8:03 PM, John Handelaar  wrote:

>
> Hello
>
> For reasons I won't bore you with, a Mysql legacy DB *whose schema I
> cannot alter* contains (inter alia) two tables.  I'm trying to write
> an alternative front-end to this DB in Django which would be
> read-only.
>
> tableone has a primary key called tableone_id
>
> tabletwo contains rows which have a 1:1 relationship with equivalent
> rows in tableone, and a column called tableone_id to allow me connect
> them with a JOIN.  It does not, however, have a primary key of its
> own.
>
> It seems obvious to me that these two tables belong in one Model
> definition. How do I define a single model which spans the two tables
> and returns querysets containing all columns from both tables?
>
> a)  With a model manager?  If so, where do I put that manager and are
> there any examples I can steal?
> b)  With custom SQL in the model definition?  If so, again, does
> someone have an example online I can see somewhere?
> c)  Somewhere else?
>

I think your best bet is to create a view to logically combine the tables in
the DB. You can then use the following link that I just stumbled on my self
in another thread on this list. It describes a method for accessing views
via a model.
http://wolfram.kriesing.de/blog/index.php/2007/django-nice-and-critical-article#comment-48425

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

2009-10-19 Thread Joshua Russo
2009/10/19 Tomasz Zieliński 

>
> On 19 Paź, 20:21, Daniel Roseman  wrote:
> >
> > You can't do this in one query with Django's ORM.
> >
> > One way of doing it in two queries might be to get use .annotate() to
> > add the max id of the related objectrevision for each revision, then
> > get all those objectrevisions (untested):
> >
> >objects = Object.objects.all().annotate(revision_id=Max
> > ('objectrevision__id'))
> >objectrevisions = ObjectRevision.objects.filter(id__in=
> > [o.revision_id for o in objects])
> >
>
> I found this solution, but we are talking about thousends of objects,
> so SQL query would be really huge. I' tested it with MySQL Query
> Browser
> and passing ton of ids to `WHERE id IN (...)` clause was causing major
> overhead
> comparing to using JOIN.
>
> Fortunately, in the mean time, I've found a nice solution using SQL
> views:
>
>
> http://wolfram.kriesing.de/blog/index.php/2007/django-nice-and-critical-article#comment-48425
>
> This is not strictly a solution to the problem I asked, but it allows
> to hide SQL under the floor
> and just use Django ORM in everydays work.
>
> Anyway, thank you for confirmation on this limitation, I wasn't sure
> about it.
>

Interesting. I've been wondering how one might tackle accessing views via
models. Thanks for the link.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Foreign language in View Model.

2009-10-11 Thread Joshua Russo
You may want to check how the encoding is set in your database. Make sure
you are using utf-8.

On Sat, Oct 10, 2009 at 9:43 PM, Rizwan <mr.mans...@googlemail.com> wrote:

>
> I am trying to extend flatpage view...I have added custom code
> here..you can see navigation showing question mark here
> http://beta.rmansuri.net/homepage/
>
>
> from django.contrib.flatpages.models import FlatPage
> from django.template import loader, RequestContext
> from django.shortcuts import get_object_or_404
> from django.http import HttpResponse, HttpResponseRedirect
> from django.conf import settings
> from django.core.xheaders import populate_xheaders
> from django.utils.safestring import mark_safe
> import datetime, MySQLdb
> DEFAULT_TEMPLATE = 'flatpages/default.html'
>
> def flatpage(request, url):
>"""
>Flat page view.
>
>Models: `flatpages.flatpages`
>Templates: Uses the template defined by the ``template_name``
> field,
>or `flatpages/default.html` if template_name is not defined.
>Context:
>flatpage
>`flatpages.flatpages` object
>"""
>if not url.endswith('/') and settings.APPEND_SLASH:
>return HttpResponseRedirect("%s/" % request.path)
>if not url.startswith('/'):
>url = "/" + url
>f = get_object_or_404(FlatPage, url__exact=url,
> sites__id__exact=settings.SITE_ID)
># If registration is required for accessing this page, and the
> user isn't
># logged in, redirect to the login page.
>if f.registration_required and not request.user.is_authenticated
> ():
>from django.contrib.auth.views import redirect_to_login
>return redirect_to_login(request.path)
>if f.template_name:
>t = loader.select_template((f.template_name,
> DEFAULT_TEMPLATE))
>else:
>t = loader.get_template(DEFAULT_TEMPLATE)
>
># To avoid having to always use the "|safe" filter in flatpage
> templates,
># mark the title and content as already safe (since they are raw
> HTML
># content in the first place).
>f.title = mark_safe(f.title)
>f.content = mark_safe(f.content)
>
>#custom code start
>db = MySQLdb.connect
> (user='rmansuri_gq',db='rmansuri_gq',passwd='riz#wan1712',host='localhost')
>cursor = db.cursor()
>cursor.execute("SELECT * from django_flatpage where id != 2")
>details = [row for row in cursor.fetchall()]
>db.close()
># custom code ends
>c = RequestContext(request, {
>'flatpage': f, 'details':details,
>})
>response = HttpResponse(t.render(c))
>populate_xheaders(request, response, FlatPage, f.id)
>return response
>
> HTML CODE
>
>  www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">
> 
>>
>
>
>
>{{flatpage.title}}
> media="screen" />
>
>
>
> 
>
> 
> 
> 
> Gujarati Quran h2>
> 
> 
> home
> about
> contact
> 
> 
> 
> 
> [+] |
>  href="javascript:ts('body',-1)">[-]
> 
>  {{flatpage.title}}
>  {{flatpage.content}}
>  
> 
> 
> 
>
>{% for id,url, title,content in details %}
>{{title|safe}}
>{% endfor %}
>
> 
>
>Recent Entries
>
>Recent Entries1 01 Des
> 06
>    Recent Entries2 01 Des
> 06
>Recent Entries3 01 Des
> 06
>Recent Entries4 01 Des
> 06
>Recent Entries5 01 Des
> 06
>
>
> 
> 
> 
> http://www.rmansuri.net/;
> rel="external">rMansuri.net. Valid http://jigsaw.w3.org/
> css-validator/check/referer" rel="external">CSS   href="http://validator.w3.org/check?uri=referer; rel="external">XHTML a>
> 
> 
>
> 
> 
>
> On 10 Oct, 20:40, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > On Sat, Oct 10, 2009 at 9:15 AM, Rizwan <br.riz...@googlemail.com>
> wrote:
> >
> > > Hello Djangoer,
> >
> > > I am trying to create website with foreign language in it. I have
> > > created model for content type and added one page in it. It saving
> > > fine in database. When I have tried to write view model for this page.
> > > Its showing me "?" rather then foreign character. I am new born
> > > baby in django world. any help or suggestion would be great.
> >
> > > you can see the this question mark athttp://
> beta.rmansuri.net/surah/001/
> >
> > Without the code from your view (and possibly the template) it's
> > too difficult to say.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Foreign language in View Model.

2009-10-10 Thread Joshua Russo
On Sat, Oct 10, 2009 at 9:15 AM, Rizwan  wrote:

>
> Hello Djangoer,
>
> I am trying to create website with foreign language in it. I have
> created model for content type and added one page in it. It saving
> fine in database. When I have tried to write view model for this page.
> Its showing me "?" rather then foreign character. I am new born
> baby in django world. any help or suggestion would be great.
>
> you can see the this question mark at http://beta.rmansuri.net/surah/001/
>

Without the code from your view (and possibly the template) it's
too difficult to say.

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

2009-09-29 Thread Joshua Russo
oh ok, so just use the filter(user_id = user.id)

On Tue, Sep 29, 2009 at 12:21 AM, luismmontielg <luismmonti...@gmail.com>wrote:

>
> Actually there it is,
>
> users = models.ManyToManyField(User, symmetrical=True)
>
> but I want to filter only the reports that contain only this user, or
> exclude the ones that do not have the user.
>
> Thanks again
>
>
> On 28 sep, 20:16, luismmontielg <luismmonti...@gmail.com> wrote:
> > sorry forgot to mention its a many to many relation so a report can
> > have multiple users
> >
> > On Sep 28, 4:29 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> >
> >
> >
> > > On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg <
> luismmonti...@gmail.com>wrote:
> >
> > > > Hello,
> > > > I have my models like this...
> >
> > > > class Report(models.Model):
> > > >title = models.CharField(max_length=50, blank=True)
> > > >users = models.ManyToManyField(User, symmetrical=True)
> > > >categories = models.ManyToManyField("Category",
> > > > through='ReportDetail', \
> > > > symmetrical=True)
> >
> > > > I would like to get all reports from 1 user, but that only contain
> > > > that user
> >
> > > > I was looking for ne, not equals, but its removed, I cant do it with
> > > > the exclude:
> > > > I want to make something like this
> > > > user = User.objects.get(pk=1)
> > > > user_reports = user.report_set.exclude(users__id__NOTEQUAL = user.id
> )
> >
> > > > how can I achieve this?
> >
> > > I'm not sure I completely follow, but user.report_set only gives you
> reports
> > > for the associated user, and it seems like that is what you want. You
> don't
> > > need any further filters or excludes.
> >
> > > For future reference:
> > > exclude(user_id__ne = user.id)
> > > is the same as
> > > filter(user_id = user.id)
> >
>

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

2009-09-28 Thread Joshua Russo
On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg wrote:

>
> Hello,
> I have my models like this...
>
> class Report(models.Model):
>title = models.CharField(max_length=50, blank=True)
>users = models.ManyToManyField(User, symmetrical=True)
>categories = models.ManyToManyField("Category",
> through='ReportDetail', \
> symmetrical=True)
>
>
> I would like to get all reports from 1 user, but that only contain
> that user
>
> I was looking for ne, not equals, but its removed, I cant do it with
> the exclude:
> I want to make something like this
> user = User.objects.get(pk=1)
> user_reports = user.report_set.exclude(users__id__NOTEQUAL = user.id)
>
> how can I achieve this?
>

I'm not sure I completely follow, but user.report_set only gives you reports
for the associated user, and it seems like that is what you want. You don't
need any further filters or excludes.

For future reference:
exclude(user_id__ne = user.id)
is the same as
filter(user_id = user.id)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: multi-db vs. data warehouse

2009-09-28 Thread Joshua Russo
On Mon, Sep 28, 2009 at 6:36 PM, David Larlet  wrote:
>
> Le 22 sept. 2009 à 03:10, snfctech a écrit :
> > I understand that there is a Django branch being actively worked on
> > for connections to multiple DB vendors, or that Django + Elixir may be
> > a good option.  But I'm wondering if building a single data warehouse
> > may still be a better way to go?
>
> Self-promotion here, but if you eventually choose the data warehouse
> approach, you should take a look at django-roa:
> http://code.welldev.org/django-roa/wiki/Home
>
> It allows you to deal with your HTTP resources as Django models
> painlessly.
> Do not hesitate to contact me if that's your final choice, I already
> use it against a data warehouse.


That looks pretty cool. I will definitely keep that in mind in the future.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: multi-db vs. data warehouse

2009-09-28 Thread Joshua Russo
I've never used Elixir so I can't really comment on the pros and cons.
With my personal experience I would go with an ETL and copy the desired data
directly into your ordering system. Just keep in mind that these new tables
should stay read-only as far as the ordering system goes. The data would be
there solely for ease of reference.

It really depends on where your skills lie. Play around with Elixir and see
if you can get what you need out of it. I see only two things to keep in
mind with Elixir and/or muti-db.
1) You won't be able to create real foreign keys because they are in
different physical systems. Though you can still create columns in the
ordering system that hold the primary keys of the other systems.
2) You won't be able to do real joins. You will have to query each system
independently. And yes this will still be the case with the multi-db support
when it is in place. Of course you will be able to intelligently build the
queries based on the dataset in the ordering system.


On Mon, Sep 28, 2009 at 3:13 PM, Tony Schmidt <tschm...@sacfoodcoop.com>wrote:

>
> "If you need to link one order item to other data in the warehouse it
> should
> only either be done in the warehouse or between the systems outside of
> the
> warehouse."
>
> Now we're back to the crux of the topic!  Joins in the warehouse, or
> cross-vendor joins between disparate systems?
>
> If multi-db _were_ done, or if multi-db connections with cross-vendor
> joins via Elixir were an option, would that be a preferable route to
> creating those joins between the order entry system and the
> warehouse?  I don't really need the warehouse for what it seems to be
> used for traditionally - analytics, reports and BI - I simply need it
> to make my life easier when trying to generate order and order_item
> records that have foreign key attributes in different systems like
> "product_id", "employee_id", "member_id", and so forth.  (Although, as
> I mentioned earlier, having a single repository for my OOBase users to
> go to would be an added plus.)
>
> So maybe I shouldn't be calling what I need a "warehouse", but rather
> a "central data repository with an ETL layer"?  Or maybe I should
> throw out the ETL overhead entirely and figure out how to perform
> cross-vendor, multi-db joins?
>
> That is still my quandary..
>
>
> On Sep 26, 7:46 am, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > No one is recommending multi-db because it's not done yet.
> >
> > I'm not sure I understand exactly what you mean by "creating new order
> and
> > order_item data with keys to data in the warehouse" but that doesn't
> sound
> > like a recommended approach.
> > A data warehouse (in my opinion) should be read only and no other system
> > should need to know about it. An important concept to keep in mind with a
> > warehouse is that it is never the originator of the base data (it may
> create
> > new computations of the data but it's always based on data from other
> > systems). As such it is for reporting purposes only and no other system
> > should treat it as the system of record.
> >
> > If you need to link one order item to other data in the warehouse it
> should
> > only either be done in the warehouse or between the systems outside of
> the
> > warehouse. It sounds like you want to modify the order entry application
> to
> > reference data in other systems and still display the data in the order
> > entry app. If this is the case the only solution I would implement is
> > between the two existing systems.
> >
> > As far as OLAP goes, it's not mutually exclusive from ER. It is simply a
> > method of extracting multidimensional data. An ER model can most
> certainly
> > be dimensional, you just need to integrate the proper timestamp
> structure.
> >
> > On Thu, Sep 24, 2009 at 4:35 PM, Tony Schmidt <tschm...@sacfoodcoop.com
> >wrote:
> >
> >
> >
> > > Well, I guess the answer to the thread is looking like:
> >
> > > - a data warehouse is preferable to multiple db connections and cross-
> > > vendor joins
> >
> > > But that's only because I haven't heard anyone voice support for the
> > > multi-db idea.
> >
> > > Now the question is:
> >
> > > How should the warehouse be constructed in tandem with new
> > > functionality and data entities?
> >
> > > What I've read about data warehouses seems to limit them to read-only
> > > OLAP, with special data modelling (namely dimensional, as opposed to
> > > the ER modelling I'm used to).  But in the example I give in my 

Re: custom dynamic admin actions

2009-09-28 Thread Joshua Russo
It sounds like you just want defaults for your relationships. Is that right?
How are you determining which account to use?

On Mon, Sep 28, 2009 at 12:30 PM, J <jobce...@gmail.com> wrote:

>
> Joshua Russo wrote:
> > When do you want your "dynamic actions" take place?
> >
>
> I apoligize if I was unclear. I am referring to the admin actions that
> one can select from a select box at the top of lists in admin pages.
> It's described at
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/
>
> There is no difficulty in adding static custom actions (as described at
> the link above), such as the default "Delete selected /item/s", but what
> I am trying to do is add actions that are based on a db relationship,
> such as "Set to account #1", which would set the local foreign key field
> to "account #1", which is a one of several records in the related model,
> and I would like one action for each of the records in the related model.
>
> 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: What JavaScript framework do you use and why?

2009-09-28 Thread Joshua Russo
MooTools does look interesting. What would you miss most about it, if you
had to develop without it?

On Mon, Sep 28, 2009 at 11:07 AM, justind <justin.don...@gmail.com> wrote:

>
> Joshua,
>
> Take a look at MooTools. It's a great library with a great API. It's
> been said that JQuery makes the DOM fun, but MooTools makes Javascript
> fun.
>
> On Sep 28, 4:37 am, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > On Mon, Sep 28, 2009 at 4:00 AM, Jani Tiainen <rede...@gmail.com> wrote:
> >
> > > Joshua Russo kirjoitti:
> > > > Great links guys, thanks. I'm still in the mindset of frameworks just
> > > > making JavaScript less painful too and I'm looking for ways to move
> > > > beyond that. I just started looking at Dojo before posting this and
> it
> > > > definitely looks like it has potential.
> >
> > > I'm pretty "heavy" user of Dojo. My project is completely built on top
> > > of Django/Dojo using JSON-RPC to do talk with Django part.
> >
> > > I'm pretty happy how it works, specially declarative way to make
> widgets
> > > is pretty cool comparing to other that usually require JS markup to
> > > achieve same thing.
> >
> > > Dojango is pretty nice. I just don't use (model)forms all.
> >
> > Do you use the Admin app at all? Or are your sites all just custom views?
> >
>

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

2009-09-28 Thread Joshua Russo
On Mon, Sep 28, 2009 at 4:30 AM, J  wrote:

>
> Hello,
>
> I need to add custom dynamic admin actions (based on records in a
> related table), but I'm not entirely sure how to do this, as it's not
> explained in the docs.
>
> Basically, I have two models: "Transaction", which has a foreign key to
> "Account", and I want to define an admin action that will set all the
> selected records in the "Transaction" model to a specific "Account".
>
> One idea I had was to have different actions: "Set to account 1", "Set
> to account 2", but I'm having trouble creating these admin actions
> dynamically.


When do you want your "dynamic actions" take place?

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



Re: What JavaScript framework do you use and why?

2009-09-28 Thread Joshua Russo
On Mon, Sep 28, 2009 at 4:00 AM, Jani Tiainen <rede...@gmail.com> wrote:

>
> Joshua Russo kirjoitti:
> > Great links guys, thanks. I'm still in the mindset of frameworks just
> > making JavaScript less painful too and I'm looking for ways to move
> > beyond that. I just started looking at Dojo before posting this and it
> > definitely looks like it has potential.
>
> I'm pretty "heavy" user of Dojo. My project is completely built on top
> of Django/Dojo using JSON-RPC to do talk with Django part.
>
> I'm pretty happy how it works, specially declarative way to make widgets
> is pretty cool comparing to other that usually require JS markup to
> achieve same thing.
>
> Dojango is pretty nice. I just don't use (model)forms all.


Do you use the Admin app at all? Or are your sites all just custom views?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: multi-db vs. data warehouse

2009-09-26 Thread Joshua Russo
No one is recommending multi-db because it's not done yet.

I'm not sure I understand exactly what you mean by "creating new order and
order_item data with keys to data in the warehouse" but that doesn't sound
like a recommended approach.
A data warehouse (in my opinion) should be read only and no other system
should need to know about it. An important concept to keep in mind with a
warehouse is that it is never the originator of the base data (it may create
new computations of the data but it's always based on data from other
systems). As such it is for reporting purposes only and no other system
should treat it as the system of record.

If you need to link one order item to other data in the warehouse it should
only either be done in the warehouse or between the systems outside of the
warehouse. It sounds like you want to modify the order entry application to
reference data in other systems and still display the data in the order
entry app. If this is the case the only solution I would implement is
between the two existing systems.

As far as OLAP goes, it's not mutually exclusive from ER. It is simply a
method of extracting multidimensional data. An ER model can most certainly
be dimensional, you just need to integrate the proper timestamp structure.


On Thu, Sep 24, 2009 at 4:35 PM, Tony Schmidt <tschm...@sacfoodcoop.com>wrote:

>
> Well, I guess the answer to the thread is looking like:
>
> - a data warehouse is preferable to multiple db connections and cross-
> vendor joins
>
> But that's only because I haven't heard anyone voice support for the
> multi-db idea.
>
> Now the question is:
>
> How should the warehouse be constructed in tandem with new
> functionality and data entities?
>
> What I've read about data warehouses seems to limit them to read-only
> OLAP, with special data modelling (namely dimensional, as opposed to
> the ER modelling I'm used to).  But in the example I give in my first
> post, I'm talking about creating new order and order_item data with
> keys to data in the warehouse.  Should that data be stored in the
> warehouse, as well, so I don't have to go back to multiple db
> connections for my joins?  If it co-exists with the read-only data,
> should it all be modelled the same? (all ER or all dimensional)  Or
> can it be mixed?
>
> I would start a new thread, but whereas the multi-db issue related
> directly to developing Django technology, I'm not sure the issue of
> the warehouse design is an appropriate topic for this group (although
> I'm also not sure where I should discuss it).
>
> On Sep 24, 2:36 am, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > If he wants to discuss it here I can do that too. It was just a little
> off
> > topic, but not not too much I suppose.
> >
> > On Thu, Sep 24, 2009 at 7:41 AM, nausikaa <g.n.muel...@gmail.com> wrote:
> >
> > > Hi Joshua
> >
> > > Thanks for sharing your knowledge.
> > > Too bad, I would've liked to read your suggestion to Tony as well. ; )
> > > I'm a just graduate and at work I'm working on something very similar
> > > to what has been discussed here.
> >
> > > On Sep 23, 9:51 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > > > I have many years of database design experience and it sounds like
> you
> > > are
> > > > getting lost in terminology.
> > > > I would start out with a set of tables in the warehouse that mirror
> the
> > > > existing data. In these tables you can either wipe and reload each
> time,
> > > or
> > > > create a mechanism to track each individual load.
> >
> > > > You can then simply write your application against these tables or if
> you
> > > > feel adventurous you can add a more unified set of tables with
> linking
> > > > foreign keys and such and have your process also update the
> cleaner/more
> > > > unified data set. This second part get's tricky and takes practice to
> > > know
> > > > you have a good structure. You will also have to track changes,
> > > additions,
> > > > and deletions. If you want some help or advice I would be happy to
> take a
> > > > gander at your structures to show you what I might do. Feel free to
> email
> > > me
> > > > directly at josh.r.ru...@gmail.com.
> >
> > > > On Wed, Sep 23, 2009 at 6:35 PM, Tony Schmidt <
> tschm...@sacfoodcoop.com
> > > >wrote:
> >
> > > > > Thanks for your reply, Joshua.
> >
> > > > > Complexity is exactly what I'm trying to avoid - but after doing a
> > > > > little research on data warehouses 

Re: What JavaScript framework do you use and why?

2009-09-24 Thread Joshua Russo
Great links guys, thanks. I'm still in the mindset of frameworks just making
JavaScript less painful too and I'm looking for ways to move beyond that. I
just started looking at Dojo before posting this and it definitely looks
like it has potential.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: multi-db vs. data warehouse

2009-09-24 Thread Joshua Russo
If he wants to discuss it here I can do that too. It was just a little off
topic, but not not too much I suppose.

On Thu, Sep 24, 2009 at 7:41 AM, nausikaa <g.n.muel...@gmail.com> wrote:

>
>
> Hi Joshua
>
> Thanks for sharing your knowledge.
> Too bad, I would've liked to read your suggestion to Tony as well. ; )
> I'm a just graduate and at work I'm working on something very similar
> to what has been discussed here.
>
> On Sep 23, 9:51 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > I have many years of database design experience and it sounds like you
> are
> > getting lost in terminology.
> > I would start out with a set of tables in the warehouse that mirror the
> > existing data. In these tables you can either wipe and reload each time,
> or
> > create a mechanism to track each individual load.
> >
> > You can then simply write your application against these tables or if you
> > feel adventurous you can add a more unified set of tables with linking
> > foreign keys and such and have your process also update the cleaner/more
> > unified data set. This second part get's tricky and takes practice to
> know
> > you have a good structure. You will also have to track changes,
> additions,
> > and deletions. If you want some help or advice I would be happy to take a
> > gander at your structures to show you what I might do. Feel free to email
> me
> > directly at josh.r.ru...@gmail.com.
> >
> > On Wed, Sep 23, 2009 at 6:35 PM, Tony Schmidt <tschm...@sacfoodcoop.com
> >wrote:
> >
> >
> >
> > > Thanks for your reply, Joshua.
> >
> > > Complexity is exactly what I'm trying to avoid - but after doing a
> > > little research on data warehouses (I've never built one), that seems
> > > like a very complex route as well!
> >
> > > I would like to just come up with my "dream schema" and run update
> > > scripts on a daily or event-driven basis, but there seem to be a
> > > million concepts related to data warehousing: data marts, dimensions,
> > > star schemas, snowflakes, EAV tables, and so on.
> >
> > > It seems more straight forward if I could just connect directly to the
> > > operational systems.  I wonder if all that theory is really necessary
> > > for a basic data warehouse...
> >
> > > On Sep 23, 12:09 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > > > The multi-db branch is just now in the process of being baked into
> the
> > > core
> > > > and from what I can tell it's not quite done yet. Even when it is
> > > completely
> > > > done I would recommend the data warehouse approach. I view the
> multi-db
> > > > functionality more as a last resort, where you really don't have an
> > > option
> > > > to merge the data. It adds a lot of complexity so if you can do
> without I
> > > > would recommend an alternative.
> > > > Just my 2 cents
> > > > Josh
> >
> > > > On Wed, Sep 23, 2009 at 4:05 PM, Tony Schmidt <
> tschm...@sacfoodcoop.com
> > > >wrote:
> >
> > > > > Hi, Nausikaa.  Thanks for your reply.
> >
> > > > > Unfortunately, the legacy systems must remain in place until they
> are
> > > > > gradually (if ever) phased out.  There's a whole bunch of
> > > > > functionality that I don't want to have to recreate in those
> systems
> > > > > (POS, inventory/accounting, products, etc.).  I just want to build
> new
> > > > > functionality that accesses that data (like the example of an order
> > > > > entry form that creates new order/item data entities in a new DB
> with
> > > > > keys to entities in the other DBs or to their versions in the
> > > > > warehouse).  Most of it should be read only.
> >
> > > > > I'm starting to hear that a data warehouse is the way to go - but
> then
> > > > > there's the question of data warehouse vs. data mart, Inmon vs.
> > > > > Kimball, and how I can get started building one in python.  I'm not
> > > > > hearing many suggestions for the multi-db approach (which makes me
> > > > > wonder what the Django muli-db branch is for?)
> >
> > > > > On Sep 22, 2:01 am, nausikaa <g.n.muel...@gmail.com> wrote:
> > > > > > Hi snfctech
> >
> > > > > > With warehouse I assume you mean keeping the datasources and
> periodic
> > > > > > transfer into a central db (

Re: multi-db vs. data warehouse

2009-09-23 Thread Joshua Russo
I have many years of database design experience and it sounds like you are
getting lost in terminology.
I would start out with a set of tables in the warehouse that mirror the
existing data. In these tables you can either wipe and reload each time, or
create a mechanism to track each individual load.

You can then simply write your application against these tables or if you
feel adventurous you can add a more unified set of tables with linking
foreign keys and such and have your process also update the cleaner/more
unified data set. This second part get's tricky and takes practice to know
you have a good structure. You will also have to track changes, additions,
and deletions. If you want some help or advice I would be happy to take a
gander at your structures to show you what I might do. Feel free to email me
directly at josh.r.ru...@gmail.com.


On Wed, Sep 23, 2009 at 6:35 PM, Tony Schmidt <tschm...@sacfoodcoop.com>wrote:

>
> Thanks for your reply, Joshua.
>
> Complexity is exactly what I'm trying to avoid - but after doing a
> little research on data warehouses (I've never built one), that seems
> like a very complex route as well!
>
> I would like to just come up with my "dream schema" and run update
> scripts on a daily or event-driven basis, but there seem to be a
> million concepts related to data warehousing: data marts, dimensions,
> star schemas, snowflakes, EAV tables, and so on.
>
> It seems more straight forward if I could just connect directly to the
> operational systems.  I wonder if all that theory is really necessary
> for a basic data warehouse...
>
> On Sep 23, 12:09 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > The multi-db branch is just now in the process of being baked into the
> core
> > and from what I can tell it's not quite done yet. Even when it is
> completely
> > done I would recommend the data warehouse approach. I view the multi-db
> > functionality more as a last resort, where you really don't have an
> option
> > to merge the data. It adds a lot of complexity so if you can do without I
> > would recommend an alternative.
> > Just my 2 cents
> > Josh
> >
> > On Wed, Sep 23, 2009 at 4:05 PM, Tony Schmidt <tschm...@sacfoodcoop.com
> >wrote:
> >
> >
> >
> > > Hi, Nausikaa.  Thanks for your reply.
> >
> > > Unfortunately, the legacy systems must remain in place until they are
> > > gradually (if ever) phased out.  There's a whole bunch of
> > > functionality that I don't want to have to recreate in those systems
> > > (POS, inventory/accounting, products, etc.).  I just want to build new
> > > functionality that accesses that data (like the example of an order
> > > entry form that creates new order/item data entities in a new DB with
> > > keys to entities in the other DBs or to their versions in the
> > > warehouse).  Most of it should be read only.
> >
> > > I'm starting to hear that a data warehouse is the way to go - but then
> > > there's the question of data warehouse vs. data mart, Inmon vs.
> > > Kimball, and how I can get started building one in python.  I'm not
> > > hearing many suggestions for the multi-db approach (which makes me
> > > wonder what the Django muli-db branch is for?)
> >
> > > On Sep 22, 2:01 am, nausikaa <g.n.muel...@gmail.com> wrote:
> > > > Hi snfctech
> >
> > > > With warehouse I assume you mean keeping the datasources and periodic
> > > > transfer into a central db (the warehouse).
> > > > Why not migrate all your datasources into e.g. a PostgreDQL db?
> > > > It is easy to write forms and implement logins/access rights in
> > > > django so that your non-technical users can read or edit the
> > > > data. Besides you'd remove some (unnecessary) heterogenity and
> thereby
> > > > complexity from your system.
> > > > But since I don't know your system I might be missing the point
> > > > completely.
> >
> > > > Nausikaa
> >
> > > > On Sep 22, 3:10 am, snfctech <tschm...@sacfoodcoop.com> wrote:
> >
> > > > > I understand that there is a Django branch being actively worked on
> > > > > for connections to multiple DB vendors, or that Django + Elixir may
> be
> > > > > a good option.  But I'm wondering if building a single data
> warehouse
> > > > > may still be a better way to go?
> >
> > > > > Here's an example of some of the relations I'm going to have to
> build
> > > > > for my project:
> >
> > > >

Re: multi-db vs. data warehouse

2009-09-23 Thread Joshua Russo
The multi-db branch is just now in the process of being baked into the core
and from what I can tell it's not quite done yet. Even when it is completely
done I would recommend the data warehouse approach. I view the multi-db
functionality more as a last resort, where you really don't have an option
to merge the data. It adds a lot of complexity so if you can do without I
would recommend an alternative.
Just my 2 cents
Josh


On Wed, Sep 23, 2009 at 4:05 PM, Tony Schmidt wrote:

>
> Hi, Nausikaa.  Thanks for your reply.
>
> Unfortunately, the legacy systems must remain in place until they are
> gradually (if ever) phased out.  There's a whole bunch of
> functionality that I don't want to have to recreate in those systems
> (POS, inventory/accounting, products, etc.).  I just want to build new
> functionality that accesses that data (like the example of an order
> entry form that creates new order/item data entities in a new DB with
> keys to entities in the other DBs or to their versions in the
> warehouse).  Most of it should be read only.
>
> I'm starting to hear that a data warehouse is the way to go - but then
> there's the question of data warehouse vs. data mart, Inmon vs.
> Kimball, and how I can get started building one in python.  I'm not
> hearing many suggestions for the multi-db approach (which makes me
> wonder what the Django muli-db branch is for?)
>
> On Sep 22, 2:01 am, nausikaa  wrote:
> > Hi snfctech
> >
> > With warehouse I assume you mean keeping the datasources and periodic
> > transfer into a central db (the warehouse).
> > Why not migrate all your datasources into e.g. a PostgreDQL db?
> > It is easy to write forms and implement logins/access rights in
> > django so that your non-technical users can read or edit the
> > data. Besides you'd remove some (unnecessary) heterogenity and thereby
> > complexity from your system.
> > But since I don't know your system I might be missing the point
> > completely.
> >
> > Nausikaa
> >
> > On Sep 22, 3:10 am, snfctech  wrote:
> >
> > > I understand that there is a Django branch being actively worked on
> > > for connections to multiple DB vendors, or that Django + Elixir may be
> > > a good option.  But I'm wondering if building a single data warehouse
> > > may still be a better way to go?
> >
> > > Here's an example of some of the relations I'm going to have to build
> > > for my project:
> >
> > > I've got order and order_item tables with their own data and relations
> > > to members (Access DB), products (flat file) and employees (MySQL).
> >
> > > I initially thought that the best way to manage this would be to
> > > create a new DB for the order and order_item tables, and then create
> > > cross-vendor joins in the ORM.  But then I came across an unexpected
> > > advantage of having all the data in an updated warehouse - my semi-
> > > technical staff could still use products like OOBase, that are limited
> > > to a single vendor connection, to make reports and forms based on the
> > > warehouse data.
> >
> > > So now I'm wondering - are direct connections to multiple databases
> > > really the best way to go?  Or are there more advantages to building a
> > > data warehouse (keeping in mind the complexities of the data
> > > replication, scripts for pushing and pulling data, etc.)
> >
> > > Thanks in advance for any tips.
> >
>

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

2009-09-23 Thread Joshua Russo
On Wed, Sep 23, 2009 at 1:00 PM, Daniel Roseman <dan...@roseman.org.uk>wrote:

>
> On Sep 23, 2:54 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
> > I want to apply style to a block of text in the middle of a sentance
> without
> > effecting the flow. I've been using what feels like a serious hack by
> using
> >  tags with a class property. My big fear is that the tags will
> > disappear from the list of supported tags. But really there has to be a
> way
> > to do this without using a class attached to a depreciated tag. Any
> > suggestions?
> > Thanks
> > Josh
>
> That is what the  tag is for.


Gotcha. 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: Help with templates

2009-09-23 Thread Joshua Russo
On Wed, Sep 23, 2009 at 12:40 PM, gustavo  wrote:

>
> Hi people!!
>
> I need help trying to understand templates.
>
> Let me explain where I am. I have finished the django tutorial and I
> am assuming ( been right or wrong, I dont know) that the best thing to
> do is to use the template automatic generation. eg, I have a class
> Galeria and to have a layout to its list I just have to create a path
> to it ((r'^$', 'django.views.generic.list_detail.object_list',
> info_dict), where info_dict = { 'queryset' : Galeria.objects.all()})
> and then create a file galeria_list.html like:
>
> {% if object_list %}
>
>{% for object in object_list %}
>{{ object.nome }}
>{% endfor %}
>
>{% else %}
>No polls are available.
>{% endif %}
>
> So far so good.
>
> The problem is that I want to put this part of the code as a menu,
> extending the base.html. But it stops workig when I did:
>
> {% extends "base.html" %}
>
> {% block menu %}
> 
> 
>{% if object_list %}
>
>{% for object in object_list %}
>{{ object.nome }}
>{% endfor %}
>
>{% else %}
>No polls are available.
>{% endif %}
> 
> 
> {% endblock %}
>
> It stops to work.
>
> So I would like to ask for help to understand whats the better way for
> doing it and what I have to change. It seems that I should not use the
> automatic generator, Am I right?


I'm not seeing a menu block in the base.html, so my guess is that it doesn't
know where to display the block. From my experience you can think of
template files as falling into two different categories. The base file that
lays out all of the bocks and the overall flow of the template, and
templates that inherit from the base file and override or extend those
blocks.

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



HTML / CSS question

2009-09-23 Thread Joshua Russo
I want to apply style to a block of text in the middle of a sentance without
effecting the flow. I've been using what feels like a serious hack by using
 tags with a class property. My big fear is that the tags will
disappear from the list of supported tags. But really there has to be a way
to do this without using a class attached to a depreciated tag. Any
suggestions?
Thanks
Josh

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

2009-09-23 Thread Joshua Russo
I was looking through the QuerySet code and noticed logic for both deepcopy
and clone. What's the difference? What would be an example of why I should
use one or the other?

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



What JavaScript framework do you use and why?

2009-09-23 Thread Joshua Russo
I've been happily using JQuery for a while and was wondering why people use
the frameworks that they do. I want to see how other's get flexibility and
efficiency (cool widgets and good response time) out of JavaScript.
For example: The current project I'm working on I've created a visual
display of a timeline using CSS and transparent PNGs and use it allow users
to visually manipulate date ranges. I ended up creating a custom JavaScript
object to represent each value/date range to centralize manipulation logic,
initialized on page load from data provided in page creation. The objects
generally end up being just a bunch of references to the objects on the page
to be manipulated, in addition to the logic. I use JQuery to create each
reference and then thus also for the manipulations themselves.

This is usually the extent of my use of JQuery and I'm wondering if I'm
missing something in other frameworks that may make my life easier in tasks
like this.

Thanks for your insights.
Josh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Finding unique ForeignKey enties.

2009-09-22 Thread Joshua Russo
On Tue, Sep 22, 2009 at 7:23 PM, MV  wrote:

>
> I have a Movie model
> and I have a Image model
> the Image model has a ForeignKey(Movie)
>
> Each Movie has an arbitrary amount of Images.
>
> I have a view where I list all the Movies.
> For each Movie entry, I want one Image.
>
> How do I do that?
>
> I can do a "movies = Movies.objects.all()" and pass "movies" to the
> template, but I don't know how to attach an image
> How do I get one, and only one, Image for each Movie?
>
> The only thing I can think about is using a for-loop on the returned
> list of movies, but that will hit the database an awfully lot.
>

You can access the images via moves.images_set.filter()...

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

2009-09-21 Thread Joshua Russo
On Mon, Sep 21, 2009 at 5:33 PM, Kevin Bache  wrote:

> Thanks for both of your ideas.
>
> Joshua: It is stopping on the first line of code, and I can step through
> the manage.py module and if I recall (I'm not in front of my computer at the
> moment) it catches breakpoints in other files (ex: settings.py) in the
> initial load.  What I can't seem to get is breakpoints triggered by the
> browser.  Have you ever had success with that?  Is it possible using
> Django's development server?  Using any server?
>
> Daniel: Will pdb breakpoints be triggered by requests from the browser?
>
> What I'm really looking for is the ability to access a url in my browser
> and step through the whole process of resolving a request on the Django
> end.  If this is possible, how do I do it?  If it isn't possible, why, and
> is there a way to jerry-rig it? Maybe passing an artificially constructed
> request object to the view function--though that sounds like a big time
> drain.
>
> This seems like a problem that most developers must hit from time to time.
> How has the community approached it in the past?
>

That is kind of strange. I vaguely remember having a similar problem though
I don't remember how I solved it, though I did solve it, so it is possible.

As far as pdb, that is what I'm actually using at the moment. I just use a
text editor and run manage.py runserver from a batch file. When it hit's a
pdb.set_trace() it will drop you into a Python comand prompt with complete
variable context of the current point in the application, in the console
window starting for manage.py. So you can inspect and try logic real time
basically. It's really powerful and I would definitely recommend looking
into it.

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

2009-09-21 Thread Joshua Russo
On Mon, Sep 21, 2009 at 10:15 AM, Joshua Russo <josh.r.ru...@gmail.com>wrote:

>
> On Sep 21, 6:00 am, Kevin Bache <kevin.ba...@gmail.com> wrote:
> > Hi Everyone,
> > I'm a bit of a Django noob so please forgive me if my hope here is
> > swimmingly optimistic:
> >
> > I'd like to be able to set breakpoints in my django project which would
> be
> > triggered by my browser's requests to the integrated Django development
> > server.  Is this possible?  I'm using NetBeans 6.7 with Python EA as my
> > IDE.  I have manage.py set as the project's main module and  "runserver
> > --noreload" for arguments.  I set sample breakpoints in my urls.py module
> > and run the server by selecting Debug >> Debug Main Project in NetBeans,
> but
> > when I surf around the website through Firefox, the requests fly right
> past
> > my breakpoints.  Am I missing something or is this just some web dev pipe
> > dream?  If what I'm trying for is impossible, what are some realistic
> > debugger usage scenarios with Django?  My development will go much faster
> if
> > I can pause and look around every now and again without having to splice
> my
> > code with print statements.
>
> It may be the way you are running the program from NB. There are 2
> buttons, Run Main Project and Debug Main Project. Make sure you are
> using the second. It should automatically break on the very first line
> of code (at least it did in 6.5), where you need to hit continue to
> actually run the project. Personally I found that particular feature
> an annoyance and a blessing. An annoyance because you always have to
> click 2 buttons to really start the debug process, a blessing in that
> when I first started with both Django and Python were new to me and it
> helped me get my head around how the entire process got off the
> ground.


Some day I might actually start reading a little better. You are doing
things properly. Is it stopping at the first line in the manage.py file when
you debug?

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

2009-09-21 Thread Joshua Russo

On Sep 21, 6:00 am, Kevin Bache  wrote:
> Hi Everyone,
> I'm a bit of a Django noob so please forgive me if my hope here is
> swimmingly optimistic:
>
> I'd like to be able to set breakpoints in my django project which would be
> triggered by my browser's requests to the integrated Django development
> server.  Is this possible?  I'm using NetBeans 6.7 with Python EA as my
> IDE.  I have manage.py set as the project's main module and  "runserver
> --noreload" for arguments.  I set sample breakpoints in my urls.py module
> and run the server by selecting Debug >> Debug Main Project in NetBeans, but
> when I surf around the website through Firefox, the requests fly right past
> my breakpoints.  Am I missing something or is this just some web dev pipe
> dream?  If what I'm trying for is impossible, what are some realistic
> debugger usage scenarios with Django?  My development will go much faster if
> I can pause and look around every now and again without having to splice my
> code with print statements.

It may be the way you are running the program from NB. There are 2
buttons, Run Main Project and Debug Main Project. Make sure you are
using the second. It should automatically break on the very first line
of code (at least it did in 6.5), where you need to hit continue to
actually run the project. Personally I found that particular feature
an annoyance and a blessing. An annoyance because you always have to
click 2 buttons to really start the debug process, a blessing in that
when I first started with both Django and Python were new to me and it
helped me get my head around how the entire process got off the
ground.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Translating App Names

2009-09-20 Thread Joshua Russo
On Sun, Sep 20, 2009 at 6:22 PM, SaiaGo  wrote:

>
> I'm trying to make an Israeli site (which means it should be written
> in Hebrew) using the latest SVN and so far Django made it so easy I
> can't believe it's free. I got a simple magazine app with up and
> running in less then a day, and I barely know Python!
> My only problem so far is application names in admin pages. I can't
> seem to find a way to translate application names.
>
> As far as I understand from the docs app names are chosen based on the
> directory name they reside in. so mysite/magazine should be
> "Magazine", which is what admin pages display.
> I tried making a .po file and translating "Magazine" (assuming my app
> is in "mysite/magazine") like so:
> msgid "Magazine"
> msgstr "מגזין"
> But this approach isn't working.
>
> Is there a way to explicitly set an app name so I could set it to
> ugettext("Magazine") or some kind of special msgid I have to use to
> translate app names, or is this functionality not implemented yet?(In
> which case I would happily implement it myself)
>
> And while I have the chance I would like to thank anyone who
> contributed to the design, programming, templates and translation of
> Django very very much. Projects like this make me hope for a better
> world where people rather share than sell, at least a better virtual
> world. And I hope I could contribute to Django in the future.
>

You can use the verbose_name properties in a Meta class in your model. Just
keep in mind you will need to use the lazy translation function.

http://docs.djangoproject.com/en/dev/topics/db/models/#id3

http://docs.djangoproject.com/en/dev/topics/i18n/#topics-i18n (there's a
section for Lazy translations)

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

2009-09-19 Thread Joshua Russo
On Sat, Sep 19, 2009 at 3:07 PM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sat, Sep 19, 2009 at 11:51 AM, Joshua Russo <josh.r.ru...@gmail.com>wrote:
>
>> Just one other thing. I was under the impression that x = u''
>> is equivalent to x = Unicode(''). Is that not correct?  Seeing as you seem
>> to be indicating a difference between the unicode object and a literal.
>>
>>
>>
> Note you could answer that yourself by changing the:
>
> u = u'¿Chapter?'
>
> in the program I posted to:
>
> u = unicode('¿Chapter?')
>
> and seeing what happens.
>
> The answer is they are not equivalent.  The unicode literal form will make
> use of the file's encoding declaration to know the correct encoding of the
> source bytes, the other cannot.  The other contains a bytestring.  The
> source file encoding declaration has no effect on bytestrings in the source,
> so Python will not be able to convert the bytestring version to unicode as
> it will by default attempt to use the ascii codec for the conversion, and
> that will fail.
>

Ok, thanks, I think I got it now. :o)

>
>

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

2009-09-19 Thread Joshua Russo
On Sat, Sep 19, 2009 at 2:40 PM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sat, Sep 19, 2009 at 11:19 AM, Joshua Russo <josh.r.ru...@gmail.com>wrote:
>
>> ... in fact using utf-8 string literals can cause problems in other places
>>> with code that assumes another encoding (e.g. ascii) for byte strings.
>>>
>>
>> Could you expand on this? I know that the Unicode string object has
>> different methods than standard String, but are there other scenarios where
>> a unicode literal could cause problems?
>>
>>
> I did not say using a unicode literal can cause problems, I said using a
> (byte) string literal with utf-8 (really any non-ASCII) encoding can lead to
> problems.  The Python interpreter itself will always (assuming no special
> site installation customization) attempt to use the ascii codec to convert
> from string to unicode, so using non-ASCII byte strings will often result in
> unicode decode errors if Python is ever relied on to do automatic coercion
> to unicode.  For example this program:
>
> #! /usr/bin/python
> #-*- encoding: utf-8 -*-
>
> u = u'¿Chapter?'
> s = '¿Chapter?'
>
> msg1 = u"I've been handed: %s" % u
> msg2 = u"I've been handed: %s" % s
>
> will result in:
>
>   File "./t.py", line 8, in 
> msg2 = u"I've been handed: %s" % s
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0:
> ordinal not in range(128)
>
> The unicode literal is handled properly, the bytestring literal causes a
> problem.
>


Gotcha, that's perfect. Thanks

Just one other thing. I was under the impression that x = u'' is equivalent
to x = Unicode(''). Is that not correct?  Seeing as you seem to be
indicating a difference between the unicode object and a literal.

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

2009-09-19 Thread Joshua Russo
>
> ... in fact using utf-8 string literals can cause problems in other places
> with code that assumes another encoding (e.g. ascii) for byte strings.
>

Could you expand on this? I know that the Unicode string object has
different methods than standard String, but are there other scenarios where
a unicode literal could cause problems?

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

2009-09-19 Thread Joshua Russo
On Sat, Sep 19, 2009 at 1:31 PM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sat, Sep 19, 2009 at 9:59 AM, Joshua Russo <josh.r.ru...@gmail.com>wrote:
>
>> I was working through some regression tests and saw a scenario I thought
>> wasn't allowed/recommended. I was under the impression that if you specified
>> UTF-8 encoding at the top of the file you where not suppose to use u
>> decorated unicode static string. So instead of u'prédio' I use 'prédio' in
>> files where I specify the encoding in the file.
>> Now in regressiontests/admin_views/models.py I see u'¿Chapter?'. Does it
>> not matter if I use the u decorator on static strings with the encoding
>> specified? I was initially told that it could create problems.
>>
>>
> Someone told you wrong.  The encoding declaration is useful specifically
> for unicode literals, see: http://www.python.org/dev/peps/pep-0263/.  With
> the encoding declaration, the Python interpreter can build a unicode object
> correctly from the source bytes, since it knows the encoding of the source
> bytes.  Without the encoding declaration, the interpreter would not know the
> encoding of the source bytes, so would be unable (without making some
> assumption) to correctly build unicode string objects from unicode literals.
>
> The encoding declaration does nothing helpful for bytestrings -- they are
> still bytestrings, with no known encoding carried around with them.  Django
> code assumes utf-8 encoding for bytestrings so in many cases where you are
> using utf-8 as the encoding you can still use string literals instead of
> unicode literals.  However there is no advantage to doing so and in fact
> using utf-8 string literals can cause problems in other places with code
> that assumes another encoding (e.g. ascii) for byte strings.
>

Ok thanks, good to know

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



String encoding question

2009-09-19 Thread Joshua Russo
I was working through some regression tests and saw a scenario I thought
wasn't allowed/recommended. I was under the impression that if you specified
UTF-8 encoding at the top of the file you where not suppose to use u
decorated unicode static string. So instead of u'prédio' I use 'prédio' in
files where I specify the encoding in the file.
Now in regressiontests/admin_views/models.py I see u'¿Chapter?'. Does it not
matter if I use the u decorator on static strings with the encoding
specified? I was initially told that it could create problems.

Thanks
Josh

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

2009-09-18 Thread Joshua Russo
On Fri, Sep 18, 2009 at 10:13 PM, aa56280  wrote:

>
> When a new instance of some object is created, I need to send out X
> number of emails. X could potentially mean hundreds of emails.
>
> What would be the most efficient way to do this?
>
> I know if I use send_mass_mail() it could potentially hang for quite a
> long time.
>
> Any thoughts greatly appreciated.
>

The way I have handled this in the past is to create a simple app that you
can run from the command line. I had it check a table that was updated with
the list of emails to send and set it up as a scheduled task (cron job) for
every 20 minutes or so.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
You might want to check this out as a more up to date intro:
http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
On Mon, Sep 14, 2009 at 1:38 PM, Randy Barlow wrote:

>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> about2flip declared:
> >   File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
> > def_str_(self):
> >   ^
> > SyntaxError: invalid syntax
>
> Looks like you are missing a space between def and __str__(self).
> Should be:
>
> def __str__(self):
>
> - --
> Randy Barlow
> Software Developer
> The American Research Institute
> http://americanri.com
> 919.228.4971


Oh ya I missed that bit. Double the underscores before and after too.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
On Mon, Sep 14, 2009 at 1:38 PM, Joshua Russo <josh.r.ru...@gmail.com>wrote:

> On Mon, Sep 14, 2009 at 1:27 PM, about2flip <mnu...@gmail.com> wrote:
>
>>
>> Hi:
>>
>> I am using learn django in 24 hours and I am following this example on
>> models.
>>
>> from django.db import models
>>
>> class Person(models.Model):
>>name = models.CharField('name', maxlength=200)
>>email = models.EmailField('Email', blank=True)
>>headshots = models.ImageField(upload_to='img', blank=True)
>>text = models.TextField('Desc', maxlength=500, blank=True)
>>def_str_(self):
>>return '%s' % (self.name)
>>
>> I keep getting an error when I use the command>>>python manage.py
>> syncdb (see below)
>>
>>
>> E:\djproj\ifriends>python manage.py syncdb
>> C:\Python26\lib\site-packages\MySQLdb\__init__.py:34:
>> DeprecationWarning: the se
>> ts module is deprecated
>>  from sets import ImmutableSet
>> Traceback (most recent call last):
>>  File "manage.py", line 11, in 
>>execute_manager(settings)
>>  File "C:\Python26\lib\site-packages\django\core\management
>> \__init__.py", line
>> 362, in execute_manager
>>utility.execute()
>>  File "C:\Python26\lib\site-packages\django\core\management
>> \__init__.py", line
>> 303, in execute
>>self.fetch_command(subcommand).run_from_argv(self.argv)
>>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
>> line 195,
>>  in run_from_argv
>>self.execute(*args, **options.__dict__)
>>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
>> line 221,
>>  in execute
>>self.validate()
>>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
>> line 249,
>>  in validate
>>num_errors = get_validation_errors(s, app)
>>  File "C:\Python26\lib\site-packages\django\core\management
>> \validation.py", lin
>> e 28, in get_validation_errors
>>for (app_name, error) in get_app_errors().items():
>>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
>> line 131, in
>>  get_app_errors
>>self._populate()
>>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
>> line 58, in
>> _populate
>>self.load_app(app_name, True)
>>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
>> line 74, in
>> load_app
>>models = import_module('.models', app_name)
>>  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
>> 35, in im
>> port_module
>>__import__(name)
>>  File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
>>def_str_(self):
>>  ^
>> SyntaxError: invalid syntax
>>
>> E:\djproj\ifriends>
>>
>> Its telling me it is line 8, but I double check 5x already and it is
>> the same as the book. The book does not have an errata, so I am not
>> sure if the syntaxt is correct because I am a Freshman learning
>> django.
>>
>> thanks too all that reply with help.
>
>
> Put a space between 'def' and '_str_' and it should work. Tho you want to
> use _unicode_ instead of _str_ in django. All string output is handled as
> unicode.
>

And to perform the unicode out correctly the string in the body of your
method needs a u decoration infront of the string to indicate unicode.

return u'%s' % (self.name)

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



  1   2   3   >