Re: dynamically excluding fields in admin form

2010-02-28 Thread Preston Holmes
On Feb 28, 12:21 pm, Simon Davies wrote: > figured out how to do it using the get_form method like this: > > class AccessoryStockOrderAdmin(admin.ModelAdmin): >     form = AccessoryStockOrderForm >     def get_form(self, request, obj=None, **kwargs): >         form =

Re: to_field connected to field in UserProfile

2010-02-28 Thread Timothy Kinney
I don't see much reason to keep Payment method separate from the Orders class then. For each order, you can have a different payment method, so just make a payment method column in the Orders model. Like this: payment_method_choices = ( ('$$', 'Cash'), ('cc', 'Credit Card'), ) class

Re: How does the default option for a field work in the model?

2010-02-28 Thread James Bennett
On Sun, Feb 28, 2010 at 5:13 PM, Andrej wrote: > I want to use the Admin module to pre-set default values when creating > the form. For example, in the gender case, I want to have default > "Unknown" option. Is this this not possible? It is possible; all you have to do is

Re: Application Name Cannot be the Same as Site Name - is this true?

2010-02-28 Thread Anthony
Thank you. That is exactly what I did in my production environment - I manually created the application directory. I used the startapp command on my development box, and thus got the error message. Thanks again for clarifying. On Feb 28, 4:41 pm, Russell Keith-Magee

RadioSelect Widget : Incorrect/Wrong Mark-up?

2010-02-28 Thread czamb...@gmail.com
It looks like the mark-up used for the RadioSelect widget is incorrect. For example: from django import forms class PersonForm(forms.Form): GENDER_OPTIONS = ( ('M','Male'), ('F','Female'), ) gender =

Re: Serving https with runserver

2010-02-28 Thread Adnan Sadzak
If it's on your local machine there is no big sense to use ssl unles you are paranoid. If someone can sniff local traffic, then ssl is useless. Anyway, as Janusz said http://www.stunnel.org/ On Mon, Mar 1, 2010 at 1:06 AM, Janusz Harkot wrote: > So you can use stunnel:

Re: Application Name Cannot be the Same as Site Name - is this true?

2010-02-28 Thread Russell Keith-Magee
On Sun, Feb 28, 2010 at 3:33 PM, Anthony wrote: > I've got my app deployed on my production server where the application > name == site name.  (It's running fine.) > > I copied it down to my development machine and tried to set up the > same thing ('python manage.py startapp

Re: Date fields and Django’s loaddata

2010-02-28 Thread Russell Keith-Magee
On Mon, Mar 1, 2010 at 2:04 AM, Michael Shafrir wrote: > Can a date be loaded into a DateField using Django's loaddata admin > feature? I have a JSON file that I'm using to bulk load data into my > app. When you dumpdata, date fields are outputted in the format - > mm-dd.

Re: Forcing HTTPS in admin

2010-02-28 Thread Janusz Harkot
no, but you can do this very easy on the fronted-webserver (nginx, apache, cherokee etc.) J. -- 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,

Re: Serving https with runserver

2010-02-28 Thread Janusz Harkot
So you can use stunnel: http://www.stunnel.org/ J. -- 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

How to display PendingDeprecationWarning using dev. server?

2010-02-28 Thread Brian Neal
I'm having trouble seeing PendingDeprecationWarning's on stderr when using the dev server. To make sure I'm not crazy, I wrote a simple Python program that looks like this: print "** WARNING **" import warnings warnings.warn( "Testing the warnings module!",

Re: Serving https with runserver

2010-02-28 Thread cool-RR
I'm not using Apache on my development machine and I don't want to use it. I enjoy the low headache factor of runserver. But it'll be nicer if it served through https as well. On Mar 1, 12:53 am, Andrej wrote: > because you need to load apache ssl gear. Set up your normal

Re: How does the default option for a field work in the model?

2010-02-28 Thread Andrej
I want to use the Admin module to pre-set default values when creating the form. For example, in the gender case, I want to have default "Unknown" option. Is this this not possible? On Feb 28, 6:00 pm, James Bennett wrote: > On Sun, Feb 28, 2010 at 4:42 PM, Andrej

Re: How does the default option for a field work in the model?

2010-02-28 Thread James Bennett
On Sun, Feb 28, 2010 at 4:42 PM, Andrej wrote: > Shouldn't this work? It's a tuple. > > gender = models.CharField(_('Gender'), max_length=1, > choices=GENDER_CHOICES, default=GENDER_CHOICES[2]) > > It doesn't. > I smell black magic! The value that goes in 'default' is the

Re: Serving https with runserver

2010-02-28 Thread Andrej
because you need to load apache ssl gear. Set up your normal virtual host and then use reverse proxy: ProxyPass / http://localhost:8000/ ProxyPassReverse / http://localhost:8000/ On Feb 28, 5:09 pm, cool-RR wrote: > Why doesn't runserver automatically serve in

How does the default option for a field work in the model?

2010-02-28 Thread Andrej
>From the docs: GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) Shouldn't this work? It's a tuple. gender = models.CharField(_('Gender'), max_length=1, choices=GENDER_CHOICES, default=GENDER_CHOICES[2]) It doesn't. I smell black magic! Please help :) -- You received this

