Re: Django vs ExtJS

2015-06-08 Thread Jani Tiainen
Hi,

I've been working with relatively large (GIS) apps that do use ExtJS and Django.

What comes to ExtJS and it's "REST" that is pure joke. It's not even close what 
REST should be. There is even long standing thread on ExtJS forums about having 
better support for REST but I guess it's totally 2nd class citizen in ExtJS 
world. But we chose ExtJS because it's components, specially grids and trees 
are pretty much best you can get for the money.

And as ExtJS is purely Javascript framework it doesn't have anything to do with 
actually Django, which is server side Web framework, written with Python.

What comes to Django it's development speed. You can evaluate and iterate 
development much faster in Django than in Java (at least in my experience). 
With development server just change something, go browser and refresh. With 
django-rest-framework (the big gun for REST apis in Django) you can even 
develop rest services without having special frontend for that - drf provides 
nice html API tool that makes developing (and even testing) faster - while 
you're building and testing your API you can have your frontend devs to do that.

And that's where Django and Python excels. Also Django has rather extensive set 
of tools that are crafted to work with web and database. ORM, Admin (which is 
valuable tool while developing), basic user system, authentication and 
authorization, permissions, form handling and data validation, and much more.



On Mon, 29 Dec 2014 06:55:57 -0800 (PST)
Joris Benschop  wrote:

> Hi List,
> 
> I;m a data maangement specialist in a rather large multinational. I'm 
> trying to push Django as a fast development framework for front-end 
> applications of our databases. Currently the company is focusing on Sencha 
> ExtJS and java solutions. Can you help me with pointers why Django is 
> better? The free-as-in-beer argument is not very convincing by itself. 
> 
> Thanks
> Joris
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/53e17853-9922-4f77-bf9a-4cea7d35ade3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


-- 
Jani Tiainen

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


Re: Command line script > Ensure that its module, "models", is located inside an installed app. error

2015-06-08 Thread Oscar Buijten
Just to let you know that I got this snippet working now Gergely :-)
Thanks again for putting me on the right track.
What I didn't get though is why I need the " *args, **options". 
I read the doc but didn't grasp the why...
Cheers,
Oscar

--  snip  --
from django.core.management.base import BaseCommand, CommandError

class Command(BaseCommand):
def handle(self, *args, **options):
from data.models import MyichiTickers
tickers_for_exchange = MyichiTickers.objects.filter(exchange="AMS")
for tickerlist in tickers_for_exchange:
print(tickerlist.ticker)
--  snip  --


Le dimanche 7 juin 2015 14:26:39 UTC+2, Oscar Buijten a écrit :
>
> Hi There,
>
> For various reasons I recently started efforts to covert an existing .php 
> application to pyhton + django.
> There are quite a few scripts that are executed through cron and so from 
> the command line while coding.
>
> I did find some info on how to setup the start of the script, but keep 
> running into an error I haven't been able to resolve so far.
>
> Using Python 2.7.x and django 1.8.x + postresql
>
> Script is starting with this:
>
> --  snip  --
> import os,sys
> sys.path.append('/home/oscar/django/trading/myichimoku')
> os.environ['DJANGO_SETTINGS_MODULE']='myichimoku.settings'
> from models import MyichiTickers
> --  snip  --
>
> The script lives in /home/oscar/django/trading/myichimoku/data in which 
> the models.py lives as well
>
> The error I get:
>
> --  snip  --
> Traceback (most recent call last):
>   File "historic_data_collector.py", line 4, in 
> from models import MyichiTickers
>   File "/home/oscar/django/trading/myichimoku/data/models.py", line 4, in 
> 
> class AuthGroup(models.Model):
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
> line 131, in __new__
> 'app.' % (new_class.__name__, model_module.__name__)
> django.core.exceptions.ImproperlyConfigured: Unable to detect the app 
> label for model "AuthGroup." Ensure that its module, "models", is located 
> inside an installed app.
> --  snip  --
>
> AuthGroup is the 1st table class in models.py
>
> My settings.py lives in: /home/oscar/django/trading/myichimoku/myichimoku/
>
> Here a snippet from the file:
> --  snip  --
> # Application definition
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'data',
> )
> --  snip  --
>
>
> So the question is: how can I ensure to execute this script from the 
> command line with something like: python mycoolscript.py ?
>
> Any help greatly appreciated.
>
> Thanks!
> Oscar
>

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


