Re: Audio Streaming Using Django

2012-04-13 Thread sebastien piquemal
Django won't be of much use for the audio streaming part in itself.

I've done it a while ago using Icecast2. Very simple to setup.


On Friday, April 13, 2012 7:21:49 AM UTC+3, atul khairnar wrote:
>
> Hi, 
> I am developing Internet Radio App using Django. But i don't know how to 
> stream the audio over web using django. which modules and technology to 
> use. Please Help. 
>
>
> Atul Khairnar
> B.Tech
> Department of Computer Engineering and Information Technology
> College of Engineering , Pune
> Cell - (+91)9579289613
>
>
>
>

-- 
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/-/SLJ0ds5HCSIJ.
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: Port Django to Javascript

2012-04-05 Thread sebastien piquemal
I guess the people that don't get the point have probably never made a 
heavy Javascript application ... Ever used Backbone.js ?

client-side - one page - websites are much nicer to use than any website 
with a page load after every click.

So I totally understand why you would do such a project, and I actually 
think it is a lovely idea !!! On the other hand, I've started to think 
lately that Django is not the best backend solution for building such 
applicatons.
So, @davide, how do you plan on making sure that any weird API can be 
plugged-in to the system ... will you separate nicely the model layer from 
the "backend" (web API, or dummy data store, or whatever) ???

Cheers anyway, and I'll follow the project !

Sébastien

On Thursday, April 5, 2012 9:22:13 AM UTC+3, DvD wrote:
>
> Hi folks,
> I created a project not long ago and I'm currently maintaining it called 
> Broke which wants to be a porting to Javascript of Django 
> https://github.com/brokenseal/broke-client
> You can find it featured inside the todomvc project from addy osmani 
> https://github.com/addyosmani/todomvc ( 
> https://github.com/brokenseal/todomvc for the latest updates from broke )
>
> I think the project itself has a lot of potential but lacks two very 
> important things: a real documentation and a community.
> I'm writing to you all to see if anyone could be interested in taking part 
> to this project.
> Broke currently features a lot of cool stuff such as:
>  - pythonic classes and models: write stuff like
>
> models.Model.create({
> __name__: "todo.models.Task"
> ,title: models.CharField({ max_length: 200 })
> ,is_complete: models.BooleanField({ 'default': false })
> ,update: function(kwargs){
> if('is_complete' in kwargs && kwargs['is_complete']) {
> this.elements().addClass('done');
> } else if('is_complete' in kwargs && !kwargs['is_complete']) {
> this.elements().removeClass('done');
> }
>
> return this._super(kwargs);
> }
> });
>
>  - django templating: you can basically reuse the same templates you are 
> currently using server side, with some limitations ( the only supported 
> tags are if-else, for cycles, ifequal, comment )
>  - database routing: you can choose to save your object on any data source 
> you want ( local storage, remote server, a local json object )
>
> Have a look at the code base and let me know what you think.
> Anyone? :)
>
> Cheers,
> Davide
>

-- 
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/-/dKBwY_yj9kMJ.
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: Creating a hospital erp (hospital management) in Django

2012-02-14 Thread sebastien piquemal
+1 to @Patricio Valarezo's comment :

If you want to build a system for hospitals, you've got to know how an
hospital works first. So, make interviews, draw mockups, more
interviews, code a prototype, more interviews, and so on ... and only
then you'll know what you need to do.

On Feb 14, 4:07 am, Python_Junkie 
wrote:
> Now that you have your file >>models.py   place this file in the
> app folder after creating your app
>
> 1.  python manage.py start app  My_Erp (for example)
> 2.  a blank models.py file will be created, overwrite this with your
> models.py
> 3. run the command to sync the database, assuming that your set up the
> settings.py file has been set up correctly to connect to the database
> of your choice.
>
> python manage.py syncdb
>
> Let me know if this works for you
>
> On Feb 13, 3:56 pm, Saadat  wrote:
>
>
>
>
>
>
>
> > Thank you Python_junkie
> > I've created the poll app and I'm working on this Hospital ERP thing.
> > I've also created the database schema and put some dummy values for
> > testing. Then I created the models using 'inspected' command and saved
> > the models in models.py file. Now I'm confused where to put the
> > models.py file and what to with it. Guide me please.
>
> > Thanks a lot.
> > Saadat
>
> > On Feb 10, 6:18 pm, Python_Junkie 
> > wrote:
>
> > > Not sure from your post, which piece you are stuck on.
>
> > > 1. Have you used Django before?
> > > If not start with the tutorial
>
> > >https://www.djangoproject.com/
>
> > > 2. If you have a basic understanding of Django, have you been able to
> > > set up a basic project /app and connect run syncdb.
> > > One can always connect to the sqllite database, because it is built
> > > in, but getting some other database to connect can be a time consuming
> > > process if the procedure has not been established on your machine.
>
> > > 3. If you have done the above 2 items then you should move in a
> > > parallel path.
>
> > > a. Start defining your database model to support the business and the
> > > workflow that you intend to create.
> > > b. Use some sort of wire frame (framework) to lay out your web pages
> > > to support and interact step 3 a.
>
> > > On Feb 10, 8:06 am, adesantoas...@gmail.com wrote:
>
> > > > Hello, nice thread.
>
> > > > **tagged to keep following..
>
> > > > +adesst
>
> > > > -Original Message-
> > > > From: Saadat 
>
> > > > Sender: django-users@googlegroups.com
> > > > Date: Fri, 10 Feb 2012 02:58:16
> > > > To: Django users
> > > > Reply-To: django-users@googlegroups.com
> > > > Subject: Creating a hospital erp (hospital management) in Django
>
> > > > Hello All,
> > > > I'm in my final year of computer science engineering and for my final
> > > > year project, i'm creating a hospital erp. I'm a bit confused about
> > > > where to start from. Any sort of help will be appreciated. Thanks a
> > > > lot.
>
> > > > Cheers
> > > > Saadat
>
> > > > --
> > > > 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 
> > > > athttp://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: Since Django has its own database schema, can we still use sqlalchemy instead?

2012-01-08 Thread sebastien piquemal
Actually the guy in that blog post forgets to mention quite a lot of
stuff. By giving-up Django ORM, not only you loose all the management
commands based on Django-orm (loaddata, dumpdata, syncdb, ...), but
also you loose admin, you loose auth, you loose the generic views, you
loose the model forms, and probably many other stuff that I forget.
I think Django and its orm are very coupled. On the other hand, Django
orm is really good, and loosing all the functionalities above for a
bit of extra control (gained by using slq-alchemy) is probably a huge
trade-off.

