Re: Add model item with AJAX pop up

2016-02-08 Thread pa xapy
hi
easiest way is to write separate view which will handle ajax requests (get 
and post) and render html (as a json field) and success status as response.
on frontend you will handle this response to show modal with form and 
submit it until model will successfully saved
once it happens, you can refetch your users list in select field

but I don't know any application which implement all this stack. I think 
you should handle this modal by yourself

On Saturday, February 6, 2016 at 4:12:48 PM UTC+3, guettli wrote:
>
> I use django-select2  for 
> easy ForeignKey picking. Works nice.
>
>
> But how can I add a new item in the ForeignKey table?
>
>
> I would like to have a big [+] button near the select2 field and then a 
> (ajax) modal dialog should open (like in the admin interface).
>
>
> AFAIK django-select2 does not help here. Is there a different library 
> which can help here?
>
>
> I would like to re-use and not to re-invent. Maybe I was blind, but I 
> could not
>
> find a matching comparison grid on djangopackages.com.
>
>
> I would like to avoid a "old-school" browser-window-pop-up :-)
>
>
> Regards,
>
>   Thomas Güttler
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2e4db59a-48b2-4108-a576-3e443df8cd14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to show python data on html

2016-02-08 Thread Omar Abou Mrad
On Sun, Feb 7, 2016 at 11:15 AM, 123asror  wrote:

> So currently i have a python console application that reads from an api
> and print some data i want. I followed the django course and they use
> models/database in it. The data that they show comes from that. So i was
> wondering how to add a html page to my console application or python code.
> Is there a tutorial i can follow for that ?
>

- Do you just want to save the data you're receiving in an HTML file?

If so, you're better off just using a template library (jinja or other),
there's no need for an entire framework to do this.

- Do you want to serve the data so that it's accessible through a browser?

If so, then yes you could use django for this purpose. Django isn't limited
to fetching data from the database, it's primary job is to enable you to
serve content. You have content, you want to deliver this content, django
is for you.

- Is your console application short running? Does it do it's job, print the
content and then exit?

If so, you can just invoke the application from within a django view.
However, if the operation isn't very fast, you may want to reach out to a
task queue, but you really should worry about this in due time.

- Is your console application long running? Does it fetch data constantly?

Then you'll need to decide on how to make content available for your django
application to serve. One of the ways you could do this is have your
application send the data to a medium and have django read from that
medium. Possibly store in files, in the database, in a queue or some other
place, then django could read from there.

- Do you plan on delivering the content in realtime as you receive it?

If so, I'd suggest placing this as a different phase of implementation, but
some keywords for you to look for if you ever get to that point: javascript
polling, websockets, tornado, gevent, socket.io...

-

Good luck.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFwtXp218gZduKLw4GQM5CnTYK5385Kg%3DvygPo5dC7TvG%2BCDSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Implement page view count without using database for Hit

2016-02-08 Thread James Schneider
On Feb 7, 2016 7:03 PM, "sonu kumar"  wrote:
>
> Hi all,
> We have develop a site where we need to maintain page view count like SO,
Quora,YouTube etc. Current approach is based on  number of retrieval using
view this leads to problem to user that they are seeing that when a page is
reloaded then count get's incremented see here
http://www.job360.io/question-answer/cse/how-to-add-two-large-numbers.
>
> How to tackle this problem, is there any exist which can do the work
without managing database ?
>

I'm a bit confused as to why you would be averse to managing a database,
assuming that you have an existing database for your users and other
content.

If you don't want to manage the page hits yourself, you may look at
something like Google Analytics to track it for you.

As far as the refresh question, I haven't researched this in detail, but as
far as I'm aware, there is no standard method for requesting refreshes that
all browsers follow, and it is difficult to determine whether a request is
an initial content load request, or a refresh request without either the
browser signaling the server with some type of request header, or some
extensive tracking of requests with timers and other heuristics on the
server side, and then of course your code has to catch all of those
scenarios.

You're trying to merge the concept of a session with a request cycle.
Unfortunately, humans think of web access more in terms of sessions, where
the HTML, images, stylesheets, authentication, etc. are a single unit
carried through while a user browsers a site, but HTTP is built to use a
single content request cycle for each resource, independent of any other
content request cycle. There are many tricks involved to provide the
'human' experience, like storing/retrieving session data for each HTTP
request (which is why your web server process should provide images and
stylesheets directly, not Django, so that those tricks are not invoked).

There's no easy answer to your question. It's possible that Analytics our a
similar service will perform those database gymnastics for you in their
optimized environments to try and remove refreshes from your counts, but
you'd have to check with them.

You should also consider the guidelines for what you are counting as a
'hit' for your counter. Perhaps a refresh after 3 seconds shouldn't be
counted, but what about a refresh after 45 minutes? What if the same user
has multiple browsers open to the same site? What if robot crawlers access
your page? Maybe you can filter those out via the reported user agent, but
what if they spoof a real browser signature and request 10K hits? What if
you have an SPA that polls the server for updates data?