Re: Command line script > Ensure that its module, "models", is located inside an installed app. error

2015-06-08 Thread felix

El 08/06/15 08:23, Oscar Buijten escribió:

Just to let you know that I got this snippet working now Gergely :-)
Thanks again for putting me on the right track.
What I didn't get though is why I need the " *args, **options".
I read the doc but didn't grasp the why...
Cheers,
Oscar

I'm a newbie. I guess that *args, **options will keep your script 
working no matter how many positional or keyword arguments your command 
or the base command may have in the future.


Cheers,
Felix.

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


Re: Command line script > Ensure that its module, "models", is located inside an installed app. error

2015-06-08 Thread Gergely Polonkai
Hello,

This SO answer[1] will provide you with decent answer on what this *args
and **kwargs things are. Hope that helps!

Best,
Gergely

[1] http://stackoverflow.com/a/3394898

2015-06-08 15:03 GMT+02:00 felix :

>  El 08/06/15 08:23, Oscar Buijten escribió:
>
>  Just to let you know that I got this snippet working now Gergely :-)
> Thanks again for putting me on the right track.
> What I didn't get though is why I need the " *args, **options".
> I read the doc but didn't grasp the why...
> Cheers,
> Oscar
>
>  I'm a newbie. I guess that *args, **options will keep your script
> working no matter how many positional or keyword arguments your command or
> the base command may have in the future.
>
> Cheers,
> Felix.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/557592A0.1060202%40epepm.cupet.cu
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


How to check if the client's browser supports cookies in Django?

2015-06-08 Thread akshat
I am making an app which uses User authentication to give access to various 
pages on the website. I want to use session management for this. But first 
I need to check if the cookie support is provided by the client's browser. 
Some conditions which I want to check are - 

1) If the user visits my site first time on the log in page and if the 
cookie is not supported then the user should not be allowed to login with a 
message that you should enable cookie support fiirst (Just like Facebook 
does).

2) User is navigating my site and in between he disables cookie 
support.Then what should be my course of actions? Should the user be logged 
out and if not then how to handle it?

Thanks

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


Re: How to check if the client's browser supports cookies in Django?

2015-06-08 Thread Larry Martell
On Mon, Jun 8, 2015 at 10:36 AM, akshat  wrote:
> I am making an app which uses User authentication to give access to various
> pages on the website. I want to use session management for this. But first I
> need to check if the cookie support is provided by the client's browser.
> Some conditions which I want to check are -
>
> 1) If the user visits my site first time on the log in page and if the
> cookie is not supported then the user should not be allowed to login with a
> message that you should enable cookie support fiirst (Just like Facebook
> does).
>
> 2) User is navigating my site and in between he disables cookie support.Then
> what should be my course of actions? Should the user be logged out and if
> not then how to handle it?

https://docs.djangoproject.com/en/1.8/topics/http/sessions/#setting-test-cookies

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


Re: How to check if the client's browser supports cookies in Django?

2015-06-08 Thread akshat
But this requires two separate views right? How does facebook know on the 
first attempt that cookie support is not enabled in my browser?

On Monday, June 8, 2015 at 8:09:26 PM UTC+5:30, larry@gmail.com wrote:
>
> On Mon, Jun 8, 2015 at 10:36 AM, akshat  > wrote: 
> > I am making an app which uses User authentication to give access to 
> various 
> > pages on the website. I want to use session management for this. But 
> first I 
> > need to check if the cookie support is provided by the client's browser. 
> > Some conditions which I want to check are - 
> > 
> > 1) If the user visits my site first time on the log in page and if the 
> > cookie is not supported then the user should not be allowed to login 
> with a 
> > message that you should enable cookie support fiirst (Just like Facebook 
> > does). 
> > 
> > 2) User is navigating my site and in between he disables cookie 
> support.Then 
> > what should be my course of actions? Should the user be logged out and 
> if 
> > not then how to handle it? 
>
>
> https://docs.djangoproject.com/en/1.8/topics/http/sessions/#setting-test-cookies
>  
>

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


