custom dynamic admin actions

2009-09-27 Thread J
Hello, I need to add custom dynamic admin actions (based on records in a related table), but I'm not entirely sure how to do this, as it's not explained in the docs. Basically, I have two models: "Transaction", which has a foreign key to "Account", and I want to define an admin action that will

Re: Custom linking of models in many-to-one relationship

2009-09-27 Thread kmike
This looks like django's generic relations ('Content types' in documentation). `select_related` for generic related models is not supported in django. So you should retreive all Notes associated with Account manually. If there are several Accounts you still can fetch all data in 2 queries using

Re: What JavaScript framework do you use and why?

2009-09-27 Thread Jani Tiainen
Joshua Russo kirjoitti: > Great links guys, thanks. I'm still in the mindset of frameworks just > making JavaScript less painful too and I'm looking for ways to move > beyond that. I just started looking at Dojo before posting this and it > definitely looks like it has potential. I'm pretty

Custom linking of models in many-to-one relationship

2009-09-27 Thread triman
I have a model that can be attached to a variety of different models, based on the value of a column. Is there any way to map this relationship in Django? If not, is there a way to automatically do post-fetch processing where I could populate it? Here is a example: class Note(models.Model):

Re: strange problem with floatformat

2009-09-27 Thread jonathan
Ha no one else seen this problem, or have any idea how it might happen? On Sep 26, 7:44 pm, jonathan wrote: > Hi, I am having a strange problem with floatformat (filter) and I > wonder if anyone else has seen it. > > I am using google app engine and am storing

Re: Admin URLs not working correctly

2009-09-27 Thread Vic Fryzel
I'm also able to reproduce this. Trying to figure out the issue. On Sep 27, 6:55 pm, Michael Williamson wrote: > > A small, recreatable example would help. > > I've just recreated by doing the following, all with Django 1.1: > >   1. Run django-admin startproject

Re: Why is this view not displaying data?

2009-09-27 Thread jeffself
Thanks Karen! That did the trick. --~--~-~--~~~---~--~~ 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

Re: Why is this view not displaying data?

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 8:41 PM, jeffself wrote: > > Here's my url.py: > > from django.conf.urls.defaults import * > > urlpatterns = patterns('Rankings.college.views', >url(r'^rankings/division/(\w+)/$', 'rankings_by_league'), > ) > > views.py > > def

Re: Update only selected fields

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 7:17 PM, jsk wrote: > > Hi all, > > I was wondering if there is built-in support for updating only > selected field(s) when calling model.save(). > When I call save() on the object, django call SQL UPDATE for all > fields of the model, which is not

Re: DateFormat in Django and Appengine

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 6:51 PM, Peter Newman < peter.newman@googlemail.com> wrote: > > Guys - > > I have a slight issue with dates in Django and appengine: > > I have the following class because i want date input in the form of DD/ > MM/YY > > class MyForm(ModelForm): > mydate =

Re: TypeError: save() got an unexpected keyword argument 'profile_callback'

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 6:04 PM, Gloria wrote: > > Hi All, > > I have inherited some Django code, I'm porting it to a new machine, > and here is an error I'm getting, which is proving to be hard to > trace: > > Traceback (most recent call last): > > File

Why is this view not displaying data?

2009-09-27 Thread jeffself
Here's my url.py: from django.conf.urls.defaults import * urlpatterns = patterns('Rankings.college.views', url(r'^rankings/division/(\w+)/$', 'rankings_by_league'), ) views.py def rankings_by_league(request, league): try: league = League.objects.get(slug__iexact=league)

Re: Admin URLs not working correctly

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 6:55 PM, Michael Williamson < mikerwilliam...@yahoo.co.uk> wrote: > > > A small, recreatable example would help. > > I've just recreated by doing the following, all with Django 1.1: > > 1. Run django-admin startproject bug > 2. Set DATABASE_ENGINE to sqlite3 and

Update only selected fields

