How to use ManyToMany model relations to track user membership?

2011-09-08 Thread jollyroger
Hi. Can someone please tell, what kind of relations is required to store user's membership in multiple groups to be able to recover: 1. history of user participation in some groups (date joined, date quit) 2. list of current user groups (in join order) to determine his current status 3.

Re: How do I render a template variable inside a for loop, when the var is a dict and the key is forloop.counter

2011-09-08 Thread Bill Freeman
You might try a with tag to get the loop counter into a variable. On Thu, Sep 8, 2011 at 5:18 PM, Rami wrote: > Thanks. > But note that I'm not looking for the dict value in MyList, rather: I > loop on MyList and (trying to) retrieve the dict value from (another > var)

Re: How do I render a template variable inside a for loop, when the var is a dict and the key is forloop.counter

2011-09-08 Thread Rami
Thanks. But note that I'm not looking for the dict value in MyList, rather: I loop on MyList and (trying to) retrieve the dict value from (another var) BOOK_PHONE with key=loop.counter. I think that makes it a bit more challenging, but still it's a fairly simple case. It's this limitation in the

Trouble expressing a query in the ORM

2011-09-08 Thread Daniel Gagnon
Hi. I have a query I am trying to perform in the ORM and I'm not sure how to do it. I have two models: Target and Property with a one-to-many relationship. One Target can have many Properties. I want to list all targets along with their latest properties (as stored under Property.export_date)

Re: How do I render a template variable inside a for loop, when the var is a dict and the key is forloop.counter

2011-09-08 Thread Andre Terra
There is an inflexibility indeed, because the template is meant for designers, not programmers. Try {% for key, value in MyList.items %} instead. A hackier solution would be to write your custom template tag like {% get_from_dict foo bar %} to try to get foo[bar]. But in this case you can just

Re: Binding two views to one url?

2011-09-08 Thread Andre Terra
What you need to do is browse the class-based views docs for how to handle forms with them. https://docs.djangoproject.com/en/dev/ref/class-based-views/#formview Instead of switching from DetailView to FormView, you can just try to add some of the mixins that FormView uses. This way you can

Binding two views to one url?

2011-09-08 Thread Petey
Is it possible to bind two views to one url adress? I have a generic view - detail_view and I prepared a form for comments. Detail_views generates urls by "type", "pk", "slug" fields. Under each publication I'd like to add a form to add my comments model and I dont really know how I could do

How do I render a template variable inside a for loop, when the var is a dict and the key is forloop.counter

2011-09-08 Thread Rami
Hi, I have a dict var defined in server side, like PHONE_BOOK={1:'634534', 2:'264886', 3:'455346' etc..} Then in my django template I have this loop where I need to print the PHONE_BOOK[loop counter]: {% for Item in MyList %} Item.first_name | PHONE_BOOK.forloop.counter {% endfor %}

Re: Django and creating new formfields.

2011-09-08 Thread zayatzz
Nm. Googled alot and figured it out. def contribute_to_class(self, cls, name): super(MyFieldName, self).contribute_to_class(cls, name) signals.post_init.connect(self.post_init, cls, True) and self.post_init: def post_init(self, **kwargs):

Re: Integrating django-honeypot with Pinax

2011-09-08 Thread Bill Freeman
They are probably off under some folder named site-packages that isn't within the project. Probably the easiest way to find it is to (first activating any virtual environment as necessary) run: python manage.py shell Then import something of interest, then type its name, such as: >>> import

Re: Integrating django-honeypot with Pinax

2011-09-08 Thread Christos Jonathan Hayward
Breadcrumb note: someone on the list pointed out the middleware described at the bottom of django-honeypot's homepage. That was what I wanted. On Thu, Sep 8, 2011 at 1:21 PM, Christos Jonathan Hayward < christos.jonathan.hayw...@gmail.com> wrote: > I would like to incorporate django-honeypot ( >

Integrating django-honeypot with Pinax