Django-Moderation

2015-06-08 Thread Aman Jhunjhunwala
Hi everyone, 
I am a inexperienced Django user and I am making a blog application, where 
users can save a blog in draft stages and then on publishing it ,the post 
gets added to a moderation queue. I have used "Django-Moderation" package 
to implement the same. In my models, I have a multiple choice field which 
shifts from "Draft" to "Submitted" on submission. I am trying to add the 
post to the moderation queue only when its state is "Submitted" .
I have simply registered the models with Django-Moderation. The problem is 
that on every save of the article ,it is being added to the moderation 
queue (As it should be,but I want it to be added only when its state is 
moderated) I would be extremely grateful if anyone could help me with a 
workaround?
 
Thank You,
Aman

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


Re: How to check if the client's browser supports cookies in Django?

2015-06-08 Thread Tom Evans
On Mon, Jun 8, 2015 at 3:42 PM, akshat  wrote:
> But this requires two separate views right? How does facebook know on the
> first attempt that cookie support is not enabled in my browser?

It doesn't, it sets a cookie and redirects you to another URL to see
if the cookie is present. You can see this if you inspect the web
traffic to/from your browser using any one of a number of tools, eg
chrome inspector.

"A view" and "a webpage displayed to a user" are not necessarily the
same thing, a view can simply be a piece of code that does something
and redirects the user without displaying a webpage to the user.

Typically, you would not implement this as one view, let alone two -
you would use middleware to set the cookie and redirect, the same
middleware then intercepts the next request and, if they have cookie
support, allow them to access the requested resource, or display a
page indicating that they need cookie support if they do not.

Cheers

Tom

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


Re: Django vs ExtJS

2015-06-08 Thread Antonio Saponara
ExtJS is a REST *client* wich uses  basic CRUD calls to obtain great 
results with *few lines of code*!

It supports CRUD, pagination, sorting and filtering out of the box! Please 
respect also the 2nd class citizen :-|

Django-rest-framework of course is  server-side so it is incomparable! It 
does a lot of things exactly like many other frameworks. The real point is 
that you, as a programmer appreciate django for features, reliability, and 
many other aspects, but your customers needs to see other things like 
available developers, competitors, references etc etc

I'd love to see django do the same thing i have done with my Zend proxy. 
Manage a table's crud created in realtime with zero added code!

I mean, you configure the db connection, and every REST calls will manage 
EVERY table in selected db via CRUD calls, automatically. 
Without configuring table, keys, fields and so on.

This can be a great way to  scaffold a prototype really fast!

Once you are at an advanced stage, you can simply change the REST pointers 
to a more advanced rest-server ;-)



Il giorno lunedì 8 giugno 2015 13:23:18 UTC+2, Jani Tiainen ha scritto:
>
> Hi, 
>
> I've been working with relatively large (GIS) apps that do use ExtJS and 
> Django. 
>
> What comes to ExtJS and it's "REST" that is pure joke. It's not even close 
> what REST should be. There is even long standing thread on ExtJS forums 
> about having better support for REST but I guess it's totally 2nd class 
> citizen in ExtJS world. But we chose ExtJS because it's components, 
> specially grids and trees are pretty much best you can get for the money. 
>
> And as ExtJS is purely Javascript framework it doesn't have anything to do 
> with actually Django, which is server side Web framework, written with 
> Python. 
>
> What comes to Django it's development speed. You can evaluate and iterate 
> development much faster in Django than in Java (at least in my experience). 
> With development server just change something, go browser and refresh. With 
> django-rest-framework (the big gun for REST apis in Django) you can even 
> develop rest services without having special frontend for that - drf 
> provides nice html API tool that makes developing (and even testing) faster 
> - while you're building and testing your API you can have your frontend 
> devs to do that. 
>
> And that's where Django and Python excels. Also Django has rather 
> extensive set of tools that are crafted to work with web and database. ORM, 
> Admin (which is valuable tool while developing), basic user system, 
> authentication and authorization, permissions, form handling and data 
> validation, and much more. 
>
>
>
> On Mon, 29 Dec 2014 06:55:57 -0800 (PST) 
> Joris Benschop > wrote: 
>
> > Hi List, 
> > 
> > I;m a data maangement specialist in a rather large multinational. I'm 
> > trying to push Django as a fast development framework for front-end 
> > applications of our databases. Currently the company is focusing on 
> Sencha 
> > ExtJS and java solutions. Can you help me with pointers why Django is 
> > better? The free-as-in-beer argument is not very convincing by itself. 
> > 
> > Thanks 
> > Joris 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/53e17853-9922-4f77-bf9a-4cea7d35ade3%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
> -- 
> Jani Tiainen 
>

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