2009-09-27 Thread jsk
Hi all, I was wondering if there is built-in support for updating only selected field(s) when calling model.save(). When I call save() on the object, django call SQL UPDATE for all fields of the model, which is not ideal from performance point of view. I've found this snippet:

Re: Admin URLs not working correctly

2009-09-27 Thread Michael Williamson
> A small, recreatable example would help. I've just recreated by doing the following, all with Django 1.1: 1. Run django-admin startproject bug 2. Set DATABASE_ENGINE to sqlite3 and DATABASE_NAME to /tmp/bug- database 3. Add 'django.contrib.admin' to INSTALLED_APPS 4. Edit urls.py so

DateFormat in Django and Appengine

2009-09-27 Thread Peter Newman
Guys - I have a slight issue with dates in Django and appengine: I have the following class because i want date input in the form of DD/ MM/YY class MyForm(ModelForm): mydate = forms.DateTimeField(input_formats=['%d-%m-%y', '%d/%m/ %y']) class Meta: model = MyObject This

Re: TypeError: save() got an unexpected keyword argument 'profile_callback'

2009-09-27 Thread Gloria
Some logging debug, placed in /usr/local/lib/python2.6/dist-packages/ django/core/handlers/base.py: import logging import pprint logging.error("Args: %s %s %s %s" % (pprint.pformat (callback),pprint.pformat(callback_args),pprint.pformat

Re: Modeling and validating international addresses?

2009-09-27 Thread Nan
Google finds one app that seems pretty heavyweight (and poorly documented): http://code.google.com/p/django-global-contact/ At first glance, building a model that can read address formats from a database for forms and output should be fairly straightforward, but input validation is much more

Re: Overriding verbose_name in contrib or 3rd-party apps?

2009-09-27 Thread Nan
Thanks for the suggestions, everyone. It seems to be popping up for all sorts of things -- from changing verbose_name in order to globally relabel form fields in ModelForms to changing __unicode__ methods to change template output. I know there are workarounds, but they seem less DRY. On Sep

TypeError: save() got an unexpected keyword argument 'profile_callback'

2009-09-27 Thread Gloria
Hi All, I have inherited some Django code, I'm porting it to a new machine, and here is an error I'm getting, which is proving to be hard to trace: Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ base.py", line 92, in get_response

Re: Admin URLs not working correctly

2009-09-27 Thread Michael Williamson
> You've listed one that doesn't work -- /admin/blog/comment/add. Is comment > listed as a model at all under /admin/blog when things break? Does > /admin/blog/comment/ work to show a change list of comment models? Can you > bring up a detail page on an existing one? Successfully change it?

Re: en vs. en_US (was 'Problems creating a new locale')

2009-09-27 Thread Lewis Taylor
Hi michael, the language code should always be in the form xx or xx-xx and the locale folders should be in the form xx or xx_XX. If you look through the translation code you can see that what django does is given a language xx-xx, it will check for xx_XX locale then xx. given xx (en for

Re: Admin URLs not working correctly

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 4:41 PM, Michael Williamson < mikerwilliam...@yahoo.co.uk> wrote: > > Admin URLs do not seem to behaving themselves for me. My urls.py looks > like this: > >from django.conf.urls.defaults import * > >from django.contrib import admin >admin.autodiscover() > >

Re: Overriding verbose_name in contrib or 3rd-party apps?

2009-09-27 Thread Michael Williamson
On Sep 25, 9:59 pm, ringemup wrote: > Is there an easy way to override strings like help_text or > verbose_name or __unicode__ methods for models in contrib or third- > party apps? I can't seem to find anything on Google. > > Thanks! A reasonably hacktastic way of doing

Re: Modeling and validating international addresses?

2009-09-27 Thread Wim Feijen
Hi ringmeup again, What I would do is choose the most common one and use that. In many web applications I find that people use American-style addresses, where I have to enter my state which has no equivalent in the Netherlands, but nevertheless I have to. Another good solution would be to

Admin URLs not working correctly

2009-09-27 Thread Michael Williamson
Admin URLs do not seem to behaving themselves for me. My urls.py looks like this: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^$', 'django.views.generic.simple.redirect_to', {'url': '/

Re: Overriding verbose_name in contrib or 3rd-party apps?

2009-09-27 Thread Wim Feijen
Can you please post some more information for what purpose you like to do this? My first guess would be you are using the admin interface. Dirty workarounds are: copying code and adapting it, importing from your adaptation in stead of the original. Maybe modifying the admin view to do something

Re: can't show admin interface

2009-09-27 Thread Wim Feijen
It does nothing to help you solve your problem, but mod_wsgi is generally preferred above mod python. Good luck solving the problem! Wim On Sep 26, 10:06 am, nausikaa wrote: > Have you done > > from yourapp.models import * > from django.contrib import admin > >

Re: rendering a table

2009-09-27 Thread Wim Feijen
Hi Hugo, Your template code, does it actually contains and ? Like below? {% for row in rows %} {% for value in row %} {{ value }} {% endfor %} {% endfor %} Then, what does rows look like? Can you post your output please? To get this output, for example, use "print rows" before you render

Re: OperationalError: unable to open database file, when saving existing object

2009-09-27 Thread Wim Feijen
So, if I understand correctly, creating new objects and saving them to the database works correctly, and updating objects fails. Is that correct? Is it an update from the admin interface or from code written by you? If the former, it might have something to do with db privileges. Which back-end

Re: Moving the .py(c|o) files out of the app?

2009-09-27 Thread Ned Batchelder
Python doesn't give you a way to write the .pyc files anywhere except next to their .py files. But you can compile everything ahead of time, and then either move the .pyc files somewhere else or just delete the .py files (assuming you have another copy!) The python module compileall is just

formfield_overrides for a specific field

2009-09-27 Thread tygielzchaosem
Hey all, Is it possible to use ModelAdmin.formfield_overrides attribute to customize a widget for only one field in an admin form, not for all fields of a certain type in a model? Say we have an admin class like this: class MyModelAdmin(admin.ModelAdmin): formfield_overrides = {

Re: Authentication for static files

2009-09-27 Thread Ben Davis
Actually, I just found out about the X-Sendfile header which I think might solve this problem. It basically allows you to set the HttpResponse content to an empty string, but the X-Sendfile header tells apache to send a file from the filesystem, so apache handles the actual serving of the file,

Re: django-trunk/django directory problem

2009-09-27 Thread Malcolm MacKinnon
Ok, thanks David. On Sun, Sep 27, 2009 at 1:30 AM, Daniel Roseman wrote: > > On Sep 27, 4:48 am, Malcolm MacKinnon wrote: > > Thanks, but I don't understand. Will removal cause problems with django > > project/app on python path. It's simlinked to the

Re: admin site doesn't refresh

2009-09-27 Thread Marek Pietrucha
FALS PROBLEM!! No NEED to reply. sory :) On Sep 27, 6:00 pm, Marek Pietrucha wrote: > I added screen shots: > > localhost:http://picasaweb.google.com/mark.pietrucha/DjangoAdminSite#5386176920... >

Re: rendering a table

2009-09-27 Thread jhugo
What i want to display as a table is the fallowing: rows---row--- row ---row | | | number1 name1 date1 number2 name2 date2 number3 name3 date3 Now when django renders my template i get this: number1

Re: My Django powered website for web based learning

2009-09-27 Thread Parag Shah
Sorry about that. It should be accessible now: http://www.adaptivelearningonline.net -- Thanks & Regards Parag Shah http://blog.adaptivesoftware.biz On Sun, Sep 27, 2009 at 9:55 PM, Grant Livingston wrote: > Same here.. > > > > >

Re: My Django powered website for web based learning

2009-09-27 Thread Grant Livingston
Same here.. --~--~-~--~~~---~--~~ 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

Re: My Django powered website for web based learning

2009-09-27 Thread Marek Pietrucha
I can't get in :( Is the site up and running? On Sep 27, 3:16 pm, Parag Shah wrote: > Hello, > > I have created a Django powered website for open learning which organizes > various computer science related course videos in the form of structured > courses. > > Many thanks

Re: admin site doesn't refresh

2009-09-27 Thread Marek Pietrucha
I added screen shots: localhost: http://picasaweb.google.com/mark.pietrucha/DjangoAdminSite#5386176920766947362 megiteam.pl: http://picasaweb.google.com/mark.pietrucha/DjangoAdminSite#5386176927362649474 I think it's not a problem with the host because when i add different modules from other

admin site doesn't refresh

2009-09-27 Thread Marek Pietrucha
Hello my dear django users, I started to write and application in django and I encountered a problem with which i'm dealing for about 2days (i'm quite frustrated ;) ) I have constructed my models, as follows: # Company Models from django.db import models class CompanyType(models.Model):

RE: login_required redirects to a specific url

2009-09-27 Thread Сергей Зигачев
Sorry, maybe you should use something like that: @login_required(redirect_field_name='redirect_to') Where `redirect_to' is the address for a specific page. -Original Message- From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On Behalf Of V Sent: Sunday,

Re: Passing parent with multiple childs from View to HTML

2009-09-27 Thread Jay
In Django template, you can make methed call. So you can pass the auther object to the template, then {% for book in auther.books.all %} {% for section in book.sections.all %} {% end for %} {% endfor %} The ordering is using the definition in the Model Meta class.

Re: login_required redirects to a specific url

2009-09-27 Thread V
but that's a site wide setting, and I would like to have a different url for a specific view only V On Sep 27, 3:41 pm, "Сергей Зигачев" wrote: > Hello, > > http://docs.djangoproject.com/en/dev/ref/settings/#setting-LOGIN_URL > > As you can see, you need to

RE: login_required redirects to a specific url

2009-09-27 Thread Сергей Зигачев
Hello, http://docs.djangoproject.com/en/dev/ref/settings/#setting-LOGIN_URL As you can see, you need to implement the LOGIN_URL value in your settings.py file. From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On Behalf Of }--o Sent: Sunday, September 27, 2009

OperationalError: unable to open database file, when saving existing object

2009-09-27 Thread pigmalione
Hello, When I attempt to save an existing db object I get the following error: File "", line 1, in File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 410, in save self.save_base(force_insert=force_insert, force_update=force_update) File

login_required redirects to a specific url

2009-09-27 Thread }--o
Hi, I'm using the login_required decorator extensively, but have one view where instead of the default landing page ('accounts/login') I would like to redirect it to a specific page. Is there a simple way to do this? Viktor --~--~-~--~~~---~--~~ You received this

[ANN] My Django powered website for web based learning

2009-09-27 Thread Parag Shah
Hello, I have created a Django powered website for open learning which organizes various computer science related course videos in the form of structured courses. Many thanks to the excellent Django and Python community for helping me get through the issues I faced. The website is hosted at:

Re: TinyMCE in Admin (Practical Django Projects book)

2009-09-27 Thread Erik Kronberg
On Sun, Sep 27, 2009 at 1:54 PM, James Bennett wrote: > > On Sun, Sep 27, 2009 at 6:48 AM, Erik Kronberg wrote: > > I'm on chapter 3 of James Bennett's Practical Django Projects. My > > problem is that TinyMCE isn't showing up in the Admin -> New

Re: How to establish foreign key contraints across models living in different applications

2009-09-27 Thread pkenjora
Guillermo, Having one application depend on another is OK. If your are writing a generic reusable application that other can download and plug in then generic keys may be the way to go. If however, you are simply having one of your own apps depend on another I strongly suggest not using

Re: Custom Command as cron

2009-09-27 Thread pkenjora
Here is an example of a complete script that does this: http://blog.awarelabs.com/2007/using-django-models-in-batch-jobs/ You will need to know the complete path to Django. In the CRON you now do not need to set PYTHONPATH for Django because it is set in the actual script. -Paul On Sep 24,

Re: TinyMCE in Admin (Practical Django Projects book)

2009-09-27 Thread James Bennett
On Sun, Sep 27, 2009 at 6:48 AM, Erik Kronberg wrote: > I'm on chapter 3 of James Bennett's Practical Django Projects. My > problem is that TinyMCE isn't showing up in the Admin -> New Flatpage > text area. Using Linux (Ubuntu 9.04) First thing I'd recommend is checking it

TinyMCE in Admin (Practical Django Projects book)

2009-09-27 Thread Erik Kronberg
Hello! I'm completely stuck, double checked spelling and tried a couple of different things. I am really new at Django and just know a bit of Python, so don't expect me to understand any complicated terminology! I'm on chapter 3 of James Bennett's Practical Django Projects. My problem is that

Re: IGNORABLE_404 woes

2009-09-27 Thread Karen Tracey
On Sat, Sep 26, 2009 at 11:33 PM, troyhitch wrote: > > I think I may have figured out what was happening. I did not have a > 404.html in templates, and assume now that the messages were coming > only because of that (the missing template seemed consequential to me > and not

Re: How to establish foreign key contraints across models living in different applications

2009-09-27 Thread James Bennett
On Sat, Sep 26, 2009 at 3:21 PM, djfis...@gmail.com wrote: > It is possible to have a model in one application have a foreign key > to another application as of Django 1.0. It's always been possible to point relationships at models in other applications. The bit you're

Re: How to establish foreign key contraints across models living in different applications

2009-09-27 Thread guillermooo
Hi David, I suppose that what you suggest would work too, but it would break the reusability of the Todo application. I think what I need is rather a GenericRelation/GenericForeignKey. Just found it in the docs. Thanks, Guillermo On Sep 26, 10:21 pm, "djfis...@gmail.com"

Re: rendering a table

2009-09-27 Thread Léon Dignòn
Could you post your list and your output please? On Sep 27, 2:04 am, jhugo wrote: > Hi, > > I want to render a table using a list of list. What I do is create a > list for the rows and append another list for the columns. I use two > fors in my template to render the table

Re: admin list_display

2009-09-27 Thread paulhide
Thanks for your reply and I think you are right, I could achieve the effect I am after (described in the middle paragraph of my first post), but it just wouldn't be such a nice user interface as just clicking a link. Paul Hide On Sep 27, 10:05 am, Daniel Roseman wrote:

Re: admin list_display

2009-09-27 Thread Daniel Roseman
On Sep 26, 12:53 pm, paulh wrote: > Using the admin list_display and a callable with its allow_tags > property set to True you can plant a link for each object on the > changle_list display page of the admin. Is there some way of making > this link dynamic without having to

Re: admin list_display

2009-09-27 Thread paulhide
Having thought about this myself and done some more research, a better question is: is there a way of getting extra args through to a list_display callable? Having stared at the code in template_tags/ admin_list.py it would appear that there is no facility for getting extra args through to these

Re: django-trunk/django directory problem

2009-09-27 Thread Daniel Roseman
On Sep 27, 4:48 am, Malcolm MacKinnon wrote: > Thanks, but I don't understand. Will removal cause problems with django > project/app on python path. It's simlinked to the python site-packages. > The file 'django' inside your django-trunk/django directory is actually a

Moving the .py(c|o) files out of the app?

2009-09-27 Thread Christophe Pettus
This is more a deployment question, but: Is there a way of specifying a directory other than the app folder hierarchy for the .pyc or .pyo files to be written to? In production, I'm not wild about the idea of the app folders being writable by the Apache process. Any guidance? Thanks?

Re: Custom Command as cron

2009-09-27 Thread Fangzx
Hi, I used ubuntu crontab to exec python script in my project. 1. In crontab, you can do like this: DJANGO_SETTINGS_MODULE=divo3.settings PYTHONPATH=/root/deploy # m h dom mon dow command 50 * * * * python /root/deploy/divo3/job.py 2. The job.py file must put in the root dir of django