Re: Django admin multiple company accounts

2011-10-20 Thread Kevin
There is no need to implement the same CRUD over and over again with
the help of generic views and signals. :)

https://docs.djangoproject.com/en/1.3/ref/class-based-views/

Mind you, I've only used these generic views in 1.2 and never yet took
some time to learn the new class-based one.  Although the class-based
one seems much more flexible to implement a CRUD with very little
work.

Signals will help for when you do updates in the database, it can auto-
fill information that should be set, such as the user saving the
entry.

https://docs.djangoproject.com/en/1.3/topics/signals/

A Django app that I think will help you realize this fine grained type
of database layout would be django-guardian.  This way you can set
permissions and group assignments per row object.  The admin interface
can even be coded to respect it as well, for managers who need more
fine grain controls to do edits at a low-level.  You can use a signal
to assign the user's group to the object they just created.  Each
company can be assigned a group, and the objects owned by that company
can be assigned to their specific group.  The users in that company
can be part of the company/branch group.  Django-guardian is very
flexible and would be the easiest way(in my eyes) to implement this
type of system you seek to make.

https://github.com/lukaszb/django-guardian

Read the docs for it here:

http://packages.python.org/django-guardian/

Hope this helps.

On Oct 20, 4:43 am, "zzart...@googlemail.com"
 wrote:
> Thanks for your time Mike, Cal, Andre!
> I had suspected that general consensus will be don't use admin :)
> still I had to ask. When i write down all the features admin has and
> features  i will need to be created on top of admin somehow,  i've
> come to the same conclusions. Still it hurts me a lot to be
> implementing the same old CRUD over and over again.
> Anyhow, thanks for sharing !
> mars
>
> On 19 Paź, 18:56, Mike Seidle  wrote:
>
>
>
>
>
>
>
> > On Wednesday, October 19, 2011 02:10:49 PM Andre Terra wrote this and sent 
> > it
> > to To: django-users@googlegroups.com::
>
> > > > To be honest, you're probably (not 100% sure) creating *more* work for
> > > > yourself trying to make something like this work in django admin, than
> > > > just designing something for yourself (YMMV).
>
> > > I couldn't agree more. Too often I see newcomers learning how to extend 
> > > the
> > > admin, when it would actually be easier to roll out their own views, not 
> > > to
> > > mention how they would be learning how to use the framework rather than a
> > > built-in app.
>
> > It's so easy to think Django-Admin is the answer.  Django's admin is a few
> > steps up from PHPMyAdmin or some other SQL GUI tool. Uless your use case for
> > your user is precicely a create, read, update and delete interface to your
> > data as represented by your model definitions, you probably will not have 
> > the
> > moving parts you need to implement what you want... The minute you want
> > more/different, is (most of the time) literally less work to just roll your 
> > own
> > view and template which will give you much more control of the user 
> > experience
> > and avoid the inevitable complaints about "why aren't totals at the bottom 
> > of
> > tables? How come we have to used this wonky Year/Month/Date drill down?
>
> > --- Mike

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



Re: default form template

2011-10-20 Thread bino oetomo

On 10/21/2011 10:49 AM, bino oetomo wrote:

On 10/21/2011 10:31 AM, Venkatraman S wrote:
https://docs.djangoproject.com/en/dev/topics/forms/#displaying-a-form-using-a-template 



For inserting javascript, why you have to 'extend'; use jquery and do 
the

needful with the form!


Kindly please give me more about how to do it



Argh ...
Acording to https://docs.djangoproject.com/en/dev/topics/forms/media/

Is it mean that I can write a java script, put in in "media" dir  
and use "class Media" to call it ?


Sincerely
-bino-

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



Re: default form template

2011-10-20 Thread bino oetomo

On 10/21/2011 10:31 AM, Venkatraman S wrote:


Its Django :) (though we call it as 'django'(with 'd' being silent).


Hahaha ... I Apologize for my typo.


https://docs.djangoproject.com/en/dev/topics/forms/#displaying-a-form-using-a-template

For inserting javascript, why you have to 'extend'; use jquery and do the
needful with the form!


Kindly please give me more about how to do it

Sincerely
-bino-

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



Re: Doing a relationship lookup from within a model.

2011-10-20 Thread Venkatraman S
On Tue, Oct 18, 2011 at 8:22 PM, Jack Morgan wrote:

> I've got 2 tables that are related to each other. Orders and History.
> Inside the History table is the 'status' column. Like so..
>
> class Orders(models.Model):
>   'order info'
>
> class History(models.Model):
> timestamp = models.DateTimeField(auto_add_now = True)
> order = models.ForeignKey(Orders)
> user = models.ForeignKey(User)
> comment = models.TextField()
> status = models.CharField(max_length = 20)
>
>
> I'm storing the status in the History table right now because I need to
> keep track of who is moving the orders along.  However, I need to do a
> lookup on orders based on their current(most recent) status.  For
> simplicities purpose it seems a good idea would be to just put a status
> field in the Orders table and update as the Order advances through the
> stages. However, that creates duplicate data, which my client has expressed
> an extreme hatred for.
>
> What It's like to be able to do is something like:
> o = Orders.filter(status = 'new')
>
> I'm not entirely sure how or when relationship managers are brought in, so
> I was thinking something like this in the Orders model:
> status = self.history_set.values('status').order_by('-id')[0]['status']
>
> But that wouldn't let me do a lookup by state.
>
> What's a good Django way to handle this issue?
>

Having the status field in the Order's column is the elegant way to do it.
History model,  should be like a revision-holder; mainly used for auditing.

-V
http://blizzardzblogs.blogspot.com/

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



Re: sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-20 Thread Venkatraman S
On Thu, Oct 20, 2011 at 11:47 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> So, just out of curiosity, how many other people didn't realise you
> could do this:
>
> >>> print '%(language)s has %(number)03d quote types.' % \
> ...   {"language": "Python", "number": 2}
>
>
> Instead of this:
>
> print "%s has %03d" % ( "python", "2" )
>
> 6 years of python development, and I never found this little beauty. Fail.
>
> Hope this helps someone else.
>

I use a similar thingy for the ORM queries. Named arguments help in good
readability, especially in complex queries.

-V
http://blizzardzblogs.blogspot.com/

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



Re: automatic models.py generation

2011-10-20 Thread Venkatraman S
On Fri, Oct 21, 2011 at 3:33 AM, Xangó3007  wrote:

> I want to generate models.py file from  a mysql database, (inverse
> reengineering). Can you show me how to do it? Thanks. Xangó from Spain
>
>
How complex is your schema, and what is the intent of doing this exercise?
For some reason, i dont think this is a good exercise, and if at all you
have to do it, i would rather hand-curate it.

-V
http://blizzardzblogs.blogspot.com/

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



Re: default form template

2011-10-20 Thread Venkatraman S
On Fri, Oct 21, 2011 at 8:13 AM, bino oetomo wrote:

> I'm learning (well ... reading) the jango template files.
>

Its Django :) (though we call it as 'django'(with 'd' being silent).


> I'm looking for the default Form templates.
>
> If I want to just insert a simple javascript to all autogenerated Form,
> what template file do I have to extend ?
>

https://docs.djangoproject.com/en/dev/topics/forms/#displaying-a-form-using-a-template

For inserting javascript, why you have to 'extend'; use jquery and do the
needful with the form!

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



Re: Django ORM - Am I trying to do the impossible?

2011-10-20 Thread Venkatraman S
On Fri, Oct 21, 2011 at 1:54 AM, Paolo  wrote:

> Any pointers would be appreciated - I'm not too excited about storing the
> latest_assignment_update_id in my Assignment model!!
>

Why need to store this?

If i understand the requirement right,  the status of the Assignement is
based on the last-assignment-update. So, every update has an associated
'status' field? - right?  If yes(which looks wrong to me, as the status
should be for the assignment and not for the update), then you need order by
desc on the last-update, and pick the top record.

I will wait to hear more from you before i jump the gun :)

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