On Jan 8, 4:44 pm, James  wrote:
> On Jan 8, 8:43 am, Venkatraman S  wrote:
>
> > On Sun, Jan 8, 2012 at 9:49 AM, Chen Xu  wrote:
>
> > > Since Django has its own database schema, can we still use sqlalchemy
> > > instead?
>
> > Just to correct the nomeclature : Django has an ORM, and *NOT* a database
> > schema. An application has its own schema.
> > And to answer the 'modified' Q : django's orm is pretty good. (but yes, i
> > would expect that you can swap it with sqlalchemy, but I havent done it
> > yet).
>
> > -Vhttp://blizzardzblogs.blogspot.com/
>
> To add to what the above poster said, the blog irrational exuberance
> has an entire series on django's loose coupling philosophy.  href='http://lethain.com/replacing-django-s-orm-with-sqlalchemy/'>This
> article is on using SQLAlchemy. I've really been considering
> switching over to jinja based on his articles (since it seems like it
> won't break anything, other than all my render_to_response and will
> need to longform the return render). For my money, django's ORM seems
> to do a pretty good job. I haven't yet said to myself "wow, it would
> be nice if it did X" but I say that all the time to myself about the
> templating engine (which is why I'm considering the switch).

-- 
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.



Best approach to code an inventory system

2011-12-12 Thread sebastien piquemal
HI !

We currently have an inventory system for our employees. It contains
laptops, phones, but also ergonomic chairs, fridges or software
licenses ... So very different stuff that admins can create/read/
update/delete.

After doing a version completely based on admin interface, I gave up
cause it didn't provide enough flexibility. So I rolled-up a complete
custom version, but there is far too much code to my taste ... it's a
pain to maintain.

Some of the problems I have been facing include :

- allowing the admins to add their own item types through an
interface, e.g. : laptop, TV, ... item types are hierarchical, e.g. TV
and Laptop are subclasses of ElectronicItem, which in turn is a
subclass of Item, ...
- polymorphism : when listing all the items, they should be aware
of what type they are, this in order to search/filter the list with
javascript and also generate urls to the item detailed view.
- updating some attributes through Ajax, e.g. laptops have
licenses. On a laptop detail page, I have a javascript  "manager", to
associate/detach licenses to that laptop.

So I was wondering if anybody had a suggestion on what to use ! I
especially wonder if one of the django CMSes apps could help me,
because that does sound like functionalities a CMS could provide !

-- 
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: New design for class-based views

2011-12-05 Thread sebastien piquemal
Hi Tobia !

Could you post a link to a place where class-based views are being
criticized ? And also in what sense are they convoluted ?

Personally, I have started using the class-based views heavily as soon
as they were released, and I think they are great. Very flexible.
However, I'll tell you what I usually do (and if you don't, it's just
not possible) : browsing the Django code online, every time I need to
customize a view. So in my sense, there is much more room for
improvement in the class-based views docs than in their actual API ...

Sébastien

