Re: mutual imports - how to do it?

2011-04-18 Thread Kenneth Gonsalves
On Tue, 2011-04-19 at 09:46 +0530, Kenneth Gonsalves wrote:
> > from django.db.models import get_model
> > 
> > Product = get_model('products', 'Product')
> > Something = get_model('incident', 'Something') 
> 
> that simple? will try. 

worked. Thanks.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: How to fix a column typo in django

2011-04-18 Thread ravi krishna
You can do this by altering the table through SQL console (if your database
is sql). The commands to do the job for you is :

*mysql -u root -p*
*
use database_name*;

//eg:-for adding new column email to table
ALTER TABLE table_name ADD email VARCHAR(200);

//for modifying a column
ALTER TABLE table_name
MODIFY column_name column_type;

Thanks & Regards,

Ravi Krishna
My profiles: [image:
Facebook] [image:
LinkedIn]  [image:
Twitter] 




On Tue, Apr 19, 2011 at 5:10 AM, Kenneth Gonsalves
wrote:

> On Mon, 2011-04-18 at 16:11 +0200, Kann Vearasilp wrote:
> > That was one of my idea, but what if the table has already been
> > populated
> > and I don't want to lose the data in the table?
> >
> > Can I just change the column name manually using SQL and modify the
> > models.py afterwards?
>
> that is the recommended way. you can also use a migration tool like
> south
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: mutual imports - how to do it?

2011-04-18 Thread Kenneth Gonsalves
On Tue, 2011-04-19 at 00:36 -0300, Fabian Ezequiel Gallina wrote:
> > In incident I can do: from products.models import Product
> > but in products if I do:
> > from incident.import Something - this fails and django says cannot
> > import Something.
> >
> > Is there any way around this?
> 
> from django.db.models import get_model
> 
> Product = get_model('products', 'Product')
> Something = get_model('incident', 'Something') 

that simple? will try.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google 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: mutual imports - how to do it?

2011-04-18 Thread Fabian Ezequiel Gallina
2011/4/18 Kenneth Gonsalves :
> hi,
>
> I have two models.py files in two applications. Say, products.models and
> incident.models.
>
> In incident I can do: from products.models import Product
> but in products if I do:
> from incident.import Something - this fails and django says cannot
> import Something.
>
> Is there any way around this?

from django.db.models import get_model

Product = get_model('products', 'Product')
Something = get_model('incident', 'Something')



Regards,
-- 
Fabián E. Gallina
http://www.anue.biz

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



mutual imports - how to do it?

2011-04-18 Thread Kenneth Gonsalves
hi,

I have two models.py files in two applications. Say, products.models and
incident.models.

In incident I can do: from products.models import Product
but in products if I do:
from incident.import Something - this fails and django says cannot
import Something.

Is there any way around this?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Import error No module named urls to url login_in in html page

2011-04-18 Thread Guevara
Hello!!

I am getting the following error on my index.html page:

Exception Type: TemplateSyntaxError
Exception Value:

Caught ImportError while rendering: No module named urls


In this line:

Login

My urls.py:

(r'^imobiliaria/', include('auth.urls')),

In my auth app, i have this:

urlpatterns = patterns('auth.views',
url(r'^$', views.index, name="index"), <-- this is index page
url(r'^accounts/login/$', views.login_in, name="login_in"), <--
this is login page
url(r'^logout/$', views.logout_view, name="logout_view"),
url(r'^register/$',  views.register,  name="register"),
url(r'^home/$', views.home, name="home"),
)


My view to render index.html is:

def index(request):
return render_to_response('imobiliaria/auth/index.html')


In my settings.py i have this:

AUTH_PROFILE_MODULE = 'imobiliaria.imobiliaria'
LOGIN_URL = '/imobiliaria/accounts/login/'

INSTALLED_APPS = (
'imobiliaria.auth',
)

ROOT_URLCONF = 'imobiliaria.urls'



Anyone know where the problem might be?
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: How to fix a column typo in django

2011-04-18 Thread Kenneth Gonsalves
On Mon, 2011-04-18 at 16:11 +0200, Kann Vearasilp wrote:
> That was one of my idea, but what if the table has already been
> populated
> and I don't want to lose the data in the table?
> 
> Can I just change the column name manually using SQL and modify the
> models.py afterwards? 

that is the recommended way. you can also use a migration tool like
south
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google 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: Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread Chris Spencer
Awesome, that was it. My old code now works again. Thanks!

Chris

On Mon, Apr 18, 2011 at 5:47 PM, akaariai  wrote:

> On Apr 19, 12:17 am, Chris Spencer  wrote:
> > Thanks. However, changing the line to:
> >
> > if not self.instance.state.adding:
> >
> > results in essentially the same error:
> >
> > AttributeError: 'MyModel' object has no attribute 'state'
>
> Doh, that should of course be ._state. Sorry for the mistake.
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread akaariai
On Apr 19, 12:17 am, Chris Spencer  wrote:
> Thanks. However, changing the line to:
>
>     if not self.instance.state.adding:
>
> results in essentially the same error:
>
> AttributeError: 'MyModel' object has no attribute 'state'