Honestly, unless analytics takes care of this for you, it probably is not
worth the extra effort of saving a couple dozen refresh requests. As your
page reaches up into tens of thousands of hits, they'll probably become
statistically insignificant anyway.

-James

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWRWGGjyBqMbtuApuRfO4Hr%3D9MNGQhcVNBSLWAqKL%3Dw6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django formtools wizard produces blank page (No error returned)

2016-02-08 Thread James Schneider
On Feb 7, 2016 11:46 AM, "Martín Torre Castro" <
martin.torre.cas...@gmail.com> wrote:
>
> James or anyone, the wizard doesn't load the main template for the
wizard, just the first step template form. Can you guess why?
>

The templates you included in your OP didn't have {% extends %} or {% block
%} tags in them. I asked about them and you mentioned those are the exact
templates you're using. Make sure your step templates have the correct
block references in them, otherwise your big parent template will never get
loaded. Each step of the form/view renders the entire page, not just the
section where the form is at.

-James

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXVwqfi%2BN62QsPZvUXRWyV0vg5%2BjhOe2Cp9WzCbXk%2BCoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polymorphic class and geomodels?

2016-02-08 Thread Sergiy Khohlov
Class Based Views has ability to include function in view from template.
 Short example:
 I have finished  small  (GTS) project  related  to  GPS system. Each car
has a array of points (car positions) and route (named as LineString in
GeoDjango).

 part of models.py


class Points(models.Model):
""" """
Car  = models.ForeignKey(Car)
Speed= models.IntegerField(default=0)
Time = models.DateTimeField()
Course   = models.IntegerField(default=0)
Altitude = models.IntegerField(default=0)
Sat  = models.IntegerField(default=1)
Point= gismodels.PointField()

 Points has connection to the Car  and has DateTime field used for correct
point sorting.
HTML page (Car) should contains array of related  object based on Car ID
and specific time range.
I add to views.py  (CarDetail class )next function:

def points(self):
""" """
timefmt= "%Y-%m-%d %H:%M:%S"
usertimezone= self.request.user.profile.timezone
try:
StartDateTime  =
usertimezone.localize(datetime.strptime(self.request.GET['StartDateTime'],
timefmt))
EndDateTime   =
usertimezone.localize(datetime.strptime(self.request.GET['EndDateTime'],
timefmt))
except:
StartDateTime  = datetime.combine(date.today(), time.min)
EndDateTime   = datetime.now()

context = super(CarDayReport, self).get_context_data()
return Points.objects.filter(Car_id=context['car'].id,
 Time__gt=StartDateTime,
 Time__lte=EndDateTime).order_by('Time')

  Time range is set via html template. Car ID is  also known.   Not hard
way to do.,



Many thanks,

Serge


+380 636150445
skype: skhohlov

On Sat, Feb 6, 2016 at 9:29 AM, Luca Moiana  wrote:

> Hi Serge,
>
> sorry for the expert warning you gave me on performance. But I have
> trouble following your really techincal suggestion, my goal is to have one
> table with measures that is related to three models with different
> geometries, so I can't use a foreign key in measure table, I don't
> understand the use of related obj, can you point me to a good source ?
>
> thanks
>
> On Friday, February 5, 2016 at 7:40:53 PM UTC+1, Sergiy Khohlov wrote:
>>
>> I’ve decided  to use  connection via key. and using via  key directly or
>>  via related objects.  Such us Car  -> Point  (multiline). Reason is simple
>> : django creates not perfect database structure  and I would like think
>> about performance as soon as possible.  My project contains Car and points
>> related to the car and of course route (POLYLINE).  I deceided to use
>> trivial PostGIS model for avoiding  bottleneck that use simple code in
>> view.  It is really easy to change view and hard to change models in case
>> of important data present. (Every 100km generates 2000 points which cause
>> and route length and motor service interval). In case of success Abstract
>> class (with good performance) let me know please.
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Fri, Feb 5, 2016 at 7:25 PM, Luca Moiana  wrote:
>>
>>> Hi Serge,
>>>
>>> thank you for your reply.
>>>
>>> I'm working on an environmental monitoring app, where I want to store,
>>> and serve, monitoring value on different geometries, points, tracks or
>>> polygon.
>>> That's why I'm trying to use a polymorphic model in order to have one
>>> entity and multiple geometries.
>>>
>>> Cheers
>>>
>>> L
>>>
>>>
>>> On Friday, February 5, 2016 at 10:51:31 AM UTC+1, Sergiy Khohlov wrote:

  I would like as simple question :  Are you planning  to have some
 advantages using this abstract class ?
  I’m working on  similar product  (look like you are making energy
 pipeline system based on postgis and gjango). My product is GTS system
 which includes POINTS (datas are received via GTS devices mounted on
 vehicles). Polylines (car route for selected time range),  etc.  Producing
 abstract class can decrease DB productivity. Which one functional do you
 need in case of abstract class for different types usage ?

 Many thanks,

 Serge


 +380 636150445
 skype: skhohlov

 On Fri, Feb 5, 2016 at 11:07 AM, Luca Moiana 
 wrote:

> Hi Collin,
>
> Sorry for the late reply, but I still don't get the google groups;
>
> Yes, I am tryng to crete a models where you can choose between the
> three geometry types.
>
> I'll go back to my app and test the code you suggested and post again
> the error.
>
> thanks
>
>
> On Wednesday, October 28, 2015 at 7:00:26 PM UTC+1, Collin Anderson
> wrote:
>>
>> Hello,
>>
>> Are you trying to combine multiple models into one, like this?
>>
>> class PolyModel(pdmpunto, pdmtransetto, pdmarea):
>> pass
>>
>> You could also try asking on the geodjango list:
>> http://groups.google.com/

Re: Provide me Links to learn django framework on Linux

2016-02-08 Thread Ajay Sharma
Many Thanks To Rafael and Christian .

:) :)   I am studying the resources now. 


On Wednesday, February 3, 2016 at 7:46:30 PM UTC+5:30, Ajay Sharma wrote:
>
> Hi everyone on the Group. 
>
> I want resources and web links, where i can learn  Django Framework On 
> Linux platform as I 
>
> am using Ubuntu for the development. 
>
> Please help me . 
>
> thank you to every one in Advance. 
>
> From Ajay .  :) 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0b8aa632-1ecf-49b7-a381-6dea59919ea8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Implement page view count without using database for Hit

2016-02-08 Thread sonu kumar
Thanks James,
We have consider database and updated sites using django-visits. Building 
such a full proof system will take longer time.

Regars,
Sonu

On Monday, February 8, 2016 at 2:29:46 PM UTC+5:30, James Schneider wrote:
>
>
> On Feb 7, 2016 7:03 PM, "sonu kumar" > 
> wrote:
> >
> > Hi all,
> > We have develop a site where we need to maintain page view count like 
> SO, Quora,YouTube etc. Current approach is based on  number of retrieval 
> using view this leads to problem to user that they are seeing that when a 
> page is reloaded then count get's incremented see here 
> http://www.job360.io/question-answer/cse/how-to-add-two-large-numbers. 
> >
> > How to tackle this problem, is there any exist which can do the work 
> without managing database ?
> >
>
> I'm a bit confused as to why you would be averse to managing a database, 
> assuming that you have an existing database for your users and other 
> content.
>
> If you don't want to manage the page hits yourself, you may look at 
> something like Google Analytics to track it for you.
>
> As far as the refresh question, I haven't researched this in detail, but 
> as far as I'm aware, there is no standard method for requesting refreshes 
> that all browsers follow, and it is difficult to determine whether a 
> request is an initial content load request, or a refresh request without 
> either the browser signaling the server with some type of request header, 
> or some extensive tracking of requests with timers and other heuristics on 
> the server side, and then of course your code has to catch all of those 
> scenarios.
>
> You're trying to merge the concept of a session with a request cycle. 
> Unfortunately, humans think of web access more in terms of sessions, where 
> the HTML, images, stylesheets, authentication, etc. are a single unit 
> carried through while a user browsers a site, but HTTP is built to use a 
> single content request cycle for each resource, independent of any other 
> content request cycle. There are many tricks involved to provide the 
> 'human' experience, like storing/retrieving session data for each HTTP 
> request (which is why your web server process should provide images and 
> stylesheets directly, not Django, so that those tricks are not invoked).
>
> There's no easy answer to your question. It's possible that Analytics our 
> a similar service will perform those database gymnastics for you in their 
> optimized environments to try and remove refreshes from your counts, but 
> you'd have to check with them.
>
> You should also consider the guidelines for what you are counting as a 
> 'hit' for your counter. Perhaps a refresh after 3 seconds shouldn't be 
> counted, but what about a refresh after 45 minutes? What if the same user 
> has multiple browsers open to the same site? What if robot crawlers access 
> your page? Maybe you can filter those out via the reported user agent, but 
> what if they spoof a real browser signature and request 10K hits? What if 
> you have an SPA that polls the server for updates data?
>
> Honestly, unless analytics takes care of this for you, it probably is not 
> worth the extra effort of saving a couple dozen refresh requests. As your 
> page reaches up into tens of thousands of hits, they'll probably become 
> statistically insignificant anyway. 
>
> -James
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01c4807a-9506-42ad-8ab7-a62a73ea3640%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


After upgrading from 1.8.8 to 1.9.2 migration applies succesfully but ends with an error

2016-02-08 Thread Richard la Croix
I just upgraded from 1.8.8 to 1.9.2 and using Python version 3.4.3.

The included Django migrations (admin.0002_logentry_remove_auto_add and 
auth.0007_alter_validators_add_error_messages) applied succesfully.

The following migration of a model update failed with error:
   TypeError: can't multiply sequence by non-int of type 'tuple'

However, the migration actually went thru correctly and is inserted into 
the 'django_migrations' table.
When I execute 'migrate' again, it responds with 'No migrations to apply.' 
and then again error message:
   TypeError: can't multiply sequence by non-int of type 'tuple'

Anybody had a similar experience or has an idea?

regards,
Richard


Complete traceback:

(MyPyEnv) C:\PycharmProjects\resortinfo>python manage.py migrate
Operations to perform:
  Apply all migrations: resorts, sessions, hbase, auth, guardian, 
contenttypes, admin
Running migrations:
  No migrations to apply.
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "C:\MyPyEnv\lib\site-packages\django\core\management\__init__.py", 
line 353, in execute_from_command_line
utility.execute()
  File "C:\MyPyEnv\lib\site-packages\django\core\management\__init__.py", 
line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\MyPyEnv\lib\site-packages\django\core\management\base.py", line 
348, in run_from_argv
self.execute(*args, **cmd_options)
  File "C:\MyPyEnv\lib\site-packages\django\core\management\base.py", line 
399, in execute
output = self.handle(*args, **options)
  File 
"C:\MyPyEnv\lib\site-packages\django\core\management\commands\migrate.py", 
line 204, in handle
emit_post_migrate_signal(self.verbosity, self.interactive, 
connection.alias)
  File "C:\MyPyEnv\lib\site-packages\django\core\management\sql.py", line 
50, in emit_post_migrate_signal
using=db)
  File "C:\MyPyEnv\lib\site-packages\django\dispatch\dispatcher.py", line 
192, in send
response = receiver(signal=self, sender=sender, **named)
  File 
"C:\MyPyEnv\lib\site-packages\django\contrib\auth\management\__init__.py", 
line 126, in create_permissions
Permission.objects.using(using).bulk_create(perms)
  File "C:\MyPyEnv\lib\site-packages\django\db\models\query.py", line 450, 
in bulk_create
self._batched_insert(objs_without_pk, fields, batch_size)
  File "C:\MyPyEnv\lib\site-packages\django\db\models\query.py", line 1056, 
in _batched_insert
using=self.db)
  File "C:\MyPyEnv\lib\site-packages\django\db\models\manager.py", line 
122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\MyPyEnv\lib\site-packages\django\db\models\query.py", line 1039, 
in _insert
return query.get_compiler(using=using).execute_sql(return_id)
  File "C:\MyPyEnv\lib\site-packages\django\db\models\sql\compiler.py", 
line 1059, in execute_sql
for sql, params in self.as_sql():
  File "C:\MyPyEnv\lib\site-packages\django\db\models\sql\compiler.py", 
line 1047, in as_sql
result.append(self.connection.ops.bulk_insert_sql(fields, 
placeholder_rows))
  File "C:\MyPyEnv\lib\site-packages\mysql\connector\django\operations.py", 
line 223, in bulk_insert_sql
return "VALUES " + ", ".join([items_sql] * num_values)
TypeError: can't multiply sequence by non-int of type 'tuple'

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ba7646b8-b710-4d7d-844e-406ff8758be3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: After upgrading from 1.8.8 to 1.9.2 migration applies succesfully but ends with an error

2016-02-08 Thread Tim Graham
Last time I checked, mysql.connector hasn't issued a release that's 
compatible with Django 1.9.

On Monday, February 8, 2016 at 7:37:36 AM UTC-5, Richard la Croix wrote:
>
> I just upgraded from 1.8.8 to 1.9.2 and using Python version 3.4.3.
>
> The included Django migrations (admin.0002_logentry_remove_auto_add and 
> auth.0007_alter_validators_add_error_messages) applied succesfully.
>
> The following migration of a model update failed with error:
>TypeError: can't multiply sequence by non-int of type 'tuple'
>
> However, the migration actually went thru correctly and is inserted into 
> the 'django_migrations' table.
> When I execute 'migrate' again, it responds with 'No migrations to apply.' 
> and then again error message:
>TypeError: can't multiply sequence by non-int of type 'tuple'
>
> Anybody had a similar experience or has an idea?
>
> regards,
> Richard
>
>
> Complete traceback:
>
> (MyPyEnv) C:\PycharmProjects\resortinfo>python manage.py migrate
> Operations to perform:
>   Apply all migrations: resorts, sessions, hbase, auth, guardian, 
> contenttypes, admin
> Running migrations:
>   No migrations to apply.
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "C:\MyPyEnv\lib\site-packages\django\core\management\__init__.py", 
> line 353, in execute_from_command_line
> utility.execute()
>   File "C:\MyPyEnv\lib\site-packages\django\core\management\__init__.py", 
> line 345, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\MyPyEnv\lib\site-packages\django\core\management\base.py", line 
> 348, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "C:\MyPyEnv\lib\site-packages\django\core\management\base.py", line 
> 399, in execute
> output = self.handle(*args, **options)
>   File 
> "C:\MyPyEnv\lib\site-packages\django\core\management\commands\migrate.py", 
> line 204, in handle
> emit_post_migrate_signal(self.verbosity, self.interactive, 
> connection.alias)
>   File "C:\MyPyEnv\lib\site-packages\django\core\management\sql.py", line 
> 50, in emit_post_migrate_signal
> using=db)
>   File "C:\MyPyEnv\lib\site-packages\django\dispatch\dispatcher.py", line 
> 192, in send
> response = receiver(signal=self, sender=sender, **named)
>   File 
> "C:\MyPyEnv\lib\site-packages\django\contrib\auth\management\__init__.py", 
> line 126, in create_permissions
> Permission.objects.using(using).bulk_create(perms)
>   File "C:\MyPyEnv\lib\site-packages\django\db\models\query.py", line 450, 
> in bulk_create
> self._batched_insert(objs_without_pk, fields, batch_size)
>   File "C:\MyPyEnv\lib\site-packages\django\db\models\query.py", line 
> 1056, in _batched_insert
> using=self.db)
>   File "C:\MyPyEnv\lib\site-packages\django\db\models\manager.py", line 
> 122, in manager_method
> return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File "C:\MyPyEnv\lib\site-packages\django\db\models\query.py", line 
> 1039, in _insert
> return query.get_compiler(using=using).execute_sql(return_id)
>   File "C:\MyPyEnv\lib\site-packages\django\db\models\sql\compiler.py", 
> line 1059, in execute_sql
> for sql, params in self.as_sql():
>   File "C:\MyPyEnv\lib\site-packages\django\db\models\sql\compiler.py", 
> line 1047, in as_sql
> result.append(self.connection.ops.bulk_insert_sql(fields, 
> placeholder_rows))
>   File 
> "C:\MyPyEnv\lib\site-packages\mysql\connector\django\operations.py", line 
> 223, in bulk_insert_sql
> return "VALUES " + ", ".join([items_sql] * num_values)
> TypeError: can't multiply sequence by non-int of type 'tuple'
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2c51f05f-e1a8-414d-a890-f0787faeb513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django formtools wizard produces blank page (No error returned)