default form template

2011-10-20 Thread bino oetomo

Dear All.

I'm learning (well ... reading) the jango template files.

I'm looking for the default Form templates.

If I want to just insert a simple javascript to all autogenerated Form, 
what template file do I have to extend ?


Sincerely
-bino-


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



Re: Radio button with nested widget

2011-10-20 Thread Kurtis Mullins
You could just create a form with two upload fields and a char field. And
then use Javascript w/ Radio buttons to disable/enable those fields.

On Thu, Oct 20, 2011 at 12:02 PM, Leonardo Giordani <
giordani.leona...@gmail.com> wrote:

> Hi all,
>
> I'm trying to implement the following form: a first ChoiceField with values
> "mode 1", "mode 2" or "manual".
>
> Depending on its value I need to show a FileUpload field (mode1 or mode2)
> or some CharFields (mode3).
>
> I'm trying to mimic a desktop GUI, where you can three radio button and
> each can contain something: a file upload the first two, some text fields
> the third.
>
> Some advices?
>
> Thank you
>
> Leo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: automatic models.py generation

2011-10-20 Thread Kurtis Mullins
I don't think it would be easily possible to do this with Django's ORM...
but of course that depends on how your database is setup in the first place.
Depending on your data-size, you might have better luck just building new
Models and migrating your data.

On Thu, Oct 20, 2011 at 8:51 PM, Sebastian Goll wrote:

> On Thu, 20 Oct 2011 15:03:33 -0700 (PDT)
> Xangó3007  wrote:
>
> > I want to generate models.py file from  a mysql database, (inverse
> > reengineering). Can you show me how to do it? Thanks. Xangó from Spain
>
> (django-admin/manage).py "inspectdb" [1] is your friend.
>
> Sebastian.
>
> [1] https://docs.djangoproject.com/en/1.3/ref/django-admin/#inspectdb
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: automatic models.py generation

2011-10-20 Thread Sebastian Goll
On Thu, 20 Oct 2011 15:03:33 -0700 (PDT)
Xangó3007  wrote:

> I want to generate models.py file from  a mysql database, (inverse
> reengineering). Can you show me how to do it? Thanks. Xangó from Spain

(django-admin/manage).py "inspectdb" [1] is your friend.

Sebastian.

[1] https://docs.djangoproject.com/en/1.3/ref/django-admin/#inspectdb

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



automatic models.py generation

2011-10-20 Thread Xangó3007
I want to generate models.py file from  a mysql database, (inverse
reengineering). Can you show me how to do it? Thanks. Xangó from Spain

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



Re: Templates available to a cluster

2011-10-20 Thread Konstantinos Pachnis
Hello,

I had the same problem, but not a clue how to implement this.
After Donald mentioned that the template system uses pluggable loaders,
I spent some time to create one for my own use. It's very basic, but at
least I believe it demonstrates how to create a template loader.

Kurtis, you can find the plugin at
https://github.com/jezdez/django-dbtemplates.



Basic database loader snippet link: http://dpaste.com/638238/


> 
>
>   Javier Guerra Giraldez 
> October 20, 2011 01:59
>
>
> On Wed, Oct 19, 2011 at 5:17 PM, Kurtis Mullins
>
> note that 'document' in MongoDB parlance means 'complex document', as
> in 'more complex than a field'. in this case, the template is just a
> (long?) text string. any good DB (relational or not) should perform
> similarly, given the same hardware.
>
> 
>
>   Kurtis Mullins 
> October 20, 2011 01:17
>
>
> Good idea. I'm going to check out MongoDB for this. Looks like there's
> already some Django tools for it out there.
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
>
>   Donald Stufft 
> October 20, 2011 00:57
>
>
> If I wanted maximum performance from a distributed on the fly template
> system. I'd probably store them in a fast document db.
>
> On Wednesday, October 19, 2011 at 5:54 PM, Kurtis Mullins wrote:
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
>
>   Kurtis Mullins 
> October 20, 2011 00:54
>
>
> Very true, I could definitely implement it as a pluggable loader. I'll
> try to find the DB Template Loader too. I'm mainly concerned with this
> being a large bottle neck for our front-facing pages so I'm not sure
> which path to choose. Maybe some R is in order :) Thanks!
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
>
>   Donald Stufft 
> October 20, 2011 00:52
>
>
> The template system uses pluggable loaders that can locate a template
> based upon it's name. So using that you can store your template
> anywhere. There is already an app for storing templates in the db, you
> could easily make one to store it somewhere else as well.
>
> On Wednesday, October 19, 2011 at 5:48 PM, Kurtis wrote:
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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