Doh, that should of course be ._state. Sorry for the mistake.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread Chris Spencer
Thanks. However, changing the line to:

if not self.instance.state.adding:

results in essentially the same error:

AttributeError: 'MyModel' object has no attribute 'state'

On Mon, Apr 18, 2011 at 4:48 PM, akaariai  wrote:

> On Apr 18, 11:08 pm, Chris  wrote:
> > I have an inline form used in my admin that looks up the value for the
> > associated model, and dynamically selects the form field widget that's
> > appropriate for the data. The class looks like:
> >
> > class MyModelInlineForm(ModelForm):
> > attribute_model = ModelChoiceField(queryset=None)
> > def __init__(self,*args,**kwargs):
> > ...do stuff...
> >
> > if not self.instance._adding:
> > attribute = self.instance.attribute_model
> > self.fields['value'] =
> > get_form_field_for_attribute(attribute, self.instance)
> >
> > However, after upgrading to Django 1.3 from 1.2.3, viewing any admin
> > pages using this form throws the exception:
> >
> > AttributeError: 'MyModel' object has no attribute '_adding'
> >
> > I can't find any documentation on the instance._adding attribute, or
> > how it would have changed since 1.2.3. I've been digging through the
> > code, but I'm quite stuck. How do I resolve this?
>
> If I am not mistaken this attribute has been moved: instance._adding -
> > instance.state.adding. See django/db/models/base.py ModelState class
> and Model.__init__ method.
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

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



Re: How to fix a column typo in django

2011-04-18 Thread Shawn Milochik
You can use South.

south.aeracode.org

You'd create a schema migration to create the new field, then a data
migration to populate the new field from the old, then another schema
migration to remove the original field.

Shawn

-- 
You received this message because you are subscribed to the Google 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: weird "must be an intance" error

2011-04-18 Thread Bobby Roberts
haha Thanks for that... i never would have figured it out




On Apr 18, 4:59 pm, akaariai  wrote:
> On Apr 18, 11:38 pm, Bobby Roberts  wrote:
>
> > oops... forgot to clarify that Item.tid is a FK to printLocation
>
> Then you would want to assign to tid_id. For foreign keys the tid
> wants an instance, the tid_id can be assigned the "db value" for that
> foreign key. I am not sure if the tid_id can be named something else.
> If it can be, you can find out the right field name to assign to by
> checking out ItemTracking._meta.get_field_by_name('tid')[0].attname in
> the django shell.
>
>  - Anssi

-- 
You received this message because you are subscribed to the Google 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: weird "must be an intance" error

2011-04-18 Thread akaariai
On Apr 18, 11:38 pm, Bobby Roberts  wrote:
> oops... forgot to clarify that Item.tid is a FK to printLocation

Then you would want to assign to tid_id. For foreign keys the tid
wants an instance, the tid_id can be assigned the "db value" for that
foreign key. I am not sure if the tid_id can be named something else.
If it can be, you can find out the right field name to assign to by
checking out ItemTracking._meta.get_field_by_name('tid')[0].attname in
the django shell.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread akaariai
On Apr 18, 11:08 pm, Chris  wrote:
> I have an inline form used in my admin that looks up the value for the
> associated model, and dynamically selects the form field widget that's
> appropriate for the data. The class looks like:
>
> class MyModelInlineForm(ModelForm):
>     attribute_model = ModelChoiceField(queryset=None)
>     def __init__(self,*args,**kwargs):
>         ...do stuff...
>
>         if not self.instance._adding:
>             attribute = self.instance.attribute_model
>             self.fields['value'] =
> get_form_field_for_attribute(attribute, self.instance)
>
> However, after upgrading to Django 1.3 from 1.2.3, viewing any admin
> pages using this form throws the exception:
>
> AttributeError: 'MyModel' object has no attribute '_adding'
>
> I can't find any documentation on the instance._adding attribute, or
> how it would have changed since 1.2.3. I've been digging through the
> code, but I'm quite stuck. How do I resolve this?

If I am not mistaken this attribute has been moved: instance._adding -
> instance.state.adding. See django/db/models/base.py ModelState class
and Model.__init__ method.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: weird "must be an intance" error

2011-04-18 Thread Bobby Roberts
oops... forgot to clarify that Item.tid is a FK to printLocation

-- 
You received this message because you are subscribed to the Google 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: weird "must be an intance" error