Re: Conditonal validators for the model

2010-02-28 Thread Andrej
Thanks for the reply, that definitely works, and it's within the MVC paradigm. On Feb 28, 3:14 pm, sc...@thereceptor.net wrote: > > Greetings, > > > Django is awesome! I'm playing around and I was wondering if there is > > a way to specify conditional validators in the model. > > > Example: if

Serving https with runserver

2010-02-28 Thread cool-RR
Why doesn't runserver automatically serve in https as well as http? It would have been useful. Ram. -- 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

Forcing HTTPS in admin

2010-02-28 Thread cool-RR
Does `admin` provide a way to force using it through https? I'd want it to simply redirect a user which doesn't use https to the same address, except with https instead of http. Is there something like this built into `admin`? Ram. -- You received this message because you are subscribed to the

Re: dynamically excluding fields in admin form

2010-02-28 Thread Simon Davies
figured out how to do it using the get_form method like this: class AccessoryStockOrderAdmin(admin.ModelAdmin): form = AccessoryStockOrderForm def get_form(self, request, obj=None, **kwargs): form = super(AccessoryStockOrderAdmin, self).get_form(request, obj, **kwargs) if

Re: Conditonal validators for the model

2010-02-28 Thread scott
> Greetings, > > Django is awesome! I'm playing around and I was wondering if there is > a way to specify conditional validators in the model. > > Example: if field x is blank, field y is required. > > Thanks for your help! You might consider making a ModelForm and then adding cleaner methods.

Re: fixtures getting created with terminal message prefixed

2010-02-28 Thread Malcolm Box
I'll take a guess: one of your apps, middleware or possibly even a management command is generating this text. Grep for it in your source code, and remove/disable. Malcolm On Sat, Feb 27, 2010 at 4:34 AM, Russell Keith-Magee wrote: > On Sat, Feb 27, 2010 at 4:07 AM,

Re: ImageField admin preview not working

