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 C

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 tab

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 d

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

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

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 thi

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 rec

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:

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

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 i

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 G

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 ins

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 name

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 = Mode

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+unsu

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: >                                 n

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__(s

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 = ItemTr

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

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 th

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

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 u

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

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 pre

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

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

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

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

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, ac

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

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() cla

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: > @M

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,

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

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

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 G

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.F

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',nul

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

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

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

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

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

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 d

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 co

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. Anothe

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

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

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) modl

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