2011-04-18 Thread akaariai
On Apr 18, 11:03 pm, Bobby Roberts  wrote:
> considering this snippet:
>
> valPrintlocation=int(request.POST.get('printlocation'))
>                         if valPrintlocation==-1:
>                                 needsprinting=0
>                         else:
>                                 needsprinting=1
>
>                         Item = ItemTracking.objects.get(Barcode =
> barcode)
>                         Item.tid=valPrintlocation
>                         Item.NeedsPrinting=needsprinting
>                         ...
>
> can you see any reason i'm getting this error:
>
> Cannot assign "-1": "ItemTracking.tid" must be a "printLocation"
> instance.
>
> I get the same error regardless of the value of valPrintlocation

It would help if you would include the definition of ItemTracking at
least. Based on that snippet I would guess the problem is that
ItemTracking.tid must be a printLocation instance... :)

 - Anssi

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



Inline Form Error After Upgrade to Django 1.3

2011-04-18 Thread Chris
I have an inline form used in my admin that looks up the value for the
associated model, and dynamically selects the form field widget that's
appropriate for the data. The class looks like:

class MyModelInlineForm(ModelForm):
attribute_model = ModelChoiceField(queryset=None)
def __init__(self,*args,**kwargs):
...do stuff...

if not self.instance._adding:
attribute = self.instance.attribute_model
self.fields['value'] =
get_form_field_for_attribute(attribute, self.instance)

However, after upgrading to Django 1.3 from 1.2.3, viewing any admin
pages using this form throws the exception:

AttributeError: 'MyModel' object has no attribute '_adding'

I can't find any documentation on the instance._adding attribute, or
how it would have changed since 1.2.3. I've been digging through the
code, but I'm quite stuck. How do I resolve this?

Regards,
Chris

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



weird "must be an intance" error

2011-04-18 Thread Bobby Roberts
considering this snippet:


 
valPrintlocation=int(request.POST.get('printlocation'))
if valPrintlocation==-1:
needsprinting=0
else:
needsprinting=1

Item = ItemTracking.objects.get(Barcode =
barcode)
Item.tid=valPrintlocation
Item.NeedsPrinting=needsprinting
...

can you see any reason i'm getting this error:

Cannot assign "-1": "ItemTracking.tid" must be a "printLocation"
instance.


I get the same error regardless of the value of valPrintlocation

-- 
You received this message because you are subscribed to the Google 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: code 128 or code 39 barcode generation

2011-04-18 Thread Steven L Smith
There's a great wrapper you can use to generate these in PIL using a
postscript library.
http://pypi.python.org/pypi/elaphe/

I did something similar with pyqrnative to generate QR Codes for a
conference, basically just create a URL that wraps the output of the
library in an HTTPResponse.



On Apr 18, 1:58 pm, Bobby Roberts  wrote:
> anyone know if there is a django module to generate code 128 or 39
> barcodes for printing out on a webpage?

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



code 128 or code 39 barcode generation

2011-04-18 Thread Bobby Roberts
anyone know if there is a django module to generate code 128 or 39
barcodes for printing out on a webpage?

-- 
You received this message because you are subscribed to the Google 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: For any dictionary in a list, does a value exist for a key?

2011-04-18 Thread Shawn Milochik
You can do this pretty easily in Python with any():

if any(['foo' in x for x in my_list]):
#do something

However, I don't know of a way to do it in a template, which is what
it appears you're asking.

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



For any dictionary in a list, does a value exist for a key?

2011-04-18 Thread Chris Roat
Does a function or construct exist to easily do the following?

my_list = [{'id': 'foo'}, {'id': 'bar', 'other': 'baz'}]
{% is my_id_value in my_list.id %}  // True if my_id_value is 'foo' or 'bar'

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: How to fix a column typo in django

2011-04-18 Thread Anurag Chourasia
Yes. That should be doable.

If you are on Oracle, you could manually change the Column Name using
the following Syntax (If you are on a different Database than Oracle
then the Syntax might differ but still doable).

ALTER TABLE  RENAME COLUMN  TO 

And later you could change the models.py manually to reflect the New
Column Name.

Regards,
Anurag

On Mon, Apr 18, 2011 at 7:41 PM, Kann Vearasilp  wrote:
> Hi Anurag,
>
> That was one of my idea, but what if the table has already been populated
> and I don't want to lose the data in the table?
>
> Can I just change the column name manually using SQL and modify the
> models.py afterwards?
>
> Kann
>
> On Mon, Apr 18, 2011 at 4:06 PM, Anurag Chourasia
>  wrote:
>>
>> Hi Kann,
>>
>> Does Dropping the Table and Recreating using SyncDB work well in your
>> setup?
>>
>> Regards,
>> Anurag
>>
>> On Mon, Apr 18, 2011 at 7:30 PM, Kann  wrote:
>> > Dear all,
>> >
>> > I am new to django and have question about fixing the typo i made in
>> > the models.py. For example, I created tables with typo in the column
>> > name. So, I didn't realized the mistake and run the 'python manage.py
>> > syncdb' which created the tables with the incorrect names. Later I
>> > realized the typos and made changes in the "models.py" file and run
>> > the "python manage.py syncdb" again, but it didn't fix the typo in my
>> > column names.
>> >
>> > How do i fix the mistakes in the column names after the 'syncdb' is
>> > already run?
>> >
>> > Best,
>> >
>> > Kann
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > 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.
>> >
>> >
>
>

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