2016-02-08 Thread Martín Torre Castro
If I understand well, you mean that my form templates have to extend the
main wizard template. Is that correct?

In previous versions this was achieved by writing template_name =
'main_wizard_template.html' into the subclass of WizardView. Am I wrong?

So, with {% extends 'registration/test_wizard.html' %} in
*registration/test_step1.html
and **registration/test_step2.html* it should work.

I will try tonight.
Thanks.



On 8 February 2016 at 10:06, James Schneider 
wrote:

>
> On Feb 7, 2016 11:46 AM, "Martín Torre Castro" <
> martin.torre.cas...@gmail.com> wrote:
> >
> > James or anyone, the wizard doesn't load the main template for the
> wizard, just the first step template form. Can you guess why?
> >
>
> The templates you included in your OP didn't have {% extends %} or {%
> block %} tags in them. I asked about them and you mentioned those are the
> exact templates you're using. Make sure your step templates have the
> correct block references in them, otherwise your big parent template will
> never get loaded. Each step of the form/view renders the entire page, not
> just the section where the form is at.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/mAi_fB_MTwo/unsubscribe.
> To unsubscribe from this group and all its topics, 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXVwqfi%2BN62QsPZvUXRWyV0vg5%2BjhOe2Cp9WzCbXk%2BCoQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django social auth

2016-02-08 Thread Christian Ledermann
django social auth is deprecated use https://github.com/omab/python-social-auth

On 6 February 2016 at 17:43, ahmed waqas Nasir  wrote:
> i am new in django i am trying to add thirdparty verification using social
> auth
>
> after configuration when i run migrations i got following error
>
> InDjango110Warning: SubfieldBase has been deprecated. Use
> Field.from_db_value i stead. RemovedInDjango110Warning)
>
> i know the reason of this error is because i am using django 1.9 and there
> is some fucntion or something which is depricated in 1.9 and that is related
> to database..
> but  i dont know how to solve this problem
>
> can any one help?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/05758f04-94ba-46fc-bc0e-39ce6ec00182%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABCjzWpMNZ1bPv_6RpU-_xiLNr021jygjUMua709OBexQiGQ-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Announcing Django-Zappa - Serverless Django on AWS Lambda + API Gateway

2016-02-08 Thread Rich Jones
Hey guys!

I'm pleased to announce the release of Django-Zappa - a way to run 
serverless Django on AWS Lambda + API Gateway.

Now, with a single command, you can deploy your Django apps in an 
infinitely scalable, zero-configuration and incredibly cheap way!

Read the announcement post here: 
https://gun.io/blog/announcing-zappa-serverless-python-aws-lambda/
Watch a screencast here: 
https://www.youtube.com/watch?v=plUrbPN0xc8&feature=youtu.be
And see the code here: https://github.com/Miserlou/django-zappa

Comments, questions and pull requests are welcome!

Enjoy,
Rich Jones

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd2fe544-6300-49c2-9a9e-94b533796b53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


AttributeError When Overwritting AUTH_USER_MODEL in Test Cases

2016-02-08 Thread Aubrey Stark-Toller
Hello,

When I override the AUTH_USER_MODEL setting to "auth.User",  when
AUTH_USER_MODEL in settings is not set to "auth.User", in 
either a TestCase or individual test, and then try to access the objects
attribute on the user model, I get an AttributeError. 

The exact error I get is:
AttributeError: Manager isn't available; 'auth.User' has been swapped
for 'None'

