Re: Connecting to external databases from Views.py

2012-10-24 Thread Russell Keith-Magee
On Thu, Oct 25, 2012 at 12:43 PM, Gregg Branquinho wrote:

> Hi Russel,
>
> First off thank you for the suggestion, I am going to give it a whirl and
> see how it works out.. I have a couple of concerns about the pricing
> database it the
> * it is on  mssql and the data is spread accross 3 database on the same
> server so the query would have to be cross database.. which also pose's a
> problem.
>

Genuine cross-database queries are going to be a problem regardless --
Django doesn't handle foreign keys that cross database boundaries. However,
if it's just a matter of having three different data stores, that's not a
problem at all -- it just means you'll have multiple entries in your
database configuration.

* the db's have like 300 table each..
>

There's a "yikes" factor here in terms of the number of tables you'll need
to configure, but inspected will help you out here, and once that's done,
you shouldn't have any problems in practice.


> Before you answer I wat thinking of accessing the database on the view
> *yuck* via pyodbc.
>
> after your answer I have a couple more questions ?
>
> Is is possible to override how a model is loaded from the database with
> raw sql and then overide the save and update methods to do nothing ? I have
> look at ovveriding __init__ but all recommendation are against it, but
> since I am not saving would it make any difference ?
>

You can certainly override the save() method and make it a no-op; you don't
need to touch __init__ at all to do this. Just make a subclass of
django.db.models.Model that defines a no-op save() method, and make sure
all your "views" extend this base class. Simliarly, you can override the
model manager to provide a default query set that makes the update a no-op.
As a third line of defence, you can write a database router that directs
write queries to a no-op database, so if something does accidentally
trigger a database write, it won't allow the update to occur.

Yours,
Russ Magee %-)

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



Re: Append only tables/models

2012-10-24 Thread Christophe Pettus

On Oct 25, 2012, at 8:26 AM, Mike Burr wrote:

> I know there are DBMS-specific ways of doing this. I know that there
> are Django ways of making fields read-only. What I cannot find is a
> way to make a table/model append-only.

You can always override the .save() method to check to see if the pk field is 
None, and refuse to save if it is not:


https://docs.djangoproject.com/en/1.4/topics/db/models/#overriding-predefined-model-methods

That being said, this kind of thing is *much* better done at the DB level, so 
that you can be certain that there are no other paths that allow data to be 
updated.

--
-- Christophe Pettus
   x...@thebuild.com

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



Re: environment variable DJANGO_SETTINGS_MODULE is undefined.

2012-10-24 Thread Mike Dewhirst

On 23/10/2012 2:10pm, Mike Dewhirst wrote:

On 23/10/2012 8:37am, DjgoNy wrote:

I have problem importing from  django_tables import tables
and when i do it on manage.py shell i get this error.

 >>> import django_tables2
Traceback (most recent call last):
   File "", line 1, in 
   File "build\bdist.win32\egg\django_tables2\__init__.py", line 3, in

   File "build\bdist.win32\egg\django_tables2\tables.py", line 4, in

   File "c:\Python27\lib\site-packages\django\db\__init__.py", line 11,
in 
 if DEFAULT_DB_ALIAS not in settings.DATABASES:
   File "c:\Python27\lib\site-packages\django\utils\functional.py", line
184, in inner
 self._setup()
   File "c:\Python27\lib\site-packages\django\conf\__init__.py", line
40, in _setup
 raise ImportError("Settings cannot be imported, because environment
variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
 >>>

how do i fix it.
what am i missing here


You are directly importing a package which is on the Python path so the
system finds it ok. But, that package (django_tables2) apparently
expects to be imported by some other bit of code which already knows
where your settings.py file lives.

If you want to import it directly it needs to know where to look.

You might need a PYTHONPATH environment variable which specifies the
path to your Django project. If settings.py lives in
C:\webwork\djngony\project\xyz\settings.py. Then your PYTHONPATH needs
to include C:\webwork\djngony

The traceback indicates, you need a DJANGO_SETTINGS_MODULE environment
variable. In my example above it would simply be project.xyz


Correction ... project.xyz.settings

or xyz.settings if C:\webwork\djngony\project is in the PYTHONPATH




hth

Mike


thank you so much.

--
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/-/e3UHoYJI0KsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.





--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9787 6598
M: 0411 704 143


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



Append only tables/models

2012-10-24 Thread Mike Burr
I know there are DBMS-specific ways of doing this. I know that there
are Django ways of making fields read-only. What I cannot find is a
way to make a table/model append-only.

It'd be great if this were at the DB level, so I don't have to rely on
my code not having any holes that allow edits. I don't know of a RDBMS-
neutral way of doing this. I'm using sqlite for testing (which appears
to have no such feature).

Is there a clean, "Django way" of doing this? I'll put my trust in
Django to prevent subsequent updates if I have to.

Just to clarify: I want for (all) users to be able to insert rows, but
not make edits after the fact (like you might want to do with logs,
but that's not the use case.)

Thank you!

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



Re: Connecting to external databases from Views.py

2012-10-24 Thread jirka . vejrazka
Hi Gregg,

  I've done something similar in the past - had several external databases (MS 
SQL and Oracle) attached to my Django project. These were backends of 
enterprise tools, hundreds of tables each.

  I used the "manage.py inspectdb" command to reverse engineer each "external" 
DB, manually polished models I needed (inspectdb is great but can't always 
perfectly guess foreign key relations or field types). Then I set 
"managed=False" for each model of those external DB's to make sure Django won't 
try to modify them.

  As for writing to those DB's, I had set up my DB routing so that these DB's 
were available only for read, not for wrining. I made sure that my code never 
attempted to write to those DB's. I also never used Django admin for this 
project. 

 YMMV

   Jirka

P.S. You can override the save() of your models in"external DB"  method to do 
nothing
-Original Message-
From: Gregg Branquinho 
Sender: django-users@googlegroups.com
Date: Wed, 24 Oct 2012 21:43:01 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: Connecting to external databases from Views.py

Hi Russel,

First off thank you for the suggestion, I am going to give it a whirl and 
see how it works out.. I have a couple of concerns about the pricing 
database it the
* it is on  mssql and the data is spread accross 3 database on the same 
server so the query would have to be cross database.. which also pose's a 
problem.
* the db's have like 300 table each..

Before you answer I wat thinking of accessing the database on the view 
*yuck* via pyodbc.

after your answer I have a couple more questions ?

Is is possible to override how a model is loaded from the database with raw 
sql and then overide the save and update methods to do nothing ? I have 
look at ovveriding __init__ but all recommendation are against it, but 
since I am not saving would it make any difference ?

Thanks very much for you previous answer as I feel it is pushing me towards 
a better solution

Kind regards
Gregg










On Thursday, 25 October 2012 02:49:49 UTC+2, Russell Keith-Magee wrote:
>
> Hi Gregg,
>
> Is there any reason you can't treat this as a mutliple-database 
> configuration?
>
> https://docs.djangoproject.com/en/dev/topics/db/multi-db/
>
> Django allows you to specify more than one database, and then direct 
> queries at specific databases. So, you have your "main" django database for 
> your own application, but you set up a connection to your "other" database 
> to access the pricing report.
>
> You'll need to write some Django model wrappers for the data in the 
> 'other' database -- inspectdb can help with that -- but once you've done 
> that, you'll be able to query the 'other' database as if it were a set of 
> normal Django models.
>
> Yours,
> Russ Magee %-)
>
> On Thu, Oct 25, 2012 at 4:43 AM, Gregg Branquinho 
> 
> > wrote:
>
>> Hi guys I am new to django and have built my first application that is 
>> being used to track and compare pricelists from vendors and it is working 
>> awesomly, I have had a request for a new feature and I am alittle boggled 
>> at to how I am going to do it..
>>
>> Basically I wasnt to create a view which returns read only data(a report) 
>> from an external database which is not the django database. I dont want to 
>> copy the data to the django database and use a models as then concurreny 
>> become an issue
>>
>> What would you guys recommened..
>>
>> I was thinking on implenting a odbc connection from the views.py method 
>> called for my url ? but database call from the view , sound a abit dodgy.
>>
>> Any ideas ?
>>
>>
>>
>>
>>
>> Email Disclaimer  | Quote 
>> Disclaimer  | All 
>> business is undertaken subject to our General Trading Conditions, a copy of 
>> which is available on request and on our website 
>> www.freightman.com 
>>
>> -- 
>> 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/-/ewQAAfxJlJ4J.
>> 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.
>>
>
>
-- 
Email Disclaimer  | Quote 
Disclaimer  | All 
business is undertaken subject to our General Trading Conditions, a copy of 
which is available on request and on our website 
www.freightman.com

-- 
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/-/rboXgSmzH3cJ

Re: "calculated" filed in model

2012-10-24 Thread Mike Burr
On Oct 25, 12:26 pm, Russell Keith-Magee 
wrote:
> Hi Mike,
>
> Easily done

Just as you said. Works like a charm. And as an added benefit, I
understand what the code's doing.

Caveats noted.

Thanks a bunch.

-Mike.

> , and no need to use signals or raw SQL: just override the save
> method on your model so that every time you call save, the value in the baz
> column is updated.
>
> class Foo(models.Model):
>     bar = models.CharField()
>     baz = models.CharField()
>
>     def save(self, *args, **kwargs):
>         self.baz = function(self.bar)
>         return super(Foo, self).save(*args, **kwargs)
>
> As a warning, there are some times when this won't work. For example, baz
> won't be updated if you use a .update() call on a queryset, and it won't be
> updated if you load a fixture or perform a "raw" save. However, this would
> also be true of a signal based approach. For most simple uses, it should be
> fine.
>
> Yours,
> Russ Magee %-)
>
>
>
>
>
>
>
> On Thu, Oct 25, 2012 at 10:12 AM, Mike Burr  wrote:
>
> > I would like to accomplish the following:
>
> > class Foo(models.Model):
> >     bar = models.CharField()
> >     baz = function(self.bar)
>
> > Of course this doesn't work (at least as I want it to), but I'm guessing
> > that most humans will know what I'm trying to do. What I want is:
>
> > 1) User supplies value for 'bar'
> > 2) User clicks 'Save'
> > 3) baz column gets value returned by 'function' (which will be a large
> > string)
>
> > I don't care if 'baz' shows up on the Admin form, so long as after saving
> > the calculated value shows up. I could probably do this with a DB trigger,
> > but I'd like to do it the Django way. A trigger would also not be
> > RDBMS-neutral I considered using signals, but:
>
> > 1) I don't think I can use pre_save, since I don't have a row yet.
> > 2) I don't think I can use post_save because I don't know of a way to
> > identify the right row. Also, post_save would make the transaction
> > non-atomic (right?) If "function" threw an exception for example, the row
> > would still get saved.
>
> > If I do use a signal, I'd also like to avoid using raw SQL if possible.
> > I'd have to hard-code table, column names, which seems ugly to me. I just
> > know there's a quick, elegant way of doing this. I'm just not Django savvy
> > enough yet.
>
> > 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/-/KC16U1q7p4AJ.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, 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: implement of view