A monthly Django session in Leicester with guest speakers on set topics - would this be of interest to you?

2011-04-18 Thread Leon
We are thinking of organising monthly Django sessions in Leicester
with guest speakers on set topics that would interest fellow
Djangonauts.

Our plan is to organise a short 2 hour session each month on a
particular topic (e.g. Django + Celery, Django + NoSQL, GeoDjango +
MapServer, etc) with a presentation from a guest speaker and a chance
to chat about it afterwards.

We're just trying to gauge the level of interest at the moment to see
if there are enough Django developers around Leicester to make it
worthwhile, if this is something that you would be interested in
attending then let me 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.



Re: Form containing a Mutipolygon field for Django 1.3

2011-04-18 Thread GARRAM karim
I am using dream weaver so when I deleted the heading

http://www.w3.org/1999/xhtml;>
the problem of plotting the openlayer map was resolved
Now my problem is still the mapping between the data to plot in the
map and the multipolygon field, in my object definition

On Apr 18, 1:12 pm, GARRAM karim  wrote:
> I am working on a GeoDjango project. I have a model.py wich extend the
> user model and contains a MultiPolygonField
>
> class Membre(models.Model):
>     user = models.ForeignKey(User, unique=True)
>
>     #some other attributes
>
>     mpoly = models.MultiPolygonField()
>     objects = models.GeoManager()
>
> class MembreForm(ModelForm):
>     class Meta:
>         model = Membre
>         exclude = ('user',)
>
> The form for this model works fine in the admin site. I am now
> building the front office for it.
> The problem that I'am facing is that in the resulting form I get a
> mpoly (the mutipolygonfield) as a text area, I am facing the same
> problem as:
>
> http://stackoverflow.com/questions/559431/how-to-display-data-using-o...
>
> I tryed to use OpenLayer script in my template to simply plot a
> OpenLayer map but it didn't work (it worked for simple html pages). Is
> there a GeoDjango specific tag to do that?
>
> I think there is maybe a way to do this by using the (GeoDjango Admin
> widget) but how to do it?
>
> How can I use google map api for this field in both admin site and the
> template I'm working on?

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



Re: How to fix a column typo in django

2011-04-18 Thread Kann Vearasilp
Hi Anurag,

That was one of my idea, but what if the table has already been populated
and I don't want to lose the data in the table?

Can I just change the column name manually using SQL and modify the
models.py afterwards?

Kann

On Mon, Apr 18, 2011 at 4:06 PM, Anurag Chourasia <
anurag.choura...@gmail.com> wrote:

> Hi Kann,
>
> Does Dropping the Table and Recreating using SyncDB work well in your
> setup?
>
> Regards,
> Anurag
>
> On Mon, Apr 18, 2011 at 7:30 PM, Kann  wrote:
> > Dear all,
> >
> > I am new to django and have question about fixing the typo i made in
> > the models.py. For example, I created tables with typo in the column
> > name. So, I didn't realized the mistake and run the 'python manage.py
> > syncdb' which created the tables with the incorrect names. Later I
> > realized the typos and made changes in the "models.py" file and run
> > the "python manage.py syncdb" again, but it didn't fix the typo in my
> > column names.
> >
> > How do i fix the mistakes in the column names after the 'syncdb' is
> > already run?
> >
> > Best,
> >
> > Kann
> >
> > --
> > You received this message because you are subscribed to the Google 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.
> >
> >
>

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



Re: How to fix a column typo in django

2011-04-18 Thread Anurag Chourasia
Hi Kann,

Does Dropping the Table and Recreating using SyncDB work well in your setup?

Regards,
Anurag

On Mon, Apr 18, 2011 at 7:30 PM, Kann  wrote:
> Dear all,
>
> I am new to django and have question about fixing the typo i made in
> the models.py. For example, I created tables with typo in the column
> name. So, I didn't realized the mistake and run the 'python manage.py
> syncdb' which created the tables with the incorrect names. Later I
> realized the typos and made changes in the "models.py" file and run
> the "python manage.py syncdb" again, but it didn't fix the typo in my
> column names.
>
> How do i fix the mistakes in the column names after the 'syncdb' is
> already run?
>
> Best,
>
> Kann
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

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



How to fix a column typo in django

2011-04-18 Thread Kann
Dear all,

I am new to django and have question about fixing the typo i made in
the models.py. For example, I created tables with typo in the column
name. So, I didn't realized the mistake and run the 'python manage.py
syncdb' which created the tables with the incorrect names. Later I
realized the typos and made changes in the "models.py" file and run
the "python manage.py syncdb" again, but it didn't fix the typo in my
column names.