I've found this to be the case in both Django 1.8 and 1.9.

This is easily reproducible in a fresh project : create a boilerplate
project with a boilerplate app, add a new user model (call it
CustomUser) to the app and set to AUTH_USER_MODEL to CustomUser, and add
the following test case to the app:

> from django.test import TestCase, override_settings
> from django.contrib.auth import get_user_model
>
> class MyTestCase(TestCase):
>@override_settings(AUTH_USER_MODEL = 'auth.User')
>def test_custom_user(self):
>UserModel = get_user_model()
>UserModel.objects.all()

get_user_model() retrieves the correct model but accessing objects
attribute gives the stated error when running the test.

If I throw in another user model (say CustomerUser2) and write a test
such as:

>@override_settings(AUTH_USER_MODEL = 'another_app.CustomerUser2')
>def test_custom_user(self):
>UserModel = get_user_model()
>UserModel.objects.all()

this works fine, and if I unset AUTH_USER_MODEL in settings again
everything works as expected.

Perhaps someone can shed some light on this behavior?

Cheers,
Aubrey

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1454941162.2753762.515065506.62DF5849%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to show python data on html

2016-02-08 Thread Derek
Depending on what your console app does or needs to do, you can also look 
at Flask as a way of serving up HTML pages to your browser; see 
http://flask.pocoo.org/docs/0.10/quickstart/  - you then do not have to use 
a database with models if those are not needed.  Django is great but not 
always appropriate.

On Sunday, 7 February 2016 15:07:52 UTC+2, 123asror wrote:
>
> So currently i have a python console application that reads from an api 
> and print some data i want. I followed the django course and they use 
> models/database in it. The data that they show comes from that. So i was 
> wondering how to add a html page to my console application or python code. 
> Is there a tutorial i can follow for that ?
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/548519fc-c84a-4733-8b71-e371aa62dc11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Right place to decrypt/decode data from DB before passing it to UI without affect data in DB itself.

2016-02-08 Thread learn django
Hi,

I store some data like email text, headers and from email address in 
encoded format in the database.
I want to have a  page where I can display all this information in readonly 
format.

What is the ideal place & way to decode this information and pass it to 
django UI.

I was thinking of reading all the information in my views.py.
But then I don't want to affect my DB. aka information in DB should remain 
encoded.

eg.

class FooViewSet(viewsets.ModelViewSet):
queryset = Message.objects.all()

Message object has headers, body and from fields which are encoded before 
storing in db.
If I perform any operation on queryset those changes will be reflected in 
DB so I cannot do that.

If I do something like below then I get exception for using list as 
queryset becomes a list object instead of queryset object.

class FooViewSet(viewsets.ModelViewSet):
queryset = list(Message.objects.all())
for obj in queryset:
body = base64.b64decode(obj.body)
obj.body = body

--089e01183b7099cbb7052b01766b--

Traceback (most recent call last):
  File "sztp/wsgi.py", line 16, in 
application = get_wsgi_application()
  File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 
14, in get_wsgi_application
django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 
18, in setup
apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", 
line 115, in populate
app_config.ready()
  File "/usr/local/lib/python2.7/dist-packages/debug_toolbar/apps.py", line 
15, in ready
dt_settings.patch_all()
  File "/usr/local/lib/python2.7/dist-packages/debug_toolbar/settings.py", 
line 232, in patch_all
patch_root_urlconf()
  File "/usr/local/lib/python2.7/dist-packages/debug_toolbar/settings.py", 
line 220, in patch_root_urlconf
reverse('djdt:render_panel')
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
550, in reverse
app_list = resolver.app_dict[ns]
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
352, in app_dict
self._populate()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
285, in _populate
for pattern in reversed(self.url_patterns):
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
402, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
396, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
  File "./sztp/urls.py", line 52, in 
url(r'^orca/', include('orca.urls.urls')),
  File 
"/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line 
33, in include
urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
  File "./orca/urls/urls.py", line 26, in 
router.register(r'notification', views.NotificationViewSet)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/routers.py", 
line 61, in register
base_name = self.get_default_base_name(viewset)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/routers.py", 
line 140, in get_default_base_name
return queryset.model._meta.object_name.lower()
AttributeError: 'list' object has no attribute 'model'

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce9b3654-6c73-4582-aae6-104d4145b466%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Running automated expiration date events

2016-02-08 Thread Rod Delaporte
I have a field of a model that changes states but I need to automatically 
modify that value after an expiration datetime has come. Is there a way to 
do this?

Here is an example:

class Post(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
languages = (
('1', 'active'),
('2', 'inactive'),
)
language = models.CharField(max_length=20, choices=languages, 
default='english')
duration = models.DurationField(blank=True, null=True)
expires = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(auto_now=True)

@property
def active(self):
return self.expires > localtime(now())

def save(self, *args, **kwargs):
self.created_at = localtime(now())
self.expires = self.created_at + self.duration
return super(Post, self).save(*args, **kwargs)


The problem I have is that I have to call the active function property to 
check if it's True or False and I'm looking for a way that this can be done 
automatically so the database updates itself.
I've been thinking about Django-cron but I can't chose when to call the 
active function, this should be done for itself.

Is this possible?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87c2360f-b02c-42d4-ac33-d1dcdf4b852a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add model item with AJAX pop up

2016-02-08 Thread guettli
There many auto-complete fields. Adding an item in a popup is needed very 
often. The django-admin does it, too.

For me it is strange that there is no reusable widget for this.

Am Montag, 8. Februar 2016 09:17:48 UTC+1 schrieb pa xapy:
>
> hi
> easiest way is to write separate view which will handle ajax requests (get 
> and post) and render html (as a json field) and success status as response.
> on frontend you will handle this response to show modal with form and 
> submit it until model will successfully saved
> once it happens, you can refetch your users list in select field
>
> but I don't know any application which implement all this stack. I think 
> you should handle this modal by yourself
>
> On Saturday, February 6, 2016 at 4:12:48 PM UTC+3, guettli wrote:
>>
>> I use django-select2  for 
>> easy ForeignKey picking. Works nice.
>>
>>
>> But how can I add a new item in the ForeignKey table?
>>
>>
>> I would like to have a big [+] button near the select2 field and then a 
>> (ajax) modal dialog should open (like in the admin interface).
>>
>>
>> AFAIK django-select2 does not help here. Is there a different library 
>> which can help here?
>>
>>
>> I would like to re-use and not to re-invent. Maybe I was blind, but I 
>> could not
>>
>> find a matching comparison grid on djangopackages.com.
>>
>>
>> I would like to avoid a "old-school" browser-window-pop-up :-)
>>
>>
>> Regards,
>>
>>   Thomas Güttler
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82af1713-5ccc-430e-affd-d6a6adbd1605%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running automated expiration date events

2016-02-08 Thread Luis Zárate
Maybe with celery and Django celery you can do what you want.  There is a
functionality called crontab that is manage by models with Django celery.
So you can create cron task that will call when you need with a reference
to you model.

As an interesting problem, think in the moment of update you model if you
use a cron task, specially when you change de date.



El lunes, 8 de febrero de 2016, Rod Delaporte 
escribió:
> I have a field of a model that changes states but I need to automatically
modify that value after an expiration datetime has come. Is there a way to
do this?
> Here is an example:
> class Post(models.Model):
> created_at = models.DateTimeField(auto_now_add=True)
> languages = (
> ('1', 'active'),
> ('2', 'inactive'),
> )
> language = models.CharField(max_length=20, choices=languages,
default='english')
> duration = models.DurationField(blank=True, null=True)
> expires = models.DateTimeField(blank=True, null=True)
> updated_at = models.DateTimeField(auto_now=True)
> @property
> def active(self):
> return self.expires > localtime(now())
> def save(self, *args, **kwargs):
> self.created_at = localtime(now())
> self.expires = self.created_at + self.duration
> return super(Post, self).save(*args, **kwargs)
>
> The problem I have is that I have to call the active function property to
check if it's True or False and I'm looking for a way that this can be done
automatically so the database updates itself.
> I've been thinking about Django-cron but I can't chose when to call the
active function, this should be done for itself.
> Is this possible?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/87c2360f-b02c-42d4-ac33-d1dcdf4b852a%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyMDOU313zLyQy8paopvuQA_TjBY9k0ZEXPigjsZ9qcr0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to show python data on html

2016-02-08 Thread Luis Zárate
Database models approuch only the most popular form of manipulate data, but
django is MVT so you could have different representation of the "M" (eg.
External API) and full use of "VT".
An example.

def myfunc(request):
 mydata = my_dict_get_by_api_call()
 return render(request, 'template.html', mydata)

Suppose that mydata has 'myobj' as a key  so in template.html you can do

{{myobj}}

Of course you could use URLs to access your view :)









El lunes, 8 de febrero de 2016, Derek  escribió:
> Depending on what your console app does or needs to do, you can also look
at Flask as a way of serving up HTML pages to your browser; see
http://flask.pocoo.org/docs/0.10/quickstart/  - you then do not have to use
a database with models if those are not needed.  Django is great but not
always appropriate.
>
> On Sunday, 7 February 2016 15:07:52 UTC+2, 123asror wrote:
>>
>> So currently i have a python console application that reads from an api
and print some data i want. I followed the django course and they use
models/database in it. The data that they show comes from that. So i was
wondering how to add a html page to my console application or python code.
Is there a tutorial i can follow for that ?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/548519fc-c84a-4733-8b71-e371aa62dc11%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyM9Kw3arLADqWiCjfsq1GnB5EiXbaZd27zyx56yTf5PCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Right place to decrypt/decode data from DB before passing it to UI without affect data in DB itself.

2016-02-08 Thread Luis Zárate
You are using django rest, sure.

Why Message doesn't have an function as a property that return the
encrypted .

