Rendering a field value in a custom way

2010-12-11 Thread Scoox
Hi guys, I want to be able to render a custom field. It's supposed to extend a normal char field. I want to place certain content in front of the field, depending upon the fields value. As an example take a simple field that allows entering a number. Instead of displaying the number, I would like

Re: Rendering a field value in a custom way

2010-12-11 Thread Scoox
Note: Why do I not to use filters? 1. It's nicer if the designer doesn't always have to put |(...) behind the field name. 2. I do not know how to access the object passed in the filter. E.g. if I use {{rating.stars|muBeautify}} the muBeautify filter would only get a unicode "5", but how would it k

Re: Django Form ChoiceField, initial not working

2010-12-11 Thread Sævar Öfjörð
I think you should provide your choices in the form field, not when creating an instance of the form. The form would then be something like this: class StoreLocationHoursForm(BForm): sl_list= [('-', 'Choose Location'), (u'Super City', u'901 PHILADELPHIA STREET')] location = forms.ChoiceFie

Re: Rendering a field value in a custom way

2010-12-11 Thread Scoox
Okay, I *think* I figured out a way to fix this. I can add methods such as get_stars to the relevant model. Then in that method I can do whatever I like with the string (e.g. convert it to star symbols). Would that be the recommended way to do this? Kind Regards Stephan -- You received this

Re: Django on a hosting service

2010-12-11 Thread tiemonster
To use Django with Apache, it would be necessary to install *some* python interpreter into the server. I used Django on our shared hosting site using an .htaccess that called the mod_python handler in Django. However, mod_python was already installed. If they are offering to install mod_wsgi, then

How to move inline into or above fieldsets in django admin?

2010-12-11 Thread mongoose
Hi there, Currently I've got a recipe application like this: class RecipeAdmin(admin.ModelAdmin): fieldsets = ( ('Recipe Details',{ 'fields': ( ('title', 'slug'),'description', 'difficulty', 'vegetarian', 'serves', (

Re: Dump & load: sqlite to poastgres

2010-12-11 Thread Russell Keith-Magee
On Fri, Dec 10, 2010 at 9:17 PM, TomPH wrote: > What is the best practise to migrate the data from sqllite to > postgres? All tries I had till now failed with DB key errors! > > What I did: > > 1) python manage.py dumpdata --indent 3 -n >../dev_data.json (dev. > system) > 2) python manage.py flush

Re: django session InvalidOperation

2010-12-11 Thread Leo
Hard to know from what's shown here, but it seems likely that your database didn't get created properly on the new server. The error suggests that the expire_date column of the django_session table in the MySQL database is of type DECIMAL rather than the expected DATETIME. How did you migrate the

Re: How to move inline into or above fieldsets in django admin?

2010-12-11 Thread wayne
On Dec 11, 8:05 am, mongoose wrote: > Hi there, > > Currently I've got a recipe application like this: > > class RecipeAdmin(admin.ModelAdmin): >         fieldsets = ( >                 ('Recipe Details',{ >                         'fields': ( >                                 ('title', 'slug'),

Re: Django Form ChoiceField, initial not working

2010-12-11 Thread wayne
On Dec 11, 5:08 am, Sævar Öfjörð wrote: > I think you should provide your choices in the form field, not when > creating an instance of the form. Agreed. To create a dynamic form such as this, the best way would probably be to use a custom __init__ function. In your view, when you create your

Re: Rendering a field value in a custom way

2010-12-11 Thread wayne
On Dec 11, 5:49 am, Scoox wrote: > Okay, I *think* I figured out a way to fix this. > > I can add methods such as get_stars to the relevant model. > > Then in that method I can do whatever I like with the string (e.g. > convert it to star symbols). > > Would that be the recommended way to do this?

Extending AdminSite for custom views

2010-12-11 Thread William Grzybowski
Hello, I am trying to extend AdminSite so I can provide custom views, so far i have this: class MyAdminSite(AdminSite): def get_urls(self): urls = super(self.__class__, self).get_urls() my_urls = patterns('', (r'^myview/$', self.admin_view(myview)) )

running projects on the back of a base URL and having issues with the homepage

2010-12-11 Thread mongoose
Hi there, I've got a base url. http://baseurl.com/ I'm trying to run projects on the back of it. For example http://baseurl.com/mongoose/ The projects run but the URL don't work properly because they all reference the base url. So for 'About Me' page it points to http://baseurl.com/about instead o

Re: How to move inline into or above fieldsets in django admin?