2012-10-24 Thread Markus Christen

>
> Thank you for this page. I take my time today, to learn on 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/-/a9kvWj-zSjAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Connecting to external databases from Views.py

2012-10-24 Thread Gregg Branquinho
Hi Russel,

First off thank you for the suggestion, I am going to give it a whirl and 
see how it works out.. I have a couple of concerns about the pricing 
database it the
* it is on  mssql and the data is spread accross 3 database on the same 
server so the query would have to be cross database.. which also pose's a 
problem.
* the db's have like 300 table each..

Before you answer I wat thinking of accessing the database on the view 
*yuck* via pyodbc.

after your answer I have a couple more questions ?

Is is possible to override how a model is loaded from the database with raw 
sql and then overide the save and update methods to do nothing ? I have 
look at ovveriding __init__ but all recommendation are against it, but 
since I am not saving would it make any difference ?

Thanks very much for you previous answer as I feel it is pushing me towards 
a better solution

Kind regards
Gregg










On Thursday, 25 October 2012 02:49:49 UTC+2, Russell Keith-Magee wrote:
>
> Hi Gregg,
>
> Is there any reason you can't treat this as a mutliple-database 
> configuration?
>
> https://docs.djangoproject.com/en/dev/topics/db/multi-db/
>
> Django allows you to specify more than one database, and then direct 
> queries at specific databases. So, you have your "main" django database for 
> your own application, but you set up a connection to your "other" database 
> to access the pricing report.
>
> You'll need to write some Django model wrappers for the data in the 
> 'other' database -- inspectdb can help with that -- but once you've done 
> that, you'll be able to query the 'other' database as if it were a set of 
> normal Django models.
>
> Yours,
> Russ Magee %-)
>
> On Thu, Oct 25, 2012 at 4:43 AM, Gregg Branquinho 
> 
> > wrote:
>
>> Hi guys I am new to django and have built my first application that is 
>> being used to track and compare pricelists from vendors and it is working 
>> awesomly, I have had a request for a new feature and I am alittle boggled 
>> at to how I am going to do it..
>>
>> Basically I wasnt to create a view which returns read only data(a report) 
>> from an external database which is not the django database. I dont want to 
>> copy the data to the django database and use a models as then concurreny 
>> become an issue
>>
>> What would you guys recommened..
>>
>> I was thinking on implenting a odbc connection from the views.py method 
>> called for my url ? but database call from the view , sound a abit dodgy.
>>
>> Any ideas ?
>>
>>
>>
>>
>>
>> Email Disclaimer  | Quote 
>> Disclaimer  | All 
>> business is undertaken subject to our General Trading Conditions, a copy of 
>> which is available on request and on our website 
>> www.freightman.com 
>>
>> -- 
>> 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/-/ewQAAfxJlJ4J.
>> 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.
>>
>
>
-- 
Email Disclaimer  | Quote 
Disclaimer  | All 
business is undertaken subject to our General Trading Conditions, a copy of 
which is available on request and on our website 
www.freightman.com

-- 
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/-/rboXgSmzH3cJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread lacrymol...@gmail.com

The short of it is that you should probably subclass the picklefield to add 
some new validation (basically is_integer_two_tuple_list), and write a custom 
widget for it that does what you want on the html side. The long of it needs 
not being written from a phone

-Mensaje original-
De: Alphydan
Enviados:  24/10/2012 19:58:29
Asunto:  Re: Displaying a custom field (PickledObjectField) in the admin

Hi Tomas & John,

Thank you for your reply.  Basically I'm trying to save curves which I 
chose to format as:
[[0,0],[1,0],[2,1],[3,1], ... ,[40,0]]

To see what I tried before (models, etc) you can see the stackoverflow 
questionI
 asked previously.
Some people there suggested the django-picklefield so I implemented it but 
couldn't get the admin to work.
Unfortunately I would eventually need users to put in numbers in a template.

For the moment I'm just saving a TextField and doing some pretty coarse and 
inelegant validation + assuming we enter the curves in the admin.

def save(self, *args, **kwargs):
pc = self.my_power_curve
if pc[0]!='[':
pc = 'error. no initial [ --- ' + pc
self.my_power_curve = pc
elif pc[-1] != ']':
pc = 'error. no final ] --- ' + pc
self.my_power_curve = pc
elif  pc.count('[') != 42 or pc.count(']') !=42:
pc = 'error. 41 pairs [,] are required or too many brackets --- 
' + pc
self.my_power_curve = pc
elif  len(pc)>362:
pc = 'error. too many items --- ' + pc
self.my_power_curve = pc
elif pc.count('(') != 0 or pc.count(')') != 0:
pc = 'error. only "[" and "]" brackets allowed --- ' + pc
self.my_power_curve = pc
else:
pass
return super(SomeClass, self).save(*args, **kwargs)


Ideally I would create form with say 41 little fields:
value 1 = [  ]
value 2 = [  ]
value 3 = [  ]
...
value 41 = [  ]

and when the users completes *some of them*, I save it as a string:
"[[0,0],[1,1],[2,3],[10,20],[20,20],[40,0]]"

Eventually I want to retrieve them and calculate things (like area under 
the curve or make a graph).

Any ideas are appreciated,

Thank you,
Alvaro

On Wednesday, 24 October 2012 20:14:16 UTC+1, Tomas Neme wrote:
>
> Just by the way, I'm looking at django-picklefield code and README 
> https://github.com/gintas/django-picklefield and it says NOTHING about 
> a widget, or an admin representation, so.. maybe it's not DESIGNED to 
> be shown on the admin? it'd make sense, too, since it's.. well, it can 
> be ANYTHING 
>
> On Wed, Oct 24, 2012 at 3:03 PM, Tomas Neme > 
> wrote: 
> > maybe restate the problem, give some more code, show your models, and 
> > your admin files, and someone may be able to help a little 
> > 
> > -- 
> > "The whole of Japan is pure invention. There is no such country, there 
> > are no such people" --Oscar Wilde 
> > 
> > |_|0|_| 
> > |_|_|0| 
> > |0|0|0| 
> > 
> > (\__/) 
> > (='.'=)This is Bunny. Copy and paste bunny 
> > (")_(") to help him gain world domination. 
>
>
>
> -- 
> "The whole of Japan is pure invention. There is no such country, there 
> are no such people" --Oscar Wilde 
>
> |_|0|_| 
> |_|_|0| 
> |0|0|0| 
>
> (\__/) 
> (='.'=)This is Bunny. Copy and paste bunny 
> (")_(") to help him gain world domination. 
>

-- 
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/-/6RtZPEgjgFsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: "calculated" filed in model

2012-10-24 Thread Russell Keith-Magee
Hi Mike,

Easily done, and no need to use signals or raw SQL: just override the save
method on your model so that every time you call save, the value in the baz
column is updated.

class Foo(models.Model):
bar = models.CharField()
baz = models.CharField()

def save(self, *args, **kwargs):
self.baz = function(self.bar)
return super(Foo, self).save(*args, **kwargs)

As a warning, there are some times when this won't work. For example, baz
won't be updated if you use a .update() call on a queryset, and it won't be
updated if you load a fixture or perform a "raw" save. However, this would
also be true of a signal based approach. For most simple uses, it should be
fine.

Yours,
Russ Magee %-)

On Thu, Oct 25, 2012 at 10:12 AM, Mike Burr  wrote:

>
> I would like to accomplish the following:
>
> class Foo(models.Model):
> bar = models.CharField()
> baz = function(self.bar)
>
> Of course this doesn't work (at least as I want it to), but I'm guessing
> that most humans will know what I'm trying to do. What I want is:
>
> 1) User supplies value for 'bar'
> 2) User clicks 'Save'
> 3) baz column gets value returned by 'function' (which will be a large
> string)
>
> I don't care if 'baz' shows up on the Admin form, so long as after saving
> the calculated value shows up. I could probably do this with a DB trigger,
> but I'd like to do it the Django way. A trigger would also not be
> RDBMS-neutral I considered using signals, but:
>
> 1) I don't think I can use pre_save, since I don't have a row yet.
> 2) I don't think I can use post_save because I don't know of a way to
> identify the right row. Also, post_save would make the transaction
> non-atomic (right?) If "function" threw an exception for example, the row
> would still get saved.
>
> If I do use a signal, I'd also like to avoid using raw SQL if possible.
> I'd have to hard-code table, column names, which seems ugly to me. I just
> know there's a quick, elegant way of doing this. I'm just not Django savvy
> enough yet.
>
> 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/-/KC16U1q7p4AJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



"calculated" filed in model

2012-10-24 Thread Mike Burr

I would like to accomplish the following:

class Foo(models.Model):
bar = models.CharField()
baz = function(self.bar)

Of course this doesn't work (at least as I want it to), but I'm guessing 
that most humans will know what I'm trying to do. What I want is:

1) User supplies value for 'bar'
2) User clicks 'Save' 
3) baz column gets value returned by 'function' (which will be a large 
string)

I don't care if 'baz' shows up on the Admin form, so long as after saving 
the calculated value shows up. I could probably do this with a DB trigger, 
but I'd like to do it the Django way. A trigger would also not be 
RDBMS-neutral I considered using signals, but:

1) I don't think I can use pre_save, since I don't have a row yet.
2) I don't think I can use post_save because I don't know of a way to 
identify the right row. Also, post_save would make the transaction 
non-atomic (right?) If "function" threw an exception for example, the row 
would still get saved.