How do i fix the mistakes in the column names after the 'syncdb' is
already run?

Best,

Kann

-- 
You received this message because you are subscribed to the Google 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: Detecting form mode in admin (create, edit, delete)

2011-04-18 Thread Sithembewena Lloyd Dube
Hey Mengu,

Thanks for the input. I have checked out teh documentation and seen that I
can use the boolean 'change', which is an argument passed to save_model.
It specifies whether or not the current request is an edit or not. :)

Thanks!

On Mon, Apr 18, 2011 at 3:05 PM, Mengu  wrote:

> sorry, accidentally posted.
>
> well, that could be done via javascript. :)
> http://localhost:8000/admin/testapp/testmodel/2/ - means i'm updating
> http://localhost:8000/admin/testapp/testmodel/add/ - means i'm adding
>
> if (document.location.href.indexOf("/add/") == -1) {
> // do not let update.
> }
>
> On Apr 18, 3:56 pm, Mengu  wrote:
> > well, that could be done via javascript. :)
> >
> > http://localhost:8000/admin/testapp/testmodel/2/- means i'm
> updatinghttp://localhost:8000/admin/testapp/testmodel/add/- means i'm adding
> >
> > if (document.location.href.indexOf("/add/") != -1) {
> >
> > }
> >
> > On Apr 18, 2:50 pm, Sithembewena Lloyd Dube  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > @Mengu, yes, precisely :)
> >
> > > On Mon, Apr 18, 2011 at 1:20 PM, Mengu  wrote:
> > > > you mean like if a new object is being added or edited in the admin?
> >
> > > > On Apr 18, 1:58 pm, Sithembewena Lloyd Dube 
> wrote:
> > > > > Hi all,
> >
> > > > > I wish to find out how I can detect current form mode in admin.py.
> What I
> > > > am
> > > > > trying to do is to stop users changing a dropdown's selection when
> in
> > > > edit
> > > > > mode.
> >
> > > > > Any ideas?
> >
> > > > > Thanks.
> >
> > > > > --
> > > > > Regards,
> > > > > Sithembewena Lloyd Dube
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> 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.
> >
> > > --
> > > Regards,
> > > Sithembewena Lloyd Dube
>
> --
> You received this message because you are subscribed to the Google 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
You received this message because you are subscribed to the Google 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: Detecting form mode in admin (create, edit, delete)

2011-04-18 Thread Mengu
sorry, accidentally posted.

well, that could be done via javascript. :)
http://localhost:8000/admin/testapp/testmodel/2/ - means i'm updating
http://localhost:8000/admin/testapp/testmodel/add/ - means i'm adding

if (document.location.href.indexOf("/add/") == -1) {
// do not let update.
}

On Apr 18, 3:56 pm, Mengu  wrote:
> well, that could be done via javascript. :)
>
> http://localhost:8000/admin/testapp/testmodel/2/- means i'm 
> updatinghttp://localhost:8000/admin/testapp/testmodel/add/- means i'm adding
>
> if (document.location.href.indexOf("/add/") != -1) {
>
> }
>
> On Apr 18, 2:50 pm, Sithembewena Lloyd Dube  wrote:
>
>
>
>
>
>
>
> > @Mengu, yes, precisely :)
>
> > On Mon, Apr 18, 2011 at 1:20 PM, Mengu  wrote:
> > > you mean like if a new object is being added or edited in the admin?
>
> > > On Apr 18, 1:58 pm, Sithembewena Lloyd Dube  wrote:
> > > > Hi all,
>
> > > > I wish to find out how I can detect current form mode in admin.py. What 
> > > > I
> > > am
> > > > trying to do is to stop users changing a dropdown's selection when in
> > > edit
> > > > mode.
>
> > > > Any ideas?
>
> > > > Thanks.
>
> > > > --
> > > > Regards,
> > > > Sithembewena Lloyd Dube
>
> > > --
> > > You received this message because you are subscribed to the Google 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.
>
> > --
> > Regards,
> > Sithembewena Lloyd Dube

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



Form containing a Mutipolygon field for Django 1.3

2011-04-18 Thread GARRAM karim
I am working on a GeoDjango project. I have a model.py wich extend the
user model and contains a MultiPolygonField


class Membre(models.Model):
user = models.ForeignKey(User, unique=True)

#some other attributes

mpoly = models.MultiPolygonField()
objects = models.GeoManager()

class MembreForm(ModelForm):
class Meta:
model = Membre
exclude = ('user',)

The form for this model works fine in the admin site. I am now
building the front office for it.
The problem that I'am facing is that in the resulting form I get a
mpoly (the mutipolygonfield) as a text area, I am facing the same
problem as:

http://stackoverflow.com/questions/559431/how-to-display-data-using-openlayers-with-openstreetmap-in-geodjango