<>

Re: Strange traceback: DoesNotExist not callable

2011-10-20 Thread Alasdair Nicol

Hi João and Torsten,

On 20/10/11 18:53, João Pedro Francese wrote:

I've just stumbled upon the same problem in my code. I have no clue on
why it happened either. Did you ever get any progress on investigating
this issue?

Regards,
Joao

On Oct 7, 12:31 pm, Torsten Bronger
wrote:

Hall chen!

I examine a traceback that ends with

 ...

   File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 
351,
 in get
 % (self.model._meta.object_name, num, kwargs))

 TypeError: 'DoesNotExist'objectisnotcallable

The error-triggering source code in query.py says

 def get(self, *args, **kwargs):
 """
 Performs the query and returns a singleobjectmatching the given
 keyword arguments.
 """
 clone = self.filter(*args, **kwargs)
 if self.query.can_filter():
 clone = clone.order_by()
 num = len(clone)
 if num == 1:
 return clone._result_cache[0]
 ifnotnum:
 raise self.model.DoesNotExist("%s matching query doesnotexist."
 % self.model._meta.object_name)
 raise self.model.MultipleObjectsReturned("get() returned more than one %s 
-- it returned %s! Lookup parameters were %s"
 % (self.model._meta.object_name, num, kwargs))

The last line triggers the error.  This is strange for two reasons:
First,DoesNotExistshould becallablefor all models.  And
secondly, there is noDoesNotExistin the last line but a
MultipleObjectsReturned.

My source code that is responsible for the error is:

 try:
 sample = self.samples.get()   # Here, the TypeError occurs
 except (Sample.DoesNotExist, Sample.MultipleObjectsReturned):
 pass
I've been caught out by this error before. In my case it was because I 
was not catching exceptions correctly *elsewhere* in my code. In another 
view, I had something like


try:
sample = self.samples.get()   # Here, the TypeError occurs
except Sample.DoesNotExist, Sample.MultipleObjectsReturned:
   pass

Without the parenthesis, it's equivalent to the following in Python 2.6+

except Sample.DoesNotExist as Sample.MultipleObjectsReturned:

The instance of the DoesNotExist exception overwrites 
Sample.MultipleObjectsReturned!


When the same process is handles a different request later on, you get 
the type error because your code is trying to call the DoesNotExist 
instance which has replaced Sample.MultipleObjectsReturned.


tschüss,

Alasdair

--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, 
Surrey, GU2 7YD, UK.

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



Django ORM - Am I trying to do the impossible?

2011-10-20 Thread Paolo
Hi all,

I'm developing a Django app that has a slightly complex model, as follows:

Teams have Assignments, which in turn have Assignment Updates.  The status 
of the Assignment (and therefore the Team) is based on the latest Assignment 
Update, which has a status of ACTIVE, STANDBY etc.

My issue is I've found it impossible so far to retrieve the current Status 
for a group of Teams/Assignments without resorting to loading everything 
into the app and processing, or (as I've actually done to get around the 
impending speed issues) have fields which act as 'pointers' to the latest 
Status Report for each Assignment.