If I do use a signal, I'd also like to avoid using raw SQL if possible. I'd 
have to hard-code table, column names, which seems ugly to me. I just know 
there's a quick, elegant way of doing this. I'm just not Django savvy 
enough yet.

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/-/KC16U1q7p4AJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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-requests seems to 404 with Django/Tasty-pie?

2012-10-24 Thread Alex
I just discovered that the requests library honors HTTP_PROXY, but does not 
honor NO_PROXY. 

Based on what you say below, I'm betting this is your problem, or at least 
a part of it.

One solution is for you to explicitly unset HTTP_PROXY when you don't want 
it.

Another is for you to specify a proxies dict for requests.

Good luck!

Best
Alex





On Tuesday, October 2, 2012 2:31:52 PM UTC-7, Victor Hooi wrote:
>
> heya,
>
> Thanks for the tips - you're probably right, I might need to whip out 
> wireshark or something and see what exactly is going on.
>
> However, one thing I did notice - I normally have the http_proxy 
> environment variable set, as we use a HTTP proxy at work.
>
> However, if I unset the http_proxy variable, Python requests suddenly 
> seems to start working again.
>
> I tried to set the no_proxy variable, and put in localhost and 127.0.0.1 
> in there - however, Python requests doesn't seem to respect that?
>
> Cheers,
> Victor
>
> On Tuesday, 2 October 2012 22:48:26 UTC+10, Cal Leeming [Simplicity Media 
> Ltd] wrote:
>>
>> Hi Victor,
>>
>> I've had my fair share of exposure with python requests - so thought I'd 
>> chime in.
>>
>> On first glance, this looks to be an issue with specifying the port 
>> number into python-requests, doing so seems to send the entire "
>> http://localhost:8000/api/v1/host/?name__regex=&format=json"; as the 
>> request. However, further analysis shows that might not be the case.
>>
>> Looking at the python requests code;
>> https://github.com/kennethreitz/requests/blob/develop/requests/models.py
>>
>> >>> urlparse.urlparse("http://localhost:8080/test/url?with=params";)
>> ParseResult(scheme='http', netloc='localhost:8080', path='/test/url', 
>> params='', query='with=params', fragment='')
>>
>> It then sends this directly into urllib3 using connection_from_url();
>> https://github.com/shazow/urllib3/blob/master/urllib3/connectionpool.py
>>
>> This then calls the following;
>> scheme, host, port = get_host(url)
>> if scheme == 'https':
>> return HTTPSConnectionPool(host, port=port, **kw)
>> else:
>> return HTTPConnectionPool(host, port=port, **kw)
>>
>> get_host -> parse_url()
>> https://github.com/shazow/urllib3/blob/master/urllib3/util.py
>>
>> Tracing through urllib3 finally gets to parse_url();
>>
>> >>> urllib3.util.parse_url("http://localhost:8080/test/url?with=params";)
>> Url(scheme='http', auth=None, host='localhost', port=8080, 
>> path='/test/url', query='with=params', fragment=None)
>>
>> So, lets look at path_url() instead;
>> https://github.com/kennethreitz/requests/blob/develop/requests/models.py
>>
>> >>> lol = requests.get("
>> http://localhost:8000/api/v1/host/?name__regex=&format=json";)
>> >>> lol.request.path_url
>> '/api/v1/host/?name__regex=&format=json'
>>
>> Performing a test connection shows;
>>
>>  foxx@test01.internal [~] > nc -p8000 -l
>> GET /api/v1/host/?name__regex=&format=json HTTP/1.1
>> Host: localhost:8000
>> Accept-Encoding: identity, deflate, compress, gzip
>> Accept: */*
>> User-Agent: python-requests/0.11.1
>>
>> So, from what I can tell, python requests is functioning normally.
>>
>> Personally, I'd say get wireshark running, or use the nc trick shown 
>> above, perform 1 request using curl and 1 using python requests, then 
>> compare the request headers.
>>
>> Can't throw much more time at this, but hope the above helps
>>
>> Cal
>>
>> On Tue, Oct 2, 2012 at 8:54 AM, Victor Hooi  wrote:
>>
>>> Hi,
>>>
>>> I have a Django app that's serving up a RESTful API using tasty-pie.
>>>
>>> I'm using Django's development runserver to test.
>>>
>>> When I access it via a browser it works fine, and using Curl also works 
>>> fine:
>>>
>>> curl 
>>> "http://localhost:8000/api/v1/host/?name__regex=&format=json
 "
>>>
>>>
>>> On the console with runserver, I see:
>>>
>>> [02/Oct/2012 17:24:20] "GET /api/v1/host/?name__regex=&format=json 
 HTTP/1.1" 200 2845
>>>
>>>
>>> However, when I try to use the Python requests module (
>>> http://docs.python-requests.org/en/latest/), I get a 404:
>>>
>>> >>> r = requests.get('
 http://localhost:8000/api/v1/host/?name__regex=&format=json')
 >>> r
 
>>>
>>>
>>> or:
>>>
>>> >>> r = requests.get('
 http://localhost:8000/api/v1/host/?name__regex=&format=json
 ')
 >>> r
 
>>>
>>>
>>> or: 
>>>
>>> >>> payload = { 'format': 'json'}
 >>> r = requests.get('http://localhost:8000/api/v1', params=payload)
 >>> r
 
 >>> r.url
 u'http://localhost:8000/api/v1?format=json'
>>>
>>>
>>> Also, on the Django runserver console, I see:
>>>
>>> [02/Oct/2012 17:25:01] "GET 
 http://localhost:8000/api/v1/host/?name__regex=&format=json HTTP/1.1" 
 404 161072
>>>
>>>
>>> For some reason, when I use requests, runserver prints out the whole 
>>> request URL, including localhost - but when I use the browser

Re: Connecting to external databases from Views.py

2012-10-24 Thread Russell Keith-Magee
Hi Gregg,

Is there any reason you can't treat this as a mutliple-database
configuration?

https://docs.djangoproject.com/en/dev/topics/db/multi-db/

Django allows you to specify more than one database, and then direct
queries at specific databases. So, you have your "main" django database for
your own application, but you set up a connection to your "other" database
to access the pricing report.

You'll need to write some Django model wrappers for the data in the 'other'
database -- inspectdb can help with that -- but once you've done that,
you'll be able to query the 'other' database as if it were a set of normal
Django models.

Yours,
Russ Magee %-)

On Thu, Oct 25, 2012 at 4:43 AM, Gregg Branquinho wrote:

> Hi guys I am new to django and have built my first application that is
> being used to track and compare pricelists from vendors and it is working
> awesomly, I have had a request for a new feature and I am alittle boggled
> at to how I am going to do it..
>
> Basically I wasnt to create a view which returns read only data(a report)
> from an external database which is not the django database. I dont want to
> copy the data to the django database and use a models as then concurreny
> become an issue
>
> What would you guys recommened..
>
> I was thinking on implenting a odbc connection from the views.py method
> called for my url ? but database call from the view , sound a abit dodgy.
>
> Any ideas ?
>
>
>
>
>
> Email Disclaimer  | Quote
> Disclaimer  | All
> business is undertaken subject to our General Trading Conditions, a copy of
> which is available on request and on our website 
> www.freightman.com
>
> --
> 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/-/ewQAAfxJlJ4J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Best way to detect if a user has changed password

2012-10-24 Thread lacrymol...@gmail.com

If you hook into pre_save, you can compare agaist the DB with 
MyModel.objects.get(id=object.id)

I think there might be a way of checking directly on the instance if a field's 
been changed in 1.4

-Mensaje original-
De: Roarster
Enviados:  24/10/2012 18:23:15
Asunto:  Best way to detect if a user has changed password

I'm running a Django 1.4 site and I have some operations I want to perform 
if a user changes their password.  I'm using the standard contrib.auth user 
accounts with the normal password_change view and I'm not sure if I should 
somehow hook into this view or if I should use a signal on post_save for 
the user.  If I do use the signal, is it possible to tell when the password 
has been changed?  I do feel that if I can use a signal this might be the 
best approach since it would handle any other password change mechanisms 
that I might add later without any extra work.

Does anyone have any ideas on the best way to do this?

-- 
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/-/yrhcGbYf0f4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread Alphydan
Hi Tomas & John,

Thank you for your reply.  Basically I'm trying to save curves which I 
chose to format as:
[[0,0],[1,0],[2,1],[3,1], ... ,[40,0]]

To see what I tried before (models, etc) you can see the stackoverflow 
questionI
 asked previously.
Some people there suggested the django-picklefield so I implemented it but 
couldn't get the admin to work.
Unfortunately I would eventually need users to put in numbers in a template.

For the moment I'm just saving a TextField and doing some pretty coarse and 
inelegant validation + assuming we enter the curves in the admin.

def save(self, *args, **kwargs):
pc = self.my_power_curve
if pc[0]!='[':
pc = 'error. no initial [ --- ' + pc
self.my_power_curve = pc
elif pc[-1] != ']':
pc = 'error. no final ] --- ' + pc
self.my_power_curve = pc
elif  pc.count('[') != 42 or pc.count(']') !=42:
pc = 'error. 41 pairs [,] are required or too many brackets --- 
' + pc
self.my_power_curve = pc
elif  len(pc)>362:
pc = 'error. too many items --- ' + pc
self.my_power_curve = pc
elif pc.count('(') != 0 or pc.count(')') != 0:
pc = 'error. only "[" and "]" brackets allowed --- ' + pc
self.my_power_curve = pc
else:
pass
return super(SomeClass, self).save(*args, **kwargs)


Ideally I would create form with say 41 little fields:
value 1 = [  ]
value 2 = [  ]
value 3 = [  ]
...
value 41 = [  ]

and when the users completes *some of them*, I save it as a string:
"[[0,0],[1,1],[2,3],[10,20],[20,20],[40,0]]"

Eventually I want to retrieve them and calculate things (like area under 
the curve or make a graph).

Any ideas are appreciated,

Thank you,
Alvaro

On Wednesday, 24 October 2012 20:14:16 UTC+1, Tomas Neme wrote:
>
> Just by the way, I'm looking at django-picklefield code and README 
> https://github.com/gintas/django-picklefield and it says NOTHING about 
> a widget, or an admin representation, so.. maybe it's not DESIGNED to 
> be shown on the admin? it'd make sense, too, since it's.. well, it can 
> be ANYTHING 
>
> On Wed, Oct 24, 2012 at 3:03 PM, Tomas Neme > 
> wrote: 
> > maybe restate the problem, give some more code, show your models, and 
> > your admin files, and someone may be able to help a little 
> > 
> > -- 
> > "The whole of Japan is pure invention. There is no such country, there 
> > are no such people" --Oscar Wilde 
> > 
> > |_|0|_| 
> > |_|_|0| 
> > |0|0|0| 
> > 
> > (\__/) 
> > (='.'=)This is Bunny. Copy and paste bunny 
> > (")_(") to help him gain world domination. 
>
>
>
> -- 
> "The whole of Japan is pure invention. There is no such country, there 
> are no such people" --Oscar Wilde 
>
> |_|0|_| 
> |_|_|0| 
> |0|0|0| 
>
> (\__/) 
> (='.'=)This is Bunny. Copy and paste bunny 
> (")_(") to help him gain world domination. 
>

-- 
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/-/6RtZPEgjgFsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Only one profile type of multiple user profiles types gets created.

2012-10-24 Thread Nicolas Emiliani
> The thing is that now the only profile that ever gets created when
> creating a  user
> is AgentProfile. I can't get it to create an AuditorProfile not even by
> setting the agency
> field on the form.
>
>
>
Ok, just for the record, I did it the shameless way.
Only one profile class with an profile type attribute.
Nasty but it works.


>
> Thanks!
>
> --
> Nicolas Emiliani
>
> Lo unico instantaneo en la vida es el cafe, y es bien feo.
>



-- 
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Puzzled about WSGI vs. FastCGI

2012-10-24 Thread Nikolas Stevenson-Molnar
Correct. I've found proxying to an HTTP WSGI server to be eaisier as you
don't need to configure passing of FastCGI params. I use Gunicorn with
nginx, and it requires very little all around configuration. I would
expect Gunicorn with lighttpd to be similar.

_Nik

On 10/24/2012 3:11 PM, Fred wrote:
> Thanks guys for the infos. It makes a lot more sense now.
>
> So it looks like Lighttpd does not support the equivalent of mod_wsgi,
> so requires a second server that speaks either FastCGI or HTTP/WSGI.
>
> On Wednesday, October 24, 2012 5:58:21 PM UTC+2, Fred wrote:
>
> Hello
>
> I'm trying to find how to install Python on a Lighttpd server that
> currently runs PHP scripts.
>
> This article
> 
> says:
>
> Although WSGI is the preferred deployment platform for Django,
> many people use shared hosting, on which protocols such as
> FastCGI, SCGI or AJP are the only viable options.
>
>
> I'm puzzled, because I seemed to understand that WSGI is an API
> that relies on a lower-level transport solution like FastCGI,
> SCGI, or AJP.
>
> Could it be that the article actually opposed mod_wsgi, which can
> run within Apache à la mod_php *?
>
> And if someone knows of a good way to run Python through FastCGI
> (with or without WSGI) on Lighttpd, I'm interested: "Python
> FastCGI on lighty with flup" at the very bottom
> 
> 
> only seems to run a specific script.
>
> Thank you.
>
> * altough it can also run in its own process, just like FastCGI 
>
> -- 
> 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/-/n62KPozSRhcJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 way to display a model formset in a ModelAdmin ?

2012-10-24 Thread Nicolas Emiliani
Hi,

As the subject states, is there a way to display a model formset in a
ModelForm?

The thing is that I have a Verification model with its ModelAdmin, and then
I have
an ImageModel that has no ForeignKey to the Verification model (and I
intend to keep
it that way) so I can not inline it into the VerificationAdmin and I would
like to show
a list of Images in my VerificationAdmin based on a queryset performed (i
assume) at
__init__ method of VerificationAdminForm. How could this be accomplished?

This is how it goes:

class Image(models.Model):
   

class Verification(models.Model):
   

class VerificationAdminForm(forms.ModelForm):
   

class VerificationAdmin(admin.ModelAdmin):
   form = VerificationAdminForm
   model = Verification
   fieldsets = [ ... ]

Any ideas would be greatly appreciated.

Thanks in advance.

-- 
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Puzzled about WSGI vs. FastCGI

2012-10-24 Thread Fred
Thanks guys for the infos. It makes a lot more sense now.

So it looks like Lighttpd does not support the equivalent of mod_wsgi, so 
requires a second server that speaks either FastCGI or HTTP/WSGI.

On Wednesday, October 24, 2012 5:58:21 PM UTC+2, Fred wrote:
>
> Hello
>
> I'm trying to find how to install Python on a Lighttpd server that 
> currently runs PHP scripts.
>
> This 
> articlesays:
>
>> Although WSGI is the preferred deployment platform for Django, many 
>> people use shared hosting, on which protocols such as FastCGI, SCGI or AJP 
>> are the only viable options.
>
>
> I'm puzzled, because I seemed to understand that WSGI is an API that 
> relies on a lower-level transport solution like FastCGI, SCGI, or AJP.
>
> Could it be that the article actually opposed mod_wsgi, which can run 
> within Apache à la mod_php *?
>
> And if someone knows of a good way to run Python through FastCGI (with or 
> without WSGI) on Lighttpd, I'm interested: "Python FastCGI on lighty with 
> flup" at the very 
> bottomonly
>  seems to run a specific script.
>
> Thank you.
>
> * altough it can also run in its own process, just like FastCGI 
>

-- 
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/-/n62KPozSRhcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 way to detect if a user has changed password

2012-10-24 Thread Brad Pitcher
You could use a "pre_save" signal. kwargs['instance'] will contain the
updated record and you can get the old record with "User.objects.get(id=
user.id) if user.pk else None". I've done this in the past to check for a
changed email address.

On Wed, Oct 24, 2012 at 2:23 PM, Roarster  wrote:

> I'm running a Django 1.4 site and I have some operations I want to perform
> if a user changes their password.  I'm using the standard contrib.auth user
> accounts with the normal password_change view and I'm not sure if I should
> somehow hook into this view or if I should use a signal on post_save for
> the user.  If I do use the signal, is it possible to tell when the password
> has been changed?  I do feel that if I can use a signal this might be the
> best approach since it would handle any other password change mechanisms
> that I might add later without any extra work.
>
> Does anyone have any ideas on the best way to do this?
>
> --
> 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/-/yrhcGbYf0f4J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Why does BaseHandler::handle_uncaught_exception() not always log?

2012-10-24 Thread Roy Smith
In core/handlers/base.py, handle_uncaught_exception() does:

if settings.DEBUG:
from django.views import debug
return debug.technical_500_response(request, *exc_info)

logger.error('Internal Server Error: %s' % request.path,
exc_info=exc_info,
extra={
'status_code': 500,
'request':request
}
)

Wouldn't it make more sense to always log the exception?  As it stands now, 
it's an either/or deal.  If DEBUG, produce the debug page and don't log. 
 If not DEBUG, log and produce a normal 500 page.

I ended up writing my own process_exception() middleware to log stack 
traces for all uncaught exceptions.  This was fine in development, but in 
production, with DEBUG = False, I get *two* stacks in my log files for 
every exception (one from my hander, another from the code above).  This 
all seems silly.  It would be so much simpler (and obvious) if 
handle_uncaught_exception() always logged, regardless of which flavor of 
response it's going to produce.

-- 
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/-/V01p8srjB_UJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 way to detect if a user has changed password

2012-10-24 Thread Roarster
I'm running a Django 1.4 site and I have some operations I want to perform 
if a user changes their password.  I'm using the standard contrib.auth user 
accounts with the normal password_change view and I'm not sure if I should 
somehow hook into this view or if I should use a signal on post_save for 
the user.  If I do use the signal, is it possible to tell when the password 
has been changed?  I do feel that if I can use a signal this might be the 
best approach since it would handle any other password change mechanisms 
that I might add later without any extra work.

Does anyone have any ideas on the best way to do this?

-- 
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/-/yrhcGbYf0f4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 ajax Post returns empty message

2012-10-24 Thread psychok7
got it, the problem was that i had to change this request.GET.get('type','') to 
thisrequest.POST.get('type','')

On Wednesday, October 24, 2012 9:56:15 PM UTC+1, psychok7 wrote:
>
> using django 1.4, I can Post but the Post response comes (undefined) empty 
> but GET works fine. i am using the csrf checks not sure if the problem also 
> comes from there
>
> my django view:
>
> @csrf_protect
> def edit_city(request,username):
> conditions = dict()
>
> #if request.is_ajax():
> if request.method == 'GET':
> conditions = request.method
> #based on http://stackoverflow.com/a/3634778/977622 
> for filter_key, form_key in (('type',  'type'), ('city', 'city'), 
> ('pois', 'pois'), ('poisdelete', 'poisdelete'), ('kmz', 'kmz'), ('kmzdelete', 
> 'kmzdelete'), ('limits', 'limits'), ('limitsdelete', 'limitsdelete'), 
> ('area_name', 'area_name'), ('action', 'action')):
> value = request.GET.get(form_key, None)
> if value:
> conditions[filter_key] = value
> print filter_key , conditions[filter_key]
>
> elif request.method == 'POST':
> print "TIPO" , request.GET.get('type','')   
> #based on http://stackoverflow.com/a/3634778/977622 
> for filter_key, form_key in (('type',  'type'), ('city', 'city'), 
> ('pois', 'pois'), ('poisdelete', 'poisdelete'), ('kmz', 'kmz'), ('kmzdelete', 
> 'kmzdelete'), ('limits', 'limits'), ('limitsdelete', 'limitsdelete'), 
> ('area_name', 'area_name'), ('action', 'action')):
> value = request.GET.get(form_key, None)
> if value:
> conditions[filter_key] = value
> print filter_key , conditions[filter_key]
>
> #Test.objects.filter(**conditions)
> city_json = json.dumps(conditions)
>
> return HttpResponse(city_json, mimetype='application/json')
>
> here is my javascript code :
>
> function getCookie(name) {
> var cookieValue = null;
> if (document.cookie && document.cookie != '') {
> var cookies = document.cookie.split(';');
> for (var i = 0; i < cookies.length; i++) {
> var cookie = jQuery.trim(cookies[i]);
> // Does this cookie string begin with the name we want?
> if (cookie.substring(0, name.length + 1) == (name + '=')) {
> cookieValue = decodeURIComponent(cookie.substring(name.length 
> + 1));
> break;
> }
> }
> }
> return cookieValue;
> }
> var csrftoken = getCookie('csrftoken');
>
> function csrfSafeMethod(method) {
> // these HTTP methods do not require CSRF protection
> return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
> }
> function sameOrigin(url) {
> // test that a given url is a same-origin URL
> // url could be relative or scheme relative or absolute
> var host = document.location.host; // host + port
> var protocol = document.location.protocol;
> var sr_origin = '//' + host;
> var origin = protocol + sr_origin;
> // Allow absolute or scheme relative URLs to same origin
> return (url == origin || url.slice(0, origin.length + 1) == origin + '/') 
> ||
> (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin 
> + '/') ||
> // or any other URL that isn't scheme relative or absolute i.e 
> relative.
> !(/^(\/\/|http:|https:).*/.test(url));
> }
> $.ajaxSetup({
> beforeSend: function(xhr, settings) {
> if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
> // Only send the token to relative URLs i.e. locally.
> xhr.setRequestHeader("X-CSRFToken",
>  $('input[name="csrfmiddlewaretoken"]').val());
> }
> }
> });
>
> $.post(url,{ type : type , city: cityStr, pois: poisStr, poisdelete: 
> poisDeleteStr, kmz: kmzStr,kmzdelete : kmzDeleteStr,limits : limitsStr, 
> area_nameStr : area_nameStr , limitsdelete : 
> limitsDeleteStr},function(data,status){
> alert("Data: " + data + "\nStatus: " + status);
> console.log("newdata" + data.kmz)
> });
>
> what am i missing?
>