I tryed to use OpenLayer script in my template to simply plot a
OpenLayer map but it didn't work (it worked for simple html pages). Is
there a GeoDjango specific tag to do that?

I think there is maybe a way to do this by using the (GeoDjango Admin
widget) but how to do it?

How can I use google map api for this field in both admin site and the
template I'm working on?

-- 
You received this message because you are subscribed to the Google 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: Detecting form mode in admin (create, edit, delete)

2011-04-18 Thread Mengu
well, that could be done via javascript. :)

http://localhost:8000/admin/testapp/testmodel/2/ - means i'm updating
http://localhost:8000/admin/testapp/testmodel/add/ - means i'm adding

if (document.location.href.indexOf("/add/") != -1) {

}

On Apr 18, 2:50 pm, Sithembewena Lloyd Dube  wrote:
> @Mengu, yes, precisely :)
>
>
>
>
>
>
>
>
>
> On Mon, Apr 18, 2011 at 1:20 PM, Mengu  wrote:
> > you mean like if a new object is being added or edited in the admin?
>
> > On Apr 18, 1:58 pm, Sithembewena Lloyd Dube  wrote:
> > > Hi all,
>
> > > I wish to find out how I can detect current form mode in admin.py. What I
> > am
> > > trying to do is to stop users changing a dropdown's selection when in
> > edit
> > > mode.
>
> > > Any ideas?
>
> > > Thanks.
>
> > > --
> > > Regards,
> > > Sithembewena Lloyd Dube
>
> > --
> > You received this message because you are subscribed to the Google 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.
>
> --
> Regards,
> Sithembewena Lloyd Dube

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



Re: Query model with multiple selfs

2011-04-18 Thread o_r
 > > Use F() objects:
>
> >     MyModel.objects.filter(mother=F(top))

Excellent, thanks!

Odd-R.

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



Re: Detecting form mode in admin (create, edit, delete)

2011-04-18 Thread Sithembewena Lloyd Dube
@Mengu, yes, precisely :)

On Mon, Apr 18, 2011 at 1:20 PM, Mengu  wrote:

> you mean like if a new object is being added or edited in the admin?
>
> On Apr 18, 1:58 pm, Sithembewena Lloyd Dube  wrote:
> > Hi all,
> >
> > I wish to find out how I can detect current form mode in admin.py. What I
> am
> > trying to do is to stop users changing a dropdown's selection when in
> edit
> > mode.
> >
> > Any ideas?
> >
> > Thanks.
> >
> > --
> > Regards,
> > Sithembewena Lloyd Dube
>
> --
> You received this message because you are subscribed to the Google 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
You received this message because you are subscribed to the Google 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: Detecting form mode in admin (create, edit, delete)

2011-04-18 Thread Mengu
you mean like if a new object is being added or edited in the admin?

On Apr 18, 1:58 pm, Sithembewena Lloyd Dube  wrote:
> Hi all,
>
> I wish to find out how I can detect current form mode in admin.py. What I am
> trying to do is to stop users changing a dropdown's selection when in edit
> mode.
>
> Any ideas?
>
> Thanks.
>
> --
> Regards,
> Sithembewena Lloyd Dube

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



Detecting form mode in admin (create, edit, delete)

2011-04-18 Thread Sithembewena Lloyd Dube
Hi all,

I wish to find out how I can detect current form mode in admin.py. What I am
trying to do is to stop users changing a dropdown's selection when in edit
mode.

Any ideas?

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube

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



Re: Query model with multiple selfs

2011-04-18 Thread Daniel Roseman
On Monday, April 18, 2011 11:57:37 AM UTC+1, Daniel Roseman wrote:
>
> On Monday, April 18, 2011 9:10:30 AM UTC+1, o_r wrote:
>>
>> Hello. 
>>
>> I have this model: 
>>
>> class MyModel(models.Model): 
>> string = models.CharField(max_length=96,unique=True,db_index=True) 
>> mother=models.ForeignKey('self',null=True,blank=True) 
>>   
>> top=models.ForeignKey('self',null=True,blank=True,related_name="Top") 
>>
>> I need to make a query which will return all those instances where 
>> mother and top is the same. Is this possible using the orm, or do I 
>> need to use raw? 
>>
>> Thanks! 
>>
>> Odd-R.
>
>
> Use F() objects:
>
> MyModel.objects.filter(mother=F(top))
>
>
> http://docs.djangoproject.com/en/1.3/topics/db/queries/#filters-can-reference-fields-on-the-model
> --
> DR.
>

Sorry, that should have been:  
MyModel.objects.filter(mother=F("top"))
--
DR.

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



Re: Query model with multiple selfs

