Re: How transform specific geometry column using Django GIS GeoQuerySet

2014-03-26 Thread Alex Mandel
On 03/26/2014 06:28 AM, Shoaib Ijaz wrote:
> Sorry i mistype queries
> 
>   Network.objects.transform(srid=3857).values('geometry', 'bbox')
>>
>>   SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
>> FROM "tbl_network"
>>
>>  Network.objects.transform(srid=3857).values('bbox')
>>
>>  SELECT "tbl_network"."bbox" FROM "tbl_network"
>>

You might get more responses on the GeoDjango mailing list:
geodja...@googlegroups.com

I think you syntax might be wrong.
https://docs.djangoproject.com/en/dev/ref/contrib/gis/gdal/#coordtransform

But since your mixing django code and SQL code it's hard to tell what
your doing.

Thanks,
Alex

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


Re: Geodjango and Python 3.3

2014-03-26 Thread Alex Mandel
You might get more responses on the GeoDjango mailing list:
geodja...@googlegroups.com

I agree the basic libraries probably all work. Are you sure you used
OSGeo4w with Python3? OSGeo4w ships 2.7.x, so unless the GDAL and GEOS
wrappers also work with Python3 that sounds odd.

pypi page makes it look like those libs work in Python3
https://pypi.python.org/pypi/GDAL/
https://pypi.python.org/pypi/Shapely (Infers Geos)

Thanks,
Alex

On 03/25/2014 05:34 PM, Sam Lai wrote:
> I'm developing a site using Python 3.3, Django, Geodjango and
> PostgreSQL. It is a bit tricky getting all the libraries to work, but
> the stack does work. I installed GEOS using OSGeo4W, but I had to
> explicitly specify the GEOS_LIBRARY_PATH and GDAL_LIBRARY_PATH in
> settings.py.
> 
> On 25 March 2014 23:28, rgreene  wrote:
>> Good day,
>>
>> I'm developing under Windows against a PostGIS database. On
>> https://docs.djangoproject.com/en/1.7/ref/contrib/gis/install/#windows,
>> Python 2.7 is shown in the installation steps. I've been reading up on
>> Python 3.3 (for instance, https://wiki.python.org/moin/Python2orPython3),
>> and as the development is just getting started I would like to go this route
>> if possible. Are their any packages/libraries in the typical
>> Geodjango/PostGIS statck that are not compatible with Python 3.3?
>>
>> Thanks in advance,
>> Randal
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5831a490-c1b6-4804-a09e-d99d79648a19%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53337086.6080804%40wildintellect.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making functions callable

2014-03-26 Thread Anthony Hawkes
Thanks Guys, especially Javier! I've spent so much time trawling Google for 
this info!

On Thursday, 27 March 2014 04:57:30 UTC+8, Anthony Hawkes wrote:
>
> Hi Guys,
>
> I'm running into a problem with django(I guess this would also affect 
> Python in general) where if I create a view eg
> def view(year=today.year())
> The year is never re-evaluated until the server is reloaded/restarted
>
> I'm trying to figure out how to make a callable method accessible as a 
> property if this is even possible to try and rectify this(not sure if this 
> is even the correct approach). I've had a look at some magic methods but 
> can't figure it out.
>
> Basically I want to make eg
>
> def year(something):
> return 'blah'
>
> Accessible using object.year as well as object.year()
>
> Any pointers/ideas etc?
>

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


Referring to the page -- https://docs.djangoproject.com/en/1.6/intro/tutorial01/

2014-03-26 Thread Dan Sveaver
https://docs.djangoproject.com/en/1.6/intro/tutorial01/

I've looked at this several times, and I was hoping to get the proverbial 
set of extra eyes.

I made it almost to the bottom of the page, but while I'm in the Python 
shell, I type the following:

>>> p = Poll.objects.get(pk=1)
>>> p.was_published_recently()


Here is the contents of the models.py file, which contains the Poll object.

import datetime
from django.utils import timezone

from django.db import models

# Create your models here

from django.db import models

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
*def was_published_recently(self):*
*return self.pub_date >= timezone.now() - 
datetime.timedelta(days=1)*

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self):
return self.choice_text

When I type  *>>> p.was_published_recently(), *I expected to see "True" 
because the published date satisfies the definition, but instead i'm 
presented with:

*AttributeError: 'Poll' object has no attribute 'was_published_recently'*


I'm new at this, so please forgive me if this seems like a silly question 
to ask.  Looking at the Poll class and the definition that I added, I'm not 
seeing why the AttributeError would be thrown.