-- 
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/-/gmNfKhGU6_EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 ajax Post returns empty message

2012-10-24 Thread psychok7
 it seems like its not posting propely, irequest.GET.get('type','') but it 
prints empty string and the Post response comes (undefined) empty but GET 
works fine.

On Wednesday, October 24, 2012 9:56:15 PM UTC+1, psychok7 wrote:
>
> using django 1.4, I can Post but the Post response comes (undefined) empty 
> but GET works fine. i am using the csrf checks not sure if the problem also 
> comes from there
>
> my django view:
>
> @csrf_protect
> def edit_city(request,username):
> conditions = dict()
>
> #if request.is_ajax():
> if request.method == 'GET':
> conditions = request.method
> #based on http://stackoverflow.com/a/3634778/977622 
> for filter_key, form_key in (('type',  'type'), ('city', 'city'), 
> ('pois', 'pois'), ('poisdelete', 'poisdelete'), ('kmz', 'kmz'), ('kmzdelete', 
> 'kmzdelete'), ('limits', 'limits'), ('limitsdelete', 'limitsdelete'), 
> ('area_name', 'area_name'), ('action', 'action')):
> value = request.GET.get(form_key, None)
> if value:
> conditions[filter_key] = value
> print filter_key , conditions[filter_key]
>
> elif request.method == 'POST':
> print "TIPO" , request.GET.get('type','')   
> #based on http://stackoverflow.com/a/3634778/977622 
> for filter_key, form_key in (('type',  'type'), ('city', 'city'), 
> ('pois', 'pois'), ('poisdelete', 'poisdelete'), ('kmz', 'kmz'), ('kmzdelete', 
> 'kmzdelete'), ('limits', 'limits'), ('limitsdelete', 'limitsdelete'), 
> ('area_name', 'area_name'), ('action', 'action')):
> value = request.GET.get(form_key, None)
> if value:
> conditions[filter_key] = value
> print filter_key , conditions[filter_key]
>
> #Test.objects.filter(**conditions)
> city_json = json.dumps(conditions)
>
> return HttpResponse(city_json, mimetype='application/json')
>
> here is my javascript code :
>
> function getCookie(name) {
> var cookieValue = null;
> if (document.cookie && document.cookie != '') {
> var cookies = document.cookie.split(';');
> for (var i = 0; i < cookies.length; i++) {
> var cookie = jQuery.trim(cookies[i]);
> // Does this cookie string begin with the name we want?
> if (cookie.substring(0, name.length + 1) == (name + '=')) {
> cookieValue = decodeURIComponent(cookie.substring(name.length 
> + 1));
> break;
> }
> }
> }
> return cookieValue;
> }
> var csrftoken = getCookie('csrftoken');
>
> function csrfSafeMethod(method) {
> // these HTTP methods do not require CSRF protection
> return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
> }
> function sameOrigin(url) {
> // test that a given url is a same-origin URL
> // url could be relative or scheme relative or absolute
> var host = document.location.host; // host + port
> var protocol = document.location.protocol;
> var sr_origin = '//' + host;
> var origin = protocol + sr_origin;
> // Allow absolute or scheme relative URLs to same origin
> return (url == origin || url.slice(0, origin.length + 1) == origin + '/') 
> ||
> (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin 
> + '/') ||
> // or any other URL that isn't scheme relative or absolute i.e 
> relative.
> !(/^(\/\/|http:|https:).*/.test(url));
> }
> $.ajaxSetup({
> beforeSend: function(xhr, settings) {
> if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
> // Only send the token to relative URLs i.e. locally.
> xhr.setRequestHeader("X-CSRFToken",
>  $('input[name="csrfmiddlewaretoken"]').val());
> }
> }
> });
>
> $.post(url,{ type : type , city: cityStr, pois: poisStr, poisdelete: 
> poisDeleteStr, kmz: kmzStr,kmzdelete : kmzDeleteStr,limits : limitsStr, 
> area_nameStr : area_nameStr , limitsdelete : 
> limitsDeleteStr},function(data,status){
> alert("Data: " + data + "\nStatus: " + status);
> console.log("newdata" + data.kmz)
> });
>
> what am i missing?
>