What are some 3rd party good django applications which handle user registration,login and authentication?

2015-06-08 Thread akshat
I know some applications and have also used them but I want to know what 
other django users use and love?

Thanks

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


Re: What are some 3rd party good django applications which handle user registration,login and authentication?

2015-06-08 Thread Marcos Lewis
For registration I like to use django-registration-redux.

https://django-registration-redux.readthedocs.org/en/latest/

El lunes, 8 de junio de 2015, 15:55:36 (UTC-3), akshat escribió:
>
> I know some applications and have also used them but I want to know what 
> other django users use and love?
>
> Thanks
>

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


push yahoo finance json data into database

2015-06-08 Thread Oscar Buijten
Hi there,
The python learning curve seems to be steeper than expected :-(
As yesterday, help converting my php app into python/django will be 
appreciated.

I have the following:

  snip  ---
from django.core.management.base import BaseCommand, CommandError
import json
from collections import OrderedDict
from yahoo_finance import Share 
from data.models import MyichiTickers, MyichiHistoricalData

exchange  = 'AMS'
startdate = '2014-04-25'
enddate   = '2014-04-29'
minimum_avg_daily_volume = '10'

class Command(BaseCommand):
def handle(self, *args, **options):
from yahoo_finance import Share 
from data.models import MyichiTickers
tickers_for_exchange = MyichiTickers.objects.filter(exchange=exchange)[:2]
if tickers_for_exchange:
for tickerlist in tickers_for_exchange:
ticker = Share(tickerlist.ticker) 
if ticker.get_avg_daily_volume() > minimum_avg_daily_volume:
data = json.dumps(ticker.get_historical(startdate, enddate))
data = json.loads(data)
print data

  snip  ---

It may not be perfect, but it works.
I would need to get 'data' into the 'MyichiHistoricalData' model

The output is like this;
  snip  ---
[{u'High': u'6.565', u'Symbol': u'AGN.AS', u'Adj_Close': u'6.31564', 
u'Volume': u'4376000', u'Low': u'6.428', u'Date': u'2014-04-29', u'Close': 
u'6.551', u'Open': u'6.435'}, {u'High': u'6.479', u'Symbol': u'AGN.AS', 
u'Adj_Close': u'6.18742', u'Volume': u'3163200', u'Low': u'6.38', u'Date': 
u'2014-04-28', u'Close': u'6.418', u'Open': u'6.428'}, {u'High': u'6.535', 
u'Symbol': u'AGN.AS', u'Adj_Close': u'6.18259', u'Volume': u'4780100', 
u'Low': u'6.379', u'Date': u'2014-04-25', u'Close': u'6.413', u'Open': 
u'6.529'}]
[{u'High': u'13.94', u'Symbol': u'AH.AS', u'Adj_Close': u'13.57496', 
u'Volume': u'2706600', u'Low': u'13.70', u'Date': u'2014-04-29', u'Close': 
u'13.92', u'Open': u'13.70'}, {u'High': u'13.735', u'Symbol': u'AH.AS', 
u'Adj_Close': u'13.34091', u'Volume': u'2784700', u'Low': u'13.56', 
u'Date': u'2014-04-28', u'Close': u'13.68', u'Open': u'13.565'}, {u'High': 
u'13.675', u'Symbol': u'AH.AS', u'Adj_Close': u'13.23364', u'Volume': 
u'3012500', u'Low': u'13.44', u'Date': u'2014-04-25', u'Close': u'13.57', 
u'Open': u'13.545'}]
  snip  ---

Where I need help it so extract the keys and values and give them the 
correct model field names in order to save them.

It should be easy really, bt several hours of readin, searching, trial & 
error haven't given me the trick yet

Any suggestions?

Thanks!

Oscar

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


display fields of form within another form

2015-06-08 Thread marcelle Kouam
hello
I have a problem.
I have an application user and another employee. i want to display all the 
fields of user in my employee forms. now, I just redisplay my form user in 
my form employee like that in my template:

{{ form_1.as_p }}
{{ form.as_p }}

this is my view employee:


def add(request, template_name='employee/add.html'):
if request.method == 'POST':
form = EmployeeAddForm(data=request.POST)
form_1 = UserRegisterForm(data = request.POST)
if form.is_valid() and form_1.is_valid():
user = form_1.save()
employee = form.save(commit=False)
employee.user = user
user.set_password(user.password)
user.save()
employee.save()
   
else:
print(form.errors)
else:
form = EmployeeAddForm()
form_1 = UserRegisterForm()
return render(request, template_name, {'form': form, 'form_1' : form_1, 
'added': added})

but I think that it'is not the best method. can you give me another method 
which will be more intelligent.
thanks

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


Re: push yahoo finance json data into database

2015-06-08 Thread James Schneider
On Mon, Jun 8, 2015 at 1:09 PM, Oscar Buijten  wrote:
>
> Hi there,
> The python learning curve seems to be steeper than expected :-(
> As yesterday, help converting my php app into python/django will be 
> appreciated.
>
> I have the following:
>
>   snip  ---

What does your MyichiHistoricalData model look like? That will be the
primary driver on how you extract the values into the right model
attributes.

If your (required) model fields exactly match the ones provided by
your JSON data, creating/updating the models is probably something as
simple as what is shown in this SO post:

http://stackoverflow.com/a/11487626

If this is a command that will update existing records in addition to
creating them (if this command runs at regular intervals), you may
also want to use update_or_create as opposed to the .update()
mentioned in the SO post.

https://docs.djangoproject.com/en/dev/ref/models/querysets/#update-or-create

Or if you are always going to create new objects based on the incoming
data, look into using bulk_create:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#bulk-create

That will save queries and processing time, but be sure to read the caveats.


> I would need to get 'data' into the 'MyichiHistoricalData' model
>
> The output is like this;
>   snip  ---
> [{u'High': u'6.565', u'Symbol': u'AGN.AS', u'Adj_Close': u'6.31564', 
> u'Volume': u'4376000', u'Low': u'6.428', u'Date': u'2014-04-29', u'Close': 
> u'6.551', u'Open': u'6.435'}, {u'High': u'6.479', u'Symbol': u'AGN.AS', 
> u'Adj_Close': u'6.18742', u'Volume': u'3163200', u'Low': u'6.38', u'Date': 
> u'2014-04-28', u'Close': u'6.418', u'Open': u'6.428'}, {u'High': u'6.535', 
> u'Symbol': u'AGN.AS', u'Adj_Close': u'6.18259', u'Volume': u'4780100', 
> u'Low': u'6.379', u'Date': u'2014-04-25', u'Close': u'6.413', u'Open': 
> u'6.529'}]
> [{u'High': u'13.94', u'Symbol': u'AH.AS', u'Adj_Close': u'13.57496', 
> u'Volume': u'2706600', u'Low': u'13.70', u'Date': u'2014-04-29', u'Close': 
> u'13.92', u'Open': u'13.70'}, {u'High': u'13.735', u'Symbol': u'AH.AS', 
> u'Adj_Close': u'13.34091', u'Volume': u'2784700', u'Low': u'13.56', u'Date': 
> u'2014-04-28', u'Close': u'13.68', u'Open': u'13.565'}, {u'High': u'13.675', 
> u'Symbol': u'AH.AS', u'Adj_Close': u'13.23364', u'Volume': u'3012500', 
> u'Low': u'13.44', u'Date': u'2014-04-25', u'Close': u'13.57', u'Open': 
> u'13.545'}]
>   snip  ---
>
> Where I need help it so extract the keys and values and give them the correct 
> model field names in order to save them.
>
> It should be easy really, bt several hours of readin, searching, trial & 
> error haven't given me the trick yet
>
> Any suggestions?


You may also want to have a look at the Django deserialization docs:
https://docs.djangoproject.com/en/dev/topics/serialization/#deserializing-data
I'm not sure if they'll help since you are working with an external
data source.

Assuming that the 'Symbol' will be used as a natural key:
https://docs.djangoproject.com/en/dev/topics/serialization/#deserialization-of-natural-keys


Another note: If you haven't already and before you go any further, be
sure to check with your legal team and with Yahoo!'s terms and
conditions on the use of Yahoo!'s finance data for your own
application. You may not be permitted to use their data in this manner
without some sort of agreement with Yahoo! and/or it's subsidiaries,
even though it is "freely" available through an API.

-James
(Not a lawyer)

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


Django rest framework and endpoints to use

2015-06-08 Thread Shekar Tippur
Hello,

I am trying to use OAuthSwift to get authenticated to my app running using 
rest framework.

I am following instruction from 
https://django-oauth-toolkit.readthedocs.org/en/0.3.2/tutorial/rest_framework_integration.html
.

Can you please indicate what URL I should be using to get myself validated. 
The api takes authorizeUrl, accessTokenUrl, and callback url 

  func doOAuthScreener(){

let oauthswift = OAuth2Swift(

//
https://django-oauth-toolkit.readthedocs.org/en/latest/rest-framework/getting_started.html

consumerKey:Screener["consumerKey"]!,

consumerSecret: Screener["consumerSecret"]!,

authorizeUrl:   *HERE*, 

accessTokenUrl: *HERE*, // This seem to be 
http://localhost:8000/o/token/

responseType:   "code"

)





let state: String = generateStateWithLength(20) as String





oauthswift.authorizeWithCallbackURL( NSURL(string: "*HERE*")!, 
scope: "user,repo", state: state, success: {

credential, response, parameters in

self.showAlertView("Screener", 
message: "oauth_token:\(credential.oauth_token)")

}, failure: {(error:NSError!) -> Void in

println(error.localizedDescription)

})


}


Thanks,

Shekar

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


Re: Django vs ExtJS

2015-06-08 Thread Jani Tiainen
On Mon, 8 Jun 2015 10:12:17 -0700 (PDT)
Antonio Saponara  wrote:

> ExtJS is a REST *client* wich uses  basic CRUD calls to obtain great 
> results with *few lines of code*!

That is true.
 
> It supports CRUD, pagination, sorting and filtering out of the box! Please 
> respect also the 2nd class citizen :-|

Sure, thing is that there is no support for HATEOAS, unless you code it your 
self so it makes working with anything more than simple data real painful. With 
ExtJS you have to know out of band information or like we did, wrote custom 
stuff to make things work better way. Begin fighting with ExtJS last 6 I've get 
used to take nothing as granted.

And what's painful is that ExtJS can't save relations (at least version 4.x). 
Unless you enhance saving functionality to do that.
 
> Django-rest-framework of course is  server-side so it is incomparable! It 
> does a lot of things exactly like many other frameworks. The real point is 
> that you, as a programmer appreciate django for features, reliability, and 
> many other aspects, but your customers needs to see other things like 
> available developers, competitors, references etc etc
> 
> I'd love to see django do the same thing i have done with my Zend proxy. 
> Manage a table's crud created in realtime with zero added code!

Well with Django admin you get all that. Plus nice way to view and edit your 
data. With a bit of additional definitions (coding iow) in admin parts you get 
even pretty good system to manage data, specially while you're developing.

> I mean, you configure the db connection, and every REST calls will manage 
> EVERY table in selected db via CRUD calls, automatically. 
> Without configuring table, keys, fields and so on.
> 
> This can be a great way to  scaffold a prototype really fast!
> 
> Once you are at an advanced stage, you can simply change the REST pointers 
> to a more advanced rest-server ;-)

Well DRF can do that, it requires a bit of code, but not hundreds of rows. See 
DRF generic views in the docs.

With a bit of coding you get all the goodies like nested (de)serialization 
(which ExtJS REST doesn't even support for writing OOTB)

But development speed was one of the big reasons why we chose Django (drf 
didn't existed though back then) and lately been adopting DRF.

And we, as our customers have been really happy with the choise. It's cheaper 
for our customers, and cheaper for us to develop.

One problem, as you noted as well, is to hire Python and Django pros.

-- 
Jani Tiainen

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