Re: Polymorphic class and geomodels?

2016-02-05 Thread Luca Moiana
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/group/geodjango
>
> Collin
>
> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>>
>> Hi, working on my first django app, and run into a problem.
>>
>> I tend to create geodjango objects, and add all data from external 
>> tables with pk.
>>
>> Then I want to have different geometries 8points, lines, polygons) 
>> into a unique polymorphic class, can I do that?
>>
>> I have an error that I'll document later, and I'm trying to figure 
>> out what to do.
>>
>> Here is the model:
>> import datetime
>>
>> from django.db import models
>> from django.contrib.gis.db import models as geomodels
>> from django.utils import timezone
>> from django.forms import ModelForm
>> from polymorphic import PolymorphicModel
>>
>> # Geometria linea da monitorare
>> class geolinea(geomodels.Model):
>> progetto = models.CharField(max_length=14, primary_key=True)
>> geom = geomodels.MultiLineStringField()
>> objects = geomodels.GeoManager()
>> def __str__(self):
>> return '%s' % (self.progetto)
>> # Oggetto Progetto soggetto a PMA
>> class linea(models.Model):
>> progetto = models.ForeignKey(geolinea)
>> nome = models.CharField(max_length=200)
>> TENSIONE = (
>> ('132', '132kV'),
>> ('150', '150kV'),
>> ('220', '220kV'),
>> ('380', '380kV'),
>> )
>> tensione = models.CharField(max_length=5,
>> choices=TENSIONE)
>> def __str__(self):
>> return '%s' % (self.nome)
>>
>> # Geometria dei pdm
>> class pdmpunto(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.Po

Re: ID for users of Speedy Net

2016-02-05 Thread Uri Even-Chen
Thanks Remco, that's what I was looking for. I'll try to implement it the
way you suggested.

Uri.


*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    

On Sat, Feb 6, 2016 at 12:00 AM, Remco Gerlich  wrote:

> The key is to start out your project with a different User model than the
> default model -- see
> https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#specifying-a-custom-user-model
> . Create your own User model that inherits from AbstractBaseUser, and set
> AUTH_USER_MODEL = YourCustomUser.
>
> It's key to do this at the beginning of the project, since it's really
> hard to migrate to this later. You can always change your custom model, but
> switching from the default to a custom model is nontrivial.
>
> Remco Gerlich
>
>
> On Fri, Feb 5, 2016 at 9:22 PM, Uri Even-Chen  wrote:
>
>> Hi James,
>>
>> Thanks for your feedback. My question was how do I change the primary key
>> of a Django model such as User - a model I didn't write myself (it's
>> already written by Django). Is it possible? Because I prefer the id/pk to
>> be 15-digits randomly generated and not auto-increment. I don't see any
>> logic in using auto-increment, I don't want the id/primary key to be short
>> (such as zuck's id on Facebook - https://www.facebook.com/messages/4)
>> but 15-digits long. And by the way, users who already signed up to Speedy
>> Net already have a 15-digits id (randomly generated) and I want to preserve
>> this id when converting Speedy Net from PHP/MySQL to Django and PostgreSQL.
>>
>> I hope I clarified my question now.
>>
>> Thanks,
>> Uri.
>>
>> *Uri Even-Chen*
>> [image: photo] Phone: +972-54-3995700
>> Email: u...@speedy.net
>> Website: http://www.speedysoftware.com/uri/en/
>> 
>> 
>> 
>> 
>>
>> On Fri, Feb 5, 2016 at 8:22 PM, James Schneider 
>> wrote:
>>
>>>
>>> On Feb 4, 2016 10:59 AM, "Uri Even-Chen"  wrote:
>>> >
>>> > Hi James,
>>> >
>>> > Thanks for your feedback. Actually I was thinking that this randomly
>>> generated number with 15 digits will be used in urls, for example of pages
>>> which don't have slugs etc. I saw similar urls in Facebook for pages who
>>> don't have a username (Facebook calls it a username), Facebook generates a
>>> slug which contains a 15-digits number. I found out that Facebook
>>> redirects to this url when entering the url with only the number (for
>>> example https://www.facebook.com/342076035998592/ - with or without the
>>> trailing slash, even with several slashes). So the UUID will be too long
>>> for this, unless I generate it with 15 digits (decimal). And how do I make
>>> it a primary key of model User? Is there a way to change the primary keys
>>> of Django models and how? I think we will use PostgreSQL anyway, thanks!
>>> >
>>>
>>> You have total control over what field is used as the primary key.
>>>
>>> https://docs.djangoproject.com/en/1.9/ref/models/fields/#primary-key
>>>
>>> The model.id field that is automatically generated is for convenience
>>> and convention. It is not generated/available when a different primary key
>>> is specified, unless of course you name the field 'id'.
>>>
>>> This is also why it is important to use model.ok when referring to the
>>> primary key for a model, rather than model.I'd, since model.pk is
>>> always made available as an alias to whatever primary key that the model
>>> it's using (be it an integer or a UUID).
>>>
>>> Unless your code performs some operation on a model's primary key that
>>> is specific to an integer data type (ie using \d+ to look for primary keys
>>> in your urls.py), using model.pk is pretty universal and shouldn't
>>> require many changes to move from an integer to something else as your PK.
>>>
>>> As far as the number that FB generates for their URL's, I'm sure it is
>>> some type of account number that is assigned upon creation, probably along
>>> the lines of what you were mentioning.
>>>
>>> I suppose you could have the same ID between the two systems, but I
>>> wouldn't necessarily make that a hard requirement. It's pretty easy to add
>>> an extra correlation table that would keep track of the user in each system
>>> with a different PK. While this could incur an extra join or extra queries,
>>> it does make the system much more flexible, with the possibility to
>>> integrate with other authentication systems such as LDAP or Shibboleth
>>> where the customer may not be able to easily modify/add the DB attribute to
>>> match your account number/PK.
>>>
>>> Also keep in mind that the PK and account number can, and probably
>>> should be, separate. Changing an account number (due to a typo, perhaps)
>>> could be dis

Re: reading CSV file with non ASCII characters

2016-02-05 Thread Erik Cederstrand

> Den 6. feb. 2016 kl. 09.14 skrev elcaiaimar :
> 
> Hello,
> 
> I have a CSV File and I want read it. The problem is that it has non ASCII 
> characters such as 'Ñ' and accents and I need that they are recognised to 
> save the CSV content in a DB.
> 
> To simplify, I've summed up my code in django to the next:
> 
> ​import csv
> 
> reader = csv.DictReader(open("file.csv", "rb"))

You should always convert bytestrings to unicode as soon as possible in Python. 
You need to specify the encoding of your file, e.g.:

reader = csv.DictReader(open("file.csv", "rb", encoding='utf-8'))

See https://docs.python.org/3/library/functions.html#open

For Python 2, have a look at the notes about encodings in 
https://docs.python.org/2/library/csv.html

Erik

-- 
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/7E3805BB-72BF-4865-8C82-3BCBAD689F16%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: reading CSV file with non ASCII characters

2016-02-05 Thread Bill Blanchard
Try this:

https://github.com/jdunck/python-unicodecsv

On Fri, Feb 5, 2016 at 9:14 PM, elcaiaimar  wrote:

> Hello,
>
> I have a CSV File and I want read it. The problem is that it has non ASCII
> characters such as 'Ñ' and accents and I need that they are recognised to
> save the CSV content in a DB.
>
> To simplify, I've summed up my code in django to the next:
>
> ​import csv
>
> reader = csv.DictReader(open("file.csv", "rb"))
> for row in reader:
> title=row['title']
> country=row['country']
> print title
> print country
>
> This code returns, for example: Espa�a or Mediterr�neo and I want to get 
> España or Mediterráneo.
>
> Thank you very much!
>
> --
> 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/54c6c685-f4dd-4233-9a30-22424c986a43%40googlegroups.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/CAP7uEDLtWxKY_5LBCGQOtSCmeT%2BVf91PExpALWTi9OVjg51Cgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django tutor/coach wanted

2016-02-05 Thread Django Learner
I'm a very experienced developer, but not experienced with Python/Django. I 
have a site that I'd like to build using these tools, and am hoping to find 
someone to help make climbing the learning curve an efficient process. I'm in 
Boston, but remote is OK. Willing to pay well for comensurate expertise. 
Contact me at melearndja...@gmail.com. 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e64d1e7d-4e17-4954-8094-cb8cc6ceac53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


reading CSV file with non ASCII characters

2016-02-05 Thread elcaiaimar
Hello,

I have a CSV File and I want read it. The problem is that it has non ASCII 
characters such as 'Ñ' and accents and I need that they are recognised to 
save the CSV content in a DB.

To simplify, I've summed up my code in django to the next:

​import csv

reader = csv.DictReader(open("file.csv", "rb"))
for row in reader:
title=row['title']
country=row['country']
print title
print country

This code returns, for example: Espa�a or Mediterr�neo and I want to get España 
or Mediterráneo.

Thank you very much!

-- 
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/54c6c685-f4dd-4233-9a30-22424c986a43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Windows + Web +Mobile application: Kivy or Django

2016-02-05 Thread Russell Keith-Magee
On Fri, Feb 5, 2016 at 10:42 PM, MHK  wrote:

> Hi All,
>
> I am planning to develop an application which should be mainly work with
> desktop and latter may be use the same desktop app to convert into web and
> mobile application using python. I wanted to know whether kivy will suffice
> for all the three platforms (desktop, web and mobile) or do I need to work
> on kivy for desktop and Django for web. Please suggest
>

It depends on what you want to produce.

Django by itself is a server-side tool. You’re not going to be able to
write a mobile application in the “available in the app store” sense of the
word. However, you will be able to write a web page that is adaptive to
mobile devices; you can also use HTML5 features like manifests to produce
an app-like experience on mobile. The same goes for desktop apps - you can
write something that will load in a browser, but unless you’re going to
wrap that web page up in a single-page app loader (like Fluidapp [1]),
you’re going to need different tools to write the desktop app.

Kivy, on the other hand, can only be used to make standalone apps. To the
best of my knowledge, there isn’t a “browser” option for Kivy - you’d be
writing a Kivy app for the mobile app (and possibly a desktop app as well),
with Django providing the server side (if a server-side is even needed -
your requirements aren’t clear). However, Kivy apps aren’t really “native”
- They *run* as native apps, but the widgets they expose are all
custom-drawn Kivy widgets. Ivy takes the approach of having a common widget
set across all platforms, rather than providing native widgets on each
platform.

I’d also be remiss if I didn’t point you in the direction of BeeWare [2]
 it’s a project that I’m working on to improve the story for developing
Python applications for mobile. It’s still early days - definitely not as
mature as Kivy - but if you’re willing to put up with plenty of sharp
edges, and contribute to an early stage project, you can develop completely
native mobile (and desktop) applications in Python.

[1] http://fluidapp.com
[2] http://pybee.org

Yours,
Russ Magee %-)

