how can i use manage.py as a command in script file

2010-03-15 Thread pyleaf
I want to use manage.py as a command in script file. e.g, >> python manage.py shell >>from testproject.testapp.models import Testee >>from testproject.others.modules import utils >>utils.do(Testee) Above are commands in command window manually. but, how to make these like : #my_script.py

Re: Tesing in Django and python

2010-03-15 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.1/topics/testing/ http://docs.python.org/library/unittest.html -- 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

Re: how to make radio buttion selected as form is loaded

2010-03-15 Thread django_jedi
Reporting back on this one. I solved the problem, but perhaps there's a more elegant way of writing this. 1) Discovered that I was not in fact comparing like data types, so {% ifequal %} was bound to fail. (Pardon my newb-ness) 2) Once I fixed that problem, I ended up putting six ifequals

Re: What validation tests are applied to ImageField?

2010-03-15 Thread creecode
Hello John, On Mar 15, 7:56 pm, john2095 wrote: > Question is "What is the definition of a 'valid image'" in this > context?" > and, optionally, where is the source code for that? My understanding from what I've read is that most of the heavy lifting for image handling is

Re: multi natural_key dependencies problem

2010-03-15 Thread Russell Keith-Magee
On Tue, Mar 16, 2010 at 11:34 AM, victor wrote: > how to set multi natural_key dependincies? > Model code as following: > class Menu(models.Model): >    mName = models.CharField(max_length=256) >    mTitle = models.CharField(max_length=256) >    url =

multi natural_key dependencies problem

2010-03-15 Thread victor
how to set multi natural_key dependincies? Model code as following: class Menu(models.Model): mName = models.CharField(max_length=256) mTitle = models.CharField(max_length=256) url = models.CharField(max_length=1024, blank=True, null=True) ordering = models.IntegerField()

Tesing in Django and python

2010-03-15 Thread kamilski81
We are having a huge issue finding a good java-like testing framework. In java you can say 'run all classes in this folder'is this possible with python/django? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: how to make radio buttion selected as form is loaded

2010-03-15 Thread django_jedi
> > Assuming that 'groupA' is a model field, there's no such property as > 'selections.groupA', because as you've stated, selections is a > queryset - ie a collection of model instances, not a single one. > > However in general you'd be better off using Django's forms framework, > which outputs

What validation tests are applied to ImageField?

2010-03-15 Thread john2095
The documentation states about the ImageField "Like FileField, but validates that the uploaded object is a valid image. Has two extra optional arguments:" http://docs.djangoproject.com/en/dev/ref/models/fields/#imagefield I went cruising the source to try and work out what tests are implemented

Re: Facebook Connect

2010-03-15 Thread Ian Langworth
Try django-socialregistration. I've had success with it. On Mon, Mar 15, 2010 at 12:52, CrabbyPete wrote: > I am trying to integrate pyfacebook into a existing project, and its > driving me nuts. I just want users to be able to sign in with > facebook.  Anyone else try this

Re: MEDIA_URL is not pushed to templates

2010-03-15 Thread Bobby Roberts
ah... my media processor got shot somehow On Mar 15, 7:51 pm, Bobby Roberts wrote: > hi group... got a strange situation.  MEDIA_URL is not being pushed to > the templates for some reason. > > In my settings file i have > > MEDIA_URL='/static/' > ... >

MEDIA_URL is not pushed to templates

2010-03-15 Thread Bobby Roberts
hi group... got a strange situation. MEDIA_URL is not being pushed to the templates for some reason. In my settings file i have MEDIA_URL='/static/' ... TEMPLATE_CONTEXT_PROCESSORS=( 'django.core.context_processors.request',) and in the template i am specifying it as {{MEDIA_URL}} however

Using urlencode with the url tag

2010-03-15 Thread saxon75
I'm trying to generate a link where the URL of the current page gets passed in the querystring of the link. Like so: . I would have thought that I could do this relatively easily with template tags, so I've tried this: <% url arg1, arg2 as the_url %> http://www.example.com?variable={{