The problem comes when I try and pull the assignment update id of the 
record.  It seems that when I use the "annotate" method, I can only get the 
value I'm grouping by (assignment_id) and the max value - if I try and pull 
out the assignment_update_id (e.g. the thing I'm interested in), the ORM 
just pulls back all records?

Broken code is something like the following:

Assignment.objects.filter(id__in=AssignmentUpdate.objects.filter(id__in=AssignmentUpdate.objects.filter(actual_report_time__isnull=False).values('assignment_id').annotate(actual_report_time=Max('actual_report_time')).values_list('id',
 
flat=True), status=ASSIGNMENT_STANDBY).values_list('assignment_id', 
flat=True)) 

Any pointers would be appreciated - I'm not too excited about storing the 
latest_assignment_update_id in my Assignment model!!

Thanks,

Paul

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



Re: Date and time picker in Django

2011-10-20 Thread Kurtis Mullins
ahh okay, haha sorry!

On Thu, Oct 20, 2011 at 4:13 PM, Mario Gudelj wrote:

> Yeah, that's the one i mentioned that doesn't work for me for some reason
>
> On 21/10/2011 7:10 AM, "Kurtis Mullins"  wrote:
>
>> No problem. I honestly haven't had to use a time picker, yet. But a quick
>> google search brought this up:
>> http://trentrichardson.com/examples/timepicker/ It seems to work w/ the
>> Jquery-ui Datepicker.
>>
>> On Thu, Oct 20, 2011 at 4:05 PM, Mario Gudelj wrote:
>>
>>> Thanks Kurtis. What do you use as a time picker?
>>>
>>> On 21/10/2011 6:39 AM, "Kurtis"  wrote:
>>>
 I just use Jquery-UI DatePicker http://jqueryui.com/demos/datepicker/

 On Oct 20, 7:46 am, Mario Gudelj  wrote:
 > Hi guys,
 >
 > I'm looking for a date/time picker that I can use in my web forms.
 I've used
 > DateTimeField in my models and have to implement date in this format
 > "2011-10-19 21:34". I have implementedhttp://
 trentrichardson.com/examples/timepicker/o my site and it kind of
 > works in a sense that the picker comes up and it fills the form field
 with
 > the date, but for some reason the form is not validated and I can't
 save it.
 > If I enter the date in the same format manually it works. I also has a
 look
 > at the POST request and the date is there, so for the life of me I
 can't
 > figure this one out.
 >
 > If anyone know of another jQuery date/time picker I could use for the
 format
 > I need that would be most appreciated!
 >
 > Thanks djangoers!
 >
 > Mario

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

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

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



Re: Date and time picker in Django

2011-10-20 Thread Mario Gudelj
Yeah, that's the one i mentioned that doesn't work for me for some reason

On 21/10/2011 7:10 AM, "Kurtis Mullins"  wrote:

> No problem. I honestly haven't had to use a time picker, yet. But a quick
> google search brought this up:
> http://trentrichardson.com/examples/timepicker/ It seems to work w/ the
> Jquery-ui Datepicker.
>
> On Thu, Oct 20, 2011 at 4:05 PM, Mario Gudelj wrote:
>
>> Thanks Kurtis. What do you use as a time picker?
>>
>> On 21/10/2011 6:39 AM, "Kurtis"  wrote:
>>
>>> I just use Jquery-UI DatePicker http://jqueryui.com/demos/datepicker/
>>>
>>> On Oct 20, 7:46 am, Mario Gudelj  wrote:
>>> > Hi guys,
>>> >
>>> > I'm looking for a date/time picker that I can use in my web forms. I've
>>> used
>>> > DateTimeField in my models and have to implement date in this format
>>> > "2011-10-19 21:34". I have implementedhttp://
>>> trentrichardson.com/examples/timepicker/o my site and it kind of
>>> > works in a sense that the picker comes up and it fills the form field
>>> with
>>> > the date, but for some reason the form is not validated and I can't
>>> save it.
>>> > If I enter the date in the same format manually it works. I also has a
>>> look
>>> > at the POST request and the date is there, so for the life of me I
>>> can't
>>> > figure this one out.
>>> >
>>> > If anyone know of another jQuery date/time picker I could use for the
>>> format
>>> > I need that would be most appreciated!
>>> >
>>> > Thanks djangoers!
>>> >
>>> > Mario
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Date and time picker in Django

2011-10-20 Thread Kurtis Mullins
No problem. I honestly haven't had to use a time picker, yet. But a quick
google search brought this up:
http://trentrichardson.com/examples/timepicker/ It seems to work w/ the
Jquery-ui Datepicker.

On Thu, Oct 20, 2011 at 4:05 PM, Mario Gudelj wrote:

> Thanks Kurtis. What do you use as a time picker?
>
> On 21/10/2011 6:39 AM, "Kurtis"  wrote:
>
>> I just use Jquery-UI DatePicker http://jqueryui.com/demos/datepicker/
>>
>> On Oct 20, 7:46 am, Mario Gudelj  wrote:
>> > Hi guys,
>> >
>> > I'm looking for a date/time picker that I can use in my web forms. I've
>> used
>> > DateTimeField in my models and have to implement date in this format
>> > "2011-10-19 21:34". I have implementedhttp://
>> trentrichardson.com/examples/timepicker/o my site and it kind of
>> > works in a sense that the picker comes up and it fills the form field
>> with
>> > the date, but for some reason the form is not validated and I can't save
>> it.
>> > If I enter the date in the same format manually it works. I also has a
>> look
>> > at the POST request and the date is there, so for the life of me I can't
>> > figure this one out.
>> >
>> > If anyone know of another jQuery date/time picker I could use for the
>> format
>> > I need that would be most appreciated!
>> >
>> > Thanks djangoers!
>> >
>> > Mario
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Date and time picker in Django

2011-10-20 Thread Mario Gudelj
Thanks Kurtis. What do you use as a time picker?

On 21/10/2011 6:39 AM, "Kurtis"  wrote:

> I just use Jquery-UI DatePicker http://jqueryui.com/demos/datepicker/
>
> On Oct 20, 7:46 am, Mario Gudelj  wrote:
> > Hi guys,
> >
> > I'm looking for a date/time picker that I can use in my web forms. I've
> used
> > DateTimeField in my models and have to implement date in this format
> > "2011-10-19 21:34". I have implementedhttp://
> trentrichardson.com/examples/timepicker/o my site and it kind of
> > works in a sense that the picker comes up and it fills the form field
> with
> > the date, but for some reason the form is not validated and I can't save
> it.
> > If I enter the date in the same format manually it works. I also has a
> look
> > at the POST request and the date is there, so for the life of me I can't
> > figure this one out.
> >
> > If anyone know of another jQuery date/time picker I could use for the
> format
> > I need that would be most appreciated!
> >
> > Thanks djangoers!
> >
> > Mario
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Date and time picker in Django

2011-10-20 Thread Kurtis
I just use Jquery-UI DatePicker http://jqueryui.com/demos/datepicker/

On Oct 20, 7:46 am, Mario Gudelj  wrote:
> Hi guys,
>
> I'm looking for a date/time picker that I can use in my web forms. I've used
> DateTimeField in my models and have to implement date in this format
> "2011-10-19 21:34". I have 
> implementedhttp://trentrichardson.com/examples/timepicker/o my site and it 
> kind of
> works in a sense that the picker comes up and it fills the form field with
> the date, but for some reason the form is not validated and I can't save it.
> If I enter the date in the same format manually it works. I also has a look
> at the POST request and the date is there, so for the life of me I can't
> figure this one out.
>
> If anyone know of another jQuery date/time picker I could use for the format
> I need that would be most appreciated!
>
> Thanks djangoers!
>
> Mario

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



Field.Choices in Template

2011-10-20 Thread Kurtis
Hey,

I'm trying to build a custom template for my ModelForm. My ModelForm
contains several M2M fields. If I run the ModelForm.as_view and then
in my template print {{ form.as_p }} it'll automagically display those
choices.

Now what I want to do is take advantage of that magic and print out
those choices myself in my template. For example:

{% for choice in form.genres.choices %}
{{ choice }}
{% endfor %}

... but it doesn't work. it doesn't print anything. I tried reading
through the source code of the forms.py and fields.py from 1.3 but
didn't get very far.

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



Re: sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-20 Thread Cal Leeming [Simplicity Media Ltd]
Damn right - too many times have my sprintf's ended up looking so ugly
- it was borderline bad code.

Goes to show, no matter how long you've used something, even if it's
day in day out, there's always something new to learn!

On Thu, Oct 20, 2011 at 7:52 PM, Bill Freeman  wrote:
> On Thu, Oct 20, 2011 at 2:21 PM, Tim Chase
>  wrote:
>> On 10/20/11 13:17, Cal Leeming [Simplicity Media Ltd] wrote:
>>>
>>> So, just out of curiosity, how many other people didn't realise you
>>> could do this:
>>>
>> print '%(language)s has %(number)03d quote types.' % \
>>>
>>> ...       {"language": "Python", "number": 2}
>>>
>>>
>>> Instead of this:
>>>
>>> print "%s has %03d" % ( "python", "2" )
>>
>> Also very useful in translations where the order of the pieces may have to
>> change, allowing the translator to put them where needed rather than
>> constraining the translator to the order in which the data is passed.
>>
>> -tkc
>
> And fantasticly useful when a given value is needed more than once
> in a string, or when you have a collection of available values and a
> passed in or chosen format string, such that some values may not
> be used at all.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-20 Thread Bill Freeman
On Thu, Oct 20, 2011 at 2:21 PM, Tim Chase
 wrote:
> On 10/20/11 13:17, Cal Leeming [Simplicity Media Ltd] wrote:
>>
>> So, just out of curiosity, how many other people didn't realise you
>> could do this:
>>
> print '%(language)s has %(number)03d quote types.' % \
>>
>> ...       {"language": "Python", "number": 2}
>>
>>
>> Instead of this:
>>
>> print "%s has %03d" % ( "python", "2" )
>
> Also very useful in translations where the order of the pieces may have to
> change, allowing the translator to put them where needed rather than
> constraining the translator to the order in which the data is passed.
>
> -tkc

And fantasticly useful when a given value is needed more than once
in a string, or when you have a collection of available values and a
passed in or chosen format string, such that some values may not
be used at all.

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



Re: sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-20 Thread Tim Chase

On 10/20/11 13:17, Cal Leeming [Simplicity Media Ltd] wrote:

So, just out of curiosity, how many other people didn't realise you
could do this:


print '%(language)s has %(number)03d quote types.' % \

...   {"language": "Python", "number": 2}


Instead of this:

print "%s has %03d" % ( "python", "2" )


Also very useful in translations where the order of the pieces 
may have to change, allowing the translator to put them where 
needed rather than constraining the translator to the order in 
which the data is passed.


-tkc



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



Re: Strange traceback: DoesNotExist not callable

2011-10-20 Thread Torsten Bronger
Hallöchen!

João Pedro Francese writes:

> I've just stumbled upon the same problem in my code. I have no
> clue on why it happened either. Did you ever get any progress on
> investigating this issue?

No, I have not investigated this further so far.  (But I still know
how to reproduce it.)  At first, it *looks* like a CPython
interpreter bug.  But I have to reduce it to a minimal example
before I can tell more.  Maybe next week.

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



sprintf in python (not strictly django, but used all the time in django webapps)

2011-10-20 Thread Cal Leeming [Simplicity Media Ltd]
So, just out of curiosity, how many other people didn't realise you
could do this:

>>> print '%(language)s has %(number)03d quote types.' % \
...   {"language": "Python", "number": 2}


Instead of this:

print "%s has %03d" % ( "python", "2" )

6 years of python development, and I never found this little beauty. Fail.

Hope this helps someone else.

Cal

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



Re: Strange traceback: DoesNotExist not callable

2011-10-20 Thread João Pedro Francese
I've just stumbled upon the same problem in my code. I have no clue on
why it happened either. Did you ever get any progress on investigating
this issue?

Regards,
Joao

On Oct 7, 12:31 pm, Torsten Bronger 
wrote:
> Hall chen!
>
> I examine a traceback that ends with
>
>     ...
>
>       File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 
> 351,
>     in get
>         % (self.model._meta.object_name, num, kwargs))
>
>     TypeError: 'DoesNotExist'objectisnotcallable
>
> The error-triggering source code in query.py says
>
>     def get(self, *args, **kwargs):
>         """
>         Performs the query and returns a singleobjectmatching the given
>         keyword arguments.
>         """
>         clone = self.filter(*args, **kwargs)
>         if self.query.can_filter():
>             clone = clone.order_by()
>         num = len(clone)
>         if num == 1:
>             return clone._result_cache[0]
>         ifnotnum:
>             raise self.model.DoesNotExist("%s matching query doesnotexist."
>                     % self.model._meta.object_name)
>         raise self.model.MultipleObjectsReturned("get() returned more than 
> one %s -- it returned %s! Lookup parameters were %s"
>                 % (self.model._meta.object_name, num, kwargs))
>
> The last line triggers the error.  This is strange for two reasons:
> First,DoesNotExistshould becallablefor all models.  And
> secondly, there is noDoesNotExistin the last line but a
> MultipleObjectsReturned.
>
> My source code that is responsible for the error is:
>
>     try:
>         sample = self.samples.get()   # Here, the TypeError occurs
>     except (Sample.DoesNotExist, Sample.MultipleObjectsReturned):
>         pass
>
> "self" is a model instance.  "samples" is a M2M field of "self" to
> the class "Sample".  In my case, ther are 20 samples connected with
> the "self" instances, so raising a MultipleObjectsReturned would be
> correct.
>
> Does anybody have an idea what is going on here?  How should I
> proceed with debugging?
>
> Tsch ,
> Torsten.
>
> --
> Torsten Bronger    Jabber ID: torsten.bron...@jabber.rwth-aachen.de
>                                   orhttp://bronger-jmp.appspot.com

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