-- 
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/CAJxq84_PP%2BRmM_T-dk2Xcq5YTgEAybWYaV2hxBppxvveaUkXRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ID for users of Speedy Net

2016-02-05 Thread Remco Gerlich
The key is to start out your project with a different User model than the
default model -- see
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#specifying-a-custom-user-model
. Create your own User model that inherits from AbstractBaseUser, and set
AUTH_USER_MODEL = YourCustomUser.

It's key to do this at the beginning of the project, since it's really hard
to migrate to this later. You can always change your custom model, but
switching from the default to a custom model is nontrivial.

Remco Gerlich


On Fri, Feb 5, 2016 at 9:22 PM, Uri Even-Chen  wrote:

> Hi James,
>
> Thanks for your feedback. My question was how do I change the primary key
> of a Django model such as User - a model I didn't write myself (it's
> already written by Django). Is it possible? Because I prefer the id/pk to
> be 15-digits randomly generated and not auto-increment. I don't see any
> logic in using auto-increment, I don't want the id/primary key to be short
> (such as zuck's id on Facebook - https://www.facebook.com/messages/4) but
> 15-digits long. And by the way, users who already signed up to Speedy Net
> already have a 15-digits id (randomly generated) and I want to preserve
> this id when converting Speedy Net from PHP/MySQL to Django and PostgreSQL.
>
> I hope I clarified my question now.
>
> Thanks,
> Uri.
>
> *Uri Even-Chen*
> [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net
> Website: http://www.speedysoftware.com/uri/en/
> 
> 
>   
>
> On Fri, Feb 5, 2016 at 8:22 PM, James Schneider 
> wrote:
>
>>
>> On Feb 4, 2016 10:59 AM, "Uri Even-Chen"  wrote:
>> >
>> > Hi James,
>> >
>> > Thanks for your feedback. Actually I was thinking that this randomly
>> generated number with 15 digits will be used in urls, for example of pages
>> which don't have slugs etc. I saw similar urls in Facebook for pages who
>> don't have a username (Facebook calls it a username), Facebook generates a
>> slug which contains a 15-digits number. I found out that Facebook
>> redirects to this url when entering the url with only the number (for
>> example https://www.facebook.com/342076035998592/ - with or without the
>> trailing slash, even with several slashes). So the UUID will be too long
>> for this, unless I generate it with 15 digits (decimal). And how do I make
>> it a primary key of model User? Is there a way to change the primary keys
>> of Django models and how? I think we will use PostgreSQL anyway, thanks!
>> >
>>
>> You have total control over what field is used as the primary key.
>>
>> https://docs.djangoproject.com/en/1.9/ref/models/fields/#primary-key
>>
>> The model.id field that is automatically generated is for convenience
>> and convention. It is not generated/available when a different primary key
>> is specified, unless of course you name the field 'id'.
>>
>> This is also why it is important to use model.ok when referring to the
>> primary key for a model, rather than model.I'd, since model.pk is always
>> made available as an alias to whatever primary key that the model it's
>> using (be it an integer or a UUID).
>>
>> Unless your code performs some operation on a model's primary key that is
>> specific to an integer data type (ie using \d+ to look for primary keys in
>> your urls.py), using model.pk is pretty universal and shouldn't require
>> many changes to move from an integer to something else as your PK.
>>
>> As far as the number that FB generates for their URL's, I'm sure it is
>> some type of account number that is assigned upon creation, probably along
>> the lines of what you were mentioning.
>>
>> I suppose you could have the same ID between the two systems, but I
>> wouldn't necessarily make that a hard requirement. It's pretty easy to add
>> an extra correlation table that would keep track of the user in each system
>> with a different PK. While this could incur an extra join or extra queries,
>> it does make the system much more flexible, with the possibility to
>> integrate with other authentication systems such as LDAP or Shibboleth
>> where the customer may not be able to easily modify/add the DB attribute to
>> match your account number/PK.
>>
>> Also keep in mind that the PK and account number can, and probably should
>> be, separate. Changing an account number (due to a typo, perhaps) could be
>> disastrous if it were the PK, but there is little, if any, reason to
>> manually update a true PK.
>>
>> You could potential do some trickery with the PK to derive the account
>> number, such as taking the existing PK and adding 1,284,386,269,433 to it,
>> and using that value as the 'account' number. Using a nice even number like
>> 1,000,000,000,000 makes the account number much more obvious, such as the
>> first account being 1,000,000,000,001. Users will 'feel' better if they
>> have a random-looking account number, although someone is 

Re: Python Windows + Web +Mobile application: Kivy or Django

2016-02-05 Thread Vernon D. Cole
Kivy will do desktop and mobile, but web applications are a different 
animal completely. Since they run on a web browser, rather than directly on 
the computer operating system, your ability to interact with the user's 
environment is very limited. Anything complex must be written in 
JavaScript.  There are a few Python-to-JavaScript "transpiler" projects out 
there which attempt to make it possible to write python code to run in a 
browser, but I have never heard of kivy running on one of them. I think 
your best bet would be to either plan on doing two implementations, or have 
your website be a portal to download your desktop app.

On Friday, February 5, 2016 at 8:18:13 AM UTC-7, MHK wrote:
>
> Hi All,
>
> I am planning to develop an application which should be mainly work with 
> desktop and latter may be use the same desktop app to convert into web and 
> mobile application using python. I wanted to know whether kivy will suffice 
> for all the three platforms (desktop, web and mobile) or do I need to work 
> on kivy for desktop and Django for web. Please suggest
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a902b1a2-3e1e-43a5-9caf-e9cab4446b76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ID for users of Speedy Net

2016-02-05 Thread Uri Even-Chen
Hi James,

Thanks for your feedback. My question was how do I change the primary key
of a Django model such as User - a model I didn't write myself (it's
already written by Django). Is it possible? Because I prefer the id/pk to
be 15-digits randomly generated and not auto-increment. I don't see any
logic in using auto-increment, I don't want the id/primary key to be short
(such as zuck's id on Facebook - https://www.facebook.com/messages/4) but
15-digits long. And by the way, users who already signed up to Speedy Net
already have a 15-digits id (randomly generated) and I want to preserve
this id when converting Speedy Net from PHP/MySQL to Django and PostgreSQL.

I hope I clarified my question now.

Thanks,
Uri.

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    

On Fri, Feb 5, 2016 at 8:22 PM, James Schneider 
wrote:

>
> On Feb 4, 2016 10:59 AM, "Uri Even-Chen"  wrote:
> >
> > Hi James,
> >
> > Thanks for your feedback. Actually I was thinking that this randomly
> generated number with 15 digits will be used in urls, for example of pages
> which don't have slugs etc. I saw similar urls in Facebook for pages who
> don't have a username (Facebook calls it a username), Facebook generates a
> slug which contains a 15-digits number. I found out that Facebook
> redirects to this url when entering the url with only the number (for
> example https://www.facebook.com/342076035998592/ - with or without the
> trailing slash, even with several slashes). So the UUID will be too long
> for this, unless I generate it with 15 digits (decimal). And how do I make
> it a primary key of model User? Is there a way to change the primary keys
> of Django models and how? I think we will use PostgreSQL anyway, thanks!
> >
>
> You have total control over what field is used as the primary key.
>
> https://docs.djangoproject.com/en/1.9/ref/models/fields/#primary-key
>
> The model.id field that is automatically generated is for convenience and
> convention. It is not generated/available when a different primary key is
> specified, unless of course you name the field 'id'.
>
> This is also why it is important to use model.ok when referring to the
> primary key for a model, rather than model.I'd, since model.pk is always
> made available as an alias to whatever primary key that the model it's
> using (be it an integer or a UUID).
>
> Unless your code performs some operation on a model's primary key that is
> specific to an integer data type (ie using \d+ to look for primary keys in
> your urls.py), using model.pk is pretty universal and shouldn't require
> many changes to move from an integer to something else as your PK.
>
> As far as the number that FB generates for their URL's, I'm sure it is
> some type of account number that is assigned upon creation, probably along
> the lines of what you were mentioning.
>
> I suppose you could have the same ID between the two systems, but I
> wouldn't necessarily make that a hard requirement. It's pretty easy to add
> an extra correlation table that would keep track of the user in each system
> with a different PK. While this could incur an extra join or extra queries,
> it does make the system much more flexible, with the possibility to
> integrate with other authentication systems such as LDAP or Shibboleth
> where the customer may not be able to easily modify/add the DB attribute to
> match your account number/PK.
>
> Also keep in mind that the PK and account number can, and probably should
> be, separate. Changing an account number (due to a typo, perhaps) could be
> disastrous if it were the PK, but there is little, if any, reason to
> manually update a true PK.
>
> You could potential do some trickery with the PK to derive the account
> number, such as taking the existing PK and adding 1,284,386,269,433 to it,
> and using that value as the 'account' number. Using a nice even number like
> 1,000,000,000,000 makes the account number much more obvious, such as the
> first account being 1,000,000,000,001. Users will 'feel' better if they
> have a random-looking account number, although someone is bound to get
> 2,000,000,000,000 at some point.
>
> You could also construct the account number through a series of
> organizational character positions to give the developer immediate
> information about the account just by looking at it, say all accounts
> created in 2016 will start with 16, with the numbers after that containing
> a department code, account type, etc. For example, an account starting with
> 1604 could mean that the account was created this year as a free account
> rather than a paid one. The remaining section of the account would be based
> on the PK of the user (assuming an integer PK).
>
> I guess that's the long way of saying that the account number is 

Django and process uploading file

2016-02-05 Thread ylativ oknesyl
How do I put the mouse cursor in the standby symbol when Django downloads a 
large file (about 1 gig) to the folder media

-- 
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/6394242d-8f0c-46ec-9ef4-1d466f74d744%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You have to use a standard admin panel to the real sites, or it's no good?

2016-02-05 Thread ylativ oknesyl
You have to use a standard admin panel to the real sites, or it's no good?

-- 
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/8d7ade37-7038-4085-9a0e-784a9c3412de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polymorphic class and geomodels?

2016-02-05 Thread Sergiy Khohlov
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/group/geodjango

 Collin

 On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>
> Hi, working on my first django app, and run into a problem.
>
> I tend to create geodjango objects, and add all data from external
> tables with pk.
>
> Then I want to have different geometries 8points, lines, polygons)
> into a unique polymorphic class, can I do that?
>
> I have an error that I'll document later, and I'm trying to figure out
> what to do.
>
> Here is the model:
> import datetime
>
> from django.db import models
> from django.contrib.gis.db import models as geomodels
> from django.utils import timezone
> from django.forms import ModelForm
> from polymorphic import PolymorphicModel
>
> # Geometria linea da monitorare
> class geolinea(geomodels.Model):
> progetto = models.CharField(max_length=14, primary_key=True)
> geom = geomodels.MultiLineStringField()
> objects = geomodels.GeoManager()
> def __str__(self):
> return '%s' % (self.progetto)
> # Oggetto Progetto soggetto a PMA
> class linea(models.Model):
> progetto = models.ForeignKey(geolinea)
> nome = models.CharField(max_length=200)
> TENSIONE = (
> ('132', '132kV'),
> ('150', '150kV'),
> ('220', '220kV'),
> ('380', '380kV'),
> )
> tensione = models.CharField(max_length=5,
> choices=TENSIONE)
> def __str__(self):
> return '%s' % (self.nome)
>
> # Geometria dei pdm
> class pdmpunto(geomodels.Model):
> linea = models.ForeignKey(linea)
> numero = models.CharField(max_length=3)
> geom = geomodels.PointField()
> objects = geomodels.GeoManager()
>
> class pdmtransetto(geomodels.Model):
> linea = models.ForeignKey(linea)
> numero = models.CharField(max_length=3)
> geom = geomodels.LineStringField()
> objects = geomodels.GeoManager()
>
> class pdmarea(geomodels.Model):
> linea = models.ForeignKey(linea)
> numero = models.CharField(max_length=3)
> geom = geomodels.PolygonField()
> objects = geomodels.GeoManager()
>
> class pdm(PolymorphicModel):
> numero = models.CharField(max_length=14, primary_key=True)
> class

Where the best and many free photos for websites on Python+Django? (please links)

2016-02-05 Thread ylativ oknesyl
Where the best and many free photos for websites on Python+Django? (please 
links)

-- 
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/8fd17174-f6e6-42b8-a2f1-9d92a105b26d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ID for users of Speedy Net

2016-02-05 Thread James Schneider
On Feb 4, 2016 10:59 AM, "Uri Even-Chen"  wrote:
>
> Hi James,
>
> Thanks for your feedback. Actually I was thinking that this randomly
generated number with 15 digits will be used in urls, for example of pages
which don't have slugs etc. I saw similar urls in Facebook for pages who
don't have a username (Facebook calls it a username), Facebook generates a
slug which contains a 15-digits number. I found out that Facebook
redirects to this url when entering the url with only the number (for
example https://www.facebook.com/342076035998592/ - with or without the
trailing slash, even with several slashes). So the UUID will be too long
for this, unless I generate it with 15 digits (decimal). And how do I make
it a primary key of model User? Is there a way to change the primary keys
of Django models and how? I think we will use PostgreSQL anyway, thanks!
>

You have total control over what field is used as the primary key.

https://docs.djangoproject.com/en/1.9/ref/models/fields/#primary-key

The model.id field that is automatically generated is for convenience and
convention. It is not generated/available when a different primary key is
specified, unless of course you name the field 'id'.

This is also why it is important to use model.ok when referring to the
primary key for a model, rather than model.I'd, since model.pk is always
made available as an alias to whatever primary key that the model it's
using (be it an integer or a UUID).

Unless your code performs some operation on a model's primary key that is
specific to an integer data type (ie using \d+ to look for primary keys in
your urls.py), using model.pk is pretty universal and shouldn't require
many changes to move from an integer to something else as your PK.

As far as the number that FB generates for their URL's, I'm sure it is some
type of account number that is assigned upon creation, probably along the
lines of what you were mentioning.

I suppose you could have the same ID between the two systems, but I
wouldn't necessarily make that a hard requirement. It's pretty easy to add
an extra correlation table that would keep track of the user in each system
with a different PK. While this could incur an extra join or extra queries,
it does make the system much more flexible, with the possibility to
integrate with other authentication systems such as LDAP or Shibboleth
where the customer may not be able to easily modify/add the DB attribute to
match your account number/PK.

Also keep in mind that the PK and account number can, and probably should
be, separate. Changing an account number (due to a typo, perhaps) could be
disastrous if it were the PK, but there is little, if any, reason to
manually update a true PK.

You could potential do some trickery with the PK to derive the account
number, such as taking the existing PK and adding 1,284,386,269,433 to it,
and using that value as the 'account' number. Using a nice even number like
1,000,000,000,000 makes the account number much more obvious, such as the
first account being 1,000,000,000,001. Users will 'feel' better if they
have a random-looking account number, although someone is bound to get
2,000,000,000,000 at some point.

You could also construct the account number through a series of
organizational character positions to give the developer immediate
information about the account just by looking at it, say all accounts
created in 2016 will start with 16, with the numbers after that containing
a department code, account type, etc. For example, an account starting with
1604 could mean that the account was created this year as a free account
rather than a paid one. The remaining section of the account would be based
on the PK of the user (assuming an integer PK).

I guess that's the long way of saying that the account number is part of
your data, and should not be relied upon as part of your internal database
structure (as a PK), especially when you have abstractions like model.pk
available. If you want the account number, you should be asking for
model.account_number anyway, not model.id or model.pk. Don't have coupling
between your data and your infrastructure. You can still index and get the
same searching benefits as a PK, so you don't gain much from it either,
other than removing one minor abstraction while increasing complication
immensely with related fields.

-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%2BciV0m0knMLYeBQtynXPufkVt35H8a%3DMF1AcAJ-DjO87Qcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polymorphic class and geomodels?

2016-02-05 Thread Luca Moiana
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/group/geodjango
>>>
>>> Collin
>>>
>>> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:

 Hi, working on my first django app, and run into a problem.

 I tend to create geodjango objects, and add all data from external 
 tables with pk.

 Then I want to have different geometries 8points, lines, polygons) into 
 a unique polymorphic class, can I do that?

 I have an error that I'll document later, and I'm trying to figure out 
 what to do.

 Here is the model:
 import datetime

 from django.db import models
 from django.contrib.gis.db import models as geomodels
 from django.utils import timezone
 from django.forms import ModelForm
 from polymorphic import PolymorphicModel

 # Geometria linea da monitorare
 class geolinea(geomodels.Model):
 progetto = models.CharField(max_length=14, primary_key=True)
 geom = geomodels.MultiLineStringField()
 objects = geomodels.GeoManager()
 def __str__(self):
 return '%s' % (self.progetto)
 # Oggetto Progetto soggetto a PMA
 class linea(models.Model):
 progetto = models.ForeignKey(geolinea)
 nome = models.CharField(max_length=200)
 TENSIONE = (
 ('132', '132kV'),
 ('150', '150kV'),
 ('220', '220kV'),
 ('380', '380kV'),
 )
 tensione = models.CharField(max_length=5,
 choices=TENSIONE)
 def __str__(self):
 return '%s' % (self.nome)

 # Geometria dei pdm
 class pdmpunto(geomodels.Model):
 linea = models.ForeignKey(linea)
 numero = models.CharField(max_length=3)
 geom = geomodels.PointField()
 objects = geomodels.GeoManager()

 class pdmtransetto(geomodels.Model):
 linea = models.ForeignKey(linea)
 numero = models.CharField(max_length=3)
 geom = geomodels.LineStringField()
 objects = geomodels.GeoManager()

 class pdmarea(geomodels.Model):
 linea = models.ForeignKey(linea)
 numero = models.CharField(max_length=3)
 geom = geomodels.PolygonField()
 objects = geomodels.GeoManager()

 class pdm(PolymorphicModel):
 numero = models.CharField(max_length=14, primary_key=True)
 class punto(pdm):
 rifpunto = models.ForeignKey(pdmpunto)
 class transetto(pdm):
 riftransetto = models.ForeignKey(pdmtransetto)
 class area(pdm):
 rifarea = models.ForeignKey(pdmarea)



 -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cd243d25-0aff-446d-b9c9-cb5682d9bdf3%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit 

