Help with little complex queryset

2010-09-15 Thread Marc Aymerich
hi, I need some help here :), I have these models: class name(models.Model): member = models.ForeignKey(member, related_name="owner") class User(models.Model): member = models.ForeignKey(member) class VirtualHost(models.Model): member = models.ForeignKey(member) ServerName = models.ForeignK

syncdb on Django

2010-09-15 Thread Odkoo Ch
Hello. everyone help me DATABASES = { 'default': { 'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'car', # Or path to database file if using sqlite3. 'USER': 'easycar', #

Django feed templates and how do I use them with images?

2010-09-15 Thread PeterR
Hi, I like to generate a feed with text and image. My objective is the communication between a client and the RSS feed django server. Similar to text, you find at feedparser the following explanation for a image in a RSS feed: >> This is a feed image: Feed logo http://example.org/logo.png

__unicode__() doesn't seem to work

2010-09-15 Thread Hayko
my django version is 1.2.1 but the __unicode__() doesn't seem to work what shall i do? thanx a lot...! -- 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 t

Re: __unicode__() doesn't seem to work

2010-09-15 Thread bagheera
Dnia 15-09-2010 o 12:47:55 Hayko napisał(a): my django version is 1.2.1 but the __unicode__() doesn't seem to work what shall i do? thanx a lot...! Post code and traceback. We ain't wizards with crystal balls :D -- Linux user -- You received this message because you are subscribed to

Re: __unicode__() doesn't seem to work

2010-09-15 Thread Hayko Karapetyan
from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.Cha

Re: syncdb on Django

2010-09-15 Thread Roderick
ENGINE should be set to 'django.db.backends.mysql' not 'mysql', if you are using mysql. On Sep 15, 1:44 am, Odkoo Ch wrote: > Hello. everyone > > help me > > DATABASES = { >     'default': { >         'ENGINE': 'mysql',  # Add 'postgresql_psycopg2', 'postgresql', > 'mysql', 'sqlite3' or 'oracle'.

Re: syncdb on Django

2010-09-15 Thread Karen Tracey
On Wed, Sep 15, 2010 at 7:34 AM, Roderick wrote: > ENGINE should be set to 'django.db.backends.mysql' not 'mysql', if you > are using mysql. > > I believe the shorthand names are still accepted, so I don't think that is the problem. Rather it appears a pre-1.2 version of Django may be in use. Tha

How to check a long string has a particular word in it

2010-09-15 Thread Pradnya
Hello, I am using django 1.1 and want to find a word from the string passed to the HTML template. eg. I have test.html and I am passing {resut : 'test application for test'} now I want to check if the world application is there on not in result. Please suggest the simplest method without using f

Re: __unicode__() doesn't seem to work

2010-09-15 Thread bagheera
Dnia 15-09-2010 o 13:35:15 Hayko Karapetyan napisał(a): from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question class Choice(models.Mode

Re: __unicode__() doesn't seem to work

2010-09-15 Thread Hayko Karapetyan
thanx a lot On 15 September 2010 16:57, bagheera wrote: > Dnia 15-09-2010 o 13:35:15 Hayko Karapetyan > napisał(a): > > > from django.db import models >> class Poll(models.Model): >>question = models.CharField(max_length=200) >>pub_date = models.DateTimeField('date published') >> >> d

Re: How to check a long string has a particular word in it

2010-09-15 Thread Piotr Kilczuk
Hi, > eg. I have test.html and I am passing {resut : 'test application for > test'} > now I want to check if the world application is there on not in > result. > > Please suggest the simplest method without using filter. or somthing > similar to slice Wouldn't simply {% if application in resut %}

Re: How to check a long string has a particular word in it

2010-09-15 Thread Masklinn
On 2010-09-15, at 17:30 , Piotr Kilczuk wrote: > Hi, >> eg. I have test.html and I am passing {resut : 'test application for >> test'} >> now I want to check if the world application is there on not in >> result. >> >> Please suggest the simplest method without using filter. or somthing >> similar

Re: How to check a long string has a particular word in it

2010-09-15 Thread Piotr Kilczuk
>> Wouldn't simply {% if application in resut %} display sth {% endif %} work? >> >> Regards, >> Piotr > > Well there's always the issue that it's not a wordwise test, so you could > have "applicationeering" in your result and it would still match. True :) Regards, Piotr -- You received this m

Re: How to check a long string has a particular word in it

2010-09-15 Thread Pradnya
hey thanks but that solution is fine for django 1.2 it's not working in 1.1 is ther somting like split function that we can use in html template On Sep 15, 5:00 pm, Piotr Kilczuk wrote: > Hi, > > > eg. I have test.html and I am passing {resut : 'test application for > > test'} > > now I want to

Re: How to check a long string has a particular word in it

2010-09-15 Thread Masklinn
On 2010-09-15, at 17:49 , Pradnya wrote: > hey thanks > > but that solution is fine for django 1.2 it's not working in 1.1 > > is ther somting like split function that we can use in html template You should probably just write your own tag (or a filter, that could be more than enough, and it's

Re: virtualenv used with mod_wsgi

2010-09-15 Thread Jagdeep Singh Malhi
On Sep 15, 11:15 am, Colin Bean wrote: > Have you tried the steps described > here:http://code.google.com/p/modwsgi/wiki/VirtualEnvironments? > now i try this i found error : raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e django.core.exceptions.ImproperlyConfigured: Error l

Re: getting force_update to work

2010-09-15 Thread Anomal
By the way, I was using Django 1.2.1. I updated to Django 1.2.3. Unfortunately, I got the same result. >>> foo.build_state='sad' >>> foo.save(force_update=True) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/dist-packages/django/db/models/base.py", line 434, i

question about the "default" Manager

2010-09-15 Thread Rev. Johnny Healey
According to the django docs: "If you use custom Manager objects, take note that the first Manager Django encounters (in the order in which they're defined in the model) has a special status. Django interprets the first Manager defined in a class as the "default" Manager, and several parts of Djang

Re: getting force_update to work

2010-09-15 Thread Daniel Roseman
On Sep 14, 8:44 pm, Anomal wrote: > According to the Django docs,  a new row is created with the new value > primary key when  when I change the value of a primary key and save > the object. > > In this case, I am looking to change the value. So, I use > force_update=True. Instead of changing the

Re: question about the "default" Manager

2010-09-15 Thread James Bennett
On Wed, Sep 15, 2010 at 8:28 AM, Rev. Johnny Healey wrote: > I may be missing something here, but this jumps out at me as being > impossible.  The ModelBase metaclass receive the attributes as a dict, > so isn't the original order lost? All instances of Manager have an internal-use-only attribute

Re: question about the "default" Manager

2010-09-15 Thread Rev. Johnny Healey
Ahh, clever. Thanks, Johnny -- 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 django-users+unsubscr...@googlegroups.com. For more o

Re: getting force_update to work

2010-09-15 Thread Anomal
"Where did you get the idea that `force_update` would allow you to change the primary key of an existing object? That's not implied by the documentation, and certainly isn't supported in the code." While it is not implied that a primary key cannot be changed, it is likewise not implied or stated t

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread nick.l...@gmail.com
Good question! :) I don't know...like I said I hadn't thought it through! :) I'll ponder it a bit... maybe you'd have to tackle it in a different direction...Say something like this: you have a dropdown in your project model that's blankable/nullable and it would essentially be a FK to other pro

Re: syncdb on Django

2010-09-15 Thread Kenneth Gonsalves
On Wed, 2010-09-15 at 13:44 +0800, Odkoo Ch wrote: > django.core.exceptions.ImproperlyConfigured: You haven't set the > database > ENGINE setting yet. what version of django? In the current version you need: 'ENGINE': 'django.db.backends.mysql' -- regards Kenneth Gonsalves -- You received this

Re: Tools to ease template/ui development

2010-09-15 Thread payala
hmm, didn't know uniform, will take a look at it. thanks! On 14 sep, 22:20, bruno desthuilliers wrote: > On 14 sep, 20:23, payala wrote: > > > I agree about Aptana. I am trying it right now and it looks very good, > > I already used eclipse and I think it rocks! > > Emacs is the OneTrueEditor !

Re: Tools to ease template/ui development

2010-09-15 Thread payala
On 14 sep, 23:18, pixelcowboy wrote: > I would really love something like pyjamas but that works with jquery > or something like that. What I would really love is to forget every > other programming language and just use python everywhere. Wouldn't > that be sweet? Python everywhere... hmmm

Re: Querying Exact Foreign Key Sets

2010-09-15 Thread Alec Shaner
Try this: I'm assuming you define Article.category as a ManyToMany field? I also assumed for the example that Category has a name field. # Build a queryset of all categories not in desired set, e.g., 'Exact1' and 'Exact2' bad_categories = Category.objects.exclude(category_name__in=['Exact1', 'Exa

Re: Tools to ease template/ui development

2010-09-15 Thread Nick
I would go with PyCharm. Unfortunately it's not free but for $49 I don't think you'll find anything better. It has really solid template highlighting and code complete along with the best Python/Django support I've seen yet. I'm still new to Django but I did spend a fair bit of time looking for an

problem with block tag and autoescaping

2010-09-15 Thread Julian
Hi, I'm a little bit confused. I'm writing a block tag which manipulates all the included urls in a special way to track users. therefor I've written a custom template-tag which does mainly the following in the render-method: 1. render the nodelist 2. parse the html with beautifulsoup 3. manipula

Re: question about the "default" Manager

2010-09-15 Thread Carlton Gibson
On 15 Sep 2010, at 14:28, Rev. Johnny Healey wrote: > According to the django docs: "If you use custom Manager objects, take > note that the first Manager Django encounters (in the order in which > they're defined in the model) has a special status. Django interprets > the first Manager defined i

syncdb problem - windows, sqlite

2010-09-15 Thread Aju
Hi, I am using the Django tutorial (Windows xp, python 2.5.4, django 1.2.3) and am facing a problem at the point where I have to run syncdb. python manage.py syncdb Error message (full error in the end): * File "C:\utils\frameworks\Python254\Lib\site-packages\django\db\backends\sqlite3\base.py

Re: syncdb problem - windows, sqlite

2010-09-15 Thread Nick
This seems to happen when you specify an incorrect path to the database in NAME. Fix: Use the correct path. :D It looks like you spelled 'frameworks' incorrectly. On Sep 15, 12:03 pm, Aju wrote: > Hi, > > I am using the Django tutorial (Windows xp, python 2.5.4, django 1.2.3) and > am facing a

Re: syncdb problem - windows, sqlite

2010-09-15 Thread Aju
Nick. Thank you Sir. Man does another set of eyes help! On Wed, Sep 15, 2010 at 12:11 PM, Nick < iregisteratwebsiteswitht...@gmail.com> wrote: > This seems to happen when you specify an incorrect path to the > database in NAME. > > Fix: > Use the correct path. :D > > It looks like you spelled 'fr

Initialize model's fields

2010-09-15 Thread marcovic
Hi all, i'm trying to do a simple task with Django but evidently it is not so simple... I have my model: class Mymodel(models.Model): random_string = models.CharField(max_length=200) def produce_string(self): a = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "L", "M",

Re: Initialize model's fields

2010-09-15 Thread ringemup
Your produce_string method is being run not just every time you create a new Mymodel, but every time you load an existing one from the database -- so it's overwriting your random strings on load. You'd probably do better producing the random strings in the save() method. On Sep 15, 12:35 pm, mar

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread pixelcowboy
Mmmm seems like inheritance is not as straight forward as I thought it was... Might be that this is the case that the admin doesnt cut it for what I need it to do... Ill probably need to see ways in which I can extend it. Like for example, I can think of adding a callback to the FK selection button

Re: Initialize model's fields

2010-09-15 Thread bruno desthuilliers
On 15 sep, 18:35, marcovic wrote: > Hi all, > i'm trying to do a simple task with Django but evidently it is not so > simple... It is - when you understand how things work. > I have my model: > > class Mymodel(models.Model): >     random_string = models.CharField(max_length=200) > >     def prod

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread nick.l...@gmail.com
well...when you say inheritance...I was thinking that you were going to create some models like this: class BaseProject(models.Model): title = models.CharField() field2 = models.IntegerField() field3 = models.TextField() class SubProject(BaseProject) """ inherits the fields fr

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread pixelcowboy
Again my problem is that i want the actual values of the fields to cascade down into child models, unless overridden by the child models. Thanks again for your help, I'll think this through a bit more, there might be a better way to conceptualize my models and their inheritance than the way Im thi

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread nick.l...@gmail.com
good luck! :) Here's another option... create a method or function that spawns a new project based off of what ever project is currenlty being viewed... The way I see it is: Adding a button to the admin that creates a new project based off the one currently being viewed...and then also redirects

How to pass in a file to a model directly

2010-09-15 Thread Yo-Yo Ma
I'm wondering how to do this: instance = SomeModelWithFile.objects.create( file = some_file, spam="Spam", foo="Foo" ) How can I manually pass in a file like this? In file=some_file should some_file be a FileUpload instance? How do I create one of those? -- You received this mes

Re: Prepopulating fields from parent, or related models, in the admin

2010-09-15 Thread pixelcowboy
It kind of does... I'll see if I can manage it that way. Thanks again! On Sep 15, 12:13 pm, "nick.l...@gmail.com" wrote: > good luck! :) > > Here's another option... > create a method or function that spawns a new project based off of what ever > project is currenlty being viewed... > > The way

Re: error after upgrading to 1.2.3

2010-09-15 Thread Börni
On Sep 14, 11:32 pm, Börni wrote: > Hello together, > after upgrading to django 1.2.3 i got the following error: > [...] > > Any suggestions what's could be wrong? Hello again, i solved the issue. If you run into the same problem you need to "compilemessages" django-1.2.3/django/conf/locale/*/LC_

Re: virtualenv used with mod_wsgi

2010-09-15 Thread Graham Dumpleton
You need to add it to sys.path in WSGI script file. The PYTHONPATH in .bashrc of your personal account isn't used by Apache/mod_wsgi. Graham On Sep 15, 10:46 pm, Jagdeep Singh Malhi wrote: > On Sep 15, 11:15 am, Colin Bean wrote:> Have you tried the > steps described > here:http://code.google

have to use older versions of django/python

2010-09-15 Thread Wendy
Hello, I've just been told that I have to run my project on the server with django 1.0, python 2.5, when previously I was told I could use any version I wanted, so I've been using python 2.6.1 and django 1.2. Ugh, another wrinkle added to deployment. I think it's possible that it'll work, and I've

How do I troubleshoot mod_wsgi 404 admin issues

2010-09-15 Thread dclaar
I'm having a problem where admin of my models works fine in the development server, but fails in production, where I'm using mod_wsgi. Here's the relevant parts of my urls.py: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() from django.conf import se

confirmation dialogue before delete object

2010-09-15 Thread dimitri pater - serpia
hi, i have this view for adding or editing or deleting an object: (actually it is a bit more complex as it also includes creating end changing an object) def manage_component(request,project_id,a_id,b_id=None,delete=None): if not b_id: # form to add object #etc.. elif b_id and not

Admin widget attributes strange behaviour

2010-09-15 Thread Peter Johnston
In the Django FAQ there's a suggestion for "How do I change the attributes for a widget on a field in my model". The method given is def formfield_for_dbfield(self, db_field, **kwargs): # This method will turn all TextFields into giant TextFields if isinstance(db_field, models.

Re: How to pass in a file to a model directly

2010-09-15 Thread Yo-Yo Ma
Anyone? On Sep 15, 1:18 pm, Yo-Yo Ma wrote: > I'm wondering how to do this: > > instance = SomeModelWithFile.objects.create( >     file = some_file, >     spam="Spam", >     foo="Foo" > ) > > How can I manually pass in a file like this? In file=some_file should > some_file be a FileUpload ins

Re: How to pass in a file to a model directly

2010-09-15 Thread nick.l...@gmail.com
Have you looked at this yet? http://docs.djangoproject.com/en/dev/topics/files/#the-file-object n On Wed, Sep 15, 2010 at 7:18 PM, Yo-Yo Ma wrote: > I'm wondering how to do this: > > > instance = SomeModelWithFile.objects.create( >file = some_file, >spam="Spam", >foo="Foo" > ) >

Re: Querying Exact Foreign Key Sets

2010-09-15 Thread Jason
Wow - that's *exactly* the way I ended up doing it! It took me a full working day to figure it out though. I'll post up a snippet when I'm at work tomorrow. Basically the same thing except filtering with pk and not name- I looped through the exact matches and then excluded the rest. On Sep 15,

Django and third party python apps, best practices for path locations?

2010-09-15 Thread Nick
Let's say you have Python installed to D:/dev/python2.6 Is it wise/common practice to put django and other third party python libraries (like pygments or markdown) in the python2.6/Lib/site- packages/ directory while putting your actual projects in a completely separate location off the python pat

Re: Django and third party python apps, best practices for path locations?

2010-09-15 Thread nick.l...@gmail.com
Nick, yes...and no. Have you looked at using Virtualenv? http://pypi.python.org/pypi/virtualenv On Thu, Sep 16, 2010 at 1:44 AM, Nick wrote: > Let's say you have Python installed to D:/dev/python2.6 > > Is it wise/common practice to put django and other third party python > libraries (like p

Re: Django and third party python apps, best practices for path locations?

2010-09-15 Thread Nick
Yes and no. I'm familiar with the term but haven't read up on it enough to wrap my head around installing it and getting it setup. Is it absolutely essential to get used to working with virtualenv if you plan to develop on a Windows machine but your production servers are running *nix? On Sep 15,

Re: Django and third party python apps, best practices for path locations?

2010-09-15 Thread Mike Dewhirst
On 16/09/2010 12:06pm, Nick wrote: Yes and no. I'm familiar with the term but haven't read up on it enough to wrap my head around installing it and getting it setup. Is it absolutely essential to get used to working with virtualenv if you plan to develop on a Windows machine but your production s

Re: Django and third party python apps, best practices for path locations?

2010-09-15 Thread Nick
Ok thanks, so I guess it's a 99% standard to have libraries installed into the /site-packages/ because that's where setup.py installs them to? I never actually used that before. When I installed django I just grabbed the zip off the site and extracted the /django/ folder directly to /site-packages

RE: Tools to ease template/ui development

2010-09-15 Thread Sells, Fred
Perhaps I'm fighting the trend, but I like Flex -- XML ---DJango best. -Original Message- From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On Behalf Of bruno desthuilliers Sent: Tuesday, September 14, 2010 4:20 PM To: Django users Subject: Re: Tools to ease templa