-- 
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/-/mtINoYH01X8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: tree.io installation with django

2012-10-24 Thread Nick Apostolakos
Just use pip and virtualenv. You
 don have to lock yourself in your distro packaged django

Fabian Weiss  wrote:

>I would like to do, but my Debian Distribution just offers 1.4! Maybe I
>can 
>install another one, but than I probably get Version missmatch.. :/
>
>Am Samstag, 15. September 2012 23:32:06 UTC+2 schrieb Nick Apostolakis:
>>
>>
>>
>> On Sat, Sep 15, 2012 at 11:41 PM, Fabian Weiss
>
>> > wrote:
>>
>>> I do so! I tried now this one: 
>>>
>http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/
>>> And it works! :) 
>>> http://project.immersight.de/
>>>
>>> I tried again all I could find in the net for treeio, but nothing
>works :(
>>> How can I totally remove all my steps? Is it just to delete the 
>>> directories? Or is there something to do in a database?
>>>
>>> Maybe I have a version of django which is too new? It is 1.4.1
>>>
>>>
>http://nopaste.immersight.de/?34b6a29be67dd853#dvMCsmIWwYZUWV2qKMFxGLMI4pq+O3PiPy2iHAp3ZzQ=
>>>
>>>
>>>
>> Why don't you use django 1.3 as it is described in the requirements
>file?
>> Thats a simple way to see if you problems stem from django version 
>> incompatibility
>>
>> -- 
>>
>---
>> Nick Apostolakis
>> email:n...@oncrete.gr 
>> Web Site: http://nick.oncrete.gr
>>
>---
>>  


-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



Connecting to external databases from Views.py

2012-10-24 Thread Gregg Branquinho
Hi guys I am new to django and have built my first application that is 
being used to track and compare pricelists from vendors and it is working 
awesomly, I have had a request for a new feature and I am alittle boggled 
at to how I am going to do it..

Basically I wasnt to create a view which returns read only data(a report) 
from an external database which is not the django database. I dont want to 
copy the data to the django database and use a models as then concurreny 
become an issue

What would you guys recommened..

I was thinking on implenting a odbc connection from the views.py method 
called for my url ? but database call from the view , sound a abit dodgy.

Any ideas ?





-- 
Email Disclaimer  | Quote 
Disclaimer  | All 
business is undertaken subject to our General Trading Conditions, a copy of 
which is available on request and on our website 
www.freightman.com

-- 
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/-/ewQAAfxJlJ4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django ajax Post returns empty message

2012-10-24 Thread psychok7


using django 1.4, I can Post but the Post response comes (undefined) empty 
but GET works fine. i am using the csrf checks not sure if the problem also 
comes from there

my django view:

@csrf_protect
def edit_city(request,username):
conditions = dict()

#if request.is_ajax():
if request.method == 'GET':
conditions = request.method
#based on http://stackoverflow.com/a/3634778/977622 
for filter_key, form_key in (('type',  'type'), ('city', 'city'), 
('pois', 'pois'), ('poisdelete', 'poisdelete'), ('kmz', 'kmz'), ('kmzdelete', 
'kmzdelete'), ('limits', 'limits'), ('limitsdelete', 'limitsdelete'), 
('area_name', 'area_name'), ('action', 'action')):
value = request.GET.get(form_key, None)
if value:
conditions[filter_key] = value
print filter_key , conditions[filter_key]

elif request.method == 'POST':
print "TIPO" , request.GET.get('type','')   
#based on http://stackoverflow.com/a/3634778/977622 
for filter_key, form_key in (('type',  'type'), ('city', 'city'), 
('pois', 'pois'), ('poisdelete', 'poisdelete'), ('kmz', 'kmz'), ('kmzdelete', 
'kmzdelete'), ('limits', 'limits'), ('limitsdelete', 'limitsdelete'), 
('area_name', 'area_name'), ('action', 'action')):
value = request.GET.get(form_key, None)
if value:
conditions[filter_key] = value
print filter_key , conditions[filter_key]

#Test.objects.filter(**conditions)
city_json = json.dumps(conditions)

return HttpResponse(city_json, mimetype='application/json')

here is my javascript code :

function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 
1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');

function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
function sameOrigin(url) {
// test that a given url is a same-origin URL
// url could be relative or scheme relative or absolute
var host = document.location.host; // host + port
var protocol = document.location.protocol;
var sr_origin = '//' + host;
var origin = protocol + sr_origin;
// Allow absolute or scheme relative URLs to same origin
return (url == origin || url.slice(0, origin.length + 1) == origin + '/') ||
(url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + 
'/') ||
// or any other URL that isn't scheme relative or absolute i.e relative.
!(/^(\/\/|http:|https:).*/.test(url));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRFToken",
 $('input[name="csrfmiddlewaretoken"]').val());
}
}
});