Re: django unittest with post not working

2016-02-05 Thread JAMES DAMILD ETIENNE

Yes but it stillnot saving the data after posting :/

-- 
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/5e6648df-e4fe-4a43-86f5-3d4ebb80e23e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Python Windows + Web +Mobile application: Kivy or Django

2016-02-05 Thread MHK
Hi All,

I am planning to develop an application which should be mainly work with 
desktop and latter may be use the same desktop app to convert into web and 
mobile application using python. I wanted to know whether kivy will suffice 
for all the three platforms (desktop, web and mobile) or do I need to work 
on kivy for desktop and Django for web. Please suggest

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2926b9ac-dfcf-48b1-8afc-3b411620c536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting up django mailbox

2016-02-05 Thread learn django
Hi All,

I was able to resolve the issue yesterday night.
Forgot to send an email.

I had to reduce the security level of gmail so that app can access it.

Thanks for all the help.

On Thursday, February 4, 2016 at 11:58:03 PM UTC-8, Daniel Chimeno wrote:
>
> This are the settings you should put:
>
> https://support.google.com/mail/troubleshooter/1668960?rd=1#ts=1665018%2C1665144
>
>
> El viernes, 5 de febrero de 2016, 2:04:44 (UTC+1), learn django escribió:
>>
>> I tried both but no luck.
>>
>> On Thursday, February 4, 2016 at 3:49:48 PM UTC-8, Dheerendra Rathor 
>> wrote:
>>>
>>> Are you sure imap.company.com is handling your imap server and not 
>>> imap.google.com?
>>>
>>> On Thu, 4 Feb 2016 at 23:24 Daniel Chimeno  wrote:
>>>
 Hello,
 If you are writing about his project: 
 https://github.com/coddingtonbear/django-mailbox I guess
 it's better to ask in the issues page of that project: 
 https://github.com/coddingtonbear/django-mailbox/issues

  

 El jueves, 4 de febrero de 2016, 23:02:36 (UTC+1), learn django 
 escribió:

> Hi,
>
> Am trying to setup django mailbox  from admin page and seeing issues.
>
> My email address is f...@company.com. We use google.com for our email 
> service.
>
> My username is "a...@company.com", name is "abc abc" and password is 
> "abc1234".
>

> Am putting following details on django_mailbox page.
>
> Name: "abc abc"
>
 URI: "imap+ssl://abc%40company.com:abc1...@imap.company.com"
> From email: "a...@company.com"
>

> I see following traceback on running "python manage.py getmail".
> I have enabled imap under setting under google for my account.
>
> $ python manage.py getmail
> /usr/local/lib/python2.7/dist-packages/djangosaml2/conf.py:20: 
> RemovedInDjango19Warning: django.utils.importlib will be removed in 
> Django 
> 1.9.
>   from django.utils.importlib import import_module
>
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>  
> line 338, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>  
> line 330, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 390, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 441, in execute
> output = self.handle(*args, **options)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django_mailbox/management/commands/getmail.py",
>  
> line 24, in handle
> messages = mailbox.get_new_mail()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django_mailbox/models.py", line 
> 393, in get_new_mail
> connection = self.get_connection()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django_mailbox/models.py", line 
> 229, in get_connection
> conn.connect(self.username, self.password)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django_mailbox/transports/imap.py",
>  
> line 41, in connect
> typ, msg = self.server.login(username, password)
>   File "/usr/lib/python2.7/imaplib.py", line 519, in login
> raise self.error(dat[-1])
> imaplib.error: Login failed.
>
> Am unable to figure out what is happening here.
> Any help is appreciated.
> Thanks in advance.
>
> -- 
 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 https://groups.google.com/group/django-users.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/7d0e657f-a3b0-42e4-821e-9b9c2c7ad15a%40googlegroups.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 visi