2011-09-08 Thread Christos Jonathan Hayward
I would like to incorporate django-honeypot ( https://github.com/sunlightlabs/django-honeypot) into a Pinax site so there's less spam; the project was cloned from the social network. The basic instructions for django-honeypot are "Add X to your settings.py, do Y to templates containing forms you

Re: Django queries with dates and __lte

2011-09-08 Thread Shawn Milochik
I think your order by needs to be "-start" instead of "start," then take [0] instead of [:1]. That will get the newest entry that matches your query. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Django queries with dates and __lte

2011-09-08 Thread Axel Bock
Hello list, I have a little trouble setting up a Django query. In my app the user logs time spans by entering two time points. I want to make sure that a time span logged is not within another span already entered. Example: ONE goes from 1000 to 1200, TWO goes from 1400 to 1600. Now I want

Call to manager._insert() in save_base() returns None

2011-09-08 Thread Jens Ådne Rydland
Hi, I'm seeing some really weird behaviour when saving new instances of certain models. After calling save() the instance's primary key isn't set, despite the data having been inserted properly, and if I fetch the newest instance of the model in question I get the expected result, I get the data I

Re: Post-save hook after inline records saved?

2011-09-08 Thread Vinicius Massuchetto
On Feb 3 2010, 8:52 pm, Andy Robinson wrote: > I'm writing a bookkeeping system using Django latest code.   I would > like to make sure that when certain records are saved, changes are > made to other records.    For example, when I save a Sale model in the > admin - or

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread Cal Leeming [Simplicity Media Ltd]
Also, my apologies to OP for misunderstanding his original request :) Cal On Thu, Sep 8, 2011 at 1:26 PM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: > Again - that subject has already been heavily discussed and is already a > work in progress :X > >

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread Cal Leeming [Simplicity Media Ltd]
Again - that subject has already been heavily discussed and is already a work in progress :X Automating the install for the end user is not a simple task - unless you want to go down the VM Appliance route. See the following threads:

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread Donald Stufft
Cal, He's not looking to automate the install for the Developer of a Django Project, but for the End Users of a Django Project. So if I, or another developer wrote a WordPress clone using Django and then allow a third party to come and download my Wordpress clone and easily install it. On

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread Cal Leeming [Simplicity Media Ltd]
The subject of self contained deployments has already been *heavily* discussed in other threads. Self contained / single binary deployments is something that Roberto @ UNBIT is currently working on (and myself), and if you do a search on the mailing list, you'll see tons of ideas on this already.

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread Donald Stufft
This is a hard question. It would probably be nice to offer a self contained deployment that nginx/apache could just proxy too, maybe pick that as the default, and then add in writing a fcgi or wsgi file for use with regular hosting. On Thursday, September 8, 2011 at 7:34 AM, graeme wrote: >

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread graeme
He wants to be able to emulate the installation of a typical PHP CMS. This is often 1) get database username and poassword, 2) copyfiles to server, 3) navigate to an install URL, 4) fill in db username and password and other config on a set of forms on web page. Installing Django and the app you

tiny mce with file browser

2011-09-08 Thread Praveen Krishna R
*Hi,* * * *I hope somebody have implemented a file browser with tinymce, * *I would like to know what module you used to implement it. * *I don't want to use Grappelli to get this feature.* *comments ? * -- Thanks and Regards, *Praveen Krishna R* -- You received this message because you are

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread graeme
On Sep 8, 12:45 am, Calvin Spealman wrote: > Can you explain to those of us to whom it is not obvious, what is the > point of this proposal? I don't understand what problem it would > solve. > > > > > > On Wed, Sep 7, 2011 at 10:41 AM, Alec Taylor

Re: Streamlining DJango Deployment — Novel idea from the world of CMSs

2011-09-08 Thread graeme
On Sep 8, 12:45 am, Calvin Spealman wrote: > Can you explain to those of us to whom it is not obvious, what is the > point of this proposal? I don't understand what problem it would > solve. The commonest use case would be something like this: Someone wants to use a Django

Re: django and thrift

2011-09-08 Thread Li Lirong
Thank you! Using json may be a good idea. I will consider this carefully. On Thu, Sep 8, 2011 at 4:25 PM, Malcolm Box wrote: > > > On 8 September 2011 03:27, Li Lirong wrote: >> >> Hi, >> Thank you for your comments.  I am new to both django

Django and creating new formfields.

2011-09-08 Thread zayatzz
I have a problem when i try to create new model field type - postgres time[]. Thanks to psycopg2 the information from database is ready out and converted into python list. the list looks like that thought: [[datetime.time(0, 0), datetime.time(23, 59, 59)], [datetime.time(0, 0),

Re: django and thrift

2011-09-08 Thread Malcolm Box
On 8 September 2011 03:27, Li Lirong wrote: > Hi, > Thank you for your comments. I am new to both django and thrift. I > am hosting my service with a shared web hosting server. That's why I > want to use django to expose a thrift API. Basically, what I want is > to

Re: intercept calls to reverse(..) in tests

2011-09-08 Thread Reikje
Excellent Daniel, thanks a lot. On Sep 7, 10:23 am, Daniel Roseman wrote: > On Wednesday, 7 September 2011 07:49:00 UTC+1, Reikje wrote: > > > Hi, I have a bunch of WebTest's which are using the reverse method > > from django.core.urlresolvers to resolve a URL which the