Re: load-on-startup equivalent in django?

2011-10-20 Thread Jacco Flenter
Another option is to create a command and run it via a cronjob

On Thu, Oct 20, 2011 at 2:55 PM, kenneth gonsalves 
wrote:
>
> On Thu, 2011-10-20 at 13:38 +0800, Ken wrote:
> > I wonder how do I do the same in django framework. Or there is some
> > other way to run some background code periodicly?
>
> look at djcelery
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Radio button with nested widget

2011-10-20 Thread Leonardo Giordani
Hi all,

I'm trying to implement the following form: a first ChoiceField with values
"mode 1", "mode 2" or "manual".

Depending on its value I need to show a FileUpload field (mode1 or mode2) or
some CharFields (mode3).

I'm trying to mimic a desktop GUI, where you can three radio button and each
can contain something: a file upload the first two, some text fields the
third.

Some advices?

Thank you

Leo

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



Re: Doing a relationship lookup from within a model.

2011-10-20 Thread Bill Freeman
Don't you have an issue in that History is many to on on Orders,
so an order has multiple states?  Unless you're expunging History
(in which case, isn't it mis-named?) or changing state in all of an
Order's History instances (in which case don't you lose you audit
trail), all Order's will have a History instance with status 'new'.

While I think you could filter Orders using history_set__status='new'
and maybe other things (such as filtering on History with select_related)
I'm not sure that's really what you want.

If it were I, I'd have status in the Orders model (and I'd be calling it
Order, not Orders) ALSO.  That's not denormalization.  status in
History is the state when the history event happended.  status in
Orders is the current status.

Bill