Re: Handling cookies that contain illegal values

2016-02-05 Thread Will Harris
Thanks Tim, fascinating. At least I can tell the big boss the problem was 
"caused" by the BDFL ;-)

Will

On Friday, February 5, 2016 at 1:52:34 PM UTC+1, Tim Graham wrote:
>
> This is caused by a security fix in Python (which Django uses for cookie 
> parsing). I think the issue can be fixed without cause security problems 
> but I'm not sure. Please follow 
> https://code.djangoproject.com/ticket/26158 and related Python tickets.
>
> On Friday, February 5, 2016 at 3:13:14 AM UTC-5, Will Harris wrote:
>>
>> Hey Daniel,
>>
>> Thanks for the reply. Unfortunately doing this in a custom middleware is 
>> not an option, as the this processing needs to take place at a very low 
>> level, at the point where the Request object is being built. By the time 
>> the request is passed in to the middleware layers for processing, the 
>> cookies would already have been lost.
>>
>> Will
>>
>> On Friday, February 5, 2016 at 12:31:30 AM UTC+1, Daniel Chimeno wrote:
>>>
>>> Hello, 
>>>

 I have resolved this in my instance as follows in django/http/cookie.py
 :

 def parse_cookie(cookie):
 cookie = re.sub('[^\x20-\x7e]+', 'X', cookie)
 ...



 It would be preferable to write that code in a middleware than in the 