$.post(url,{ type : type , city: cityStr, pois: poisStr, poisdelete: 
poisDeleteStr, kmz: kmzStr,kmzdelete : kmzDeleteStr,limits : limitsStr, 
area_nameStr : area_nameStr , limitsdelete : 
limitsDeleteStr},function(data,status){
alert("Data: " + data + "\nStatus: " + status);
console.log("newdata" + data.kmz)
});

what am i missing?

-- 
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/-/rq4EbSg0dWcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Puzzled about WSGI vs. FastCGI

2012-10-24 Thread Javier Guerra Giraldez
On Wed, Oct 24, 2012 at 10:58 AM, Fred  wrote:
> This article says:
>>
>> Although WSGI is the preferred deployment platform for Django, many people
>> use shared hosting, on which protocols such as FastCGI, SCGI or AJP are the
>> only viable options.
>
>
> I'm puzzled, because I seemed to understand that WSGI is an API that relies
> on a lower-level transport solution like FastCGI, SCGI, or AJP.

not exactly like that.  it's not about which is higher-level, or which
runs on top of what... i see it more like a chain of protocol
conversions.

at one end, it's WSGI, it's a standard, a convention of how to call
Python functions to implement web applications.  Django is implemented
as a WSGI application, so you need something that makes those WSGI
calls.

at the other end is the user browser, which does HTTP requests.

so, you need to translate HTTP requests to WSGI calls, and the
returned WSGI responses into HTTP responses.

there are HTTP-WSGI servers, like gunicorn, and tornado, and lots others.

there are also many HTTP servers that can use a multitude of back-end
protocols to talk to webapps.

Apache, for instance can do FastCGI.  if so, you can use flup to serve
FastCGI with WSGI calls.

or you could use mod_wsgi to skip flup and keep the HTTP-WSGI within
Apache.  (this is the recommended structure for Apache)

several other webservers can do FastCGI, like lighttp or nginx.  in
all those cases you can still use flup.

but nginx is also a quite good HTTP-HTTP load-balancer, so you can use
gunicorn to serve HTTP behind nginx.  this is a very popular setup.
or you can replace nginx with lighttp in proxy mode.

another very good alternative is uWSGI, which adapts several protocols
and calls WSGI apps (and others!).  It was originally designed to use
a very compact and efficient protocol, mainly driven by a mod_uwsgi
add-in for nginx.  this can be a very low-overhead, high-performance
option.  uWSGI also has many, many options to administer the whole
system with great detail.

hope that helps.

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread Tomas Neme
Just by the way, I'm looking at django-picklefield code and README
https://github.com/gintas/django-picklefield and it says NOTHING about
a widget, or an admin representation, so.. maybe it's not DESIGNED to
be shown on the admin? it'd make sense, too, since it's.. well, it can
be ANYTHING

On Wed, Oct 24, 2012 at 3:03 PM, Tomas Neme  wrote:
> maybe restate the problem, give some more code, show your models, and
> your admin files, and someone may be able to help a little
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread Tomas Neme
maybe restate the problem, give some more code, show your models, and
your admin files, and someone may be able to help a little

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



virtualenvwrapper dies while mkproject & mkvirtualenv

2012-10-24 Thread Ashkan Roshanayi
Hi I've installed pip using easy_install on my mac and later installed 
virtualenv and virtualenvwrapper both successfully.  

wrapper doesn't work at all and when I invoke it by mkproject or mkvirtualenv 
it go on till this line:

> Setting project for test to $PROJECT_HOME/test
> 



and from here it takes a long time with no output or progress. Any idea on how 
can I fix this?

Cheers, 

-- 
Ashkan



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



Date widget not HTML5

2012-10-24 Thread Juan Pablo Tamayo


Is there any reason not to have the date widget input tag have the 
attribute type="date" instead of just type="text"?

I mean, most browser do not treat it differently, but it tells them that 
they should; besides it would mean that Django tries to support the full 
range of HTML5.


Is there a way to change this particular behavior?

Thanks in advance fellow Django-mates!!!

-- 
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/-/8fUlgENHuYAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Internationalization: trans with object property

2012-10-24 Thread Ma Ba
Hi,
I have a question about the internationalization feature ...

I have a country model:

class Country(models.Model):
nameKey = models.CharField(max_length=50)
shortNameKey = models.CharField(max_length=30)

The properties 'nameKey' and 'shortNameKey' contain resource keys like 
'_country_af' or '_country_af_short'. I need this to show the country names 
depending on the current locale.

The problem was/is to add the resource keys to the .po file, so I found a 
solution in a forum: 
http://stackoverflow.com/questions/7625991/how-to-properly-add-entries-for-computed-values-to-the-django-internationalizati

For example, I added the following to a model file:

def dummy_for_makemessages():
#countries
pgettext('forecast type', '_country_af')
pgettext('forecast type', '_country_af_short')

Runing makemessages this generates the following entries in the .po file:

msgctxt "forecast type"
msgid "_country_af"
msgstr "Afghanistan"

msgctxt "forecast type"
msgid "_country_af_short"
msgstr "Afghanistan"

For testing purposes I tried to iterate over all countries in my database 
in a template and to print out the translated names:

{% for country in countries %}
{% trans country.nameKey %}
{% endfor %}

Unfortunately, it only prints out the following (the resource keys instead 
of the translated names):

_country_af 
_country_ai 
_country_qa 
_country_ke 
_country_kg 
_country_ki 
_country_cc 
_country_co 
...

I found out that the 'msgctxt' part in the .po file causes the missing 
translation. I removed it for testing purposes and this time it worked fine.

So, my question is, how can I translate resource keys that are not defined 
in the template itself but in an object property instead? Is there a way to 
generate the resource keys without the 'msgctxt' part? I tried NONE or an 
empty string but this generates a commented out resource key in the .po 
file (please see the link to the other forum above).
Does anybody have an idea how to solve this problem?

Thanks for your help in advance!!

-- 
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/-/ufCAPzasLcEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: [Q: Basic] Strange behaviour after pressing on button

2012-10-24 Thread Nikolas Stevenson-Molnar
It's possible that the CSRF token isn't being sent correctly. As a test,
try adding the @csrf_exempt decorator to your view. If you no longer get
the 403, then it's a CSRF problem.

_Nik