On Tue, Oct 18, 2011 at 10:52 AM, Jack Morgan  wrote:
> I've got 2 tables that are related to each other. Orders and History.
> Inside the History table is the 'status' column. Like so..
>
> class Orders(models.Model):
>   'order info'
>
> class History(models.Model):
>     timestamp = models.DateTimeField(auto_add_now = True)
>     order = models.ForeignKey(Orders)
>     user = models.ForeignKey(User)
>     comment = models.TextField()
>     status = models.CharField(max_length = 20)
>
>
> I'm storing the status in the History table right now because I need to keep
> track of who is moving the orders along.  However, I need to do a lookup on
> orders based on their current(most recent) status.  For simplicities purpose
> it seems a good idea would be to just put a status field in the Orders table
> and update as the Order advances through the stages. However, that creates
> duplicate data, which my client has expressed an extreme hatred for.
>
> What It's like to be able to do is something like:
> o = Orders.filter(status = 'new')
>
> I'm not entirely sure how or when relationship managers are brought in, so I
> was thinking something like this in the Orders model:
> status = self.history_set.values('status').order_by('-id')[0]['status']
>
> But that wouldn't let me do a lookup by state.
>
> What's a good Django way to handle this issue?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Geodjango Tutorial: SRID problem when loading data from shapefile to PostGIS table

2011-10-20 Thread Pauline Emery
Dear all,

I'm having a problem doing the section "LayerMapping" of the GeoDjango
official Tutorial [1].

After creating load.py in the world directory. Leaving as specified: "the
transform keyword set to False because the data in the shapefile does not
need to be converted -- it's already in WGS84 (SRID=4326)"

I execute as indicate the following commands:

$ python manage.py shell
>>> from world import load
>>> load.run()

And obtain the following error:

Failed to save the feature (id: 0) into the model with the keyword
arguments:
{'iso2': u'AG', 'pop2005': 83039, 'area': 44, 'region': 19, 'lon':
-61.7830001, 'iso3': u'ATG', 'subregion': 29, 'fips': u'AC',
'lat': 17.077, 'un': 28, 'mpoly': 'MULTIPOLYGON
(((-61.72917199949 17.6086084,-61.
73111699983
17.5472220009,-61.7327791 17.54,-61.73889199964
17.540554001,-61.75194499921
...
17.64472200115,-61.73167399941
17.62499600067,-61.72917199949 17.6086084)))', 'name':
u'Antigua and Barbuda'}
[... stack trace]
IntegrityError: new row for relation "world_worldborder" violates check
constraint "enforce_srid_mpoly"

Postgres enforcing the check constraint for SRID=4326. I don't know to say
to Django to insert explicitely the SRID into the MULTIPOLYGON
command. Inserting the line by hand on Postgres work fine using
ST_Geomfromtext( 'MULTIPOLYGON(((...) (...)),4326).


The same problem occurs with other tutorials:
GeoDjango Database API  with the Zipcode model [2]
GeographicAdminQuickStart [3]

I'm working with Python 2.6 / Django 1.3 with GeoDjango  / GDAL 1.7.2 /
PostgreSQL 8.4.8 / PostGIS 1.5 / Pyscopg2 2.4

Thank you for your time and your help,

Pauline Emery

[1] https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/
[2] https://docs.djangoproject.com/en/1.3/ref/contrib/gis/model-api/
[3]
http://code.google.com/p/geodjango-basic-apps/wiki/GeographicAdminQuickStart

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



Re: load-on-startup equivalent in django?

2011-10-20 Thread kenneth gonsalves
On Thu, 2011-10-20 at 13:38 +0800, Ken wrote:
> I wonder how do I do the same in django framework. Or there is some
> other way to run some background code periodicly?

look at djcelery
-- 
regards
Kenneth Gonsalves

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



passing data between views / functions

2011-10-20 Thread John
Hello all,

I'm building an interactive plotting routine. I have a question on how
to manage data objects.

I have a View (CBV inherited from DetailView and FormView) that uses
information in the URL to parse out a few variables. From those
variables I make a file system call to create a dictionary. This
dictionary is critical to the remainder of my 'workflow', and it takes
some seconds for the file system call to complete.

Once the dictionary is created, I use it to prepopulate fields in the
form. I'm okay up to here, but my question is one of 'design choice'.

At this point, I am storing the dictionary in the session for later
access. Once the form is posted I use the dictionary again (pulling it
from the session). Here comes the part I'm not so sure about. My
plotting routines are outside of django, and I don't want (would
prefer anyway) to have django as a dependency. I would prefer to just
'pass' the data to the external class/function.

The plot routines need to create the png files, and thus, need to tell
the calling routine where they files were created, so I can pass this
information back in the context to the return render_to_response.

I can force things to work if I don't validate the form, but if I
validate the form first, I get an error. Any insight on to where that
would be coming from?? Is this the correct paradigm for this process?

Here's some pseudocode:

MyView(DetailView, FormView):
   def post()
 H = MyForm( POST )
 C = externalClass(H)

   def get_object:
 H = externFileCall(*args)

   def get_context
 if not POST:
 C = MyForm(H)
 put_to_session(H)


   return render_to_response(C)

Actual code here:
http://paste2.org/p/1728601

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



load-on-startup equivalent in django?

2011-10-20 Thread Ken
Hello all
I'm new to django and I have a question.

I want to find a way to run some code periodicly in the background.
Because I have a fax device which will put incoming call data in the
database, I scan the database each 3 minutes for new incomings.

In tomcat when I can make a servlet load on startup. I add
"0"  in the web.xml file. This servlet
will be autoloaded when tomcat started and I then started the 3-min rountine
repeatly.

I wonder how do I do the same in django framework. Or there is some
other way to run some background code periodicly?


Thank you in advance.

Ken

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



Re: .count() returning unexpected results

2011-10-20 Thread Tom Evans
On Thu, Oct 20, 2011 at 12:40 PM, Tim Chase
 wrote:
> On 10/19/11 20:35, Tim Chase wrote:
>
> Perhaps I should have changed the test to be more clear, instead of using
>
>>   results = m.Person.objects.filter(
>>       Q(name__iexact=alias) |
>>       Q(aliases__alias__iexact=alias)
>>       )
>>   self.assertEqual(1, results.count(),
>>       "Failed #%i on %r" % (i, alias),)
>
> use
>
>  self.assertEqual(
>     m.Person.objects.count(), #only 1
>     results.count(), # comes back as 6 for "William"
>     "Failed #%i on %r" % (i, alias),
>     )
>
> This makes it clearer that there's only the one person in the DB (no
> fixtures being loaded).  The underlying SQL brings back the number of rows
> caused by the join of Person with Alias, but it seems a bug that
> .objects.filter().count() should ever return more than .objects.count()
>
> -tkc
>

It might seem that way, but it is definitely not a bug.

count() counts the number of rows found by the query, and your query
can find the same row multiple times, as you are joining across a M2M
relationship.

If you want distinct results from the query, make sure that you tell
django so by using distinct().

Eg:

>>> Type.objects.filter(department__backend_type__name='Other')
[, , ,
, ]
>>> Type.objects.filter(department__backend_type__name='Other').count()
5
>>> Type.objects.filter(department__backend_type__name='Other').distinct()
[]
>>> Type.objects.filter(department__backend_type__name='Other').distinct().count()
1

Cheers

Tom

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



Date and time picker in Django

2011-10-20 Thread Mario Gudelj
Hi guys,

I'm looking for a date/time picker that I can use in my web forms. I've used
DateTimeField in my models and have to implement date in this format
"2011-10-19 21:34". I have implemented
http://trentrichardson.com/examples/timepicker/ o my site and it kind of
works in a sense that the picker comes up and it fills the form field with
the date, but for some reason the form is not validated and I can't save it.
If I enter the date in the same format manually it works. I also has a look
at the POST request and the date is there, so for the life of me I can't
figure this one out.

If anyone know of another jQuery date/time picker I could use for the format
I need that would be most appreciated!

Thanks djangoers!

Mario

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



Re: .count() returning unexpected results

2011-10-20 Thread Tim Chase

On 10/19/11 20:35, Tim Chase wrote:

Perhaps I should have changed the test to be more clear, instead 
of using



   results = m.Person.objects.filter(
   Q(name__iexact=alias) |
   Q(aliases__alias__iexact=alias)
   )
   self.assertEqual(1, results.count(),
   "Failed #%i on %r" % (i, alias),)


use

 self.assertEqual(
 m.Person.objects.count(), #only 1
 results.count(), # comes back as 6 for "William"
 "Failed #%i on %r" % (i, alias),
 )

This makes it clearer that there's only the one person in the DB 
(no fixtures being loaded).  The underlying SQL brings back the 
number of rows caused by the join of Person with Alias, but it 
seems a bug that .objects.filter().count() should ever return 
more than .objects.count()


-tkc



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



Re: Forms with FileField - access file content

2011-10-20 Thread Leonardo Giordani
Yes you are right, I was not thinking about security. :)

Thanks

2011/10/20 Tom Evans 

> On Thu, Oct 20, 2011 at 10:49 AM, Leonardo Giordani
>  wrote:
> > No, I think I didn't correctly explain the matter; say I have a Thing
> model
> > with a list of strings in it.
> >
> > I want the user to be able to:
> >
> > 1. Access the Thing creation form
> > 2. While editing the form loading a file and being presented with the
> full
> > content
> > 3. Choosing some lines from that content
> > 4. Submit the form
> >
> > So I need to "modify" the view attaching fields which content comes from
> > what the user uploads.
>
> You cannot do that. You can upload the file in the background after
> the user has selected the file, using AJAX. Once the file has been
> uploaded the server could return the contents as a form control, and
> allow the user to select the parts of it they wish. Gmail partially
> does this - once you have selected a file to attach, it uses AJAX to
> upload it in the background whilst you type your email.
>
> Fortunately, there is no way for a web developer to instruct a browser
> to open a file from disk and insert its contents into form controls.
> If you think about it, you will understand why.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Forms with FileField - access file content

2011-10-20 Thread Tom Evans
On Thu, Oct 20, 2011 at 10:49 AM, Leonardo Giordani
 wrote:
> No, I think I didn't correctly explain the matter; say I have a Thing model
> with a list of strings in it.
>
> I want the user to be able to:
>
> 1. Access the Thing creation form
> 2. While editing the form loading a file and being presented with the full
> content
> 3. Choosing some lines from that content
> 4. Submit the form
>
> So I need to "modify" the view attaching fields which content comes from
> what the user uploads.

You cannot do that. You can upload the file in the background after
the user has selected the file, using AJAX. Once the file has been
uploaded the server could return the contents as a form control, and
allow the user to select the parts of it they wish. Gmail partially
does this - once you have selected a file to attach, it uses AJAX to
upload it in the background whilst you type your email.

Fortunately, there is no way for a web developer to instruct a browser
to open a file from disk and insert its contents into form controls.
If you think about it, you will understand why.

Cheers

Tom

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



Django Atom feed Item Category

2011-10-20 Thread ggavy

Hi everyone,
 I'm geting a little confused with the 'item category' section of
Django's atom feed framework. I want to extend each entry in a feed
with a further piece of information beyond the standard title, id,
etc. The only way I see how to do this is to make use of the
'category' element (correct me if I shoudn't be doing things in this
way). For example I want to tag each entry with say
'institution' (without going down the path of breaking out into
seperate feeds for each institution). So I'm hoping for a feed along
the lines of:


  x
  xx
  x
  xxx
  ..
  ...

  
urn:uuid:354ed4ec-e346-11df-9343-00163e9152a5
x

.
.
 My_Institution 
  

At the moment I have the following in my feed class:

def item_categories(self,item):
return [{'term':'Insitution'}]

which generates the element with the attribute correctly. But how do I
get the value embedded, i.e. the 'My_Institution'?

Any help or even advice if I'm using atom feed wrongly here would be
much appreciated.

Thanks,
G

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



Re: Android browser and csrf protection

2011-10-20 Thread Ivan Uemlianin
Dear All

Just to follow up slightly:

- iPhone and Blackberry browsers access the site properly;
- the Android browser gets the csrf errors with django 1.2 and django
1.3
- with another site I'd developed earlier on django 1.2, the Android
browser passes csrf verification properly.
- the "failing" site is on webfaction, the Working" site is on a bare
machine (centos, nginx, etc).