Increase width of filter_horizontal in django admin

2010-03-15 Thread rc
I need to increase the width of the filter_horizontal in my django admin page. When the profile_test (keys off of testcase.test_name which is very wide) fields are displayed both sides of the filter_horizontal are to narrow. How do I increase the width? I don't need the max_length of 300, but 75

Re: how to make radio buttion selected as form is loaded

2010-03-15 Thread Alastair Campbell
On Mon, Mar 15, 2010 at 10:26 AM, Daniel Roseman wrote: > Assuming that 'groupA' is a model field, there's no such property as > 'selections.groupA', because as you've stated, selections is a > queryset - ie a collection of model instances, not a single one. > > However in

Re: Handling upload, adding M2M relation before saving object in admin form

2010-03-15 Thread Henry Andersen
Thanks for your answer, but I do need a ManyToManyField(). In case anyone is curious about the answer, I solved my problem by overriding my custom admin form's save method. In save(), I checked for the existence of the file field in self.files; passed self.files to a document form, which

Re: object has no attribute 'count'

2010-03-15 Thread Masklinn
On 15 Mar 2010, at 22:44 , wubble u wrote: > > Hi All, > > I'm trying to get a count of the number of rows in my queryset, > basically a SELECT COUNT(*). > > According to the django documentation, you can simply use > queryset.count(), but I'm getting the error: > > object has no attribute

Re: object has no attribute 'count'

2010-03-15 Thread Shawn Milochik
If you're doing a 'get,' then you're always going to return exactly one results (or get an error). If you do a 'filter' you can use count(). Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

object has no attribute 'count'

2010-03-15 Thread wubble u
Hi All, I'm trying to get a count of the number of rows in my queryset, basically a SELECT COUNT(*). According to the django documentation, you can simply use queryset.count(), but I'm getting the error: object has no attribute 'count' my view code is: hResults =

Re: django and buildout and mr.developer

2010-03-15 Thread John Griessen
andreas schmid wrote: it seems to work with mr.developer [buildout] extensions = mr.developer sources = sources auto-checkout = django-mptt parts = django eggs = mock django-notification django-page-cms django-haystack

Facebook Connect

2010-03-15 Thread CrabbyPete
I am trying to integrate pyfacebook into a existing project, and its driving me nuts. I just want users to be able to sign in with facebook. Anyone else try this and any recommendations. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: Resize image if too large

2010-03-15 Thread Rafael de Oliveira Lopes Gonçalves
By the way, I don't think the user should wait for this kind of heavy load work (resizing images, waiting the response). Try to use lazy or remote call after you saved the image. Give celery a try: http://ask.github.com/celery/ -- Rafael Lopes (11)6729-1897 On Mon, Mar 15, 2010 at 1:59 PM,

Re: File validation process

2010-03-15 Thread Vincent
Thanks for the reply hcarvalhoalves. I can see bypassing the file name extensions as you have mentioned, they don't guarantee the file type anyway. That said, I would like to be able to use some other means than mimetypes as I need to make sure that the files are of a specific type (e.g. not just

Re: send_mail UnicodeDecodeError: 'ascii' codec can't decode byte

2010-03-15 Thread Michał Klich
Yes it did. I must have messed up something as i tried unicode(). Thanks On Mar 14, 5:01 pm, "ge...@aquarianhouse.com" wrote: > it should work with: > > body = unicode("Tre¶æ", 'utf-8') > > On Mar 14, 3:49 pm, Micha³ Klich wrote:> Hi, > > I do

Re: form.save_m2m() and exclude field

2010-03-15 Thread jul
hi, sorry. Here's the copy of the traceback. It's actually a warning, not an error. I'm using form.save_m2m() because my model includes another m2m field (I simplified the code for readability), and I'm using form.save(commit=False) because I don't set the city field using the city value from

