using relationship fields in ModelAdmin

2010-01-11 Thread Mike Thon
I have an object in my model that has a OneToOne relationship with an object in another app. I would like to customize the way my object is displayed in the admin interface by subclassing ModelAdmin as shown in the tutorial. I'm not sure how to reference fields across the OneToOne relationship -

Re: Order model objects by foreign key "set" count

2010-01-11 Thread Margie Roginski
Ah - yes, that is so awesome! For anyone interested, here's the magic incantation: Book.objects.annotate(Count('reader')).order_by('reader__count') Or more verbosely: Book.objects.annotate(num_readers=Count('reader')).order_by ('num_readers') That documentation link describes it very well.

Re: Viewing details on a record in admin pages gives DoesNotExist error

2010-01-11 Thread kkerbel
That was it! Thank you very much for your time and effort! On Jan 11, 5:36 pm, Karen Tracey wrote: > On Mon, Jan 11, 2010 at 4:54 PM, kkerbel wrote: > > [snip] > >  File "/usr/local/lib64/python2.5/site-packages/django/db/models/ > > fields/related.py",

How crypt python code

2010-01-11 Thread nameless
I have to upload my django project on shared hosting. How can I crypt my code ? I want to hide my code on server. 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

Re: Order model objects by foreign key "set" count

2010-01-11 Thread Scott Maher
Margie Roginski wrote: Say I have a Reader model that has a foreign key to a Book class Reader(models.Model): book = models.ForeignKey(Book) Now say I want to find all books and order them by the number of readers. Is that possible, ie something like this?

Re: Brief tutorial to get a django dev server up.

2010-01-11 Thread Ovnicraft
2010/1/11 spike > Wow. Just WOW. > > I'm sorry to say this but, your audacity is embarrassing. > > I will continue to post here. > Would be better if you talk about you problems, experience, etc with django **here** and tutorials or whatever in your blog :). Cristian,

Re: Updated to revision 12207, now CSRF verification failed. Request aborted.

2010-01-11 Thread neridaj
I guess I had to add the middleware even though I'm using django.contrib.comments and generic views? On Jan 11, 7:12 pm, neridaj wrote: > what's up with this now. I'm suing contrib apps and generic views > i.e., no middleware needed, and I've added {% csrf_token %} to my POST

Re: Brief tutorial to get a django dev server up.

2010-01-11 Thread spike
Wow. Just WOW. I'm sorry to say this but, your audacity is embarrassing. I will continue to post here. Thank you. On Jan 11, 3:38 pm, Daniel Roseman wrote: > On Jan 11, 10:27 pm, spike wrote: > > > If you're planning on making a series of

Order model objects by foreign key "set" count

2010-01-11 Thread Margie Roginski
Say I have a Reader model that has a foreign key to a Book class Reader(models.Model): book = models.ForeignKey(Book) Now say I want to find all books and order them by the number of readers. Is that possible, ie something like this? Book.objects.all().order_by(reader_set__count) This

Re: Brief tutorial to get a django dev server up.

2010-01-11 Thread spike
Wow. On Jan 11, 3:38 pm, Daniel Roseman wrote: > On Jan 11, 10:27 pm, spike wrote: > > > If you're planning on making a series of posts, can I beg you to > please not post them here, but to get a blog and put them there? It's > great that you have

Updated to revision 12207, now CSRF verification failed. Request aborted.

2010-01-11 Thread neridaj
what's up with this now. I'm suing contrib apps and generic views i.e., no middleware needed, and I've added {% csrf_token %} to my POST forms but can't get rid of this. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

contrib.comments get_absolute_url raising 404 only on remote server

2010-01-11 Thread neridaj
I've been testing my site locally and figured I should commit some of my changes. I'm using django.contrib.comments and for some reason the comment.get_absolute_url is resulting in a broken link on the live server. When I mouse over the link the status bar reads the link correctly i.e.,

Re: form.has_changed always true?

2010-01-11 Thread Alastair Campbell
On Fri, Jan 8, 2010 at 1:09 AM, Karen Tracey wrote: > Using the instance parameter is the POST leg also allows you to simply > save() the form to get the changes to the instance saved.  There is then no > need to individually copy each of the fields from the form's

Re: Brief tutorial to get a django dev server up.

2010-01-11 Thread Daniel Roseman
On Jan 11, 10:27 pm, spike wrote: > Good points. Anyone looking for information of this nature after > reading this thread is sure to find information that helps. I write > this as a Django novice, hoping that the process of writing tutorials > for myself as I learn and

Re: Viewing details on a record in admin pages gives DoesNotExist error