2010-12-11 Thread mongoose
Hi wayne, to be honest I've no idea how i'd do that by overriding a template. On Dec 11, 7:20 pm, wayne wrote: > On Dec 11, 8:05 am, mongoose wrote: > > > > > Hi there, > > > Currently I've got a recipe application like this: > > > class RecipeAdmin(admin.ModelAdmin): > >         fieldsets = (

Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread jc
Apache & mod_wsgi are configured correctly (I've created a hello world .html apache file and a hello world mod_wsgi application with no problems). I know need my Django app to recognize my django.wsgi file. What makes me think that it's not recognizing my wsgi file is that I went into my django.wsg

Re: How to move inline into or above fieldsets in django admin?

2010-12-11 Thread Wayne Smith
Well, the template is what controls the ordering of fields. You can create your own template that Django will then use in the admin interface. From there you can control exactly how things are displayed. On Dec 11, 2010 1:30 PM, "mongoose" wrote: > Hi wayne, > > to be honest I've no idea how i'd

Re: Calling a mssql stored procedure and displaying the result as a datagrid

2010-12-11 Thread Dan Fairs
Hi, > 1. I have a stored procedure in my mssql database server and i would > like to call the procedure in my program with certain parameters.(Is > there a way the results of the stored procedure be represented as a > queryset?) > Read about raw SQL: http://docs.djangoproject.com/en/dev/topi

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Mike Dewhirst
On 12/12/2010 7:14am, jc wrote: Apache& mod_wsgi are configured correctly (I've created a hello world .html apache file and a hello world mod_wsgi application with no problems). I know need my Django app to recognize my django.wsgi file. What makes me think that it's not recognizing my wsgi file

Is it possible to specify the html class attribute for a form field?

2010-12-11 Thread codecowboy
Thank you in advance for any feedback. Here is what I have {{ form.name }}. I would like to set the class attribute for this form element to "style01". Is this possible? If it is not possible then I have been trying to get this working as well without much luck. I realize that this syntax is i

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread jc
You definitely lost me in some places but you've also cleared some things up in the process. I also noticed that I had "", which is lacking a directory for the WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my listing of my files in my project when I go to my address *but* I now get 5

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread jc
I've tried to fix my config files and it gives me a 500 error, here is what i see n the logs. I've been told by someone else that they think it's still my mod_wsgi/Apache configuration and not the error that I'm getting in the log about missing modules. Any suggestions? Here is the server error log

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Tim Sawyer
Here's the config I'm using for mod_wsgi: http://drumcoder.co.uk/blog/2009/nov/21/apache-mod_wsgi-config/ Hope that helps, Tim. On 11/12/10 23:35, jc wrote: You definitely lost me in some places but you've also cleared some things up in the process. I also noticed that I had "", which is lack

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Mike Dewhirst
On 12/12/2010 10:35am, jc wrote: You definitely lost me in some places but you've also cleared some things up in the process. I also noticed that I had "", which is lacking a directory for the WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my listing of my files in my project when I

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread Mike Dewhirst
On 12/12/2010 10:56am, jc wrote: I've tried to fix my config files and it gives me a 500 error, here is what i see n the logs. I've been told by someone else that they think it's still my mod_wsgi/Apache configuration and not the error that I'm getting in the log about missing modules. Any sugges

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread jc
I think after that comment I'm slowly getting it but I still need to go back and learn more. Regardless of the the horrible security holes in my application, this still wouldn't do anything as far as *not* making this django app run, would it? In other words, I know it's insecure as hell to do what

Re: Is it possible to specify the html class attribute for a form field?

2010-12-11 Thread Martin Ostrovsky
When you create your form, you can specify extra attributes to each widget of each field. For example: myfield = forms.CharField(widget=forms.Textarea(attrs={'cols':80, 'rows':80}) So as one of the keys in your attrs argument, you can make it 'class' and then provide the class name as the value.

Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.

2010-12-11 Thread jc
I ran the Django develplment server and everything runs fine. It's only when I go back to the other web server that things start to break on me. On Dec 11, 8:06 pm, Mike Dewhirst wrote: > On 12/12/2010 10:56am, jc wrote: > > > > > > > > > > > I've tried to fix my config files and it gives me a 50

Re: Generic Views - do you use them?

2010-12-11 Thread Rainy
On Dec 10, 5:22 pm, Łukasz Rekucki wrote: > > On Fri, Dec 10, 2010 at 9:37 AM, Rainy wrote: > > >> Is there a doc somewhere that details what the limitations are? How > >> do you tell if some task is definitely too much for new generic views? > >> I'm not using 1.3 yet and generally what I've b

Re: Django on a hosting service

2010-12-11 Thread Todd Wilson
tiemonster wrote, on 12/11/2010 05:45 AM: > To use Django with Apache, it would be necessary to install *some* > python interpreter into the server. I used Django on our shared > hosting site using an .htaccess that called the mod_python handler in > Django. However, mod_python was already installe

Re: How to move inline into or above fieldsets in django admin?

2010-12-11 Thread mongoose
mind giving a short example? >From what I see in the template {% for fieldset in adminform %} {% include "admin/includes/fieldset.html" %} {% endfor %} {% for inline_admin_formset in inline_admin_formsets %} {% include inline_admin_formset.opts.template %} {% endfor %} I can either have it