Does anyone have any suggestions as to what's going on?  Why should
the Android browser be behaving differently to all the others?

Best wishes

Ivan

On Oct 19, 3:17 pm, Ivan Uemlianin  wrote:
> Dear All
>
> I have a django webapp with a very simple login page, a form with
> username, password and the {% csrf %} tag.  The page works as expected
> when using Chrome, Firefox and Safari, but when trying to login from
> my Android phone browser, the page returns the "CRSF verification
> failed" error page (django running debug=True for the moment).
> However, I have been logged in: if I reload the page, I get the page I
> was expecting, along with the user details.
>
> eg.com/login/  #  ok, enter username "tu01", password, send
> eg.com/profile/  #  error: csrf verification failed, reload
> eg.com/profile/  #  ok, "tu01"'s homepage
>
> Has anyone else had odd behaviour like this from the Android browser?
> Can anyone suggest what might be the problem?
>
> (Haven't tested with iPhone or Blackberry yet, will do do this
> evening).
>
> With thanks and best wishes
>
> Ivan

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



Re: Forms with FileField - access file content

2011-10-20 Thread Leonardo Giordani
No, I think I didn't correctly explain the matter; say I have a Thing model
with a list of strings in it.

I want the user to be able to:

1. Access the Thing creation form
2. While editing the form loading a file and being presented with the full
content
3. Choosing some lines from that content
4. Submit the form

So I need to "modify" the view attaching fields which content comes from
what the user uploads.

2011/10/20 Venkatraman S 

>
> On Thu, Oct 20, 2011 at 1:32 PM, Leonardo Giordani <
> giordani.leona...@gmail.com> wrote:
>
>>
>> I'm trying to implement a an application where the user creates a new
>> object through a form. Up to here I'm fine.
>>
>> This time though the object creation involves loading a file and choosing
>> some data from it (say choosing some lines, for examples).
>>
>> So I'm a little stuck here. How can I let the user load the file and show
>> the file content in the form itself before submitting?
>>
>> Or is this behaviour wrong for a Web application?
>>
>
>
> Probably, you may want to show the contents of the file after the user
> uploads the file? So that the file's copy is present in the server.
> If you want to show the preview of the doc in the app, i would suggest
> generating a summary or clip a few lines when the model is saved, and store
> the summary in a different field, so that you can avoid run-time
> computations of the summary when the file is to be accessed.
>
> Did i get you right?
>
> -V
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django admin multiple company accounts

2011-10-20 Thread zzart...@googlemail.com
Thanks for your time Mike, Cal, Andre!
I had suspected that general consensus will be don't use admin :)
still I had to ask. When i write down all the features admin has and
features  i will need to be created on top of admin somehow,  i've
come to the same conclusions. Still it hurts me a lot to be
implementing the same old CRUD over and over again.
Anyhow, thanks for sharing !
mars


On 19 Paź, 18:56, Mike Seidle  wrote:
> On Wednesday, October 19, 2011 02:10:49 PM Andre Terra wrote this and sent it
> to To: django-users@googlegroups.com::
>
> > > To be honest, you're probably (not 100% sure) creating *more* work for
> > > yourself trying to make something like this work in django admin, than
> > > just designing something for yourself (YMMV).
>
> > I couldn't agree more. Too often I see newcomers learning how to extend the
> > admin, when it would actually be easier to roll out their own views, not to
> > mention how they would be learning how to use the framework rather than a
> > built-in app.
>
> It's so easy to think Django-Admin is the answer.  Django's admin is a few
> steps up from PHPMyAdmin or some other SQL GUI tool. Uless your use case for
> your user is precicely a create, read, update and delete interface to your
> data as represented by your model definitions, you probably will not have the
> moving parts you need to implement what you want... The minute you want
> more/different, is (most of the time) literally less work to just roll your 
> own
> view and template which will give you much more control of the user experience
> and avoid the inevitable complaints about "why aren't totals at the bottom of
> tables? How come we have to used this wonky Year/Month/Date drill down?
>
> --- Mike

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



Re: Forms with FileField - access file content

2011-10-20 Thread Venkatraman S
On Thu, Oct 20, 2011 at 1:32 PM, Leonardo Giordani <
giordani.leona...@gmail.com> wrote:

>
> I'm trying to implement a an application where the user creates a new
> object through a form. Up to here I'm fine.
>
> This time though the object creation involves loading a file and choosing
> some data from it (say choosing some lines, for examples).
>
> So I'm a little stuck here. How can I let the user load the file and show
> the file content in the form itself before submitting?
>
> Or is this behaviour wrong for a Web application?
>


Probably, you may want to show the contents of the file after the user
uploads the file? So that the file's copy is present in the server.
If you want to show the preview of the doc in the app, i would suggest
generating a summary or clip a few lines when the model is saved, and store
the summary in a different field, so that you can avoid run-time
computations of the summary when the file is to be accessed.

Did i get you right?

-V

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



Re: does php code works in Django

2011-10-20 Thread Sam Lai
On 20 October 2011 20:15, Chen Xu  wrote:
> Hi, everyone:
> I am new to Django, does anyone know whether php code works in Django?

This list's archives will have the answer to your question, and many
variations of it.

http://groups.google.com/group/django-users

The short answer is no; PHP and Python are two different languages,
and Django has a different way of structuring web apps, compared to
plain-old PHP.

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

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



Re: does php code works in Django

2011-10-20 Thread @@
no

On Thu, Oct 20, 2011 at 5:15 PM, Chen Xu  wrote:

> Hi, everyone:
> I am new to Django, does anyone know whether php code works in Django?
>
> Thanks
>
> --
> ⚡ Chen Xu ⚡
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



does php code works in Django

2011-10-20 Thread Chen Xu
Hi, everyone:
I am new to Django, does anyone know whether php code works in Django?

Thanks

-- 
⚡ Chen Xu ⚡

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



Forms with FileField - access file content

2011-10-20 Thread Leonardo Giordani
Hi all,

I'm trying to implement a an application where the user creates a new object
through a form. Up to here I'm fine.

This time though the object creation involves loading a file and choosing
some data from it (say choosing some lines, for examples).

So I'm a little stuck here. How can I let the user load the file and show
the file content in the form itself before submitting?

Or is this behaviour wrong for a Web application?

Any advice is appreciated, thank you in advance

Leo

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