On 10/24/2012 6:31 AM, Stone wrote:
> My Django application is running on real server (apache2-2.2.22).
> In urls.py is mentioned:
> (r'^configSave/$', configSave),
>
> My HTML is bellow. After pressing on configSave I am receiving HTTP
> 403 error page.
>
> In view.py is mentioned:
> def configSave(request):
>   configFile={}
>   if os.path.isfile(SSO_CONF) != False:
>   f = open(SSO_CONF,"r")
>   for line in f:
>   line = line.strip()
>   if re.search('^#',line) != None:
>   '''print 'This is the commentary'''
>   else:
>   '''print line'''
>   try:
>   name, value = line.split('=',2)
>   configFile[name]=value
>   print '<%s>%s' % (name, value, 
> name)
>   except ValueError, err:
>   ''' print 'This is empty row'''
>   configFile['SlaveDeactAppl']=configFile['SlaveDeactAppl'].split(',');
>   
> configFile['SlaveDeactScripts']=configFile['SlaveDeactScripts'].split(',');
>   configFile={}
>   if os.path.isfile(SSO_CONF) != False:
>   f = open(SSO_CONF,"r")
>   for line in f:
>   line = line.strip()
>   if re.search('^#',line) != None:
>   '''print 'This is the commentary'''
>   else:
>   '''print line'''
>   try:
>   name, value = line.split('=',2)
>   configFile[name]=value
>   print '<%s>%s' % (name, value, 
> name)
>   except ValueError, err:
>   ''' print 'This is empty row'''
>   configFile['SlaveDeactAppl']=configFile['SlaveDeactAppl'].split(',');
>   
> configFile['SlaveDeactScripts']=configFile['SlaveDeactScripts'].split(',');
>   c = {}
>   c = Context({
>   'config':configFile,
>   'item':2,
>   })
>   c.update(csrf(request))
>   return
> render_to_response('config.html',c,context_instance=RequestContext(request))
>
> By the way how to really fast define logging mechanism which can be
> use for debugging.
>
> Is this my programmer approach corrector is there any other way how to
> react on the pressing of button?
>
>  www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> {% extends "index.html" %}
> {% block content %}
> http://www.w3.org/1999/
> xhtml">
> 
>   top.helpID="SSO_config";
>   $(document).ready(function () {
>
>   function sendAjax()
>   {
>   $(document).ajaxSend(function(event, xhr, settings) {
>   function getCookie(name) {
>   var cookieValue = null;
>   if (document.cookie && document.cookie != '') {
>   var cookies = document.cookie.split(';');
>   for (var i = 0; i < cookies.length; i++) {
>   var cookie = jQuery.trim(cookies[i]);
>   if (cookie.substring(0, name.length + 1) == (name
> + '=')) {
>   cookieValue =
> decodeURIComponent(cookie.substring(name.length + 1));
>   break;
>   }
>   }
>   }
>   return cookieValue;
>   }
>   function sameOrigin(url) {
>   var host = document.location.host; // host + port
>   var protocol = document.location.protocol;
>   var sr_origin = '//' + host;
>   var origin = protocol + sr_origin;
>   // Allow absolute or scheme relative URLs to same origin
>   return (url == origin || url.slice(0, origin.length + 1)
> == origin + '/') ||
>   (url == sr_origin || url.slice(0, sr_origin.length +
> 1) == sr_origin + '/') ||
>   !(/^(\/\/|http:|https:).*/.test(url));
>   }
>   function safeMethod(method) {
>   return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
>   }
>   if (!safeMethod(settings.type) && sameOrigin(settings.url)) {
>   xhr.setRequestHeader("X-CSRFToken",
> getCookie('csrftoken'));
>   }
>   });
>   }
>
>   $("#saveCfg").click(function(event){
>
>   sendAjax();
> $.ajax({
>   type: "POST",
>   url: "/SSO/con

Re: Puzzled about WSGI vs. FastCGI

2012-10-24 Thread Nikolas Stevenson-Molnar
The easiest way would probably be to run Gunicorn (http://gunicorn.org/)
or some other WSGI HTTP server, and then configure lighttpd as a proxy,
e.g: https://gist.github.com/514252

_Nik

On 10/24/2012 8:58 AM, Fred wrote:
> Hello
>
> I'm trying to find how to install Python on a Lighttpd server that
> currently runs PHP scripts.
>
> This article
>  says:
>
> Although WSGI is the preferred deployment platform for Django,
> many people use shared hosting, on which protocols such as
> FastCGI, SCGI or AJP are the only viable options.
>
>
> I'm puzzled, because I seemed to understand that WSGI is an API that
> relies on a lower-level transport solution like FastCGI, SCGI, or AJP.
>
> Could it be that the article actually opposed mod_wsgi, which can run
> within Apache à la mod_php *?
>
> And if someone knows of a good way to run Python through FastCGI (with
> or without WSGI) on Lighttpd, I'm interested: "Python FastCGI on
> lighty with flup" at the very bottom
> 
> only seems to run a specific script.
>
> Thank you.
>
> * altough it can also run in its own process, just like FastCGI 
> -- 
> 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/-/5L_njBv3dUwJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Puzzled about WSGI vs. FastCGI

2012-10-24 Thread Fred
Hello

I'm trying to find how to install Python on a Lighttpd server that 
currently runs PHP scripts.

This 
articlesays:

> Although WSGI is the preferred deployment platform for Django, many people 
> use shared hosting, on which protocols such as FastCGI, SCGI or AJP are the 
> only viable options.


I'm puzzled, because I seemed to understand that WSGI is an API that relies 
on a lower-level transport solution like FastCGI, SCGI, or AJP.

Could it be that the article actually opposed mod_wsgi, which can run 
within Apache à la mod_php *?

And if someone knows of a good way to run Python through FastCGI (with or 
without WSGI) on Lighttpd, I'm interested: "Python FastCGI on lighty with 
flup" at the very 
bottomonly
 seems to run a specific script.

Thank you.

* altough it can also run in its own process, just like FastCGI 

-- 
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/-/5L_njBv3dUwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread John DeRosa
Nope, I didn't find a solution. I moved on to another issue and never got back 
to this. We just learned to work around this, I'm semi-ashamed to say.

John

On Oct 23, 2012, at 2:29 PM, Alphydan  wrote:

> I have the same problem (on ubuntu, python 2.7, django 1.4, 
> django-picklefield 0.2.1) ... does anybody have any insight?
> John, did you find a solution?
> 
> Thank you. 
> 
> On Thursday, 8 April 2010 19:30:20 UTC+1, John DeRosa wrote:
> Hello Djangonauts,
> 
> I'm doing something wrong, but I just can't see it!
> 
> My problem is that a custom model field isn't being displayed in the Admin 
> interface.
> 
> I'm running OS X 10.6.3, Python 2.6, and Django 1.1.1. I installed 
> django-picklefield 0.1.5 from PyPi, and I'm trying to use it in a database 
> model. I defined a couple of custom PickledObjectField fields. They show up 
> in the Admin model docs as being of type "Text", but they *don't* show up in 
> the Admin when I add or change a row.
> 
> Here's what I'm doing. What am I doing wrong?
> 
> John
> 
> --
> 
> In models.py:
> 
> from picklefield.fields import PickledObjectField
> 
> class LayoutTemplate(models.Model):
> [snip]
> attachment_points = PickledObjectField(help_text="A list of 
> TemplateAttachmentPoints")
> placed_objects = PickledObjectField(blank=True,
> help_text="A list of objects placed 
> on this template")
> # These LayoutObjects are allowed on this template.
> allowed_objects = PickledObjectField(help_text="A list of allowed 
> objects.")
> 
> def __unicode__(self):
> return u"%s" % self.name
> 
> 
> In admin.py:
> 
> from hosted.models import LayoutTemplate
> from django.contrib import admin
> admin.site.register(LayoutTemplate)
> 
> 
> 
> 
> -- 
> 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/-/QHA-yQ1spEIJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: implement of view

2012-10-24 Thread Tomas Neme
>> Thank you for your answer. i have chapter 1-4 of
>> http://www.djangobook.com/en/2.0/index.html done, but not much time to go
>> throught the hole book atm. i will try it with your code. :)

the django book is somewhat outdated, and long.

https://docs.djangoproject.com/en/dev/intro/tutorial01/

do that tutorial, it's quite short, you can get through it in a couple of hours.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: implement of view

2012-10-24 Thread Markus Christen

>
> Thank you for your answer. i have chapter 1-4 of 
> http://www.djangobook.com/en/2.0/index.html done, but not much time to go 
> throught the hole book atm. i will try it with your code. :)
>

-- 
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/-/OhKq_pl-TqkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: implement of view

2012-10-24 Thread Tomas Neme
>
> how can i implements now these "def sql(request):" into my html code? pls
> help me...
>

you're saying next to nothing, but I *guess* you could do something like

return render_to_response("sql.html", { 'row': row })

at the bottom of your sql view, and write an sql.html template that
shows it the way you want...

Also, you'll better go on and learn that pyodbc library and how to
pass parameters into your queries, which will protect you against SQL
injection attacks.. and you should probably learn SOME python if
you're going to be coding in it.

And you shuold *really* at least run through the django tutorial at
least once, in order to get a grip on some of the basic django
concepts, like forms and models, which will help you a lot

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: implement of view

2012-10-24 Thread Markus Christen

>
> I forgot, sql is now hardcodet and i have to change it. on first page i 
> have to give the filter and the username...
>

-- 
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/-/aq_OCQt8vxkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



implement of view

2012-10-24 Thread Markus Christen
Hi all
i have there a little problem and my knowhow with django is not existent. ^^
What i have...
--- urls.py -
from django.conf.urls import patterns, include, url
from klasse.views import portal, sql
urlpatterns = patterns('',
 (r'^portal/$', portal),
 (r'^sql/$', sql),
)
-
 views.py 
from django.shortcuts import render_to_response
import datetime
def portal(request):
now = datetime.datetime.now()
return render_to_response('portal.html', {'current_date': now})
 
def sql(request):
 cnxn = pyodbc.connect('DRIVER={SQL 
Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=***')
 cursor = cnxn.cursor()
 cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, 
tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = '***')")
 row = cursor.fetchall()
 return HttpResponse(row)
---
 
The Settings are correct... The output of sql works
 
- portal.html 

{% extends "base.html" %}
{% block title %}Kundendaten{% endblock %}
{% block content %}Zeit der Aktualisierung {{ current_date }}.{% 
endblock %}
-
 
--- base.html 
---
{% include "header.html" %}
{% block title %}{% endblock %}


Portal
 Ausgabe Kundendaten
{% block content %}{% endblock %}
{% include "footer.html" %}
-
 
how can i implements now these "def sql(request):" into my html code? pls 
help 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/-/YtO3FCGz1UMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[Q: Basic] Strange behaviour after pressing on button

2012-10-24 Thread Stone
My Django application is running on real server (apache2-2.2.22).
In urls.py is mentioned:
(r'^configSave/$', configSave),

My HTML is bellow. After pressing on configSave I am receiving HTTP
403 error page.

In view.py is mentioned:
def configSave(request):
configFile={}
if os.path.isfile(SSO_CONF) != False:
f = open(SSO_CONF,"r")
for line in f:
line = line.strip()
if re.search('^#',line) != None:
'''print 'This is the commentary'''
else:
'''print line'''
try:
name, value = line.split('=',2)
configFile[name]=value
print '<%s>%s' % (name, value, 
name)
except ValueError, err:
''' print 'This is empty row'''
configFile['SlaveDeactAppl']=configFile['SlaveDeactAppl'].split(',');

configFile['SlaveDeactScripts']=configFile['SlaveDeactScripts'].split(',');
configFile={}
if os.path.isfile(SSO_CONF) != False:
f = open(SSO_CONF,"r")
for line in f:
line = line.strip()
if re.search('^#',line) != None:
'''print 'This is the commentary'''
else:
'''print line'''
try:
name, value = line.split('=',2)
configFile[name]=value
print '<%s>%s' % (name, value, 
name)
except ValueError, err:
''' print 'This is empty row'''
configFile['SlaveDeactAppl']=configFile['SlaveDeactAppl'].split(',');

configFile['SlaveDeactScripts']=configFile['SlaveDeactScripts'].split(',');
c = {}
c = Context({
'config':configFile,
'item':2,
})
c.update(csrf(request))
return
render_to_response('config.html',c,context_instance=RequestContext(request))

By the way how to really fast define logging mechanism which can be
use for debugging.

Is this my programmer approach corrector is there any other way how to
react on the pressing of button?


{% extends "index.html" %}
{% block content %}
http://www.w3.org/1999/
xhtml">

  top.helpID="SSO_config";
  $(document).ready(function () {

function sendAjax()
{
$(document).ajaxSend(function(event, xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name
+ '=')) {
cookieValue =
decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
function sameOrigin(url) {
var host = document.location.host; // host + port
var protocol = document.location.protocol;
var sr_origin = '//' + host;
var origin = protocol + sr_origin;
// Allow absolute or scheme relative URLs to same origin
return (url == origin || url.slice(0, origin.length + 1)
== origin + '/') ||
(url == sr_origin || url.slice(0, sr_origin.length +
1) == sr_origin + '/') ||
!(/^(\/\/|http:|https:).*/.test(url));
}
function safeMethod(method) {
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
if (!safeMethod(settings.type) && sameOrigin(settings.url)) {
xhr.setRequestHeader("X-CSRFToken",
getCookie('csrftoken'));
}
});
}

$("#saveCfg").click(function(event){

sendAjax();
$.ajax({
type: "POST",
url: "/SSO/configSave/",
dataType: "text",
success: function(data) {
alert(data);
},
error: function(xhr,ajaxOptions,thrownError) {
alert(xhr.status +" "+xhr.statusText);
alert(thrownError);
  

Re: Django setup with elsatic beanstalk

2012-10-24 Thread Stefano Tranquillini
thx.
later i try both yr suggestions. i haven;t been notified of the previous 
reply.
thx

On Wednesday, October 24, 2012 12:06:13 AM UTC+2, Andrzej Winnicki wrote:
>
> Try also to change settings in .elasticbeanstalk/optionsettings. 
>
>
> [aws:elasticbeanstalk:application:environment]
> DJANGO_SETTINGS_MODULE = 
> PARAM1 = 
> PARAM2 = 
> PARAM4 = 
> PARAM3 = 
> PARAM5 = 
>
> [aws:elasticbeanstalk:container:python]
> WSGIPath = application.py
> NumProcesses = 1
> StaticFiles = /static=
> NumThreads = 15
>
> [aws:elasticbeanstalk:container:python:staticfiles]
> /static = 
>
>
> Then type eb update and trick should work.
>
>
> On Friday, 12 October 2012 11:54:37 UTC+2, Stefano Tranquillini wrote:
>>
>> Mmm. seems that i missing something.
>>
>> this is the log
>>
>> 2012-10-12 09:36:51,352 [INFO] (24716 MainThread) 
>> [directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Output 
>> from script: 2012-10-12 09:36:51,331* ERRORThe specified WSGIPath of 
>> "application.py" was not found in the source bundle*
>>
>> 2012-10-12 09:36:51,353 [INFO] (24716 MainThread) 
>> [directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Script 
>> succeeded.
>> 2012-10-12 09:36:51,443 [INFO] (24641 MainThread) [command.py-126] [root 
>> command execute] Command returned: (code: 0, stdout: , stderr: None)
>> 2012-10-12 09:36:51,449 [INFO] (24641 MainThread) [command.py-118] [root 
>> command execute] Executing command: Infra-EmbeddedPostBuild - 
>> AWSEBAutoScalingGroup
>> 2012-10-12 09:36:52,621 [INFO] (24641 MainThread) [command.py-126] [root 
>> command execute] Command returned: (code: 1, stdout: Error occurred during 
>> build: Command 01_syncdb failed
>> , stderr: None)
>> 2012-10-12 09:36:52,623 [DEBUG] (24641 MainThread) [commandWrapper.py-60] 
>> [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': 
>> [{'status': 'SUCCESS', 'config_set': u'Hook-PreAppDeploy', 'events': 
>> [*{'msg': 
>> 'Your WSGIPath refers to a file that does not exist.', 'timestamp': 
>> 1350034611, 'severity': 'ERROR'}]*}, {'status': 'FAILURE', 'config_set': 
>> u'Infra-EmbeddedPostBuild', 'returncode': 1, 'events': [], 'msg': 'Error 
>> occurred during build: Command 01_syncdb failed\n'}], 'api_version': '1.0'}
>>
>> what's is this application.py (it's not mentioned in the tutorial) ? idea 
>> about the WSGIPath?
>>
>> this is the directory tree:
>>
>> .
>> |.ebextensions
>> | |config
>> |.elasticbeanstalk
>> | |config
>> | |optionsettings
>>  |manage.py
>> |mysites
>> | |.DS_Store
>> | |__init__.py
>> | |__init__.pyc
>> | |settings.py
>> | |settings.pyc
>> | |urls.py
>> | |urls.pyc
>> | |wsgi.py
>> | |wsgi.pyc
>> |requirements.txt
>>
>>
>>
>> two things. tutorial says that config file should be .config . it sounds 
>> strange. 
>> is it correct?
>> where the requirements.txt should be located?
>>
>>
>>
>> On Thu, Oct 11, 2012 at 6:47 PM, Stefano Tranquillini <
>> stefano.tr...@gmail.com> wrote:
>>
>>> same problem, did you solve it?
>>>
>>>
>>> On Monday, October 8, 2012 7:22:51 PM UTC+2, shlomi oberman wrote:

 I'm trying without succes to setup a simple application using django 
 with elastic beanstalk from my windows machine.
 Does anyone have any expreience with this? I am currently getting the 
 following error from the EB console: 
 "Your WSGIPath refers to a file that does not exist."

  -- 
>>> 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/-/WiWZ2EApeWUJ.
>>>
>>> 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.
>>>
>>
>>
>>
>> -- 
>> Stefano
>>  
>

-- 
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/-/CrszrQwUHzAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 data back to a table from template or send back to a view

2012-10-24 Thread Thomas Rega

Am 24.10.12 11:26, schrieb Coulson Thabo Kgathi:

i used django template language to access value from my models in the
database which are coordinates the using javascript i wrote a function
that give a list of coordinates that are within a polygon in a map.

now i want to send that list back to a view or view then database table



Hi,

like Stephen mentioned you can use a post request [1] for that.

The field 'data' could contain the list of coordinates in an array [2] 
with the name 'coords' which itself can be accessed within the view via 
request.POST['coords'].


One of many examples you can find here: 
http://stackoverflow.com/questions/5457568/retrieving-post-data-from-jquery-in-django-without-a-form


[1] http://api.jquery.com/jQuery.post/
[2] http://de.selfhtml.org/javascript/objekte/array.htm

Good luck,

TR



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/-/Xf7F_Q9554YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 Software Development - http://www.pyt3ch.com


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



Re: [ver. 1.5] Specifying custom User model (extends AbstractUser) doesn't work

2012-10-24 Thread Russell Keith-Magee
On Wed, Oct 24, 2012 at 5:51 PM, Stephen Anto wrote:

> Hi,
>
> You can extend Default Django User model without breaking its
> architecture. Just visit http://www.f2finterview.com/web/Django/21/ It
> will explain you in detail.


If you're going to give advice, it's probably a good idea to check that
your advice is current.

The approach that the original poster has suggested is in no way "breaking
the architecture" of Django - it's one of the new features in Django 1.5.

As a side effect of the changes introduced in 1.5, the API you've suggested
(AUTH_PROFILE_MODULE) has been deprecated. It will raise warnings if used
in Django 1.5 and 1.6, and be removed completely in Django 1.7.

Yours,
Russ Magee %-)

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



Re: [ver. 1.5] Specifying custom User model (extends AbstractUser) doesn't work

2012-10-24 Thread Stephen Anto
Hi,

You can extend Default Django User model without breaking its architecture.
Just visit http://www.f2finterview.com/web/Django/21/ It will explain you
in detail.

On Wed, Oct 24, 2012 at 9:32 AM, Surya Mukherjee wrote:

> Django's standard User class isn't sufficient for my needs so I am making
> my own User class. As per the User Authentication doc page, I am
> subclassing AbstractUser (not AbstractBaseUser) to add some new stuff.
>
> 
> from django.contrib.auth.models import AbstractUser
>
> class MyUser(AbstractUser):
> test = 'Hello world'
> 
>
> Pretty simple so far. In settings.py:
> 
> # Specifies SDBUser as the custom User class for Django to use
> AUTH_USER_MODEL = 'app.MyUser'
> 
>
> But when i try to syncdb, everything breaks:
>
> [root@Surya project]# manage syncdb
> CommandError: One or more models did not validate:
> app.userprofile: 'user' defines a relation with the model 'auth.User',
> which has been swapped out. Update the relation to point at
> settings.AUTH_USER_MODEL.
> auth.user: Model has been swapped out for 'app.SDBUser' which has not been
> installed or is abstract.
> django_openid_auth.useropenid: 'user' defines a relation with the model
> 'auth.User', which has been swapped out. Update the relation to point at
> settings.AUTH_USER_MODEL.
>
> django_openid_auth is a third party OpenID library, but the first two are
> pure Django and they're still breaking. Wat 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/-/fLbSAxq1RysJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards
Stephen S



Website: www.f2finterview.com
Blog:  blog.f2finterview.com
Tutorial:  tutorial.f2finterview.com
Group:www.charvigroups.com

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



Re: Send data back to a table from template or send back to a view

2012-10-24 Thread Coulson Thabo Kgathi
i used django template language to access value from my models in the 
database which are coordinates the using javascript i wrote a function that 
give a list of coordinates that are within a polygon in a map.

now i want to send that list back to a view or view then database table

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/-/Xf7F_Q9554YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 data back to a table from template or send back to a view

2012-10-24 Thread Coulson Thabo Kgathi
i had an array of coordinated tht i got from a dictionary via a view in 
views.py

now i used a javascript function in the template called index.html to find 
coordinates that are in a polygon

and i want to send the list of those coordinates back to the view so that i 
ca save them into a table.

views.py

# Import django modules
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.template.loader import render_to_string
from django.core.urlresolvers import reverse
from django.contrib.gis.geos import Point
from django.contrib.gis.gdal import DataSource
# Import system modules
import simplejson
import itertools
import tempfile
import os
import MySQLdb
# Import custom modules
from mochudimaps.locations.models import Location
from mochudimaps import settings


def index(request):
'Display map'
locations = Location.objects.order_by('name')
return render_to_response('locations/index.html', {
'locations': locations,
'content': render_to_string('locations/locations.html', 
{'locations': locations}),
}, context_instance=RequestContext(request))

-- 
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/-/odX6hK66IAsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Billing and invoicing app?

2012-10-24 Thread Stephen Anto
Hi,

Why can't you try it yourself, It is very easy only

On Wed, Oct 24, 2012 at 7:38 AM, Jesramz wrote:

> Quick question, is there a good billing and invoicing app, that anyone can
> point me to?
>
> Thanks all!
>
> --
> 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/-/cg8sQsl98K0J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards
Stephen S



Website: www.f2finterview.com
Blog:  blog.f2finterview.com
Tutorial:  tutorial.f2finterview.com
Group:www.charvigroups.com

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



Re: Send data back to a table from template or send back to a view

2012-10-24 Thread Stephen Anto
Hi,

Are you meant form submission? if Yes...

Submit your form and get all submitted values in view method using
request.POST/GET.copy()

Thank you for visiting http://www.f2finterview.com/web/Django/

On Wed, Oct 24, 2012 at 11:35 AM, Coulson Thabo Kgathi
wrote:

> Please help i have send a dictionary to a template now i want to send the
> processed data back to the database how do i do that in template language
> or javascript
>
> --
> 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/-/aSAzhnVceMQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards
Stephen S



Website: www.f2finterview.com
Blog:  blog.f2finterview.com
Tutorial:  tutorial.f2finterview.com
Group:www.charvigroups.com

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



Re: Send data back to a table from template or send back to a view

2012-10-24 Thread Daniel Roseman
On Wednesday, 24 October 2012 07:05:56 UTC+1, Coulson Thabo Kgathi wrote:

> Please help i have send a dictionary to a template now i want to send the 
> processed data back to the database how do i do that in template language 
> or javascript
>

Templates don't process data.

Do you mean to use a form?
--
DR. 

-- 
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/-/89w6MyhH_S4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.