El lunes, 8 de febrero de 2016, learn django 
escribió:
> Hi,
> I store some data like email text, headers and from email address in
encoded format in the database.
> I want to have a  page where I can display all this information in
readonly format.
> What is the ideal place & way to decode this information and pass it to
django UI.
> I was thinking of reading all the information in my views.py.
> But then I don't want to affect my DB. aka information in DB should
remain encoded.
> eg.
> class FooViewSet(viewsets.ModelViewSet):
> queryset = Message.objects.all()
> Message object has headers, body and from fields which are encoded before
storing in db.
> If I perform any operation on queryset those changes will be reflected in
DB so I cannot do that.
> If I do something like below then I get exception for using list as
queryset becomes a list object instead of queryset object.
> class FooViewSet(viewsets.ModelViewSet):
> queryset = list(Message.objects.all())
> for obj in queryset:
> body = base64.b64decode(obj.body)
> obj.body = body
> --089e01183b7099cbb7052b01766b--
> Traceback (most recent call last):
>   File "sztp/wsgi.py", line 16, in 
> application = get_wsgi_application()
>   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line
14, in get_wsgi_application
> django.setup()
>   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line
18, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 115, in populate
> app_config.ready()
>   File "/usr/local/lib/python2.7/dist-packages/debug_toolbar/apps.py",
line 15, in ready
> dt_settings.patch_all()
>   File
"/usr/local/lib/python2.7/dist-packages/debug_toolbar/settings.py", line
232, in patch_all
> patch_root_urlconf()
>   File
"/usr/local/lib/python2.7/dist-packages/debug_toolbar/settings.py", line
220, in patch_root_urlconf
> reverse('djdt:render_panel')
>   File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line
550, in reverse
> app_list = resolver.app_dict[ns]
>   File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line
352, in app_dict
> self._populate()
>   File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line
285, in _populate
> for pattern in reversed(self.url_patterns):
>   File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line
402, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
>   File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line
396, in urlconf_module
> self._urlconf_module = import_module(self.urlconf_name)
>   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
import_module
> __import__(name)
>   File "./sztp/urls.py", line 52, in 
> url(r'^orca/', include('orca.urls.urls')),
>   File
"/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line
33, in include
> urlconf_module = import_module(urlconf_module)
>   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
import_module
> __import__(name)
>   File "./orca/urls/urls.py", line 26, in 
> router.register(r'notification', views.NotificationViewSet)
>   File
"/usr/local/lib/python2.7/dist-packages/rest_framework/routers.py", line
61, in register
> base_name = self.get_default_base_name(viewset)
>   File
"/usr/local/lib/python2.7/dist-packages/rest_framework/routers.py", line
140, in get_default_base_name
> return queryset.model._meta.object_name.lower()
> AttributeError: 'list' object has no attribute 'model'
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/ce9b3654-6c73-4582-aae6-104d4145b466%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyOPubsFWhGvf28WKRdY83aqsUZX_druHdhCkHrw9i1ZNA%40mail.gmail.com.
For more options, vi

What python package is accurate to detect languages and count words?

2016-02-08 Thread Allison
I am trying to detect languages, so far I have used langdetect, langid. I 
heard goslate is blocked by Google, is there any package as good as 
goslate? It was simple and direct? Or would you recommend a python package 
for detecting languages and counting words? 

Thanks in advance, 

Allison

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2a1729c4-4164-4967-aaee-931108c92347%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Right place to decrypt/decode data from DB before passing it to UI without affect data in DB itself.

2016-02-08 Thread Xavier Ordoquy
Hi,

> Le 8 févr. 2016 à 19:00, learn django  > a écrit :
> 
> Hi,
> 
> I store some data like email text, headers and from email address in encoded 
> format in the database.
> I want to have a  page where I can display all this information in readonly 
> format.
> 
> What is the ideal place & way to decode this information and pass it to 
> django UI.
> 
> I was thinking of reading all the information in my views.py.
> But then I don't want to affect my DB. aka information in DB should remain 
> encoded.
> 
> eg.
> 
> class FooViewSet(viewsets.ModelViewSet):
> queryset = Message.objects.all()
> 
> Message object has headers, body and from fields which are encoded before 
> storing in db.
> If I perform any operation on queryset those changes will be reflected in DB 
> so I cannot do that.
> 
> If I do something like below then I get exception for using list as queryset 
> becomes a list object instead of queryset object.
> 
> class FooViewSet(viewsets.ModelViewSet):
> queryset = list(Message.objects.all())
> for obj in queryset:
> body = base64.b64decode(obj.body)
> obj.body = body

This wil not work for different reasons.
First one is about Python scope. Doing this will get you a fixed list of 
Message unless you restart the server.
Second is you’re using a generic view that expects QuerySet as you’ve noticed. 
Overriding get_queryset would get somewhat bette result but it still wouldn’t 
work as QuerySet are expected for pagination and filtering.

The best place to perform that are to_representation and to_internal_value for 
that field.
You should have a look at the custom fields 
(http://www.django-rest-framework.org/api-guide/fields/#custom-fields 
) for 
guidance about how to handle that.

Regards,
Xavier,
Linovia.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/74175DA3-19EE-4D91-BC16-16374DFA2D45%40linovia.com.
For more options, visit https://groups.google.com/d/optout.