2011-04-18 Thread Daniel Roseman
On Monday, April 18, 2011 9:10:30 AM UTC+1, o_r wrote:
>
> Hello. 
>
> I have this model: 
>
> class MyModel(models.Model): 
> string = models.CharField(max_length=96,unique=True,db_index=True) 
> mother=models.ForeignKey('self',null=True,blank=True) 
>   
> top=models.ForeignKey('self',null=True,blank=True,related_name="Top") 
>
> I need to make a query which will return all those instances where 
> mother and top is the same. Is this possible using the orm, or do I 
> need to use raw? 
>
> Thanks! 
>
> Odd-R.


Use F() objects:

MyModel.objects.filter(mother=F(top))

http://docs.djangoproject.com/en/1.3/topics/db/queries/#filters-can-reference-fields-on-the-model
--
DR.

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



Query model with multiple selfs

2011-04-18 Thread o_r
Hello.

I have this model:

class MyModel(models.Model):
string = models.CharField(max_length=96,unique=True,db_index=True)
mother=models.ForeignKey('self',null=True,blank=True)
 
top=models.ForeignKey('self',null=True,blank=True,related_name="Top")

I need to make a query which will return all those instances where
mother and top is the same. Is this possible using the orm, or do I
need to use raw?

Thanks!

Odd-R.

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



CSRF verification fails when using nginx reverse proxy cache

2011-04-18 Thread Sævar Öfjörð
Hi

I'm considering using nginx as a caching reverse-proxy to improve my
site's performance.
When I have the proxy turned on, the CSRF verification does not work
(at least not for contrib.auth login view).
Probably because the csrf_token in the form is cached and invalid.

I've googled this without much success to a point where I'm thinking
this is maybe some setting I'm missing.

Does anyone have experience with nginx as a caching reverse-proxy and
working CSRF?

Here are the relevant portions from my nginx config:

proxy_cache_path  /var/lib/nginx/cache  levels=1:2
keys_zone=staticfilecache:180m  max_size=500m;
proxy_temp_path /var/lib/nginx/proxy;
proxy_connect_timeout 30;
proxy_read_timeout 120;
proxy_send_timeout 120;
proxy_cache_key "$scheme://$host$request_uri";

server {
listen x.x.x.x:80;
server_name www.example.com;

proxy_cache_valid 200 5m;

location / {
proxy_cache staticfilecache;
proxy_passhttp://server;
add_header X-Handled-By $upstream_addr;
}
}

- Sævar

-- 
You received this message because you are subscribed to the Google 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: Growl-like notifications in your Django app.

2011-04-18 Thread Shawn Milochik
Thanks for those links. I started reading the first one and will check
them both out.

Shawn

-- 
You received this message because you are subscribed to the Google 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: Growl-like notifications in your Django app.

2011-04-18 Thread Rudi
Hey,

I haven't put it all together as one unit yet but I'm working
on it in the evenings when I have spare time.

FYI these are the two links that led to my "Ah ha" moment
in my quest for sending messages to the user from a django app.

http://www.alittletothewright.com/index.php/2010/01/comet-with-django-and-ape/

http://www.alittletothewright.com/index.php/2010/01/apedjango-and-signals/

The 1st link is what I was searching for, the 2nd link introduced me to signals.
Which is a nice way to wrap up the session messages app w/ signals and instant
message to the user.

I was thinking to use a css row plus div for incoming messages
to the browser using http://cssgrid.net/.

Your link today about "jQuery UI Notify Widget" looks much better though
and for me is like the icing on the cake I want to bake :-)

My intial layout ideas are:

cssgrid.net + "jQuery UI Notify Widget"

and then backend could be like:

django + messages + signals + ape-server

Cheers.

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



Re: Growl-like notifications in your Django app.

2011-04-18 Thread Shawn Milochik
Rudi,

I'm experimenting with Hookbox (http://hookbox.org/) myself for a
bunch of uses, including this sort of thing. If you get something
going with ape please post a follow-up, and I'll do the same with
Hookbox. It would help me (and the community) a lot, because it seems
like there's very little going on with Comet in the Django community.

In fact, I just made my first screencast today (unrelated topic), so
when I get something maybe I'll do a Hookbox screencast. If so, I'll
post it to the list.

Thanks,
Shawn

-- 
You received this message because you are subscribed to the Google 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: Growl-like notifications in your Django app.

2011-04-18 Thread Rudi
Shawn,

Very nice indeed and thank you for posting.

I've recently just discovered and started to use the 'messages' app in django.

I'm now tinkering with the django 'signals' app and using ape-project.org to
send real time message to the user.

Your link looks perfect for receiving message from django + ape.

Cheers.

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



Growl-like notifications in your Django app.

2011-04-18 Thread Shawn Milochik
http://www.erichynds.com/examples/jquery-notify/

I just implemented this today and it's awesome. It is great to use
with the new 'messages' app added to Django 1.2, and also with your
own JavaScript code live during the life of a page.

It's not 100% on-topic for the list, but I think it's fair considering
that a lot of apps would benefit from providing a lot more user
feedback. If you have a product with a non-technical user-base you may
avoid a lot of frustration and support calls if you could easily let
users know what's going on (or not going on) when they're failing to
fill out a form properly.