2010-02-28 Thread lockwooddev
(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), the diffirence. (r'^static_media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), Thanks a lot!! :-) It cost me one day this tiny problem.. -- You

Conditonal validators for the model

2010-02-28 Thread Andrej
Greetings, Django is awesome! I'm playing around and I was wondering if there is a way to specify conditional validators in the model. Example: if field x is blank, field y is required. Thanks for your help! -- You received this message because you are subscribed to the Google Groups "Django

Re: ImageField admin preview not working

2010-02-28 Thread Malcolm Box
Read your settings.py file carefully: - you've said that the MEDIA_URL is / - but that Django is only configured to serve static content from /static So when the photo is uploaded, it's stored in /photos/x.jpg, which you've told Django is accessible via the URL /photos. But this gives

Date fields and Django’s loaddata

2010-02-28 Thread Michael Shafrir
Can a date be loaded into a DateField using Django's loaddata admin feature? I have a JSON file that I'm using to bulk load data into my app. When you dumpdata, date fields are outputted in the format - mm-dd. However, if you try loading data back in with the same format, the field is treated

Re: How can I apply ordering through a M2M join model?

2010-02-28 Thread Malcolm Box
I don't know if you can do it directly using the ordering metadata - easiest way to find out is to try it and see. If not, I'd suggest a customer manager on the Gallery that returns the photos in order so that the line: Gallery.photos.all() refers to your customer manager that "does the right

ImageField admin preview not working

2010-02-28 Thread lockwooddev
Hi people, I started working on an image gallery with Django and I'm stuck. I suppose that my static files on the development server are not configured properly. I have the following models.py code: from django.db import models from PIL import Image class Photo(models.Model): name =

Re: Django with Jquery

2010-02-28 Thread andreas schmid
Alexis Selves wrote: > Hello, > I am totally helpless. I am trying to use JQuery in my django > templates, but I always get in firebug this: $ not defined. > > In my template I am linking jquery : > > > where do you have your static files? did you serve them as static files? maybe ur only

Re: Django with Jquery

2010-02-28 Thread Malcolm Box
On Sun, Feb 28, 2010 at 5:39 PM, Alexis Selves wrote: > Hello, > I am totally helpless. I am trying to use JQuery in my django > templates, but I always get in firebug this: $ not defined. > Check with Firebug if the jquery script has been successfully loaded (using either

Django with Jquery

2010-02-28 Thread Alexis Selves
Hello, I am totally helpless. I am trying to use JQuery in my django templates, but I always get in firebug this: $ not defined. In my template I am linking jquery : And then $(document).ready(function() { alert("Hello from jQuery"); }); But I always get nothing.. using ubuntu

Re: How can I apply ordering through a M2M join model?

2010-02-28 Thread Kyle Fox
The user needs to be able to manually position the photos in the gallery (using drag and drop, for example). A photo can exist in multiple galleries, which is why the join model GalleryPhoto is required (and this is where the position gets stored). On Feb 27, 7:36 pm, Prabhu

Re: Handling input of external urls

2010-02-28 Thread russianbandit
Thanks guys. It appears using URLField is the best answer here. It automatically prepends http:// if the url doesn't include that. On Feb 27, 7:27 pm, Prabhu wrote: > If you use URLField it should do the trick. Just prefix http:// if it > doesn't exist already using

Re: Problem with ForeignKey field

2010-02-28 Thread Ben Dowling
OK thanks. I didn't realise that was the implication of the related_name field. All working as expected now. Thanks, Ben On 28 Feb, 13:16, Daniel Roseman wrote: > On Feb 28, 11:46 am, Ben Dowling wrote: > > > > > I have a Thread and a

Re: search_field doesn't work ?

2010-02-28 Thread mendes.rich...@gmail.com
Unfortunately that didn't do the trick. The strange thing is that the same code is working on another server. We just migrated everything to a new server environment, making it sound to me that there might be something different in versions installed. could anyone point me to the actual method

Re: how to get the one-to-one relation class's name of a class

2010-02-28 Thread Daniel Roseman
On Feb 28, 7:07 am, sinanjj wrote: > hello everyone. > I am doing a GIS related project, with django. > There is a question that how to get the one-to-one relation class's > name of a class? > for example: > class Thing(models.Model): >         lat =

Re: Problem with ForeignKey field

2010-02-28 Thread Daniel Roseman
On Feb 28, 11:46 am, Ben Dowling wrote: > I have a Thread and a Message model, as defined below: > > class Thread(models.Model): >         modified = models.DateTimeField(auto_now=True, auto_now_add=True) > > class Message(models.Model): >         subject =

Problem with ForeignKey field

2010-02-28 Thread Ben Dowling
I have a Thread and a Message model, as defined below: class Thread(models.Model): modified = models.DateTimeField(auto_now=True, auto_now_add=True) class Message(models.Model): subject = models.CharField(max_length = 100) thread = models.ForeignKey(Thread,

Re: "Illegal mix of collations": how to handle that?

2010-02-28 Thread jul
Ok, I'll change my database charset. Thanks On Feb 27, 1:06 pm, jul wrote: > hi, > > when submitting some characters in a charfield of a django form I get > the following error (e.g. when submitting 'ś') > > (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and >

dynamically excluding fields in admin form

2010-02-28 Thread Simon Davies
Hi I have a model which I access from the admin application. I want to exclude some fields dynamically. My model looks like this: class StockOrder(models.Model): number_of_items_pending_order = models.PositiveIntegerField(max_length=5, default=1) number_of_items_ordered =

Re: Django not reading the URLConf (urls.py)

2010-02-28 Thread Rodrigo
I checked the ROOT_URLCONF and it was fine, and deleted all the *.pyc, without good results, but finally I found the problem. There was a copy of the same project in some other folder under the PYTHONPATH, so there was some kind of collision. Thanks everybody for helping me out. On Feb 28, 1:57 

how to get the one-to-one relation class's name of a class

2010-02-28 Thread sinanjj
hello everyone. I am doing a GIS related project, with django. There is a question that how to get the one-to-one relation class's name of a class? for example: class Thing(models.Model): lat = models.FloatField(default=0.0) lng = models.FloatField(default=0.0) class