2010-01-11 Thread Karen Tracey
On Mon, Jan 11, 2010 at 4:54 PM, kkerbel wrote: > [snip] > File "/usr/local/lib64/python2.5/site-packages/django/db/models/ > fields/related.py", line 257, in __get__ > rel_obj = QuerySet(self.field.rel.to).get(**params) > > File

Re: Brief tutorial to get a django dev server up.

2010-01-11 Thread spike
Good points. Anyone looking for information of this nature after reading this thread is sure to find information that helps. I write this as a Django novice, hoping that the process of writing tutorials for myself as I learn and submitting them to the community for some amount of review will push

Re: Brief tutorial to get a django dev server up.

2010-01-11 Thread Shawn Milochik
Since you asked for comments: The Django core developers are looking to discontinue Python 2.3 support soon, so it's a good idea to recommend 2.4 as the minimum, or state which version of Django requires Python 2.3 or higher. Just a personal preference, but I wouldn't recommend downloading and

Re: Viewing details on a record in admin pages gives DoesNotExist error

2010-01-11 Thread kkerbel
admin.py === from django.contrib import admin from . import models class PerDiemInline(admin.StackedInline): model = models.PerDiem class AccountInline(admin.StackedInline): model = models.Account class RequestAdmin(admin.ModelAdmin): list_display = ('requested_by',

Brief tutorial to get a django dev server up.

2010-01-11 Thread spike
This is just a brief tutorial I wrote for myself without the intention of releasing, but I figure if I can help just 1 person get started, then why keep it to myself. Again, not to be passed off as anything more then notes I wrote one afternoon for my own understanding on a Windows machine. Hope

Re: mod_wsgi and stderr

2010-01-11 Thread Graham Dumpleton
On Jan 12, 3:13 am, Patrick May wrote: > On Jan 5, 1:55 pm, Patrick May wrote: > > >                 I'm running Django using mod_wsgi under Apache.  I'm trying > > to write messages to the Apache error log with: > > >                

Re: mod_wsgi and stderr

2010-01-11 Thread Graham Dumpleton
On Jan 6, 6:29 am, Karen Tracey wrote: > On Tue, Jan 5, 2010 at 2:22 PM, Patrick May wrote: > > > > > > > On Jan 5, 2:18 pm, Karen Tracey wrote: > > > On Tue, Jan 5, 2010 at 1:55 PM, Patrick May >

Re: How to get ModelAdmin given a Model

2010-01-11 Thread Matt Schinckel
On Jan 12, 4:11 am, Tomasz Zieliński wrote: > On 11 Sty, 16:23, Marco Rogers wrote: > > > I'm reposting this from earlier to see if I have better luck. I need > > to be able to get the ModelAdmin associated with a model at runtime. > >

Best way to fix django admin preview of flatpage attached to multiple sites

2010-01-11 Thread Tomasz Zieliński
I have flatpage attached to multiple sites. Its admin preview chooses arbitrary site, which is quite obvious after debugging up to lines 35-36 of django.contrib.contenttypes.views.shortcut(). What would be the best way of fixing this problem? I see that mentioned shortcut() function receives

Re: Django with embedded python - module error

2010-01-11 Thread Wim De Hul
On Mon, Jan 11, 2010 at 05:58:07PM -0300, Gonzalo Delgado wrote: > El 10/01/10 18:06, Wim De Hul escribió: > > I'm trying to use Django in an embedded python app (main program is in C). > > When I try to import the models from my Django app, I get the following > > error: > > > > Traceback (most

Re: Viewing details on a record in admin pages gives DoesNotExist error

2010-01-11 Thread kkerbel
Ok...I'm sorry. The change list page is what I'm referring to...I'll try to gather some info and post 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-us...@googlegroups.com. To unsubscribe from

Re: Django with embedded python - module error

2010-01-11 Thread Gonzalo Delgado
El 10/01/10 18:06, Wim De Hul escribió: > I'm trying to use Django in an embedded python app (main program is in C). > When I try to import the models from my Django app, I get the following error: > > Traceback (most recent call last): > File "/data/mytest/test.py", line 4, in > from

Re: Viewing details on a record in admin pages gives DoesNotExist error

2010-01-11 Thread Karen Tracey
On Mon, Jan 11, 2010 at 2:59 PM, kkerbel wrote: > When viewing the admin pages for a travel request app we wrote, the > admin page shows the record links, however, when you click to view the > details of any record, I get an error stating "DoesNotExist: Employee > matching

Re: If Statements inside For Loops

2010-01-11 Thread Karen Tracey
On Mon, Jan 11, 2010 at 1:02 PM, Dave Merwin wrote: > First of all, thanks to everyone for the help!!! > > I'm not getting any output after the else. Nothing displays in the > template. > > That is what is confusing. > > "Nothing displays in the template" sounds like

Re: text in translation strings?

2010-01-11 Thread Andreas Pfrengle
> {% url login as login_url %} > {% blocktrans %}You need to login before > you can do anything {% endblocktrans %} > > I'm curious if this is good guess, so please let me know. It works! Didn't know that the url tag can name its result with "as". Thanks again :-) -- You received this message