>>> Django code itself.
>>> Before the middleware that handles the cookie (I guess it would be 
>>> Session), you can *sanitize* that cookie.
>>>
>>> Hope it helps.
>>>  
>>>
>>

-- 
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/2d48945b-b1fc-4811-b795-b11d92f0948b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Handling cookies that contain illegal values

2016-02-05 Thread Tim Graham
This is caused by a security fix in Python (which Django uses for cookie 
parsing). I think the issue can be fixed without cause security problems 
but I'm not sure. Please follow https://code.djangoproject.com/ticket/26158 
and related Python tickets.

On Friday, February 5, 2016 at 3:13:14 AM UTC-5, Will Harris wrote:
>
> Hey Daniel,
>
> Thanks for the reply. Unfortunately doing this in a custom middleware is 
> not an option, as the this processing needs to take place at a very low 
> level, at the point where the Request object is being built. By the time 
> the request is passed in to the middleware layers for processing, the 
> cookies would already have been lost.
>
> Will
>
> On Friday, February 5, 2016 at 12:31:30 AM UTC+1, Daniel Chimeno wrote:
>>
>> Hello, 
>>
>>>
>>> I have resolved this in my instance as follows in django/http/cookie.py:
>>>
>>> def parse_cookie(cookie):
>>> cookie = re.sub('[^\x20-\x7e]+', 'X', cookie)
>>> ...
>>>
>>>
>>>
>>> It would be preferable to write that code in a middleware than in the 
>> Django code itself.
>> Before the middleware that handles the cookie (I guess it would be 
>> Session), you can *sanitize* that cookie.
>>
>> Hope it helps.
>>  
>>
>