On Dec 3, 8:56 pm, Tobia Conforto  wrote:
> Hello
>
> As you may know, current class-based views have been criticized for
> their complexity.
>
> Their design is a bit convoluted and difficult to understand by the
> average view author and therefore any work made with them may hide
> sneaky bugs.
>
> On top of that, it's difficult to apply common decorators to them. The
> recommended approach seems to be to apply them to the dispatch()
> method. But this requires overriding that method even when the base
> dispatch strategy is otherwise adequate, and converting the decorators
> with method_decorator(). This is ugly and is only a partial solution,
> as method_decorator() doesn't currently support decorators with
> arguments, such as @user_passes_test(a_test).
>
> All this is unfortunate, because there is a clear need for a simple,
> Pythonic object-oriented approach to view authoring, to achieve
> separation of concerns and code reuse. Dispatching by http method (one
> of the basic features of class-based views) is also a growing need, in
> the world of AJAX and REST-based web applications.
>
> I have attached my proposal for a slight change in the design of class-
> based views. It is similar in purpose to the existing ones, but much
> simpler to use and to extend.
>
> Examples speak louder than words:
>
> --- urls.py ---
>
> urlpatterns = patterns('',
>     url(r'^(\d)+/$', views.Article),
> )
>
> --- views.py ---
>
> @login_required
> class Article(View):
>
>     def __init__(self, request, pk):
>         super(Article, self).__init__(request, pk)
>         self.pk = pk
>
>     def get(self):
>         article = get_object_or_404(Article, pk=self.pk)
>         return render_to_response('hello.html', {'article': article})
>
>     def post(self):
>         return HttpResponse('You posted something but I threw it
> away.')
>
> ---
>
> Points of note:
>  - the usage in urls.py is now indistinguishable from regular views;
>  - subclasses may extend __init__ to make use of request parameters;
>  - the dispatch logic, based on http method, is hidden in the base
> class;
>  - standard decorators may be simply applied to the class (Python >=
> 2.6)
>
> Here is the View base class:http://dpaste.com/hold/665528/
> It's very simple, even shorter than the existing implementation.
>
> I haven't taken the time to translate the whole django.views.generic
> package to this new design, but I will do so shortly, assuming I get
> some kind of positive feedback. The existing functionality (the
> various generic views and mixins) should be fairly easy to port to the
> new design.
>
> This is a slightly different design, so there are bound to be a few
> incompatibilities. For example in my code the dispatched methods (get,
> post...) don't receive the request object and parameters, because they
> were already passed to __init__ and it wouldn't make sense to pass
> them again.
>
> I'm not familiar with Django practices about backwards compatibility.
> If it's really important not to break old code, I guess the new style
> classes could be made to keep the same interface as existing ones,
> including a dummy as_view() method. But it would pollute the code with
> old cruft. Or they could be implemented in a new package. I need
> further directions on this issue.
>
> -Tobia

-- 
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: Constructing / rendering a complex

2011-08-03 Thread sebastien piquemal
Hi !

I have written this small library a while ago : 
http://code.google.com/p/django-cube/
. It is not exactly what you are looking for, but one of the aim is
indeed easy generation of html tables. I don't know if it can be of
any help to you, but you could check how the template tag is written
for example...

Cheers,

Sébastien

On Aug 3, 11:25 am, Michał Sawicz  wrote:
> Dnia 2011-08-03, śro o godzinie 10:34 +1000, Sam Walters pisze:
>
> > Hi i dont see what is complex about this.
> --8<--
> > The view 'rendering' as much as possible. So i assume you would rather
> > have an initial template rendered. then perhaps have views that
> > deliver data via JSON or something? AJAX+JSON
>
> No, I mean I want to have the view only prepare the data, not describe
> its visual properties like col/rowspan.
>
> > I cant see why it would be impossible to change. Use javascript to
> > change the table col and rowspans. (why do visual formatting work on
> > the serverside if you can do it clientside)
> > at the very least you can have style="display:None" and variious other
> > CSS rules to help with any dynamic changes to the table.
>
> I'm not going into JS at all at the moment. I'd like the table to be
> rendered static in the template.
>
> > I dont quite understand this one. If you are comparing data
> > server-side then submitting data via a form would be recommended.
> > Where is the data being changed that requires the comparison anyway?
>
> I mean comparing forloop.counters with column/row/header/whatnot count
> and rendering differently. No forms involved here, just a dynamic
> dataset.
>
> > use multiple classes eg  jse a javascript library to
> > add remove classes select child elements of the DOM im sure the
> > information doesnt have to be partitioned down the a super fine level
> > of granularity requiring individual id's for every element does it?
>
> Yes I'll probably try and run with that approach, I'll prepare the whole
> grid within the view, and then "merge" cells that I need spanning in the
> template.
>
> > What javascript library do you use? jquery, prototype, dojo etc all
> > good options to simplify manipulation of DOM elements.
>
> Yes, I use jQuery, but as stated before I need to create the table in
> HTML without client-side tweaks.
>
> Thanks for the comments, keep 'em coming ;)
> --
> Michał (Saviq) Sawicz 
>
>  signature.asc
> < 1KViewDownload

-- 
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 Knowledge Strorehouse

2011-07-08 Thread sebastien piquemal
Hi all !

My humble opinion, ... where there is the most room for improvements
in existing services is django-snippets. It is very useful, the idea
is good, but it is not so nice to use at the moment.
Instead of using own custom code to power the site, wouldn't it be
good to use something like OSQA (http://www.osqa.net/) ?
Most of us know, use (and like !) SO, and I think it can be adapted to
snippets as well ...

Sébastien

On Jul 8, 6:52 am, Venkatraman S  wrote:
> On Fri, Jul 8, 2011 at 5:20 AM, Russell Keith-Magee 
> > wrote:
> > So -- my humble suggestion: If you think there is a need for improving
> > Django documentation, I wholeheartedly agree. There's plenty of room
> > for improvement in Django's docs. But the place to start isn't to
> > write a massive technical site to host new documentation. You start by
> > *writing documentation*.
>
> Agreed. Charity begins at home. To start with i am going to atleast start
> posting some of my articles on both my blog and also
> in the wiki. I have been working on a django project and have learnt quiet a
> lot in the recent past - which i
> think is essential for any website. I am going to start documenting the
> knowledge from now on.
>
> It would be great if the other in this group can join in and start
> contributing.
> *
> Lets start this "Documentation Drive" for the next 6 months and see how we
> are doing. It would be great if
> all in the community can spread the word. * I would call it "Django
> Documentation Drive" (#3d).
> [http://twitter.com/venkasub/status/89179595714203649] Please RT.
>
> On the other hand, i was thinking that we dont actually need another
> site(project?), *if at all* we have to do
> something of this sort, then django-snippets can be improved or used. But,
> looks to me that wiki is a better place.
>
> So lets start sharing the knowledge :)
>
> -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: Json serialization for use in JS

2011-05-20 Thread sebastien piquemal
Hi !

I have written a small library that (among other transformations) can
serialize django objects to dict (then you can just use 'json' to make
your dict to a json string) :

Docs on readthedocs : 
http://readthedocs.org/docs/any2any/en/latest/doc_pages/djangocast.html
Pypi page : http://pypi.python.org/pypi/any2any/0.1

You can achieve very easily the format you need. Please ask if you
need help !

Cheers,

Sébastien

On May 19, 5:05 pm, Tom Evans  wrote:
> On Thu, May 19, 2011 at 1:23 PM, Jonas Geiregat  wrote:
> > Hello,
> > I'm also finding the built in serialization a bit overhead.
>
> Me too! I use a simple HttpResponse subclass for generating JSON though:
>
> from django.http import HttpResponse
> from django.utils import simplejson
>
> class JsonResponse(HttpResponse):
>   def __init__(self, data):
>     super(JsonResponse, self).__init__(content=simplejson.dumps(data),
>         mimetype='application/json')
>
> Use it like this:
>
> return JsonResponse({'id': foo.id, 'some_list': [ 1,2,3,4 ]})
>
> 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.



Re: ANN : any2any, serializers & deserializers for Django

2011-05-07 Thread sebastien piquemal
Apparently there was a bug in my setup file on the release on pypi. It
is now fixed !

On May 6, 10:16 am, sebastien piquemal <seb...@gmail.com> wrote:
> Hi all !
>
> I am pleased to announce that I have finally released a piece of code
> I begun to write a while ago, ...
> It is a python library called any2any, which helps to write casts
> operations (from one python instance, to another of a different type).
>
> It all started with Django serializations and deserializations (I had
> very custom needs, in order to build some APIs), and then it went on
> with serializations and deserializations for ldap ... so I decided to
> abstract those operations in one library that would simplify writing
> casts from one Python type to another.
>
> And guess what !? It contains cool Django serializers/deserializers
> which :
>
>     - supports MTI nicely
>     - serializes/deserializes foreign keys and many2many fields nicely
>     - deep serialization and deserialization
>     - natural keys
>     - include/exclude a subset of fields
>     - virtual attributes
>     - very very easy to customize
>     - ...
>
> You can find the "docs" for Django here 
> :http://readthedocs.org/docs/any2any/en/latest/doc_pages/djangocast.html
> On pypi :http://pypi.python.org/pypi/any2any/0.1
>
> Of course, there is always more work to do to make it better and add
> missing features ... So any suggestion, any contribution, critics ...
> are very welcome !
>
> Cheers,
>
> Sébastien

-- 
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.



ANN : any2any, serializers & deserializers for Django

2011-05-06 Thread sebastien piquemal
Hi all !

I am pleased to announce that I have finally released a piece of code
I begun to write a while ago, ...
It is a python library called any2any, which helps to write casts
operations (from one python instance, to another of a different type).

It all started with Django serializations and deserializations (I had
very custom needs, in order to build some APIs), and then it went on
with serializations and deserializations for ldap ... so I decided to
abstract those operations in one library that would simplify writing
casts from one Python type to another.

And guess what !? It contains cool Django serializers/deserializers
which :

- supports MTI nicely
- serializes/deserializes foreign keys and many2many fields nicely
- deep serialization and deserialization
- natural keys
- include/exclude a subset of fields
- virtual attributes
- very very easy to customize
- ...

You can find the "docs" for Django here :
http://readthedocs.org/docs/any2any/en/latest/doc_pages/djangocast.html
On pypi : http://pypi.python.org/pypi/any2any/0.1

Of course, there is always more work to do to make it better and add
missing features ... So any suggestion, any contribution, critics ...
are very welcome !

Cheers,

Sébastien

-- 
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.



Bug with ModelForm ?

2011-04-20 Thread sebastien piquemal
Hi !

I have posted this question on SO :
http://stackoverflow.com/questions/5718838/django-adding-new-form-fields-dynamically-in-admin

As you can see I am not the only one to have this problem. I was
wondering, could it be reported as a bug ? Or enhancement proposal ?

-- 
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: Creating REST APIs in Django...advice

2011-04-12 Thread sebastien piquemal
Well ... http://django-rest-framework.org  allows you to override the
method by adding a post parameter. So in your form, you just add a
hidden input



or



and django-rest-framework will pipe your POST request into the "put"
handler or "delete" handler. Of course name="_method" can be
configured (I mean that you can use another parameter name). That's a
quite elegant way to overcome the limitation you are talking about
(even though CRUD and REST are not exactly the same things).

I am not sure that piston is still actively maintained ...

On Apr 12, 3:57 pm, Brian Bouterse  wrote:
> I've been reading through the documentation for piston and
> django-rest-framework.org and they both look like great projects.  Could
> anyone with experience working with either of these applications (or their
> authors themselves) provide some compare and contrasting of the
> features/usability/etc.
>
> Also, as a general REST-ism, the HTML
> formtag doesn't
> allow for HTTP methods besides GET and POST.  As such we
> typically write a full REST API (GET, PUT, POST, DELETE), and then end up
> doing the following to "make it work" for HTML/browser settings.
>
> CREATE - POST to /resource/
> READ - GET to /resource/
> UPDATE - POST to /resource/
> DELETE - POST to /resource/delete
>
> The really non-restful part of the "make it work for browsers" hack is
> adding the verb delete into the URL.  I couldn't think of a better way.
>  This is a common pattern I end up implementing a lot, and it would be cool
> if a rest framework let me accomplish this in an easier way.
>
> Brian
>
> On Tue, Apr 12, 2011 at 6:23 AM, Tom Christie wrote:
>
>
>
> > I've been working on this with some folks:
>
> >http://django-rest-framework.org
>
> > Released 0.1 a few weeks ago, and it's coming along *really* nicely. It's
> > under v active development ATM. The auto-generated API browser is
> > particularly cool. Really would advise anyone taking a look at building web
> > APIs in python to take a look at it.
>
> > --
> > 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.
>
> --
> Brian Bouterse
> ITng Services

-- 
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: Implementing a ldap db backend

2011-03-24 Thread sebastien piquemal
After the initial post, following the advice of many people I didn't
try to implement a backend for ldap... Instead I wrote my own o(r)m -
it supports very basically the same functionalities as django-orm :
foreignkeys, manytomany, inheritance, ...- it is somewhat integrated
with Django (this only means that you can use django settings module).
I think it works quite well, the code is quite simple, even though I
still have a few improvements to make before releasing it. However I
have reached a point where it could indeed be "released", so I'll make
those improvements tomorrow, write what's missing of documentation,
and I'll make an announcement next week on django-users !

Cheers,

Sébastien

On Mar 22, 7:49 pm, "Sells, Fred" <fred.se...@adventistcare.org>
wrote:
> I'm using my own auth and ldap via python-ldap as a query only; others 
> maintain it.  My only issue is that of response.  I query all the groups I 
> care about and get all their members and keep that in a MySQL db that I 
> refresh every 5 minutes of an unrelated cron job.
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Felipe Prenholato
> Sent: Tuesday, March 22, 2011 9:19 AM
> To: django-users@googlegroups.com
> Subject: Re: Implementing a ldap db backend
>
> I have read and tested some more libs.
>
> My concern is that:
>
> django-ldapdb 
> (http://opensource.bolloretelecom.eu/projects/django-ldapdb/):amazing idea, 
> I'm working very well to query users, having some issues to write on LDAP but 
> is more probably due server stuff and not django-ldapdb itself. Probably 
> django-ldapdb is a good start for a backend, but doesn't have much 
> documentation, mostly examples only.
>
> django-auth-ldap (doc athttp://packages.python.org/django-auth-ldap/, source 
> athttps://bitbucket.org/psagers/django-auth-ldap):testing now, the docs show 
> that it's amazing with all backend and update of users working very well at 
> user login. This kind of functionality is required for me.
>
> Since ldapdb can search, update and add users as I see in code we just need 
> to do some work on lookups and doc, because istartswith as example doesn't 
> works, but it is not much trouble I guess. At other side ldapdb lacks a 
> authentication backend that can update user data at login and is easy to 
> update django tables like auth-ldap does (see documentation). I'll use both 
> for now because my time about it is very small but in future I'm ready to 
> join on efforts to merge both apps and construct a full ldap backend / ldap 
> orm for django.
>
> Felipe 'chronos' Prenholato.
> Linux User nº 405489
> Home page:http://chronosbox.org/blog
> Twitter:http://twitter.com/chronossc
>
> 2011/3/21 David De La Harpe Golden <david.delaharpe.gol...@ichec.ie>
>
> On 03/11/10 07:48, sebastien piquemal wrote:
>
> > I have thought of many solutions to replace ldapdb. I came to
> > conclusion than the cleanest, and most useful for the community, would
> > be to implement a real db backend for ldap. However, I have been told
> > that it is an awfully big task !
>
> It would be big...
>
> BTW "pumpkin" is another project that attempts an ORM-like (let's say
> ODM) interface.  It's not django integrated, i.e. it's not a ldap-nonrel
> backend for the Django ORM, it's a separate Somewhat-Django-ORM-like
> ODM.  http://pypi.python.org/pypi/pumpkin/0.1.0
>
> I'd also recommend taking a close look at ldap.schema.models in
> python-ldap source itself - it's "half an ODM" in itself, though it
> can't save and still doesn't really datatype-map (python-ldap is a thin
> layer on top of libldap and returns strings e.g. you get a "FALSE" back
> not a python False. Yeargh), it does introspect the schema and handle
> some horrible little details of attribute lookup for you.
>
> We also grew something of an ODM for in-house use, sitting on top of
> python-ldap, doing a little mapping of datatypes (only just enough for
> our needs), allowing saving.  It's unreleased at time of writing and,
> um, what happens to it later won't be up to me.  Pumpkin is probably
> better anyway.  Our Django ORM integration, such as it is, is by "fake"
> surrogate django models in RDBMS.  So again not a /backend/ for the
> django ORM - Instead we (ab)use entryUUID and syncrepl entryCSN ldap
> operational attributes to keep some almost featureless "LDAPEntry" model
> instances in the RDBMS roughly in-sync via polling*.  This allowed
> signals to fire etc so a django/celery based system can be somewhat
> reactive to directory changes both inside and  outside its control.  But
> our ldap directory is and will remain fairly small (thousands to ten

Re: ANN: Django 1.3 release candidate available

2011-03-03 Thread sebastien piquemal
Oh ... actually, I just deleted the django folder from `dist-packages`
and ran again `setup.py`, and now it works.

On Mar 4, 9:18 am, sebastien piquemal <seb...@gmail.com> wrote:
> Great !
>
> 
>
> However, I don't know if it is me, but I just installed it, tried to
> start my development server, and I got :
>
>   File "manage.py", line 14, in 
>     execute_manager(settings)
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 438, in execute_manager
>     utility.execute()
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 261, in fetch_command
>     klass = load_command_class(app_name, subcommand)
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 67, in load_command_class
>     module = import_module('%s.management.commands.%s' % (app_name,
> name))
>   File "/usr/local/lib/python2.6/dist-packages/django/utils/
> importlib.py", line 35, in import_module
>     __import__(name)
>   File "/usr/local/lib/python2.6/dist-packages/django/contrib/
> staticfiles/management/commands/runserver.py", line 4, in 
>     from django.core.management.commands.runserver import
> BaseRunserverCommand
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> commands/runserver.py", line 8, in 
>     from django.core.handlers.wsgi import WSGIHandler
>   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> wsgi.py", line 11, in 
>     from django.core import signals
>   File "/usr/local/lib/python2.6/dist-packages/django/core/
> signals.py", line 1, in 
>     from django.dispatch import Signal
>   File "/usr/local/lib/python2.6/dist-packages/django/dispatch/
> __init__.py", line 9, in 
>     from django.dispatch.dispatcher import Signal, receiver
> ImportError: cannot import name receiver
>
> Same thing goes if I start a blank project and run : `python manage.py
> runserver`. Any idea ???
>
> Sébastien
>
> On Mar 4, 8:00 am, James Bennett <ubernost...@gmail.com> wrote:
>
> > Tonight we're proud to announce the first release candidate for Django
> > 1.3; if all goes well, the final release will happen in about a week.
>
> > Details for the release candidate are available on the official Django 
> > weblog:
>
> >http://www.djangoproject.com/weblog/2011/mar/03/13-rc/
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."

-- 
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: ANN: Django 1.3 release candidate available

2011-03-03 Thread sebastien piquemal
Great !



However, I don't know if it is me, but I just installed it, tried to
start my development server, and I got :

  File "manage.py", line 14, in 
execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 438, in execute_manager
utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name,
name))
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
importlib.py", line 35, in import_module
__import__(name)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/
staticfiles/management/commands/runserver.py", line 4, in 
from django.core.management.commands.runserver import
BaseRunserverCommand
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/runserver.py", line 8, in 
from django.core.handlers.wsgi import WSGIHandler
  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
wsgi.py", line 11, in 
from django.core import signals
  File "/usr/local/lib/python2.6/dist-packages/django/core/
signals.py", line 1, in 
from django.dispatch import Signal
  File "/usr/local/lib/python2.6/dist-packages/django/dispatch/
__init__.py", line 9, in 
from django.dispatch.dispatcher import Signal, receiver
ImportError: cannot import name receiver

Same thing goes if I start a blank project and run : `python manage.py
runserver`. Any idea ???

Sébastien


On Mar 4, 8:00 am, James Bennett  wrote:
> Tonight we're proud to announce the first release candidate for Django
> 1.3; if all goes well, the final release will happen in about a week.
>
> Details for the release candidate are available on the official Django weblog:
>
> http://www.djangoproject.com/weblog/2011/mar/03/13-rc/
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
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: Announcing djeneralize

2011-01-25 Thread sebastien piquemal
Great packages ...

I was looking for something exactly similar for a project I am working
on. I will surely use one of those !


On Jan 25, 4:49 pm, Euan Goddard  wrote:
> Hi Tom,
>
> I hadn't seen that. django_polymorphic looks pretty fully featured and
> from a quick look, I'd say it accomplishes everything we set out to
> do. I guess a use case for djeneralize would be to handle the simple
> specializations and generalizations and nothing more. The impetuous to
> write the package was just to augment Django's model inheritance which
> did almost everything we needed.
>
> Thanks again for the link.
>
> Euan
>
> On Jan 25, 2:26 pm, Tom Evans  wrote:
>
> > On Tue, Jan 25, 2011 at 11:43 AM, Euan Goddard  
> > wrote:
> > > Hi,
>
> > > I've recently been working on an open source project to augment the
> > > inheritance of models in Django. This project, called "djeneralize"
> > > allows you to declare specializations on your models and then query
> > > the general case model and get back the specialized instances. A
> > > simple example of the models might be:
>
> > Hi Euan, sounds good.
>
> > Had you come across django_polymorphic[1]? This library also covers
> > similar goals.
>
> > Cheers
>
> > Tom
>
> > [1]http://bserve.webhop.org/django_polymorphic/

-- 
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: ANN: django-widget-tweaks

2011-01-12 Thread sebastien piquemal
Sounds cool !

On Jan 12, 9:48 pm, Mikhail Korobov  wrote:
> Hi guys,
>
> Designers often want to add some css classes and html attributes to
> django form fields. But now they have to either patch the python code
> or copy-paste full html widget output and then customize it. In order
> to make them happy I just released an app 
> (https://bitbucket.org/kmike/django-widget-tweaks
> ) that makes it possible to customize html attributes and css classes
> of form fields without touching python code.
>
> Example:
>
>     {% load widget_tweaks %}
>     ...
>     {{ form.city|attr:"autocomplete:off"|add_class:"my_css_class" }}
>
> Hope somebody will find it useful.

-- 
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.



Implementing a ldap db backend

2010-11-03 Thread sebastien piquemal
Hi !

I am currently on a big project, which should result in a ldap
management service (modifying users, groups, and any other ldap
object).

Until now, I have been using django-ldapdb, in order to use ldap as a
db backend. It was good for a very basic read-only prototype of the
service. However, this library is not really maintained anymore, and
due to a very high-level implementation (it only subclasses Model,
Query, Queryset, ...), there are a lot of quirks which makes it
unusable for more complex cases.

I have thought of many solutions to replace ldapdb. I came to
conclusion than the cleanest, and most useful for the community, would
be to implement a real db backend for ldap. However, I have been told
that it is an awfully big task !

So, here come my questions ... Do some of you have an implementation
of such a thing in mothballs ? Are some of you interested in sharing
the effort for this ?

If no good answer, I guess I'll just do as I was advised and implement
for myself a few python classes based on python-ldap :-(

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How to aggregate values by month

2010-10-29 Thread sebastien piquemal
Hi !

You could also give django-cube a try :
http://code.google.com/p/django-cube/
Unlike Mikhail's app, the aggregates are not efficient (because no
optimization is made, I am working on this), but this is more than
enough if you have a reasonable amount of data (less than millions of
rows !!!).
Use the following code, and you should have what you need :

from cube.models import Cube

class SalesCube(Cube):

month = Dimension('date_created__absmonth',
queryset=Sale.objects.filter(date_created__range=(init_date,ends_date)))

@staticmethod
def aggregation(queryset):
return queryset.count()

The advantage is that if you want to add more dimensions (type of sale/
place/month, etc ...), you can do it very easily.
Hope that helps, and don't hesitate to ask me if you can't have it
working (documentation is not very good yet).

On Oct 29, 12:54 am, Mikhail Korobov  wrote:
> Hi Rogério,
>
> You can givehttp://bitbucket.org/kmike/django-qsstats-magic/srca
> try.
> It currently have efficient aggregate lookups (1 query for the whole
> time series) only for mysql but it'll be great if someone contribute
> efficient lookups for other databases :)
>
> On 28 окт, 19:31, Rogério Carrasqueira
>
>  wrote:
> > Hello!
>
> > I'm having an issue to make complex queries in django. My problem is, I have
> > a model where I have the sales and I need to make a report showing the sales
> > amount per month, by the way I made this query:
>
> > init_date = datetime.date(datetime.now()-timedelta(days=365))
> > ends_date = datetime.date(datetime.now())
> > sales =
> > Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_ 
> > created__month).aggregate(total_sales=Sum('total_value'))
>
> > At the first line I get the today's date past one year
> > after this I got the today date
>
> > at sales I'm trying to between a range get the sales amount grouped by
> > month, but unfortunatelly I was unhappy on this, because this error
> > appeared:
>
> > global name 'date_created__month' is not defined
>
> > At date_created is the field where I store the information about when the
> > sale was done., the __moth was a tentative to group by this by month.
>
> > So, my question: how to do that thing without using a raw sql query and not
> > touching on database independence?
>
> > Thanks so much!
>
> > Rogério Carrasqueira
>
> > ---
> > e-mail: rogerio.carrasque...@gmail.com
> > skype: rgcarrasqueira
> > MSN: rcarrasque...@hotmail.com
> > ICQ: 50525616
> > Tel.: (11) 7805-0074
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Staticstic app, ask for idea.

2010-09-12 Thread sebastien piquemal
You could run the django-cube tests !

If you don't give me the error trace, I cannot really help you !

On Sep 11, 8:10 pm, Lucian Romi <romi.luc...@gmail.com> wrote:
> Thanks for your help. It's very clear.
> I used measure_list method but it thrown and exception.
> Here's how I did,
> In my app's ModelAdmin I override changelist_view method.
> I was able to get the queryset, then instantied cube with this queryset.
> If I didn't call measure_list, everything works fine. But if I call
> it, there is exception, but django didn't give much useful infomation
> in stdout, and I'm going to debug it later.
> If you aware of anything I'm doing wrong, please let me know. Or is
> there any sample I can quickly run just to verify there is nothing
> wrong with my enviroment.
> Thanks.
>
> On Sat, Sep 11, 2010 at 7:40 AM, sebastien piquemal <seb...@gmail.com> wrote:
> >    class MyModelCube(Cube):
> >        my_dimension = Dimension(field='my_float_field__range',
> > sample_space=[(0, 1.5), (1.5, 6.2)])
>
> >       �...@static
> >        def aggregation(queryset):
> >            return queryset.count()/MyModel.objects.count() * 100
>
> > Basically when you declare a dimension, you can use any field-lookup
> > from Django, so when I write 'my_float_field__range' it means :
> > -> You said in your question "There is a float field in my
> > model(table)", as you didn't tell the name of your "float field", I
> > wrote : 'my_float_field'
> > -> You said that you want the percentage in each range... so I used
> > the field look-up '__range' from Django.
>
> > If your "float field" is called "gnagna", then you would declare your
> > dimension like this : Dimension(field="gnagna__range", ...
>
> > Ok ... when you have declared this, you have a Cube class. After, you
> > need to instantiate an object from this class, in order to use its
> > methods ! To do this, you call the Cube constructor, with a queryset
> > as argument :
> >>>> instantiated_cube = MyModelCube(a_queryset)
>
> > Then, and only then, you can use the methods (all the calculations
> > will be based on "a_queryset"). For exemple, if you want a list of
> > measures :
> >>>> my_measures = instantiated_cube.measure_list("my_dimension")
>
> > Considering the sample space I used to declare the dimension, this
> > should give something like this :
> >>>> my_measures
> > [65, 29]
> > Where 65 means "65% of the floats are in the range [0, 1.5]", 29 means
> > "29% of the floats are in the range [1.5, 6.2]"
>
> > Is it clearer like this ?
>
> > On Sep 11, 4:04 am, Lucian Romi <romi.luc...@gmail.com> wrote:
> >> Also, need I define "my_float_field__range"? Thanks
>
> >> On Fri, Sep 10, 2010 at 6:52 PM, Lucian Romi <romi.luc...@gmail.com> wrote:
> >> > Hi, Sebastien
>
> >> > Follow your instruction, I was able to create a Cube object and define
> >> > sample_space.
> >> > However, I don't know how to retrieve the measure result. Can you tell
> >> > me how to do that?
> >> > What do you mean by "instantiate a cube with a base queryset, and use
> >> > one of the methods
> >> > provided to calculate the statistics"
>
> >> > Thanks.
>
> >> > On Tue, Aug 31, 2010 at 1:33 AM, sebastien piquemal <seb...@gmail.com> 
> >> > wrote:
> >> >> To integrate a calculated value with search features from admin app, I
> >> >> don't know any other way than create and save a calculated field on
> >> >> your model ...
> >> >> This calculated field, you can calculate it with cube ... but if you
> >> >> don't use the Cube for any other statistic than that, it is too much
> >> >> overhead.
>
> >> >> On Aug 31, 5:30 am, Lucian Romi <romi.luc...@gmail.com> wrote:
> >> >>> Thanks Sebastien.
>
> >> >>> Can I integrate Cube with filter and search features from the admin 
> >> >>> app?
> >> >>> Also, to make things simple, I'm going to use GChart, but I need
> >> >>> statistic data.
> >> >>> Let me download Cube and spend some time on it. Thanks.
>
> >> >>> On Mon, Aug 30, 2010 at 4:16 PM, sebastien piquemal <seb...@gmail.com> 
> >> >>> wrote:
> >> >>> > I created an app to easily generate the stats part :
> >> 

Re: Staticstic app, ask for idea.

2010-09-11 Thread sebastien piquemal
class MyModelCube(Cube):
my_dimension = Dimension(field='my_float_field__range',
sample_space=[(0, 1.5), (1.5, 6.2)])

@static
def aggregation(queryset):
return queryset.count()/MyModel.objects.count() * 100

Basically when you declare a dimension, you can use any field-lookup
from Django, so when I write 'my_float_field__range' it means :
-> You said in your question "There is a float field in my
model(table)", as you didn't tell the name of your "float field", I
wrote : 'my_float_field'
-> You said that you want the percentage in each range... so I used
the field look-up '__range' from Django.

If your "float field" is called "gnagna", then you would declare your
dimension like this : Dimension(field="gnagna__range", ...


Ok ... when you have declared this, you have a Cube class. After, you
need to instantiate an object from this class, in order to use its
methods ! To do this, you call the Cube constructor, with a queryset
as argument :
>>> instantiated_cube = MyModelCube(a_queryset)

Then, and only then, you can use the methods (all the calculations
will be based on "a_queryset"). For exemple, if you want a list of
measures :
>>> my_measures = instantiated_cube.measure_list("my_dimension")

Considering the sample space I used to declare the dimension, this
should give something like this :
>>> my_measures
[65, 29]
Where 65 means "65% of the floats are in the range [0, 1.5]", 29 means
"29% of the floats are in the range [1.5, 6.2]"

Is it clearer like this ?

On Sep 11, 4:04 am, Lucian Romi <romi.luc...@gmail.com> wrote:
> Also, need I define "my_float_field__range"? Thanks
>
> On Fri, Sep 10, 2010 at 6:52 PM, Lucian Romi <romi.luc...@gmail.com> wrote:
> > Hi, Sebastien
>
> > Follow your instruction, I was able to create a Cube object and define
> > sample_space.
> > However, I don't know how to retrieve the measure result. Can you tell
> > me how to do that?
> > What do you mean by "instantiate a cube with a base queryset, and use
> > one of the methods
> > provided to calculate the statistics"
>
> > Thanks.
>
> > On Tue, Aug 31, 2010 at 1:33 AM, sebastien piquemal <seb...@gmail.com> 
> > wrote:
> >> To integrate a calculated value with search features from admin app, I
> >> don't know any other way than create and save a calculated field on
> >> your model ...
> >> This calculated field, you can calculate it with cube ... but if you
> >> don't use the Cube for any other statistic than that, it is too much
> >> overhead.
>
> >> On Aug 31, 5:30 am, Lucian Romi <romi.luc...@gmail.com> wrote:
> >>> Thanks Sebastien.
>
> >>> Can I integrate Cube with filter and search features from the admin app?
> >>> Also, to make things simple, I'm going to use GChart, but I need
> >>> statistic data.
> >>> Let me download Cube and spend some time on it. Thanks.
>
> >>> On Mon, Aug 30, 2010 at 4:16 PM, sebastien piquemal <seb...@gmail.com> 
> >>> wrote:
> >>> > I created an app to easily generate the stats part :
> >>> >http://code.google.com/p/django-cube/;however you still have to
> >>> > create the chart, for example with matplotlib :
> >>> >http://www.scipy.org/Cookbook/Matplotlib/Django.
>
> >>> > To create your stats with django-cube, you can use this code :
>
> >>> >    from cube.models import Cube, Dimension
>
> >>> >    class MyModelCube(Cube):
> >>> >        my_dimension = Dimension(field='my_float_field__range',
> >>> > sample_space=[(0, 1.5), (1.5, 6.2)])
>
> >>> >       �...@static
> >>> >        def aggregation(queryset):
> >>> >            return queryset.count()/MyModel.objects.count() * 100
>
> >>> > - You specify one dimension for the cube, this dimension refers to the
> >>> > field lookup 'my_float_field__range' (where 'my_float_field' is of
> >>> > course the name of your field)
> >>> > - then you specify a sample space for this dimension, which in fact
> >>> > means that you specify for which ranges the stats will be calculated
> >>> > (here, on the ranges (0, 1.5) and (1.5, 6.2))
> >>> > - then you write your aggregation function, which is in your case a
> >>> > percentage calculation ('queryset' is the queryset filtered according
> >>> > to the dimensions you will use while querying the cube, divided by the
> >

Re: Aggregate on part of a date field?

2010-09-08 Thread sebastien piquemal
I created a library to address this kind of problems :
http://code.google.com/p/django-cube/

It bases the aggregation on a multidimensional view of your data (a
cube), so basically you can group_by in any way you want ("any way you
want" = "on all the dimensions that you want", so you have to declare
a cube and its dimensions).

Furthermore, if I understood your query, you want to group by  (which is not possible in Django yet), and this is something I
implemented in "django-cube".

However, the fact that it is based on something that you have to
declare (in a very similar fashion to declaring Django models),
introduces a small overhead, which means that it might not be a good
solution if you are not going to calculate more aggregations than this
single one with it (it was originally meant for data visualization
purposes).

This is still beta, and the documentation is unclear, so if you want
to use it, feel free to ask me any question.

Yours,

Sébastien


On Sep 7, 6:51 pm, Don  wrote:
> I need to create a query that aggregates values by the year of a date
> field. I have not been able to discover a way to do this yet, perhaps
> someone can help. I can issue the following raw query, which gives the
> results I want:
>
> cursor.execute("""SELECT year(oac_date) as year, month(oac_date) as
> month, sum(oac_actualconsumption) as consumption
>              FROM actualconsumption
>             WHERE oac_object = %s AND oac_commodity = %s AND
> year(oac_date) = %s
>             GROUP BY year(oac_date), month(oac_date)
>             ORDER BY month(oac_date)""", [object_id, commodity, year])
>
> Where oac_object is the pk for the table.
>
> This summarizes the oac_actualconsumption by year. Does anyone have an
> idea how to do this without resorting to a raw query? I have not been
> able to get the aggregates to work over parts of a date field in the
> database, only on the whole field.
>
> 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-us...@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: Staticstic app, ask for idea.

2010-08-31 Thread sebastien piquemal
To integrate a calculated value with search features from admin app, I
don't know any other way than create and save a calculated field on
your model ...
This calculated field, you can calculate it with cube ... but if you
don't use the Cube for any other statistic than that, it is too much
overhead.

On Aug 31, 5:30 am, Lucian Romi <romi.luc...@gmail.com> wrote:
> Thanks Sebastien.
>
> Can I integrate Cube with filter and search features from the admin app?
> Also, to make things simple, I'm going to use GChart, but I need
> statistic data.
> Let me download Cube and spend some time on it. Thanks.
>
> On Mon, Aug 30, 2010 at 4:16 PM, sebastien piquemal <seb...@gmail.com> wrote:
> > I created an app to easily generate the stats part :
> >http://code.google.com/p/django-cube/; however you still have to
> > create the chart, for example with matplotlib :
> >http://www.scipy.org/Cookbook/Matplotlib/Django.
>
> > To create your stats with django-cube, you can use this code :
>
> >    from cube.models import Cube, Dimension
>
> >    class MyModelCube(Cube):
> >        my_dimension = Dimension(field='my_float_field__range',
> > sample_space=[(0, 1.5), (1.5, 6.2)])
>
> >       �...@static
> >        def aggregation(queryset):
> >            return queryset.count()/MyModel.objects.count() * 100
>
> > - You specify one dimension for the cube, this dimension refers to the
> > field lookup 'my_float_field__range' (where 'my_float_field' is of
> > course the name of your field)
> > - then you specify a sample space for this dimension, which in fact
> > means that you specify for which ranges the stats will be calculated
> > (here, on the ranges (0, 1.5) and (1.5, 6.2))
> > - then you write your aggregation function, which is in your case a
> > percentage calculation ('queryset' is the queryset filtered according
> > to the dimensions you will use while querying the cube, divided by the
> > total, multiplied by 100)
> > - finally, you instantiate a cube with a base queryset, and use one of
> > the methods provided to calculate the statistics
>
> > Ok, the doc is kind of bad for now, but I can help you if you want to
> > use it but you don't manage to do so.
>
> > On Aug 30, 8:24 pm, hollando <romi.luc...@gmail.com> wrote:
> >> I want to make a statistic app.
> >> There is a float field in my model(table).I want to use a chart to
> >> show what's the percentage in each range.
> >> Any suggestion to make such and app that can fit into django model.
> >> 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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-us...@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: Staticstic app, ask for idea.

2010-08-30 Thread sebastien piquemal
I created an app to easily generate the stats part :
http://code.google.com/p/django-cube/ ; however you still have to
create the chart, for example with matplotlib :
http://www.scipy.org/Cookbook/Matplotlib/Django.

To create your stats with django-cube, you can use this code :

from cube.models import Cube, Dimension

class MyModelCube(Cube):
my_dimension = Dimension(field='my_float_field__range',
sample_space=[(0, 1.5), (1.5, 6.2)])

@static
def aggregation(queryset):
return queryset.count()/MyModel.objects.count() * 100

- You specify one dimension for the cube, this dimension refers to the
field lookup 'my_float_field__range' (where 'my_float_field' is of
course the name of your field)
- then you specify a sample space for this dimension, which in fact
means that you specify for which ranges the stats will be calculated
(here, on the ranges (0, 1.5) and (1.5, 6.2))
- then you write your aggregation function, which is in your case a
percentage calculation ('queryset' is the queryset filtered according
to the dimensions you will use while querying the cube, divided by the
total, multiplied by 100)
- finally, you instantiate a cube with a base queryset, and use one of
the methods provided to calculate the statistics

Ok, the doc is kind of bad for now, but I can help you if you want to
use it but you don't manage to do so.

On Aug 30, 8:24 pm, hollando  wrote:
> I want to make a statistic app.
> There is a float field in my model(table).I want to use a chart to
> show what's the percentage in each range.
> Any suggestion to make such and app that can fit into django model.
> 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-us...@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.



Introducing django-cube

2010-07-25 Thread sebastien piquemal
Hi everybody,

I just want to "advertise" a small Django app that I have begun a few
months ago, and little by little came to maturity : 
http://code.google.com/p/django-cube/

"
django-cube realizes multi-dimensional analysis on a queryset. It
tries to make easy :

   1. Calculating complex aggregates on a queryset
   2. Grouping these aggregates by multiple attributes
   3. Querying aggregates in your templates, easily outputting tables
"

The usefulness might not be obvious for everybody, so let's say that
it was developed as a base for a data visualization application.

There is still A LOT of room for improvement, but I think it could
potentially lead to really cool things :
* Base for a django-olap ? Doing "real" OLAP stuff
* Base for a django-dataviz ? Out-of-the-box data visualization
application (I already have some generic views for using django-cube
with OFC, ... I am thinking also of matplotlib, etc ...)

So here it is ...
Use it !
Give some feedback if you feel like, contribute if you feel like ...

Sébastien

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: annotate with query set for distinct values

2010-06-10 Thread sebastien piquemal
I think you didn't really look well anotate, because it looks like it
is what you qre looking for ! Or is there something I misunderstood ?

http://docs.djangoproject.com/en/dev/ref/models/querysets/#annotate-args-kwargs

"Annotates each object in the QuerySet with the provided list of
aggregate values (averages, sums, etc) that have been computed over
the objects that are related to the objects in the QuerySet. Each
argument to annotate() is an annotation that will be added to each
object in the QuerySet that is returned."

On Jun 11, 12:24 am, SlafS  wrote:
> Thanks.
>
> I've already tried that but this isn't quite what i'm looking for. As
> u wrote this returns a list, but I would like to obtain my calculated
> property when I'm iterating over this. Like so (let's say the result
> is in res variable) :
>
> {% for r in res %}
>    {{r.xxx}} - {{r.name__count}}
> {% endfor %}
>
> I'm starting to think that there's no such nice way to acheive that :/
>
> On 10 Cze, 23:06, Dan Harris  wrote:
>
>
>
> > Here is an example:
>
> > # In models.py
> > class TestModel(models.Model):
> >    name = models.CharField()
>
> > # Get a listing of unique names and their counts
> > # In some view
> > from django.db.models import Count
>
> > TestModel.objects.values("name").annotate(Count("name"))
>
> > This will return a list of the form:
>
> > [{'name__count': 2, 'name': u''}, {'name__count': 1, 'name':
> > u'bbb'}]
>
> > Hope this helps!
>
> > Dan Harris
> > dih0...@gmail.com
>
> > On Jun 10, 5:01 pm, SlafS  wrote:
>
> > > Hi there!
> > > I have a question. If i have a model with some fields (let's say all
> > > CharFields named aaa,bbb,ccc etc. and some calculated properties named
> > > xxx and zzz) how can I obtain something similar to
>
> > > "SELECT aaa, count(aaa) FROM my_model_table GROUP BY aaa;"
> > > i.e. a list of - lazy loaded - objects with distinct aaa values and an
> > > extra column which indicates how many entries of a specific aaa are in
> > > the table.
>
> > > I would like to acheive that with QuerySet and annotate so that I can
> > > get a list of objects to use their other properties (xxx or zzz) e.g.
> > > in my template
>
> > > Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.