Re: form.save_m2m() and exclude field

2010-03-15 Thread Daniel Roseman
On Mar 15, 5:33 pm, jul wrote: > hi, > > in a ModelForm I replace a field by excluding it and adding a new one > with the same name, as shown below in AddRestaurantForm. When saving > the form with the code shown below, I get an error in form save_m2m() > (Truncated incorrect

form.save_m2m() and exclude field

2010-03-15 Thread jul
hi, in a ModelForm I replace a field by excluding it and adding a new one with the same name, as shown below in AddRestaurantForm. When saving the form with the code shown below, I get an error in form save_m2m() (Truncated incorrect DOUBLE value), which seems to be due to the function to attempt

Trouble installing satchmo

2010-03-15 Thread Jonathan Hayward
I'm trying to get satchmo up and running from the instructions at http://bitbucket.org/chris1610/satchmo/downloads/Satchmo.pdf , and when I get to 2.1.3 (installing PIL manually as a workaround), there is no /bin/clonesatchmo.py. After digging around, I move the scripts from the install directory

Re: Resize image if too large

2010-03-15 Thread When ideas fail
Turned out it was all up the pole, but have it working now. The validation to check the size did work though. On 15 Mar, 16:12, "ge...@aquarianhouse.com" wrote: > well, something is missing, like > > def save(self, *args, **kwargs): >     #your code > > but in our case

Re: is there any possibility for two settings.py

2010-03-15 Thread dalore
Another common technique is to use the local_settings.py way, like so: # local_settings.py can be used to override environment-specific settings # like database and email that differ between development and production. try: from settings_local import * except ImportError: pass ---

Re: register model on different App

2010-03-15 Thread j.c.sackett
> I've created a custom model, that I'd like to be shown on the "Auth" box > instead of the default one (a box with my app's name). > Is there a particular reason you want it in Auth? Is it logically part of one of the Auth models, like Group or User? If so you could do an inline admin: from

Re: Resize image if too large

2010-03-15 Thread ge...@aquarianhouse.com
well, something is missing, like def save(self, *args, **kwargs): #your code but in our case the form class should do the validation... On Mar 15, 5:07 pm, When ideas fail wrote: > Hello, I've been trying to create a save method which resizes an image > if it is

Resize image if too large

2010-03-15 Thread When ideas fail
Hello, I've been trying to create a save method which resizes an image if it is too large. Using pil this is what I have so far: class Photo(models.Model): title = models.CharField(max_length=750) photo = models.FileField(upload_to='full_size/') alt = models.CharField(max_length=50,

Re: Self Join

2010-03-15 Thread Karen Tracey
On Fri, Mar 12, 2010 at 5:54 PM, jrs wrote: > I'm trying, without a great deal of success, to perform a simple self > join using the django orm. I'm pretty sure the F() function is not > the answer. I believe this only allows you to compare two field > within the same

Re: Self Join

2010-03-15 Thread jrs
Thanks... I'm perfectly comfortable with using foreign keys (and reverse) with the django orm. For basic joins this is fine. For more advanced queries involving complex aggregations (ie-reporting), the orm seems to be pretty useless... looking at the generated sql shows this. It's It's quite

Re: Self Join

2010-03-15 Thread Daniel Roseman
On Mar 15, 1:40 pm, jrs wrote: > I see nothing on this page that is in the slightest bit related to my > question... Does anyone know if there is a way in the django orm to > accomplish my query above? > > Thanks. As I explained, there's nothing different in a self-join than

Re: Putting dictionary element according to another element's value

2010-03-15 Thread ge...@aquarianhouse.com
{% with o.id as key %}{{ dictionary.key }}{% endwith %} would be better, as in comments mentioned On Mar 15, 3:14 pm, "pjrhar...@gmail.com" wrote: > You'll need a custom template tag. Something like this will probably > do: > >

Re: Putting dictionary element according to another element's value

2010-03-15 Thread pjrhar...@gmail.com
You'll need a custom template tag. Something like this will probably do: http://push.cx/2007/django-template-tag-for-dictionary-access Peter On Mar 12, 7:48 pm, Rishat Muhametshin wrote: > Hello everyone, > > I just can't solve a problem. I have an array of dictionaries

Re: Handling upload, adding M2M relation before saving object in admin form

2010-03-15 Thread pjrhar...@gmail.com
On Mar 12, 12:42 pm, Henry A wrote: > Hi, > > For a client, I've got the following (simplified) models: > > class Document (models.Model): >   file = models.FileField() > > class Publication (models.Model): >   title = models.CharField() >   ... >   documents =

Re: REMOTE_ADDR

2010-03-15 Thread James Bennett
On Mon, Mar 15, 2010 at 8:45 AM, Ken Lacey wrote: > Using request.META['REMOTE_ADDR'] I get an error > > Exception Type: TemplateSyntaxError > Exception Value: Could not parse the remainder: '['REMOTE_ADDR']' from > 'request.METTA['REMOTE_ADDR']' > > > How do I get over this?

Re: REMOTE_ADDR

2010-03-15 Thread ge...@aquarianhouse.com
it seem to me, it's in the template. when it should work like this: {{ request.META.REMOTE_ADDR }} btw: > 'request.METTA['REMOTE_ADDR']' <--- in META is one T to much On Mar 15, 2:45 pm, Ken Lacey wrote: > Hi > > I am trying to access the remote addr in a view. > > Using

REMOTE_ADDR

2010-03-15 Thread Ken Lacey
Hi I am trying to access the remote addr in a view. Using request.META['REMOTE_ADDR'] I get an error Exception Type: TemplateSyntaxError Exception Value: Could not parse the remainder: '['REMOTE_ADDR']' from 'request.METTA['REMOTE_ADDR']' How do I get over this? Thanks Ken -- You

Re: Self Join

2010-03-15 Thread jrs
I see nothing on this page that is in the slightest bit related to my question... Does anyone know if there is a way in the django orm to accomplish my query above? Thanks. On Mar 13, 4:17 am, Daniel Roseman wrote: > On Mar 12, 10:54 pm, jrs wrote: >

Re: Modelling question: TypeError at Post?

2010-03-15 Thread Karen Tracey
On Mon, Mar 15, 2010 at 6:07 AM, BobAalsma wrote: > I get a TypeError at Post from the admin interface and I suspect this > is connected to my key definition, but couldn't find documentation on > this. > > Any ideas? > > Error message: > TypeError at

register model on different App

2010-03-15 Thread Matias
Is there any way to register a model on a different app so that on the admin site I get it on a different "box"? I've created a custom model, that I'd like to be shown on the "Auth" box instead of the default one (a box with my app's name). Thanks! -- You received this message because you

Modelling question: TypeError at Post?

2010-03-15 Thread BobAalsma
I get a TypeError at Post from the admin interface and I suspect this is connected to my key definition, but couldn't find documentation on this. Any ideas? Error message: TypeError at /admin/LeadDeviceSysteem/vraagcomponentinhoud/add/ coercing to Unicode: need string or buffer,

Re: how to make radio buttion selected as form is loaded

2010-03-15 Thread Daniel Roseman
On Mar 15, 3:42 am, django_jedi wrote: > Hi All, > > Pardon a newbie. > > I'm building a form that will display workshop selections a person has > made.  They'll be able to update their selections using this form. > > Selections are represented by radio buttons; I'm trying to

ANN: django-admin-tools 0.2.0 released

2010-03-15 Thread David Jean Louis
Hello, I'm happy to announce the availability of the version 0.2.0 of django-admin-tools. Django-admin-tools is a collection of extensions/tools for the default django administration interface, it includes: * a full featured and customizable dashboard, * a customizable menu bar, * tools