-- 
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/e544bbb7-0c37-4a88-8c55-c6b1b1005ae9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to disable atomic() in tests

2016-02-05 Thread marcin . j . nowak
Hi,

I want to disable atomic() in tests (Django 1.8 and newer). I would like to 
"noop" it and implement alternate BEGIN-ROLLBACK sequence for every test. 
Anyone did this?

It comes from bad design of Django tests, where database is created, 
cleaned, dropped, fixtrue-loaded in every test, which is terrible in terms 
of performance and flexibility. 
Databases should be created/cleaned/prepared before running test suite, and 
running tests shouldn't alter database` state. That's why every test should 
end with rollback for all transactions and all databases.

Kind Regards,
Marcin

-- 
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/91768f6f-c1aa-4d95-8a63-2f84b239b0a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polymorphic class and geomodels?

2016-02-05 Thread Sergiy Khohlov
 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/group/geodjango
>>
>> Collin
>>
>> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>>>
>>> Hi, working on my first django app, and run into a problem.
>>>
>>> I tend to create geodjango objects, and add all data from external
>>> tables with pk.
>>>
>>> Then I want to have different geometries 8points, lines, polygons) into
>>> a unique polymorphic class, can I do that?
>>>
>>> I have an error that I'll document later, and I'm trying to figure out
>>> what to do.
>>>
>>> Here is the model:
>>> import datetime
>>>
>>> from django.db import models
>>> from django.contrib.gis.db import models as geomodels
>>> from django.utils import timezone
>>> from django.forms import ModelForm
>>> from polymorphic import PolymorphicModel
>>>
>>> # Geometria linea da monitorare
>>> class geolinea(geomodels.Model):
>>> progetto = models.CharField(max_length=14, primary_key=True)
>>> geom = geomodels.MultiLineStringField()
>>> objects = geomodels.GeoManager()
>>> def __str__(self):
>>> return '%s' % (self.progetto)
>>> # Oggetto Progetto soggetto a PMA
>>> class linea(models.Model):
>>> progetto = models.ForeignKey(geolinea)
>>> nome = models.CharField(max_length=200)
>>> TENSIONE = (
>>> ('132', '132kV'),
>>> ('150', '150kV'),
>>> ('220', '220kV'),
>>> ('380', '380kV'),
>>> )
>>> tensione = models.CharField(max_length=5,
>>> choices=TENSIONE)
>>> def __str__(self):
>>> return '%s' % (self.nome)
>>>
>>> # Geometria dei pdm
>>> class pdmpunto(geomodels.Model):
>>> linea = models.ForeignKey(linea)
>>> numero = models.CharField(max_length=3)
>>> geom = geomodels.PointField()
>>> objects = geomodels.GeoManager()
>>>
>>> class pdmtransetto(geomodels.Model):
>>> linea = models.ForeignKey(linea)
>>> numero = models.CharField(max_length=3)
>>> geom = geomodels.LineStringField()
>>> objects = geomodels.GeoManager()
>>>
>>> class pdmarea(geomodels.Model):
>>> linea = models.ForeignKey(linea)
>>> numero = models.CharField(max_length=3)
>>> geom = geomodels.PolygonField()
>>> objects = geomodels.GeoManager()
>>>
>>> class pdm(PolymorphicModel):
>>> numero = models.CharField(max_length=14, primary_key=True)
>>> class punto(pdm):
>>> rifpunto = models.ForeignKey(pdmpunto)
>>> class transetto(pdm):
>>> riftransetto = models.ForeignKey(pdmtransetto)
>>> class area(pdm):
>>> rifarea = models.ForeignKey(pdmarea)
>>>
>>>
>>>
>>> --
> 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/cd243d25-0aff-446d-b9c9-cb5682d9bdf3%40googlegroups.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/CADTRxJNEAoP1Vn4tq2%3DpkZ_TDpt%2Bg_9xAjmQXQHQmYLjOk0GWA