I quadruple-checked for typos, too.  If anyone has an idea, please let me 
know.




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


Re: Making functions callable

2014-03-26 Thread Javier Guerra Giraldez
On Wed, Mar 26, 2014 at 5:53 PM, Anthony  wrote:
> I've yet to test it but I read a few people stating to use lambdas
> variables/properties. Is it definitely the case that it will only evaluate
> once?


from the python docs (2.7):

Default parameter values are evaluated when the function definition is
executed. This means that the expression is evaluated once, when the
function is defined, and that the same “pre-computed” value is used
for each call. This is especially important to understand when a
default parameter is a mutable object, such as a list or a dictionary:
if the function modifies the object (e.g. by appending an item to a
list), the default value is in effect modified. This is generally not
what was intended. A way around this is to use None as the default,
and explicitly test for it in the body of the function.

-- 
Javier

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


Re: Making functions callable

2014-03-26 Thread John DeRosa
Not sure what is going on without seeing the code. But something is None when 
it should be a string, as the exception is telling you.

It's often easiest to try out problem code interactively in Python, and zero in 
on the problem.

John


On Mar 26, 2014, at 3:53 PM, Anthony  wrote:

> Thanks John,
> 
> I've yet to test it but I read a few people stating to use lambdas 
> variables/properties. Is it definitely the case that it will only evaluate 
> once?
> 
> Either way I've embarked on the mission to make methods return as properties 
> and have found @property decorator to fit my needs, the issue was I was 
> calling Object.property not ObjectI().property, However I want to apply this 
> functionality to all my methods and am using:
> 
> __getattribute__
> 
> def __getattribute__(self, item):
> super(DateCalc, self).__getattribute__(item)
> 
> But I've run into the problem that my __init__ properties don't seem to be 
> initialised eg I get
> self._date_actual = datetime.strptime("{Y}-{m}-{d}".format(Y=year, m=month, 
> d=day), self._format_global).date() TypeError: must be string, not None
> 
> Anyone have an idea about what's going on?
> 
> 
> On Thu, Mar 27, 2014 at 5:07 AM, John DeRosa  wrote:
> For the default value to work as you expect, do this:
> 
> def view(request, year=None):
> if year is None:
> year = today.year()
> 
> 
> Kwarg defaults are evaluated when the module is interpreted for the first 
> time.
> 
> John
> 
> 
> On Mar 26, 2014, at 1:57 PM, Anthony Hawkes  wrote:
> 
>> Hi Guys,
>> 
>> I'm running into a problem with django(I guess this would also affect Python 
>> in general) where if I create a view eg
>> def view(year=today.year())
>> The year is never re-evaluated until the server is reloaded/restarted
>> 
>> I'm trying to figure out how to make a callable method accessible as a 
>> property if this is even possible to try and rectify this(not sure if this 
>> is even the correct approach). I've had a look at some magic methods but 
>> can't figure it out.
>> 
>> Basically I want to make eg
>> 
>> def year(something):
>> return 'blah'
>> 
>> Accessible using object.year as well as object.year()
>> 
>> Any pointers/ideas etc?
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> 
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/e7adace8-ffc9-4f77-b970-e73bed5ae8e1%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> 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/gcx1oTBAZlA/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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/FE30EAD3-E463-4379-B11C-970D86703AC3%40ipstreet.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> -- 
> Anthony Hawkes
> E-Mail: lifesillus...@gmail.com
> Ph: 0400 372 260
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CABqJoT1rSB4YeHQHiZH_4KNqMuub1THHyuzAvOCjas_Drz94sg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7BECE858-26BB-402C-A5DA-5A613F14FE1F%40ipstreet.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making functions callable

2014-03-26 Thread Mike Dewhirst

On 27/03/2014 7:57am, Anthony Hawkes wrote:

Hi Guys,

I'm running into a problem with django(I guess this would also affect
Python in general) where if I create a view eg
def view(year=today.year())
The year is never re-evaluated until the server is reloaded/restarted

I'm trying to figure out how to make a callable method accessible as a
property if this is even possible to try and rectify this(not sure if
this is even the correct approach). I've had a look at some magic
methods but can't figure it out.

Basically I want to make eg

def year(something):
 return 'blah'


You should be able to pass the callable as an argument. It then gets 
evaluated each time it is called ...


Here is one I use ... from time to time :)

def when():
return datetime.now(tz=pytz.utc)