Viewing details on a record in admin pages gives DoesNotExist error

2010-01-11 Thread kkerbel
When viewing the admin pages for a travel request app we wrote, the admin page shows the record links, however, when you click to view the details of any record, I get an error stating "DoesNotExist: Employee matching query does not exist." I've looked at the database and the employee does indeed

Re: Mysterious transactions wrapping views without middleware.

2010-01-11 Thread apramanik
Sure, but the transaction is still open and PostgresSQL prevents any other statements form being executed until it is closed. So, the db is pretty much locked until the next transaction is started (which in my case is when i render the view). I filed a bug for it:

Re: Mysterious transactions wrapping views without middleware.

2010-01-11 Thread Tomasz Zieliński
On 10 Sty, 02:38, apramanik wrote: > Thanks! That partially fixes my problem. I wrapped a function with > commit_on_success and it doesn't rollback the changes if it throws an > IntegrityError coming from PostgresSQL: > > @transaction.commit_on_success >     def

Re: Permissions (was: Namespace Security)

2010-01-11 Thread Shawn Milochik
Tim, I think that if you replace the term "namespace" with "group," we can do what we both want with the same solution. Or, in other words, we're kind of saying the same thing but using different words. In my scenario, each user would be in one or more groups. Each user could read or write

Re: How to get ModelAdmin given a Model

2010-01-11 Thread Tomasz Zieliński
On 11 Sty, 16:23, Marco Rogers wrote: > I'm reposting this from earlier to see if I have better luck. I need > to be able to get the ModelAdmin associated with a model at runtime. > Similar to how django.db.models.get_model allows you to retrieve a > model. > >    

Re: Permissions (was: Namespace Security)

2010-01-11 Thread Tim
That looks like a pretty good starting point. It's a little different in that for my scenario, UserA and UserB would both be accessing django admin, but would get different results based on what Namespaces they have access to. Seems like it should be pretty easy to create a Model Admin that

Re: text in translation strings?

2010-01-11 Thread Tomasz Zieliński
On 10 Sty, 12:59, Andreas Pfrengle wrote: > I'm having a template, where a link shall be inside a translation- > marked text. I see two ways how to accomplish this, but both don't > work: > 1. {% trans "You need to login before > you can do anything" %} (...) > 2. {%

Re: If Statements inside For Loops

2010-01-11 Thread Dave Merwin
First of all, thanks to everyone for the help!!! I'm not getting any output after the else. Nothing displays in the template. That is what is confusing. Dave On Jan 11, 8:58 am, Karen Tracey wrote: > On Mon, Jan 11, 2010 at 2:39 AM, Dave Merwin

Permissions (was: Namespace Security)

2010-01-11 Thread Shawn Milochik
This is something we've been thinking a lot about recently. The direction we are considering is something like this: http://github.com/paltman/django-logicaldelete This code, "logical delete," overrides the delete() method of models so that they are simply marked as deleted, and not returned

Re: Design Question - Extending a model

2010-01-11 Thread Igor
Thanks a lot - I didn't know about generic relations, and will definitely look at them - right now :). The minimal subset - and that's where I'm trying to follow DRY - boils down to a Title, a slug, Content HTML of the entry, maybe a couple more things - all are very much like what you would

Re: If Statements inside For Loops

2010-01-11 Thread Karen Tracey
On Mon, Jan 11, 2010 at 2:39 AM, Dave Merwin wrote: > I have the following: > > {% for group in user.groups.all %} >{{ group.name }} >{% ifequal group.name "subscribed" %} >I'm subscribed >{% else %} >{{ group.name }} >{% endifequal %} > {%

Namespace Security

2010-01-11 Thread Tim
There is an interesting requirement in a project I am working on. For lack of a better term, I'll call it Namespace Security. Basically, there are arbitrary namespaces that can be defined, and every object belongs to a namespace. Then, users only have access to certain namespaces. So if a user has

Download avatar 2009 for free

2010-01-11 Thread avatar3
Download avatar 2009 In the future, Jake, a paraplegic war veteran, is brought to another planet, Pandora, which is inhabited by the Na'vi, a humanoid race with their own language and culture. Those from Earth find themselves at odds with each other and the local culture. Download avatar 2009  

Download avatar 2009 for free

2010-01-11 Thread avatar3
Download avatar 2009 In the future, Jake, a paraplegic war veteran, is brought to another planet, Pandora, which is inhabited by the Na'vi, a humanoid race with their own language and culture. Those from Earth find themselves at odds with each other and the local culture. Download avatar 2009  

Re: Design Question - Extending a model

2010-01-11 Thread Ethan Jucovy
My instinct is that you may be trying to be too generic. Without knowing more details, a "generic Entry" sounds a lot like .. a database record. :) Django's model.Model base class already does a great job at being easily extensible. Is there a specific minimal-but-interesting set of database