Re: Polymorphic class and geomodels?

2016-02-05 Thread Luca Moiana
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/group/geodjango
>
> Collin
>
> On Monday, October 26, 2015 at 7:18:24 AM UTC-4, Luca Moiana wrote:
>>
>> Hi, working on my first django app, and run into a problem.
>>
>> I tend to create geodjango objects, and add all data from external tables 
>> with pk.
>>
>> Then I want to have different geometries 8points, lines, polygons) into a 
>> unique polymorphic class, can I do that?
>>
>> I have an error that I'll document later, and I'm trying to figure out 
>> what to do.
>>
>> Here is the model:
>> import datetime
>>
>> from django.db import models
>> from django.contrib.gis.db import models as geomodels
>> from django.utils import timezone
>> from django.forms import ModelForm
>> from polymorphic import PolymorphicModel
>>
>> # Geometria linea da monitorare
>> class geolinea(geomodels.Model):
>> progetto = models.CharField(max_length=14, primary_key=True)
>> geom = geomodels.MultiLineStringField()
>> objects = geomodels.GeoManager()
>> def __str__(self):
>> return '%s' % (self.progetto)
>> # Oggetto Progetto soggetto a PMA
>> class linea(models.Model):
>> progetto = models.ForeignKey(geolinea)
>> nome = models.CharField(max_length=200)
>> TENSIONE = (
>> ('132', '132kV'),
>> ('150', '150kV'),
>> ('220', '220kV'),
>> ('380', '380kV'),
>> )
>> tensione = models.CharField(max_length=5,
>> choices=TENSIONE)
>> def __str__(self):
>> return '%s' % (self.nome)
>>
>> # Geometria dei pdm
>> class pdmpunto(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.PointField()
>> objects = geomodels.GeoManager()
>>
>> class pdmtransetto(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.LineStringField()
>> objects = geomodels.GeoManager()
>>
>> class pdmarea(geomodels.Model):
>> linea = models.ForeignKey(linea)
>> numero = models.CharField(max_length=3)
>> geom = geomodels.PolygonField()
>> objects = geomodels.GeoManager()
>>
>> class pdm(PolymorphicModel):
>> numero = models.CharField(max_length=14, primary_key=True)
>> class punto(pdm):
>> rifpunto = models.ForeignKey(pdmpunto)
>> class transetto(pdm):
>> riftransetto = models.ForeignKey(pdmtransetto)
>> class area(pdm):
>> rifarea = models.ForeignKey(pdmarea)
>>
>>
>>
>>

-- 
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/cd243d25-0aff-446d-b9c9-cb5682d9bdf3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Handling cookies that contain illegal values

2016-02-05 Thread Will Harris
Hey Daniel,

Thanks for the reply. Unfortunately doing this in a custom middleware is 
not an option, as the this processing needs to take place at a very low 
level, at the point where the Request object is being built. By the time 
the request is passed in to the middleware layers for processing, the 
cookies would already have been lost.

Will

On Friday, February 5, 2016 at 12:31:30 AM UTC+1, Daniel Chimeno wrote:
>
> Hello, 
>
>>
>> I have resolved this in my instance as follows in django/http/cookie.py:
>>
>> def parse_cookie(cookie):
>> cookie = re.sub('[^\x20-\x7e]+', 'X', cookie)
>> ...
>>
>>
>>
>> It would be preferable to write that code in a middleware than in the 
> Django code itself.
> Before the middleware that handles the cookie (I guess it would be 
> Session), you can *sanitize* that cookie.
>
> Hope it helps.
>  
>

-- 
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/08dde6a1-1eb8-4428-906b-f619947ea8b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.