Shawn

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



Re: get_model not working

2011-04-18 Thread Shawn Milochik
This sounds like a perfect job for pdb.

One easy way is to put these lines where you want it to pause execution:

import pdb
pdb.set_trace()

Then you can type 'n' (next) to go line-by-line. If you type a
variable name or "print varname" at any time it will print the current
value.

Another way which is even better is to create a file named .pdbrc
(note the leading period) in the same directory as manage.py (wherever
you'll be launching your code from).

Assuming the line "nme = k.split('_')[0]" is on line 23:

break 
/home/lawgon/servicefirst/servicefirst/../servicefirst/incident/views.py:23

This will halt on line 23.

Even better:
break 
/home/lawgon/servicefirst/servicefirst/../servicefirst/incident/views.py:23,
'product' in k
This will halt on line 23 if 'product' is in 'k.'

If you use a .pdbrc file, instead of manage.py runserver, do this:

python -m pdb manage.py runserver

That will help you find the problem. Note also that you don't need to
import pdb anywhere in your code if you do the latter method. It's
great for debugging imported modules as well.
More info: http://www.doughellmann.com/PyMOTW/pdb/

Shawn

-- 
You received this message because you are subscribed to the Google 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: Dajaxice and CSRF issues

2011-04-18 Thread Vincent den Boer
> I found this thread today as I have come across the same problem.
> 
> I did find a solution that seems to work OK and I'd like to post
> it and get some feedback.
>
> ..
>

The thing with your solution is that the user won't get the token if he 
happens to come through another page than the home page, he won't get the CSRF 
token. To solve this, you'd have to let Django serve all HTML pages. Even if 
I'd wan't that, I couldn't because we also have PHP pages on the site.

I've ditched Dajaxice entirely, wrote my own little JavaScript and some Python 
(about 50 LoC) to handle Ajax requests. I can now use a GET when I don't need 
a POST, so CSRF is not an issue for me anymore :).

Another thing you could maybe do is retrieve a CSRF token through a GET 
request, and use that for your POSTs.

Kind regards,
Vincent

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



Re: problems with errors in templates

2011-04-18 Thread Antonio Sánchez
thanks, i think you are right, but now i cant check it, i'll do it
later!

thanks!

On 17 abr, 23:00, Daniel Roseman  wrote:
> On Sunday, 17 April 2011 21:41:15 UTC+1, Antonio Sánchez wrote:
>
> > hi, im working with a modelform, and overrided clen methos for making
> > some custom checks, raising a forms.ValidationError when i need, im
> > sure this error is raised, but i dont know why in the template errors
> > are not showed (instead of form is showed again cause it's not
> > valid!), here is some of the code:http://pastebin.com/j2SvJYgA some
> > help, thanks
>
> With that code, if the form is not valid and `new` is None, the form will be
> re-instantiated without any bound data. Replace `if new is None` with `elif
> new is None`.
> --
> DR.

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



get_model not working

2011-04-18 Thread Kenneth Gonsalves
hi,

I have this code snippet:

for k,v in match.__dict__.items():
if k in
['_state','id','incident_id','initiaterequest_id','matched']:
continue
if v:
nme = k.split('_')[0]
modl = get_model('incident',nme)
modlinstance = modl.objects.get(pk=int(v))
qlist[nme] = modlinstance
query = Incident.objects.filter(**qlist)

this was working fine. It works fine in the shell. But over the web
django barfs saying: None type does not have attribute 'objects'. But if
I print 'modl' - it gives



in the shell if I do 
get_model('incident','product').objects.get(pk=1) it works.

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8999/incident/showmatches/5/

Django Version: 1.3 SVN-16037
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'employee',
 'incident',
 'customer',
 'vendor',
 'assets',
 'products']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in
get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File
"/usr/lib/python2.6/site-packages/django/contrib/auth/decorators.py" in
_wrapped_view
  19. return view_func(request, *args, **kwargs)
File
"/home/lawgon/servicefirst/servicefirst/../servicefirst/incident/views.py" in 
showmatches
  200. modlinstance = modl.objects.get(pk=int(v))

Exception Type: AttributeError at /incident/showmatches/5/
Exception Value: 'NoneType' object has no attribute 'objects'

-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google 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: Unexplainable delay when binding request.POST to form

2011-04-18 Thread Jirka Vejrazka
> I'm getting 20-30 seconds delay when trying to bind request.POST data
> to form.

  Hi Toni,

  it's a very long shot, but similar delays are often related to DNS
issues. Is there anything in your code or data that might be using
domain name? It *might* be possible that some part of your code (or
even Django) tries to resolve a domain name and fails.

  As stated above, it's a very long shot but it certainly wouldn't be
the first time similar delay would be found related to DNS after some
debugging...

  HTH

Jirka

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