Re: mod_wsgi and stderr

2010-01-11 Thread Patrick May
On Jan 5, 1:55 pm, Patrick May wrote: >                 I'm running Django using mod_wsgi under Apache.  I'm trying > to write messages to the Apache error log with: > >                 sys.stderr.write('Message...') > > but for some reason they don't appear.  This is

How to get ModelAdmin given a Model

2010-01-11 Thread Marco Rogers
I'm reposting this from earlier to see if I have better luck. I need to be able to get the ModelAdmin associated with a model at runtime. Similar to how django.db.models.get_model allows you to retrieve a model. admin_class = get_admin(Model) Is this possible? The original post has more

Design Question - Extending a model

2010-01-11 Thread Igor
Hi all, This is a general question for whoever is good with best practices for Django design (software design that is). I'd like to implement (well, kinda have implemented), a generic Entry object that would be good for several uses. For example, an Event (such as, say, a website presentation)

models.DateTimeField - Filter only time

2010-01-11 Thread tom
Hi, i have a datetime field for my model. Now i want to filter all entries where the time is between 12:00:00 and 13:00:00 . How to do this? I tried Entry.objects.filter(begin__gt='12:00:00', end__lt='13:00:00') Cheers, tom -- You received this message because you are subscribed to the Google

Re: Inline Admin and ForeignKey

2010-01-11 Thread Igor
Thanks, you're right... was posting this late at night while experimenting and copied the experimental version... The way it looks now is this: class EventInline(admin.TabularInline): model = Event class EntryAdmin(admin.ModelAdmin): prepopulated_fields = { 'slug': ['title'] }

how to use an internal (multi-table inherited) OneToOneField

2010-01-11 Thread }--o
Hi, I have the following three models class AbstractModel title = CharField class Quote(AbstractModel) class Project(AbstractModel) Instead of creating a new Project when a Quote gets accepted, I would prefer extending the Quote's abstractproject_prt instance could someone show me how to

Re: Form Validation in Admin

2010-01-11 Thread Daniel Roseman
On Jan 11, 3:24 am, "Sasuke" wrote: > Hi all, > I'm using the form's clean() method to do validation for models in admin. The > validation we need to do is to make sure there are no more than a certain > number of items totally submitted. So I calculate the total number of

Re: Inline Admin and ForeignKey

2010-01-11 Thread Daniel Roseman
On Jan 11, 12:43 am, Igor wrote: > Hi, > > I have a blog model and would like to be able to add an arbitrary > number of event dates to it (i.e. turn a blog post into an event > announcement). For that I use > > class Event(models.Model): >     entry =

Re: If Statements inside For Loops

2010-01-11 Thread G B Smith
If the docs are to be believed, {% ifequal %} does provide an option for an {% else %} clause. See http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ifequal That said, I can't tell from the code above why it would not work. But if you are using Django dev version (post 1.1) then go

Re: Reverse filtering via ManytoManyField

2010-01-11 Thread janedenone
Solved (in Django 1.1): tags = Tag.objects.annotate(num_pages=Count('page')).filter (num_pages__gt=0) On 9 Jan., 19:50, janedenone wrote: > I defined two models (Tag and Page), where the Page model links to the > Tag model: > > tags = models.ManyToManyField(Tag,

Re: autocomplete widget

2010-01-11 Thread Sam Walters
Hi The widget source code is here, its pretty easy to see wats going on, if im dealing with forms i spend a lot of time in here: http://code.djangoproject.com/browser/django/trunk/django/forms/widgets.py And the docs are here:

Re: text in translation strings?

2010-01-11 Thread Michael P. Jung
> I'm having a template, where a link shall be inside a translation- > marked text. (...) I've recently run across a similar problem and solved it using some nasty with-tag trickery. In your case the following code should do the trick: {% url login as login_url %} {% with "" as link_begin %} {%

Re: handle astronomically high number of users via the new BigIntegerField and contrib.auth.user

2010-01-11 Thread G B Smith
That's a good snippet, but I am sticking with django.contrib.auth.models.user.id = BigIntegerField(primary_key=True) for now. On Jan 10, 11:46 pm, Eric Chamberlain wrote: > We used one of the UUID fields from djangosnippets.org > . > >