Accessible using object.year as well as object.year()

Any pointers/ideas etc?

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/e7adace8-ffc9-4f77-b970-e73bed5ae8e1%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53335B04.4040701%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Making functions callable

2014-03-26 Thread Anthony
Thanks John,

I've yet to test it but I read a few people stating to use lambdas
variables/properties. Is it definitely the case that it will only evaluate
once?

Either way I've embarked on the mission to make methods return as
properties and have found @property decorator to fit my needs, the issue
was I was calling Object.property not ObjectI().property, However I want to
apply this functionality to all my methods and am using:

__getattribute__

def __getattribute__(self, item):
super(DateCalc, self).__getattribute__(item)

But I've run into the problem that my __init__ properties don't seem to be
initialised eg I get
self._date_actual = datetime.strptime("{Y}-{m}-{d}".format(Y=year, m=month,
d=day), self._format_global).date() TypeError: must be string, not None

Anyone have an idea about what's going on?


On Thu, Mar 27, 2014 at 5:07 AM, John DeRosa  wrote:

> For the default value to work as you expect, do this:
>
> def view(request, year=None):
> if year is None:
> year = today.year()
>
>
> Kwarg defaults are evaluated when the module is interpreted for the first
> time.
>
> John
>
>
> On Mar 26, 2014, at 1:57 PM, Anthony Hawkes 
> wrote:
>
> Hi Guys,
>
> I'm running into a problem with django(I guess this would also affect
> Python in general) where if I create a view eg
> def view(year=today.year())
> The year is never re-evaluated until the server is reloaded/restarted
>
> I'm trying to figure out how to make a callable method accessible as a
> property if this is even possible to try and rectify this(not sure if this
> is even the correct approach). I've had a look at some magic methods but
> can't figure it out.
>
> Basically I want to make eg
>
> def year(something):
> return 'blah'
>
> Accessible using object.year as well as object.year()
>
> Any pointers/ideas etc?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
>
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7adace8-ffc9-4f77-b970-e73bed5ae8e1%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> 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/gcx1oTBAZlA/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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/FE30EAD3-E463-4379-B11C-970D86703AC3%40ipstreet.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Anthony Hawkes
E-Mail: lifesillus...@gmail.com
Ph: 0400 372 260

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


Re: the best ways export datas for my project

2014-03-26 Thread Mike Dewhirst

On 27/03/2014 5:01am, carlos wrote:

Hi all,

What is de best ways for export data?

for example i have 3 apps, but apps 1 and 2 have relation with apps 1
and i want download data in only one file all data

APP1
class Model1(...):
 field1 = 
 field2 = ...

--

APP2
class Model2():
   fk = (Model1)
   field3 = ...
   field4 = 

-
APP3
class Model3():
 fk = (Model1)
 field5 = ...
 field6 = 

and now I would like to download my data so ( exclude all id )

field1 | field2  | field3 | field4  | field5  | field6

I do not care if excel or csv! for download

know any app that does this?


https://github.com/magopian/django-data-exports

https://docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata-app-label-app-label-app-label-model

https://github.com/bmihelac/django-import-export

... not necessarily in that order




any idea?

Cheers

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAM-7rO3kYckxS71ZZ7n%2BW1fwKmsiZKoiW_j3S2pQzmt6tedC4w%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53335893.3050509%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: How to keep each field changes history?

2014-03-26 Thread Mike Dewhirst

On 27/03/2014 5:00am, sanmugasundaram k wrote:

Hi,

I want to keep the history of each field changes. I think to do this ,
Insert one more record with changes.
To check the changes, i want to check each field or Django having any
function. If i am wrong correct me.


A quick google found ...

https://pypi.python.org/pypi/django-simple-history/

... and there are probably more out there.



Thanks,
Sanmugam

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/bd17704b-1ea5-4aef-a570-ae27955d5709%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53335741.1040004%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Making functions callable

2014-03-26 Thread John DeRosa
For the default value to work as you expect, do this:

def view(request, year=None):
if year is None:
year = today.year()


Kwarg defaults are evaluated when the module is interpreted for the first time.

John


On Mar 26, 2014, at 1:57 PM, Anthony Hawkes  wrote:

> Hi Guys,
> 
> I'm running into a problem with django(I guess this would also affect Python 
> in general) where if I create a view eg
> def view(year=today.year())
> The year is never re-evaluated until the server is reloaded/restarted
> 
> I'm trying to figure out how to make a callable method accessible as a 
> property if this is even possible to try and rectify this(not sure if this is 
> even the correct approach). I've had a look at some magic methods but can't 
> figure it out.
> 
> Basically I want to make eg
> 
> def year(something):
> return 'blah'
> 
> Accessible using object.year as well as object.year()
> 
> Any pointers/ideas etc?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e7adace8-ffc9-4f77-b970-e73bed5ae8e1%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/FE30EAD3-E463-4379-B11C-970D86703AC3%40ipstreet.com.
For more options, visit https://groups.google.com/d/optout.


Making functions callable

2014-03-26 Thread Anthony Hawkes
Hi Guys,

I'm running into a problem with django(I guess this would also affect 
Python in general) where if I create a view eg
def view(year=today.year())
The year is never re-evaluated until the server is reloaded/restarted

I'm trying to figure out how to make a callable method accessible as a 
property if this is even possible to try and rectify this(not sure if this 
is even the correct approach). I've had a look at some magic methods but 
can't figure it out.

Basically I want to make eg

def year(something):
return 'blah'

Accessible using object.year as well as object.year()

Any pointers/ideas etc?

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


the best ways export datas for my project

2014-03-26 Thread carlos
Hi all,

What is de best ways for export data?

for example i have 3 apps, but apps 1 and 2 have relation with apps 1
and i want download data in only one file all data

APP1
class Model1(...):
field1 = 
field2 = ...

--

APP2
class Model2():
  fk = (Model1)
  field3 = ...
  field4 = 

-
APP3
class Model3():
fk = (Model1)
field5 = ...
field6 = 

and now I would like to download my data so ( exclude all id )

field1 | field2  | field3 | field4  | field5  | field6

I do not care if excel or csv! for download

know any app that does this?

any idea?

Cheers

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


How to keep each field changes history?

2014-03-26 Thread sanmugasundaram k
Hi,

I want to keep the history of each field changes. I think to do this , 
Insert one more record with changes.
To check the changes, i want to check each field or Django having any 
function. If i am wrong correct me.

Thanks,
Sanmugam

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


Re: IntegrityError --- NOT NULL constraint failed: books_book.publication_date

2014-03-26 Thread Sami Razi
i used

python manage.py sqlall 

you're right sam, when i set null to true, it doesn't really change. 
thank you so very much.
i'm a newbie with databases and i don't know what statements sould i use... 
i don't know the syntax...
i would install south. thank you.

 thank you so very much.
but i'm a newbie with databases, should i type something like this in the 
dbshell? 

UPDATE BOOKS_BOOK SET PUBLICATION_DATE NULL=TRUE

On Wednesday, March 26, 2014 11:40:03 AM UTC-4, Sam Walters wrote:
>
> Did you perhaps change the schema of the database after you had created it.
>
> Eg: added null=True as a constraint after creating the table?
>

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


Re: IntegrityError --- NOT NULL constraint failed: books_book.publication_date

2014-03-26 Thread Sam Walters
Did you perhaps change the schema of the database after you had created it.

Eg: added null=True as a constraint after creating the table?

If so check the db sheme using:
python manage.py sqlall 

It sounds simple enough. You will have to go into the db shell and update
your schema manually.

using

python manage.py dbshell

If you're developing something where the schema is always getting modified
and you dont want to manually update table constraints
look into

django south addon.

hope this helps


On Wed, Mar 26, 2014 at 3:31 PM, Sami Razi  wrote:

>
>  i'm learning django using djangobook , in chapter
> 6, i'm having this error:
>
>   IntegrityError at /admin/books/book/add/
>
>   NOT NULL constraint failed: books_book.publication_date
>
>
> it seems i should set null=True for  publication_date field. but i did it 
> already, this is my models.py:
>
>
> from django.db import models
>
> class Publisher(models.Model):
> name = models.CharField(max_length=30)
> address = models.CharField(max_length=50)
> city = models.CharField(max_length=60)
> state_province = models.CharField(max_length=30)
> country = models.CharField(max_length=50)
> website = models.URLField()
>
> def __unicode__(self):
> return self.name
>
> class Author(models.Model):
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=40)
> email = models.EmailField(blank=True, verbose_name='e-mail')
>
> def __unicode__(self):
> return u'%s %s' % (self.first_name, self.last_name)
>
> class Book(models.Model):
> title = models.CharField(max_length=100)
> authors = models.ManyToManyField(Author)
> publisher = models.ForeignKey(Publisher)
>publication_date = models.DateField(blank=True, *null=True*)
>
> def __unicode__(self):
> return self.title
>
>
> what am i doing wrong?
> i googled the error message but didn't find a related answer.
> thank you for your 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/87ef0e56-f90f-4097-8a2c-e747ac874b71%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMbLS2-4SLs_OqCrKj4qQm_Xif2oDsCG97RJWDmrAFUR%2BCuxNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


IntegrityError --- NOT NULL constraint failed: books_book.publication_date

2014-03-26 Thread Sami Razi
   
 i'm learning django using djangobook , in chapter 
6, i'm having this error:

  IntegrityError at /admin/books/book/add/ 

  NOT NULL constraint failed: books_book.publication_date


it seems i should set null=True for  publication_date field. but i did it 
already, this is my models.py:

 
from django.db import models

class Publisher(models.Model):
name = models.CharField(max_length=30)
address = models.CharField(max_length=50)
city = models.CharField(max_length=60)
state_province = models.CharField(max_length=30)
country = models.CharField(max_length=50)
website = models.URLField()
  
def __unicode__(self):
return self.name
  
class Author(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField(blank=True, verbose_name='e-mail')
 
def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)
 
class Book(models.Model):
title = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
   publication_date = models.DateField(blank=True, *null=True*)
  
def __unicode__(self):
return self.title
  

what am i doing wrong?
i googled the error message but didn't find a related answer.
thank you for your 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87ef0e56-f90f-4097-8a2c-e747ac874b71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How transform specific geometry column using Django GIS GeoQuerySet

2014-03-26 Thread Shoaib Ijaz
Sorry i mistype queries

  Network.objects.transform(srid=3857).values('geometry', 'bbox')
>
>   SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
> FROM "tbl_network"
>
>  Network.objects.transform(srid=3857).values('bbox')
>
>  SELECT "tbl_network"."bbox" FROM "tbl_network"
>
>
>

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


How transform specific geometry column using Django GIS GeoQuerySet

2014-03-26 Thread Shoaib Ijaz


I am trying to transform geometry column type in django, here is my model

class Network(models.Model):
name = models.CharField(max_length=50, blank=True)
alias = models.CharField(max_length=100, blank=True)
geometry = models.GeometryField(srid=3857, null=True, blank=True)
bbox = models.GeometryField(srid=3857, null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'tbl_network'

def __unicode__(self):
return '%s' % self.name

Problem is that when i tried to transform bbox it does not transform it

  Network(srid=3857).values('geometry','bbox')

  SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
FROM "tbl_network"

Above query automaticly tranform geomtery field and igonre bbox field

So i tried it different different way

 Network(srid=3857).values('bbox')

 SELECT "tbl_network"."bbox" FROM "tbl_network"

Now this query totally ignored transform function.

So my questions is,

How can i transform specific column of model?

thank you

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


Django admin inline forms

2014-03-26 Thread Andreas Kuhne
Hi all,

I have 2 models that look something like this:

class Address(models.Model):
address_row1 = models.CharField(max_length=200, null=True, blank=True)
address_row2 = models.CharField(max_length=200, null=True, blank=True)
postal_code = models.CharField(max_length=30, null=True, blank=True)
city = models.CharField(max_length=80, null=True, blank=True)
state = models.ForeignKey(USState, null=True, blank=True)
country = models.CharField(max_length=2, null=True, blank=True,
choices=regional.COUNTRY_CODES)

class Customer(AbstractUser):
company = models.CharField('company', max_length=100, null=True,
blank=True)
phone = models.CharField('phone', max_length=80, null=True, blank=True)
cellphone = models.CharField('cell phone', max_length=80, null=True,
blank=True)

newsletter = models.BooleanField('newsletter', default=True)

billing_address_same_as_shipping = models.BooleanField(default=True)
shipping_address = models.ForeignKey(Address, null=True, blank=True,
related_name="shipping_address")
billing_address = models.ForeignKey(Address, null=True, blank=True,
related_name="billing_address")

So the Customer model has 2 foreignkeys to the Address model. What I would
like to do in django admin is have the ability to add address models to the
customer model. This is of course the way it is from the beginning, however
I don't want a dropdown list to choose the address from, I want to be able
to edit the address model inline, and add one inline if it doesn't exist.
How would I be able to do that with the admin interface?

I don't want to have to create an Address object and then choose it from
the dropdown list. What I want to be able to do is edit the Address object
directly in the Customer object if the Address object exists and then be
able to add one if it doesn't.

Regards,

Andréas

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