Re: Building Django web application
On Oct 10, 8:53 pm, mguthrie <[EMAIL PROTECTED]> wrote: > Graham, > Thanks for the detailed response. I have yet to get too much into > the internals of Apache in regards to Python applications. My > background is in PHP which is a whole different beast with it's own > unique way of being tweaked. I'll have to look into the mod_wsgi > setup you mentioned. I've heard a lot of things regarding wsgi with > other Python projects. > Discussing all of this has made me re-think my approach and whether > Django will be a good fit for this specific project. It may be better > for me to simply use a different python framework and let the client > separation be handled via the application and not separated out by > Apache or any other server (lighttpd, nginx, etc). > Like I noted my background is in PHP development so understanding > the Python way of doing things is new territory for me. Thanks for > the feedback. The way I see it, any good design will end with you setting up separate instances of your code per client. You COULD have a "client id" field in every single model that will be distinguished between clients, but this will be difficult. For one, you're going to need to create a new User model (Totally doable, actually, but a hassle), and trying to maintain all those different clients in the same tables is just begging for mix-ups and errors. As said above, if you use apache, I would try using the worker MPM and mod_wsgi, and just make sure that all your code is thread safe. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: gettext is not defined - js error in admin calendar.js
You have to do like that : And define in you urls.py (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': 'django.conf'}), Let me know if it does works :) On 8 sep, 14:37, ykb <[EMAIL PROTECTED]> wrote: > Could you please let us know in a little more detail on how to set the > jsi18n path. > Where is "/admin/jsi18n/" referring to? > > Thanks, > Yadu. > > On Aug 20, 1:38 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > That did it. Many Thanks! > > > On Aug 19, 3:09 pm, Daniel Roseman <[EMAIL PROTECTED]> > > wrote: > > > > On Aug 19, 5:28 pm, "[EMAIL PROTECTED]" > > > > <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > > I'm trying to use the datetime picker widget from the admin widgets. > > > > > My form is displaying, but the datetime picker is not. When I check > > > > the error console, I see the message: > > > > > Error: gettext is not defined > > > > Source File:http://localhost:8001/media/js/calendar.js > > > > Line: 26 > > > > > And another in DateTimeShortcuts. > > > > > Searching this group I > > > > found:http://groups.google.com/group/django-users/browse_thread/thread/f0ab... > > > > > But I'm running the latest update from the trunk. > > > > > In my HTML output I see: > > > > > > > > > > > > > > > > > > The second two lines are coming from the media property of my form > > > > object, and I inserted the first to quiet another JS error. > > > > > I've searched all the JS in my Django check out and I can't find > > > > gettext described there. I turned internationalization off in my > > > > settings file. Any one have any ideas? > > > > > -Justin > > > > The admin templates have this extra line: > > > > > > which refers to an actual Django admin view which renders Javascript, > > > rather than an included JS file. I think if you resolve the path it > > > ends up as /admin/jsi18n/ - would definitely be worth including that > > > before your other script tags and see if that helps. > > > > -- > > > DR. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
I could never get Eric to install on Windows On Sun, Oct 12, 2008 at 10:20 PM, oso che bol <[EMAIL PROTECTED]> wrote: > Hi, > > How do you think about Eric4.2.1 with Django plugin? > > Regards, > -LN > > > On Mon, Oct 13, 2008 at 9:28 AM, reyjexter <[EMAIL PROTECTED]> wrote: > >> >> I use pydev because I'm more of an eclipse guy >> >> -rey >> >> On Oct 13, 12:19 am, zjffdu <[EMAIL PROTECTED]> wrote: >> > I am a newbie of django, and want to know which IDE is suit for >> > django? >> > >> > thank your >> >> > > > > -- http://www.goldwatches.com/ http://www.jewelerslounge.com/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
Hi, How do you think about Eric4.2.1 with Django plugin? Regards, -LN On Mon, Oct 13, 2008 at 9:28 AM, reyjexter <[EMAIL PROTECTED]> wrote: > > I use pydev because I'm more of an eclipse guy > > -rey > > On Oct 13, 12:19 am, zjffdu <[EMAIL PROTECTED]> wrote: > > I am a newbie of django, and want to know which IDE is suit for > > django? > > > > thank your > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Handling Dynamic Image Uploads
Hi, I can't figure out how to handle image uploads in a form that accepts a variable number of uploads. I would happily use Django newforms to take care of it, but I'm using a form that can be extended to include multiple file uploads (implemented by dynamically adding file input tags to the DOM). What are my options? Can I use python in the view to copy the uploaded image from a tmp directory to the file system? To my knowledge, I can't use an UploadedFile object without using form.ImageField or file.FileField in the template. New to Django and loving it - but ran into this bump. Thanks so much! Justin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
makemessages create invalid msgid in django.po file
The base language of my site is Chinese. I want to change to English when user select language perferrence. In my base.html, I have {% trans "产品" %} I generated django.po file using django-admin.py makemessages -l en In django.po file of en locale, #: .\templates\base.html.py:36 msgid "å…¬å ¸äº§å“ " msgstr "Products" As you can see, the generated msgid is scrambled and invalid. This caused translation failed. If I manually changed the msgid to be msgid "产品" msgstr "Products" The translation works. I verified that my base.html is utf-8 encoded. Anyone know what is the reason for the scrambled msgid in django.po file? I suspect this is an encoding issue on makemessages command, but don't know how to resolve this. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Possible pug with Model inheritence - Inserts instead of Update
On Sun, 2008-10-12 at 00:16 -0700, shabda wrote: > My models.py > > class Foo(models.Model): > name = models.CharField(max_length = 100) > > def save(self): > self.id = None > super(Foo, self).save() > > class Bar(Foo): > created = models.DateTimeField(auto_now_add = 1) > > > This gives me, > > In [1]: from djcalendar.models import Foo > > In [2]: shabda = Foo(name = 'Shabda') > > In [3]: shabda.save() > > In [4]: Foo.objects.all() > Out[4]: [] > > In [5]: shabda.name = 'Shabda Raaj' > > In [6]: shabda.save() > > In [7]: Foo.objects.all() > Out[7]: [, ] > > > Which is what I expect. Now doing the same thing to Bar > > In [1]: from djcalendar.models import Bar > > In [2]: shabda = Bar(name = 'Shabda') > > In [3]: shabda.save() > > In [4]: shabda.name = 'Shabda Raaj' > > In [5]: shabda.save() > > In [6]: Bar.objects.all() > Out[6]: [] > > Here I am expecting two objects, similar to what happened with Foo, > but I get only one. > > Am I missing something, or is this a bug? You're missing something. You are assuming that setting Foo.id to be None will create a new Bar object. Since "id" is not the primary key of the Bar model, this won't be the case. Your code is creating another copy of Foo and then changes the parent to which the shabda object points. The primary key of shabda doesn't change throughout this process. Regards, Malcolm --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Extend a field of an abstract model
On Sun, 2008-10-12 at 08:55 -0700, mrsource wrote: > I have defined an abstract Model with some fields: > > class Componente(models.Model): > name = models.CharField(max_length=80,unique=True) > description = models.TextField(blank=True) > class Meta: > abstract = True > > and then in the derived class I would to define verbose_name property > for some field of the super Model: > > class Pagina(Componente): > # Stuff to set verbose_name of fileds "name" and "description " > class Meta: > verbose_name = 'Pagina statica' > verbose_name_plural = 'Pagine statiche' > > I have tried to put some stuff in __init__ function with no success... You can't really do this without diving deep into the internals of the model creation stuff. Which means you should probably be questioning the approach. If the name and description aren't the same every time, then it's not a common piece of data and doesn't really belong in the abstract base class. Abstract base classes are for data that is the same in every subclass. Regards, Malcolm --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to unit test form clean methods
On Sun, Oct 12, 2008 at 8:30 PM, meppum <[EMAIL PROTECTED]> wrote: > I would like to be able to unit test my forms. Specifically, I'd like > to be able to test individual clean methods, but I get errors when I > try to call cleaned methods directly. Below is an example of testing a > registration form. I couldn't find any documentation on this. First, create an instance of the form using a dictionary of data which should fail, then check that is_valid() is False and inspect the error dictionary to make sure it got the right message. Then, create an instance using a dictionary that should pass, and check that is_valid() is True. django-registration does this in its unit-test suite (form tests start at line 145): http://www.bitbucket.org/ubernostrum/django-registration/src/tip/registration/tests.py -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
I use pydev because I'm more of an eclipse guy -rey On Oct 13, 12:19 am, zjffdu <[EMAIL PROTECTED]> wrote: > I am a newbie of django, and want to know which IDE is suit for > django? > > thank your --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to unit test form clean methods
you can simply create a form on your test case and pass in dictionary to mimic request parameters. I have blogged about it and you can find it here: http://www.reyjexter.com/post/unit-testing-django-component-example -rey On Oct 13, 9:30 am, meppum <[EMAIL PROTECTED]> wrote: > I would like to be able to unit test my forms. Specifically, I'd like > to be able to test individual clean methods, but I get errors when I > try to call cleaned methods directly. Below is an example of testing a > registration form. I couldn't find any documentation on this. > > def testRegistrationFormCleanUsername(self): > data = {'username': 'test'} > form = RegistrationForm(data) > form.is_valid() > > form.clean_username() # this method uses > cleaned_data['username'] to get the form entry for username > > AttributeError: 'RegistrationForm' has no object 'cleaned_data' > > -meppum --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with i18n - "en_US" locale translations coming through for "en"
Hi Fran, Sorry if I can't help but I've been looking myself for a possibly quick answer to a strange problem regarding i18n. I am running latest svn rev and the strangest thing is that in the admin app I am presented with both LANGUAGES and LANGUAGE_CODE. My custom templates however do not recognize these variables, even though they're being passed through the same middleware and context processors (or at least I'd like to believe that) Maybe i'm just thinking out loud, Regards RiCardo On Aug 28, 1:44 am, "Fran O'Reilly" <[EMAIL PROTECTED]> wrote: > I've raised the following ticket for this issue: > > http://code.djangoproject.com/ticket/8626 > > Have also confirmed on latest from svn, 1.0-beta_2-SVN-8643. The > ticket includes all the files needed to reproduce the problem. > > On Aug 27, 5:35 pm, "Fran O'Reilly" <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I've got a situation where even though the user has selected language > > "en", the "en_US" translations are being rendered. My setup has three > > languages - "en", "en-us" and "en-gb". I also have three locale > > translations corresponding, i.e. "en", "en_GB" and "en_US". > > > Anyone seen a similar problem before? > > > My settings file has the following: > > > LANGUAGE_CODE = 'en' > > > ugettext = lambda s: s > > LANGUAGES = ( > > ('en', ugettext('English (Default)')), > > ('en-us', ugettext('English (American)')), > > ('en-gb', ugettext('English (British)')), > > ) > > > I have created translations for each of the three locales above using > > the normal django-admin.py commands: > > > % django-admin.py makemessages -l en > > % django-admin.py makemessages -l en-gb > > % django-admin.py makemessages -l en-us > > > ... then filled in the django.po files with the translations (for this > > test, I made sure to use text that was different for each locale so I > > could tell which translations were coming through), then : > > > % django-admin.py compilemessages > > > then restart my server to pick them up. > > > I also have locale middleware setup so that LANGUAGE_CODE is available > > on the request. Here's my settings.py: > > > MIDDLEWARE_CLASSES = ( > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.middleware.locale.LocaleMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.middleware.doc.XViewMiddleware', > > 'django.middleware.transaction.TransactionMiddleware', > > ) > > > Here's a snippet from my template. It lives at /index.html/ and has a > > dropdown control that allows the user to select the default language. > > It's basically just a homepage where the user chooses their preferred > > language setting with a dropdown form and submit button. It hooks into > > the django set-language view (django.conf.urls.i18n) being mapped to > > the url /i18n/setlang/. It has a h1 element that is translated as well > > as a debug print of the value of request.LANGUAGE_CODE. The "Homepage" > > text is translated in each of the locale's django.po files with text > > like "Homepage (en)", "Homepage (en-gb)" or "Homepage (en-us)" so I > > can tell which translation is coming through to the template. > > > --snip-- > > > > > > {% trans "Current selected native language/dialect" > > %} > > > > {% for lang in LANGUAGES %} > > > %}selected {% endifequal %}>{{ lang.1 }} > > {% endfor %} > > > > > > > > > LANGUAGE_CODE={{ request.LANGUAGE_CODE }} > > > {% trans "Homepage" %} > > --snip-- > > > So when I select the language "en", the template renders the "en_US" > > values in the template which is wrong - expect "en" locale. If I > > switch to "en-gb" or "en-us", it works as you'd expect, pulling back > > the en_GB or en_US locale translations. Just with "en", for some > > reason, it pulls back the "en_US" translations, but obviously I'd > > expect the "en" translation to come back. > > > Also very odd: If I take out the "en_US" locale and language code from > > the above, the "en" and "en_GB" locales now work correctly! It's as if > > there were something special about the "en_US" locale in the code > > somewhere?! > > > I'm running django svn 8015, about a month old or thereabouts. Haven't > > had time to try this on the latest svn. > > > Any help appreciated, > > > Fran O'Reilly. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb adapter
I was hoping I wouldn't have to use 2.5 instead of 2.6 but thats what it looks like I must do. Thanks for the look into my problem. On Oct 12, 5:39 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Sun, Oct 12, 2008 at 8:08 PM, Narshe <[EMAIL PROTECTED]> wrote: > > > I'm running Windows XP with WAMPSERVER 2.0 installed. Python2.6 > > MySQL is installed on my computer at this location: C:\wamp\bin\mysql > > Here is how my settings.py is set up: > > [snip] > > running build_ext > > building '_mysql' extension > > error: None > > Ok notice the "building '_mysql' extension" part. > > Where it says "error: None" I think what it is really saying is "error: I > don't know what's wrong". That is, it didn't build but has no information > about what, specifically, went wrong. > > I once spent a bit of time trying to build MySQLdb on Windows and failed. I > don't know what C compiler it builds properly with, but it's apparently not > any of the free-software ones I tried, where header file conflicts between > what the compiler and MySQL provided generated a mess of duplicate > conflicting #defines that I didn't care to get to the bottom of. > > So, I have stuck with the precompiled Windows binaries available for > MySQLdb, that is the .exe files available here: > > http://sourceforge.net/project/showfiles.php?group_id=22307&package_i... > > Unfortunately that means Python 2.5, not Python 2.6, since there is no .exe > available for Python 2.6. > > Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb adapter
On Sun, Oct 12, 2008 at 8:08 PM, Narshe <[EMAIL PROTECTED]> wrote: > > I'm running Windows XP with WAMPSERVER 2.0 installed. Python2.6 > MySQL is installed on my computer at this location: C:\wamp\bin\mysql > Here is how my settings.py is set up: > [snip] > running build_ext > building '_mysql' extension > error: None > Ok notice the "building '_mysql' extension" part. > Where it says "error: None" I think what it is really saying is "error: I don't know what's wrong". That is, it didn't build but has no information about what, specifically, went wrong. I once spent a bit of time trying to build MySQLdb on Windows and failed. I don't know what C compiler it builds properly with, but it's apparently not any of the free-software ones I tried, where header file conflicts between what the compiler and MySQL provided generated a mess of duplicate conflicting #defines that I didn't care to get to the bottom of. So, I have stuck with the precompiled Windows binaries available for MySQLdb, that is the .exe files available here: http://sourceforge.net/project/showfiles.php?group_id=22307&package_id=15775 Unfortunately that means Python 2.5, not Python 2.6, since there is no .exe available for Python 2.6. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
MySQLdb adapter
I'm running Windows XP with WAMPSERVER 2.0 installed. Python2.6 MySQL is installed on my computer at this location: C:\wamp\bin\mysql Here is how my settings.py is set up: DATABASE_ENGINE = 'mysql' DATABASE_NAME = 'pythonDB' DATABASE_USER = 'py' DATABASE_PASSWORD = '#py' DATABASE_HOST = '' DATABASE_PORT = '3306' I downloaded the adapter needed (MySQLdb, http://www.djangoproject.com/r/python-mysql/). I used 7zip to place in C:\Python26\Lib\site-packages\MySQL- python-1.2.2. When I cd to that and input 'setup.py install' , here is the output: C:\Python26\Lib\site-packages\MySQL-python-1.2.2>setup.py install running install running bdist_egg running egg_info writing MySQL_python.egg-info\PKG-INFO writing top-level names to MySQL_python.egg-info\top_level.txt writing dependency_links to MySQL_python.egg-info \dependency_links.txt deleting MySQL_python.egg-info\native_libs.txt reading manifest file 'MySQL_python.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'MySQL_python.egg-info\SOURCES.txt' installing library code to build\bdist.win32\egg running install_lib running build_py creating build creating build\lib.win32-2.6 copying _mysql_exceptions.py -> build\lib.win32-2.6 creating build\lib.win32-2.6\MySQLdb copying MySQLdb\__init__.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\converters.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\connections.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\cursors.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\release.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\times.py -> build\lib.win32-2.6\MySQLdb creating build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win32-2.6\MySQLdb \constants copying MySQLdb\constants\CR.py -> build\lib.win32-2.6\MySQLdb \constants copying MySQLdb\constants\FIELD_TYPE.py -> build \lib.win32-2.6\MySQLdb \constants copying MySQLdb\constants\ER.py -> build\lib.win32-2.6\MySQLdb \constants copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.6\MySQLdb \constants copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.6\MySQLdb \constants copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.6\MySQLdb \constants running build_ext building '_mysql' extension error: None Ok notice the "building '_mysql' extension" part. Now when I go to the Python Shell: >>> import MySQLdb Traceback (most recent call last): File "", Line 1, in ImportError: No module named MySQLdb If I put the MySQLdb folder in the site-packages dir: >>> import MySQLdb Traceback (most recent call last): File "", Line 1, in File "C:\Python26\Lib\site-packages\MySQLdb\__init__.py", line 19 in import _mysql ImportError: No module named _mysql So my question is how do I correctly install the MySQLdb adapter? Or more specifically, can my current setup be saved? (Go easy on me, I just started with Django 2 days ago) Thanks bunches in advance ^^ --Narshe --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Get m2m id to update the m2m model.
On Mon, Oct 13, 2008 at 5:27 AM, xkill <[EMAIL PROTECTED]> wrote: > > Hello, > > I try to update a m2m relation. > > So this is the problem: > > models.py > --- > from django.db import models > > class instruments(models.Model): >name = models.CharField(max_length=10) > > class people(User): >objects = UserManager() >phone = models.CharField(max_length=9, blank=True, null=True) >movil = models.CharField(max_length=9, blank=True, null=True) > > class relations(models.Model): >person = models.ForeignKey(people) >instrument = models.ForeignKey(instruments) >def __unicode__(self): >return '%s => %s' % (self.person, self.instrument > > class concerts(models.Model): >title = models.CharField(max_length=80) >date = models.DateTimeField() >description = models.TextField() >musicians = models.ManyToManyField(relations, blank=True, > null=True) >def __unicode__(self): >return self.title > > > If I add some concerts with musicians, and I need to change the > relation of the person with the instrument. > I think updating the relations class using the id to update the > instrument. > > How can I get the IDs of the relations associated to the m2m > (musicians) field? > > If I use: from my_project.test.models import concerts, relations, people, instruments b = concerts.objects.get(id = 2) b.title > u'Test2 Concert' b.musicians.all() > [ Djembe>, Tambourin>, > Djembe>] > > > But I want to change the relation 'Juan => Djembe' to 'Juan => > Tambourin'. How can I do it? The model that you are using for the m2m relation is just another model, so if you want to modify an instance of that model, select an instance it and change it directly. >>> p = person.objects.get(name='Juan') >>> r = relation.objects.get(person__name='Juan', instrument__name='Djembe') >>> tamb = instrument.objects.get(name='Tambourin') >>> r.instrument = tamb >>> r.save() Also - as a matter of style, it's a good habit to get into the capitalization scheme suggested by PEP8 [1] - that means that class/model names should be captialized (i.e., class Person, not class person) [1] http://www.python.org/dev/peps/pep-0008/ Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is trunk usually stable enough to run in a development server?
On Sun, Oct 12, 2008 at 6:17 PM, jmat <[EMAIL PROTECTED]> wrote: > > Just curious what anyones suggestions are for running satchmo on a dev > server? Is trunk stable enough to develop a new site on (perhaps > anticipating the site being done soon after the .8 release)? > > > If so do you have any (general) suggestions on how to stay relatively > up to date with the code base? If not no problem using .7 but just > curious what others are doing? > > I gather you're asking about running the Satchmo trunk code vs. a released sStchmo since the numbers you mention don't correspond to Django release numbers? The satchmo-users list might be a better place to get feedback on that: http://groups.google.com/group/satchmo-users Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weird errors when i transfer from production to local ...
On Sun, Oct 12, 2008 at 4:25 PM, Daniel Roseman < [EMAIL PROTECTED]> wrote: > On Oct 12, 8:46 pm, dbee <[EMAIL PROTECTED]> wrote: > > ### ERROR 2 ### > > > Exception Type: ProgrammingError at /blog/venture-capital-pitfalls/ > > Exception Value: ERROR: operator does not exist: character varying = > > integer > > LINE 1: ...M "tarait1_blog" WHERE ("tarait1_blog"."category" = 0 AND > > "... > > ^ > > HINT: No operator matches the given name and argument type(s). You > > might need to add explicit type casts. > > > > SELECT COUNT(*) FROM "tarait1_blog" WHERE ("tarait1_blog"."category" = > > 0 AND "tarait1_blog"."active" = True ) > > > This sounds like a difference in the way your database is set up. Are > you sure you have the same table definitions, collations, charsets, > etc? Or possibly a change to PostgreSQL 8.3 from something earlier. This could be the result of the change "Non-character data types are no longer automatically cast to TEXT" described here: http://www.postgresql.org/docs/8.3/static/release-8-3.html This was "fixed" (by Django code automatically adding a cast) for search-type lookups (like, contains, etc.) per this ticket: http://code.djangoproject.com/ticket/6523 But that change doesn't affect equal lookups, which is what you are doing. The SQL shown actually looks like the PostgreSQL change may be exposing a latent bug in your code. 'category = 0' rather sounds more like it should be 'category = ""' or 'category is null'. I'd take a look at the code causing that SQL to be generated and see if it is really doing what you intend it to. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is trunk usually stable enough to run in a development server?
Oops sorry to many groups open, this was meant for the satchmo group. On Oct 12, 3:17 pm, jmat <[EMAIL PROTECTED]> wrote: > Just curious what anyones suggestions are for running satchmo on a dev > server? Is trunk stable enough to develop a new site on (perhaps > anticipating the site being done soon after the .8 release)? > > If so do you have any (general) suggestions on how to stay relatively > up to date with the code base? If not no problem using .7 but just > curious what others are doing? > > Thx. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
WingIde for python code and e-text editor for templates (sometimes notepad++) On Sun, Oct 12, 2008 at 3:08 PM, Marco Bazzani <[EMAIL PROTECTED]>wrote: > > > On Sun, Oct 12, 2008 at 11:32 PM, Jeff Anderson <[EMAIL PROTECTED]>wrote: > >> zjffdu wrote: >> > I am a newbie of django, and want to know which IDE is suit for >> > django? >> > >> I'd say that it'd be good to continue using whatever IDE you use for >> your other Python development. Django is, after all, simply Python code >> that you call from your code. >> >> Jeff Anderson >> >> I've used VC2008 for coding some asp.net 2.0 web app and while the whole > asp.net2.0 thing is a pain the IDE is really powerfull I hope somebody > (maybe aptana) come up with an ide with some facilities like: > manage.py in a more "visual" way, > metaclasses (e.g. models, admin, FormFromModel ecc...) autocompletion and > maybe template helper > would be really great... > but this is only my wondering :) > cheers > > > -- > > Helen Hayes - "Age is not important unless you're a cheese." > > > > -- http://www.goldwatches.com/ http://www.jewelerslounge.com/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is trunk usually stable enough to run in a development server?
Just curious what anyones suggestions are for running satchmo on a dev server? Is trunk stable enough to develop a new site on (perhaps anticipating the site being done soon after the .8 release)? If so do you have any (general) suggestions on how to stay relatively up to date with the code base? If not no problem using .7 but just curious what others are doing? Thx. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
On Sun, Oct 12, 2008 at 11:32 PM, Jeff Anderson <[EMAIL PROTECTED]>wrote: > zjffdu wrote: > > I am a newbie of django, and want to know which IDE is suit for > > django? > > > I'd say that it'd be good to continue using whatever IDE you use for > your other Python development. Django is, after all, simply Python code > that you call from your code. > > Jeff Anderson > > I've used VC2008 for coding some asp.net 2.0 web app and while the whole asp.net2.0 thing is a pain the IDE is really powerfull I hope somebody (maybe aptana) come up with an ide with some facilities like: manage.py in a more "visual" way, metaclasses (e.g. models, admin, FormFromModel ecc...) autocompletion and maybe template helper would be really great... but this is only my wondering :) cheers -- Helen Hayes - "Age is not important unless you're a cheese." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
zjffdu wrote: > I am a newbie of django, and want to know which IDE is suit for > django? > I'd say that it'd be good to continue using whatever IDE you use for your other Python development. Django is, after all, simply Python code that you call from your code. Jeff Anderson signature.asc Description: OpenPGP digital signature
Get m2m id to update the m2m model.
Hello, I try to update a m2m relation. So this is the problem: models.py --- from django.db import models class instruments(models.Model): name = models.CharField(max_length=10) class people(User): objects = UserManager() phone = models.CharField(max_length=9, blank=True, null=True) movil = models.CharField(max_length=9, blank=True, null=True) class relations(models.Model): person = models.ForeignKey(people) instrument = models.ForeignKey(instruments) def __unicode__(self): return '%s => %s' % (self.person, self.instrument class concerts(models.Model): title = models.CharField(max_length=80) date = models.DateTimeField() description = models.TextField() musicians = models.ManyToManyField(relations, blank=True, null=True) def __unicode__(self): return self.title If I add some concerts with musicians, and I need to change the relation of the person with the instrument. I think updating the relations class using the id to update the instrument. How can I get the IDs of the relations associated to the m2m (musicians) field? If I use: >>> from my_project.test.models import concerts, relations, people, instruments >>> b = concerts.objects.get(id = 2) >>> b.title u'Test2 Concert' >>> b.musicians.all() [ Djembe>, Tambourin>, Djembe>] But I want to change the relation 'Juan => Djembe' to 'Juan => Tambourin'. How can I do it? Thank you very much. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
My personal favorite is "Editra" Regards, Gerard. zjffdu wrote: > I am a newbie of django, and want to know which IDE is suit for > django? > > thank your > > -- urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
On Sun, Oct 12, 2008 at 3:01 PM, Tim Chase <[EMAIL PROTECTED]> wrote: > Emacs is your thing, that would do, as would any other good > text-editor (some folks swear by TextMate or Notepad++). > I use Komodo Editor - http://www.activestate.com/Products/komodo_ide/komodo_edit.mhtml - I find that in combination with using the dejngo development server and import pdb; pdb.set_trace() you can have a pretty solid edit and debug environment without too much learning curve. > Some folks do use Eclipse (with the Python plugin) for their > needs, but I've found that overkill for my simple needs (and my > underpowered home machine(s)) Amen to that :-) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
On Sun, Oct 12, 2008 at 6:19 PM, zjffdu <[EMAIL PROTECTED]> wrote: > > I am a newbie of django, and want to know which IDE is suit for > django? > > thank your I use Komodo Edit, it's free and it has Python auto-completion etc. It runs on Windows, OS X and Linux. -- Anders Bergh --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
> I am a newbie of django, and want to know which IDE is suit > for django? I second the use of a good text editor. I'm a Vim user, but if Emacs is your thing, that would do, as would any other good text-editor (some folks swear by TextMate or Notepad++). Some folks do use Eclipse (with the Python plugin) for their needs, but I've found that overkill for my simple needs (and my underpowered home machine(s)) -tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Keeping track of song play count in django and flash
i'm looking at this problem too. 1. either the flash player can send a javascript/ajax ping to a url where it can be logged 2. or the songfile can be a django served url which logs and then redirects to the actual static URL. probably the second is easiest. On Oct 10, 9:28 pm, M Godshall <[EMAIL PROTECTED]> wrote: > Is anyone familiar with any techniques or tutorials that would allow > me to keep track of a song's play count using django and a flash > player? I realize this might be a question more directed toward flash > users, but I figured I'd try here in case any django users have had > experience with this. Thanks. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weird errors when i transfer from production to local ...
On Oct 12, 8:46 pm, dbee <[EMAIL PROTECTED]> wrote: > I'm bringing my django code base from production server to a clean > install on development. The environments are different, but I'm > getting some very strange errors that I don't seem to be able to > figure out ... I was wondering if anyone had experienced the same > issues ... > > Prod Server : django-.97 && Python 2.3.4 > > Dev Server: django 1.0 && Python 2.5 > > ### ERROR 1 ### > Exception Value: 'WSGIRequest' object has no attribute 'has_key' Since you're running different versions, have you looked at the backwards incompatible changes page? This issue is described there: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Removeddictionaryaccesstorequestobject Basically, you can no longer do request['key'] to get a value from the request object, or request.has_key('key'). You have to do request.REQUEST.has_key('key'). > ### ERROR 2 ### > Exception Type: ProgrammingError at /blog/venture-capital-pitfalls/ > Exception Value: ERROR: operator does not exist: character varying = > integer > LINE 1: ...M "tarait1_blog" WHERE ("tarait1_blog"."category" = 0 AND > "... > ^ > HINT: No operator matches the given name and argument type(s). You > might need to add explicit type casts. > > SELECT COUNT(*) FROM "tarait1_blog" WHERE ("tarait1_blog"."category" = > 0 AND "tarait1_blog"."active" = True ) This sounds like a difference in the way your database is set up. Are you sure you have the same table definitions, collations, charsets, etc? > Neither error occurs on the production server. These are fairly > strange errors that occur on both the dev server locally and the local > apache server ... > > Anyone have any ideas ? Yes: run the same version in both environments. -- DR. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How can I check which view is being called in response to a specific Url?
another way is to use the javascript Bookmarklet. go to Documentation > Bookmarklets also the debug footer http://www.djangosnippets.org/snippets/766/ is very useful, I just added in the code erik allik posted: from django.core.urlresolvers import resolve view_func, args, kwargs = resolve(request.META['PATH_INFO']) view = '%s.%s' % (view_func.__module__, view_func.__name__) now the debug footer always shows the view used On Oct 12, 8:38 pm, shabda <[EMAIL PROTECTED]> wrote: > One of my views is returning a Http404, and I think it is calling a > view function diffrent from what I am expecting to be called. > > So How can I check which view is being called in response to a > specific Url? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Possible pug with Model inheritence - Inserts instead of Update
ah ok. you will have problems here because the parent class also has a database record and an id. it would be messy I think to try to fool django. better would be to make a kind of save_as or maybe you can copy the object and it will also copy its parent class. or make a specific method for this class that returns a clone with just the fields you want to copy for the history. there is some pluggable app called "django-versions". check this out and see if it works for you. -f;lix On Oct 12, 8:23 pm, shabda <[EMAIL PROTECTED]> wrote: > As long as model_obj.id is None, Django does an Insert, I want an > insert to happen all the time. (Sort of like trying to get > FullHistory, wherein I can roll back my object to a previous state. I > can do save(force_insert = True), but that also gives me an > Exception.) > > On Oct 12, 6:32 pm, felix <[EMAIL PROTECTED]> wrote: > > > well this is interesting and curious what you are trying to do. > > why are you trying to do this self.id= None ? > > > what is the real world purpose ? can you give a non abstract > > example ? > > > in any case since Bar is a subclass of Foo there are two database > > tables. > > you set Bar id to None, > > but the object still has a Foo ptr id, so ultimately there is still > > only one object. > > that is, I think, the primary key that is accessed when using > > Bar.objects.all() > > > really, you have broken it by this self.id = None, > > so I would expect more problems > > > On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote: > > > > My models.py > > > > class Foo(models.Model): > > > name = models.CharField(max_length = 100) > > > > def save(self): > > > self.id = None > > > super(Foo, self).save() > > > > class Bar(Foo): > > > created = models.DateTimeField(auto_now_add = 1) > > > > This gives me, > > > > In [1]: from djcalendar.models import Foo > > > > In [2]: shabda = Foo(name = 'Shabda') > > > > In [3]: shabda.save() > > > > In [4]: Foo.objects.all() > > > Out[4]: [] > > > > In [5]: shabda.name = 'Shabda Raaj' > > > > In [6]: shabda.save() > > > > In [7]: Foo.objects.all() > > > Out[7]: [, ] > > > > Which is what I expect. Now doing the same thing to Bar > > > > In [1]: from djcalendar.models import Bar > > > > In [2]: shabda = Bar(name = 'Shabda') > > > > In [3]: shabda.save() > > > > In [4]: shabda.name = 'Shabda Raaj' > > > > In [5]: shabda.save() > > > > In [6]: Bar.objects.all() > > > Out[6]: [] > > > > Here I am expecting two objects, similar to what happened with Foo, > > > but I get only one. > > > > Am I missing something, or is this a bug? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to detect changes in a model's fields before save() ?
On 11 oct, 18:03, Donn <[EMAIL PROTECTED]> wrote: > Sounds like you should be doing something in the form's clean() function. You > can compare what's in the cleaned_data to what's in the model and then move > from there. And what if you didn't use a form to alter the model instance ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to detect changes in a model's fields before save() ?
On 11 oct, 02:59, zhango <[EMAIL PROTECTED]> wrote: > I'm overriding a model's save() method, and I want to detect changes > in values for some of the model's fields (i.e. differences between the > unsaved instance's values for some fields, and the values for those > same fields currently in the database and about to be overwritten). > Is it possible to do this, and if so, how? class Yadda(models.Model): blah = models.CharField(max_length=32) def __unicode__(self): return u"%s" % self.blah def __init__(self, *args, **kw): print "yadda __init__", args, kw super(Yadda, self).__init__(*args, **kw) self._old_blah = self.blah def save(self, **kw): print "yadda save" if self.blah != self._old_blah: print "blah changed - was : %s - now : %s" % (self._old_blah, self.blah) super(Yadda, self).save(**kw) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
On 12 oct, 18:19, zjffdu <[EMAIL PROTECTED]> wrote: > I am a newbie of django, and want to know which IDE is suit for > django? Any decent text/code editor with support for Python and HTML will do. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Weird errors when i transfer from production to local ...
I'm bringing my django code base from production server to a clean install on development. The environments are different, but I'm getting some very strange errors that I don't seem to be able to figure out ... I was wondering if anyone had experienced the same issues ... Prod Server : django-.97 && Python 2.3.4 Dev Server: django 1.0 && Python 2.5 ### ERROR 1 ### Environment: Request Method: GET Request URL: http://localhost:8000/telelist/ Django Version: 1.0-final-SVN-unknown Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'tarait.tarait1'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.middleware.transaction.TransactionMiddleware') Traceback: File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/home/babo/django/tarait/../tarait/tarait1/views.py" in telelist 1178. if request.method == 'GET' and request.has_key('location') : Exception Type: AttributeError at /telelist/ Exception Value: 'WSGIRequest' object has no attribute 'has_key' ### ERROR 2 ### Environment: Request Method: GET Request URL: http://localhost:8000/blog/venture-capital-pitfalls/ Django Version: 1.0-final-SVN-unknown Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'tarait.tarait1'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.middleware.transaction.TransactionMiddleware') Traceback: File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/home/babo/django/tarait/../tarait/tarait1/views.py" in blog 405. tally_count = Blog.objects.filter(category = i).filter(active = 't').count() File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in count 290. return self.query.get_count() File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py" in get_count 237. data = obj.execute_sql(SINGLE) File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py" in execute_sql 1700. cursor.execute(sql, params) File "/usr/lib/python2.5/site-packages/django/db/backends/util.py" in execute 19. return self.cursor.execute(sql, params) File "/usr/lib/python2.5/site-packages/django/db/backends/postgresql/ base.py" in execute 52. return self.cursor.execute(smart_str(sql, self.charset), self.format_params(params)) Exception Type: ProgrammingError at /blog/venture-capital-pitfalls/ Exception Value: ERROR: operator does not exist: character varying = integer LINE 1: ...M "tarait1_blog" WHERE ("tarait1_blog"."category" = 0 AND "... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. SELECT COUNT(*) FROM "tarait1_blog" WHERE ("tarait1_blog"."category" = 0 AND "tarait1_blog"."active" = True ) Neither error occurs on the production server. These are fairly strange errors that occur on both the dev server locally and the local apache server ... Anyone have any ideas ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Attachment not recognized as such in EmailMultiAlternatives email
Hi, When I create a EmailMultiAlternatives email and attach a PDF attachment after having provided both a text and HTML body the PDF attachment is not recognized as such by an email client (although the text and HTML representations are correctly displayed). It looks like the EmailMultiAlternatives email does not include an mulitpart/mixed wrapper arround the multipart/alternative views. Any suggestions? Is this intentionally or a bug? Loek --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mysql with Django on Jython
On Sun, Oct 12, 2008 at 2:58 PM, Hingarajiya,Ravi <[EMAIL PROTECTED]>wrote: > Hi All, > > I am using Jython for Django. > > I want to know that how to connect mysql to Django on Jython. > > Thanks in Advance > You asked the same question yesterday, and nobody answered. That means nobody who read the list yesterday and had time to answer questions knew the answer. Asking the same thing again isn't particularly helpful to anyone. Instead of reposting, did you consider doing some independent research? I've never run Django on Jython but a simple Google search on "Django Jython mysql" reveals this project as the 1st hit: http://code.google.com/p/django-jython/ It apparently has PostgreSQL and sqlite backends, and lists MySQL as "Should be easy to implement" here: http://code.google.com/p/django-jython/wiki/DevelopingNewDatabaseBackends So it doesn't appear there is a mysql backend for Django on Jython available at the moment. Further investigation of the Google hits reveals at least one blog of someone who maybe started on one, so that also might be a place to look further. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom form/formset for edit inline
Hi, I'm trying to figure out how to use a custom form for when editing objects inline in the admin. The case is something like this: I have Images that have foreign keys to image galleries. When editing a gallery, the images associated with it are edited inline. The image model has quite a few options, so the listing on each gallery page gets pretty long. Images also have a field for sorting weight. I would like to implement simons snippet for sorting inline objects with drag and drop (from http://www.djangosnippets.org/snippets/1053/), which is pretty unusable with a very long page. I would therefore like the image form to collapse, showing only the ordering field, title and hopefully a thumbnail of the image. I know I could probably do this via a custom template, but that felt a bit messy for some reason. So, I decided to take a shot at learning a bit about customizing the admin form stuff via formset factories. I tried reading the docs, googled a bit but couldn't get it working. So far I've done the following: 1. Create a normal ModelAdmin-subclass for both Image and ImageGallery 2. Created a ModelForm-subclass for the galleries to get the extra JS stuff in to get the draggable stuff working 3. Created an ImageInline (subclass of admin.StackedInline) 4. Pointed to the ImageInline from the ModelAdmin options for ImageGallery 5. In the ImageInline-class, I specified the formset-option, pointing to... 6. ...the ImageInlineFormset, which a formset created with inlineformset_factory, that in turn specifies a form in the function call, namely... 7. ...ImageInlineForm, which is a subclass of ModelForm. There, I've specified exactly how I want my fieldsets laid out. My admin.py is up at http://dpaste.com/83994/ Nothing seems to take in changing the inline form for the image though. I get no errors, but the form stays the same... I'm not 100% sure about everything I'm doing every step of the way here, so... Have I got all this backwards? I just assumed that since I can specify a formset-option on the inline, I should be able to use a formset created through inlineformset_factory, and, in creating that, pointing to a custom ModelForm... //emil --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Ordering object collection by computed field?
On Sun, Oct 12, 2008 at 2:12 PM, Peter Krantz <[EMAIL PROTECTED]>wrote: > > Hi! > > I have a model like this: > > class Thing(models.Model): > x = models.PositiveIntegerField() > y = models.PositiveIntegerField() > > def z(self): > return self.x / self.y * A_CONSTANT > > > In a view I would like to retrieve a collection of Things ordered by z > (the computed field). I expected the order_by method to do the trick > like this: > > things_collection = Thing.objects.order_by('z') > > ...but order_by will only work for fields actually stored in the > database (the above gives a "Cannot resolve keyword 'z' into field"). > What would be the best way to implement a custom order_by that allows > ordering of computed model fields? Or have I missed some feature for > this in Django? > > order_by on a QuerySet translates to 'ORDER BY' in the SQL SELECT sent to the database. So you have to order_by something known to the database. You can force the calculation & result to be part o fthe SQL select and thus be something you can specify in order_by by using extra(): Thing.objects.extra(select={"calcz" : "x / y * %d" % A_CONSTANT},order_by=["calcz"]) Whether that's "best" depends on how complicated your actual computation is, how many rows you have in your table, how often you do this select vs. update rows, etc. Alternatively you could store z directly in the database and avoid having to do the computation for every row when you do the select. But then you have to ensure z stays in sync with changes to x & y. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Possible pug with Model inheritence - Inserts instead of Update
As long as model_obj.id is None, Django does an Insert, I want an insert to happen all the time. (Sort of like trying to get FullHistory, wherein I can roll back my object to a previous state. I can do save(force_insert = True), but that also gives me an Exception.) On Oct 12, 6:32 pm, felix <[EMAIL PROTECTED]> wrote: > well this is interesting and curious what you are trying to do. > why are you trying to do this self.id= None ? > > what is the real world purpose ? can you give a non abstract > example ? > > in any case since Bar is a subclass of Foo there are two database > tables. > you set Bar id to None, > but the object still has a Foo ptr id, so ultimately there is still > only one object. > that is, I think, the primary key that is accessed when using > Bar.objects.all() > > really, you have broken it by this self.id = None, > so I would expect more problems > > On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote: > > > My models.py > > > class Foo(models.Model): > > name = models.CharField(max_length = 100) > > > def save(self): > > self.id = None > > super(Foo, self).save() > > > class Bar(Foo): > > created = models.DateTimeField(auto_now_add = 1) > > > This gives me, > > > In [1]: from djcalendar.models import Foo > > > In [2]: shabda = Foo(name = 'Shabda') > > > In [3]: shabda.save() > > > In [4]: Foo.objects.all() > > Out[4]: [] > > > In [5]: shabda.name = 'Shabda Raaj' > > > In [6]: shabda.save() > > > In [7]: Foo.objects.all() > > Out[7]: [, ] > > > Which is what I expect. Now doing the same thing to Bar > > > In [1]: from djcalendar.models import Bar > > > In [2]: shabda = Bar(name = 'Shabda') > > > In [3]: shabda.save() > > > In [4]: shabda.name = 'Shabda Raaj' > > > In [5]: shabda.save() > > > In [6]: Bar.objects.all() > > Out[6]: [] > > > Here I am expecting two objects, similar to what happened with Foo, > > but I get only one. > > > Am I missing something, or is this a bug? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Mysql with Django on Jython
Hi All, I am using Jython for Django. I want to know that how to connect mysql to Django on Jython. Thanks in Advance Regards, Ravi Hingarajiya. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Which IDE do you choose with django?
I'm using Eclipse with WTP (Web Tool Platform) and Pydev plugins. The eclipse debug interface is very powerful. On 12 Ott, 18:19, zjffdu <[EMAIL PROTECTED]> wrote: > I am a newbie of django, and want to know which IDE is suit for > django? > > thank your --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How can I check which view is being called in response to a specific Url?
from django.core.urlresolvers import resolve view_func, args, kwargs = resolve('/your/url/here/') print '%s.%s' % (view_func.__module__, view_func.__name__) Erik On 12.10.2008, at 21:38, shabda wrote: > > One of my views is returning a Http404, and I think it is calling a > view function diffrent from what I am expecting to be called. > > So How can I check which view is being called in response to a > specific Url? > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How can I check which view is being called in response to a specific Url?
One of my views is returning a Http404, and I think it is calling a view function diffrent from what I am expecting to be called. So How can I check which view is being called in response to a specific Url? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Ordering object collection by computed field?
Hi! I have a model like this: class Thing(models.Model): x = models.PositiveIntegerField() y = models.PositiveIntegerField() def z(self): return self.x / self.y * A_CONSTANT In a view I would like to retrieve a collection of Things ordered by z (the computed field). I expected the order_by method to do the trick like this: things_collection = Thing.objects.order_by('z') ...but order_by will only work for fields actually stored in the database (the above gives a "Cannot resolve keyword 'z' into field"). What would be the best way to implement a custom order_by that allows ordering of computed model fields? Or have I missed some feature for this in Django? Regards, Peter --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyFieldManager in post_save signal
There is not way track M2M field change with post_save signal. You can write your own derived M2M field class with needed hooks. On Oct 12, 9:01 pm, Viktor <[EMAIL PROTECTED]> wrote: > Hi, > > I have three simple models Project and Member, where Project.member is > a ManyToManyField to User through Member > > then I would like to add some post save action when a new member is > added to a project. Should I connect this signal to Project or to > Member? Of course, new members can be added on creation and later as > well, and I use the generic view create_object for this. > > I've actually tried both, but with Project instance.members is an > "empty" ManyToManyFieldManager, that is instance.members.all() gives > [ ] (an empty queryset), while the signal on Member never gets called > > how would you do this post_save signal? > > V --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Exception Value: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)
On Sun, Oct 12, 2008 at 11:09 AM, kele <[EMAIL PROTECTED]> wrote: > > i am using the django 1.0 , and while i am try to post some data > (japanes ,chinese characters) and insert to my Mysql db , i got this > error . my table is create in utf8 character , and my setting.py > already has the > DEFAULT_CHARSET = 'utf-8' , > DEFAULT_CHARSET doesn't really matter here since it has nothing to do with the database or communicating with the database. See: http://docs.djangoproject.com/en/dev/ref/settings/#setting-DEFAULT_CHARSET It's used for encoding HttpResponse objects, not for database communiction. > > > where going wrong ?? i am getting MAD in this . HELP! > > Environment: > > Django Version: 1.0-final-SVN-unknown > Python Version: 2.4.3 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.admin', > 'mytest.shaft'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > > Traceback: > [snip] > File "build/bdist.linux-i686/egg/MySQLdb/connections.py" in > unicode_literal > 185. return > db.literal(u.encode(unicode_literal.charset)) > > Exception Type: UnicodeEncodeError at /admin/shaft/clothes/add/ > Exception Value: 'latin-1' codec can't encode characters in position > 0-2: ordinal not in range(256) > This is odd. MySQLdb appears to be using latin-1 for the connection charset, yet Django always sets the connection charset to utf8, see: http://code.djangoproject.com/browser/django/tags/releases/1.0/django/db/backends/mysql/base.py#L242 Somehow that is being overridden or is not working on your machine. Have you specified anything in DATABASE_OPTIONS in your settings.py? What version of MySQL are you using? Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ManyToManyFieldManager in post_save signal
Hi, I have three simple models Project and Member, where Project.member is a ManyToManyField to User through Member then I would like to add some post save action when a new member is added to a project. Should I connect this signal to Project or to Member? Of course, new members can be added on creation and later as well, and I use the generic view create_object for this. I've actually tried both, but with Project instance.members is an "empty" ManyToManyFieldManager, that is instance.members.all() gives [ ] (an empty queryset), while the signal on Member never gets called how would you do this post_save signal? V --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
RE: model definition must come before reference in models.ForeignKey?
Thanks Malcom, that was helpful. Jacob -Original Message- From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Malcolm Tredinnick Sent: Friday, October 10, 2008 8:41 PM To: django-users@googlegroups.com Subject: Re: model definition must come before reference in models.ForeignKey? On Fri, 2008-10-10 at 19:39 -0400, Fenwick, Jacob L. wrote: > If I have a model that has a models.ForeignKey field, does the model > it depends on have to be defined before the model that contains the > field? > > > > I suppose this makes sense, but what if I have a very complicated > hierarchy? Such as if I have three tables, and their foreign keys > relationships form a triangle? This is documented as almost the first thing in the documentation for ForeignKey. http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey "If you need to create a relationship on a model that has not yet been defined, you can use the name of the model, rather than the model object itself." The documentation really is your friend when learning Django (and afterwards). Regards, Malcolm > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Which IDE do you choose with django?
I am a newbie of django, and want to know which IDE is suit for django? thank your --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: macports and django problem
Thanks Jarek. I got it to work -- it is actually not the /opt/local/bin, but rather the /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin that has the "right" python. Thanks for your help! I still don't like that there are multiple versions of Python on my computer, though :-(. Does anyone know if the BSDs have this problem? I'm thinking of switching rather soon. David Jarek Zgoda wrote: > Wiadomość napisana w dniu 2008-10-12, o godz. 17:26, przez David > Koppstein: > > >> I have updated my $PATH variable properly: >> /sw/bin:/sw/sbin:/macosx-bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ >> local/bin:/usr/X11/bin:/usr/X11R6/bin:/Users/david/bin:/sw/bin:/sw/ >> sbin:/Users/david/godi/bin:/Users/david/godi/sbin:/usr/local/ >> smlnj-110.67/bin:/opt/local/bin:/opt/local/sbin >> >> Has anyone installed Django successfully using MacPorts? I really like >> the idea of MacPorts as a philosophy, especially since it's derived >> from >> BSD, but it seems poorly integrated with the existing infrastructure. >> > > > I did this recently. And it works, but my path looks quite different: > > jarek:~$ echo $PATH > /opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/ > Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/ > usr/local/bin:/usr/X11/bin > jarek:~$ python > Python 2.5.2 (r252:60911, Sep 28 2008, 15:23:45) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import django > >>> django.__file__ > '/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/__init__.pyc' > >>> > > What is worth noticing, the /opt/lcoal/bin path comes first on list. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: macports and django problem
Wiadomość napisana w dniu 2008-10-12, o godz. 17:26, przez David Koppstein: > I have updated my $PATH variable properly: > /sw/bin:/sw/sbin:/macosx-bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ > local/bin:/usr/X11/bin:/usr/X11R6/bin:/Users/david/bin:/sw/bin:/sw/ > sbin:/Users/david/godi/bin:/Users/david/godi/sbin:/usr/local/ > smlnj-110.67/bin:/opt/local/bin:/opt/local/sbin > > Has anyone installed Django successfully using MacPorts? I really like > the idea of MacPorts as a philosophy, especially since it's derived > from > BSD, but it seems poorly integrated with the existing infrastructure. I did this recently. And it works, but my path looks quite different: jarek:~$ echo $PATH /opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/ Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/ usr/local/bin:/usr/X11/bin jarek:~$ python Python 2.5.2 (r252:60911, Sep 28 2008, 15:23:45) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> django.__file__ '/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/__init__.pyc' >>> What is worth noticing, the /opt/lcoal/bin path comes first on list. -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R&D, Redefine [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Extend a field of an abstract model
I have defined an abstract Model with some fields: class Componente(models.Model): name = models.CharField(max_length=80,unique=True) description = models.TextField(blank=True) class Meta: abstract = True and then in the derived class I would to define verbose_name property for some field of the super Model: class Pagina(Componente): # Stuff to set verbose_name of fileds "name" and "description " class Meta: verbose_name = 'Pagina statica' verbose_name_plural = 'Pagine statiche' I have tried to put some stuff in __init__ function with no success... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
macports and django problem
Hi, I seem to have come across this problem while trying to install Django using Macports: http://mail.python.org/pipermail/pythonmac-sig/2007-September/019181.html Basically, the django install succeeds, but when I enter the python toplevel and do 'import django' I get an ImportError. As the author of the previous article has stated, I also seem to have two versions of python now, one at /opt/local/bin and one at /usr/bin/python. Apparently neither of them will 'import django.' I have updated my $PATH variable properly: /sw/bin:/sw/sbin:/macosx-bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin:/Users/david/bin:/sw/bin:/sw/sbin:/Users/david/godi/bin:/Users/david/godi/sbin:/usr/local/smlnj-110.67/bin:/opt/local/bin:/opt/local/sbin Has anyone installed Django successfully using MacPorts? I really like the idea of MacPorts as a philosophy, especially since it's derived from BSD, but it seems poorly integrated with the existing infrastructure. Thanks for your help, David --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Exception Value: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)
i am using the django 1.0 , and while i am try to post some data (japanes ,chinese characters) and insert to my Mysql db , i got this error . my table is create in utf8 character , and my setting.py already has the DEFAULT_CHARSET = 'utf-8' , where going wrong ?? i am getting MAD in this . HELP! Environment: Django Version: 1.0-final-SVN-unknown Python Version: 2.4.3 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.admin', 'mytest.shaft'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py" in root 158. return self.model_page(request, *url.split('/', 2)) File "/usr/lib/python2.4/site-packages/django/views/decorators/ cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py" in model_page 177. return admin_obj(request, rest_of_url) File "/usr/lib/python2.4/site-packages/django/contrib/admin/ options.py" in __call__ 191. return self.add_view(request) File "/usr/lib/python2.4/site-packages/django/db/transaction.py" in _commit_on_success 238. res = func(*args, **kw) File "/usr/lib/python2.4/site-packages/django/contrib/admin/ options.py" in add_view 502. self.save_model(request, new_object, form, change=False) File "/usr/lib/python2.4/site-packages/django/contrib/admin/ options.py" in save_model 376. obj.save() File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in save 307. self.save_base(force_insert=force_insert, force_update=force_update) File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in save_base 379. result = manager._insert(values, return_id=update_pk) File "/usr/lib/python2.4/site-packages/django/db/models/manager.py" in _insert 138. return insert_query(self.model, values, **kwargs) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in insert_query 888. return query.execute_sql(return_id) File "/usr/lib/python2.4/site-packages/django/db/models/sql/ subqueries.py" in execute_sql 308. cursor = super(InsertQuery, self).execute_sql(None) File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py" in execute_sql 1700. cursor.execute(sql, params) File "/usr/lib/python2.4/site-packages/django/db/backends/util.py" in execute 19. return self.cursor.execute(sql, params) File "/usr/lib/python2.4/site-packages/django/db/backends/mysql/ base.py" in execute 83. return self.cursor.execute(query, args) File "build/bdist.linux-i686/egg/MySQLdb/cursors.py" in execute 151. query = query % db.literal(args) File "build/bdist.linux-i686/egg/MySQLdb/connections.py" in literal 247. return self.escape(o, self.encoders) File "build/bdist.linux-i686/egg/MySQLdb/connections.py" in unicode_literal 185. return db.literal(u.encode(unicode_literal.charset)) Exception Type: UnicodeEncodeError at /admin/shaft/clothes/add/ Exception Value: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why does MySql gives warning? Incorrect string value: '\xE6\x9D\xB1\xE8\xA8\xBC...' for column 'title' at row 1
On Sun, Oct 12, 2008 at 9:56 AM, felix <[EMAIL PROTECTED]> wrote: > but what does the unittest runner do ?? (since it creates its own > database) > > it also creates a latin1 db: > > CREATE TABLE `website_releasefeedback` ( > ... > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 > Use this setting: http://docs.djangoproject.com/en/dev/ref/settings/#test-database-charset to set the character set for the database. I wonder if django should create all tables with UTF-8 regardless of > how the db is configured. > I don't think so. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blank and null values for a foreign key
On Sun, Oct 12, 2008 at 5:45 AM, Fabio Natali <[EMAIL PROTECTED]>wrote: > > ... > As you can see, a new person can be added with no license at all: > "blank=True,null=True" options. That's what I want. > > In my admin panel I get the list of all the persons I have added. I > wish I could filter or order this list so that I get all the persons > that have no license. > > The point is, if I use "blank=True,null=True" I'm not allowed to have > this filtering/ordering in my admin panel. (The table I get in the > admin panel can't be ordered by the column "license".) > The inability to sort blank=True,null=True ForeignKey columns has been fixed (post 1.0): http://code.djangoproject.com/ticket/7582 So if you run with the current trunk or 1.0.X branch code you can sort these columns in Admin. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Possible pug with Model inheritence - Inserts instead of Update
well this is interesting and curious what you are trying to do. why are you trying to do this self.id= None ? what is the real world purpose ? can you give a non abstract example ? in any case since Bar is a subclass of Foo there are two database tables. you set Bar id to None, but the object still has a Foo ptr id, so ultimately there is still only one object. that is, I think, the primary key that is accessed when using Bar.objects.all() really, you have broken it by this self.id = None, so I would expect more problems On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote: > My models.py > > class Foo(models.Model): > name = models.CharField(max_length = 100) > > def save(self): > self.id = None > super(Foo, self).save() > > class Bar(Foo): > created = models.DateTimeField(auto_now_add = 1) > > This gives me, > > In [1]: from djcalendar.models import Foo > > In [2]: shabda = Foo(name = 'Shabda') > > In [3]: shabda.save() > > In [4]: Foo.objects.all() > Out[4]: [] > > In [5]: shabda.name = 'Shabda Raaj' > > In [6]: shabda.save() > > In [7]: Foo.objects.all() > Out[7]: [, ] > > Which is what I expect. Now doing the same thing to Bar > > In [1]: from djcalendar.models import Bar > > In [2]: shabda = Bar(name = 'Shabda') > > In [3]: shabda.save() > > In [4]: shabda.name = 'Shabda Raaj' > > In [5]: shabda.save() > > In [6]: Bar.objects.all() > Out[6]: [] > > Here I am expecting two objects, similar to what happened with Foo, > but I get only one. > > Am I missing something, or is this a bug? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why does MySql gives warning? Incorrect string value: '\xE6\x9D\xB1\xE8\xA8\xBC...' for column 'title' at row 1
thanks too for this. rather than alter the table manually of course, it should have been created correctly the first time. mysql will create new tables with the character encoding of the database. you can set that this way: alter database cruxxial_md CHARACTER SET = utf8; now tables created with syncdb will have the correct encoding. mysql will create new DATABASES with the charset that was used to start the server mysqld --character-set-server=utf8; which is often out of our control on hosted environments, or even when using handy os x control panels to start the db. so I guess a tip is : when you create the database, make sure to alter the charset before running syncdb. but what does the unittest runner do ?? (since it creates its own database) it also creates a latin1 db: CREATE TABLE `website_releasefeedback` ( ... ) ENGINE=MyISAM DEFAULT CHARSET=latin1 I wonder if django should create all tables with UTF-8 regardless of how the db is configured. On Oct 6, 11:14 am, tamonash <[EMAIL PROTECTED]> wrote: > Thanks Malcolm, > You solved my problem. These tables were something that I was using > from a previous application so all the mess.. > > mysql> alter table ac_project_messages modify title varchar(100) > character setutf8default NULL; > Query OK, 81 rows affected (0.20 sec) > Records: 81 Duplicates: 0 Warnings: 0 > > mysql> alter table ac_project_messages modify text text character setutf8; > Query OK, 81 rows affected (0.05 sec) > Records: 81 Duplicates: 0 Warnings: 0 > > And WOW!! it worked. Thanks again.. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blank and null values for a foreign key
Fabio, If you define de foreignkey in the license model, you can create persons without a problem. The only requirement then for creating a license would be that it needs an existing person. Something like this: class Person(models.Model): name = models.CharField(max_length=30) class License(models.Model): person = models.ForeignKey(Person) number = models.IntegerField(max_length=10) Regards, Gerard. Fabio Natali wrote: > Hi all! > > I have two models, Person and License. > > class License(models.Model): > number = models.IntegerField(max_length=10) > > class Person(models.Model): > name = models.CharField(max_length=30) > license = models.ForeignKey(License,verbose_name="Centro di > costo",blank=True,null=True) > > class PersonAdmin(admin.ModelAdmin): > list_display = ('name', 'license') > ordering = ('name','license') > list_filter = ('name','license') > > As you can see, a new person can be added with no license at all: > "blank=True,null=True" options. That's what I want. > > In my admin panel I get the list of all the persons I have added. I > wish I could filter or order this list so that I get all the persons > that have no license. > > The point is, if I use "blank=True,null=True" I'm not allowed to have > this filtering/ordering in my admin panel. (The table I get in the > admin panel can't be ordered by the column "license".) > > If I only use the "blank=True" option, then I am allowed to order by > license but no "empty" values are then allowed when adding a new > person. This way, each person must have a license, which is not the > case. > > Well, I guess I could use a not-existing license number instead of > null. For example 00 instead of NULL. But it seems tricky and > I might need that number in the future. > > How can I solve this? > > Thanks, Fabio. > -- urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: array grouping in templates
> I have an array and I want to use Django templating to display each > item in a table, grouped by 3 per row. > For example, if i have > arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] > Then I'd want it to show up as > > abc > def > ghi > j > > > In general, the array could be any length, and it's possible I'd want > to do 4 or 5 per row, not necessarily 3. > > What's the easiest way to do this? Thanks a bunch. I've solved this a couple times before on this list, so you might find either of these two threads (and the python code for creating a corresponding columnize template filter) useful: http://groups.google.com/group/django-users/browse_frm/thread/b5f531e2aba49b4a/ http://groups.google.com/group/django-users/browse_frm/thread/a9ca56a9f601271a/ It also allows you to tweak the values returned for the "empty" cells when it squares it off (your content of your last two nodes), so you can pad with the empty string, or you can use something like " " as your padding. Hope this helps, -tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Building Django web application
mguthrie wrote: > The following link seems to support Graham's conclusion: > > http://www.technobabble.dk/2008/aug/25/django-mod-wsgi-perfect-match/ > > Since Graham was a major contributor to mod_python and is the author of mod_wsgi it would be surprising if he'd given you anything other than the scoop on using Django with Apache. regards Steve --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: array grouping in templates
Daniel Roseman wrote: > On Oct 11, 7:58 am, jhf555 <[EMAIL PROTECTED]> wrote: > >> I have an array and I want to use Django templating to display each >> item in a table, grouped by 3 per row. >> For example, if i have >> arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] >> Then I'd want it to show up as >> >> abc >> def >> ghi >> j >> >> >> In general, the array could be any length, and it's possible I'd want >> to do 4 or 5 per row, not necessarily 3. >> >> What's the easiest way to do this? Thanks a bunch. >> > > Use a for loop and the 'divisibleby' filter. > > > {% for letter in arr %} > {% if forloop.counter|divisibleby:"3" %}{% endif %} > {{ letter }} > {% if forloop.counter|divisibleby:"3" %}{% endif %} > {% endfor %} > > Better still, see http://www.djangosnippets.org/snippets/401/ which may well have solved this problem for you in a tidily-packaged way. regards Steve --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: contrib admin and admindocs problem
On Sun, Oct 12, 2008 at 5:51 AM, Nash <[EMAIL PROTECTED]> wrote: > I get this error, you can see a paste here: http://dpaste.com/83932/ > The admin site doesn't work on production at all, on the testserver it > works after a refresh. You appear to have an error in your own code, as evidenced by the final line of the traceback (when in doubt, always *read* the error message): "Tried view_form in module px.heroes.views. Error was: 'module' object has no attribute 'view_form'" This says that your code tries to access something named "view_form" in the module "px.heroes.views", but that there is no such thing available. This raises an exception, which breaks everything. (and the reason why you see this in the admin is because the admin uses reverse URL resolution, which means it has to be able to import all of your views -- any error, anywhere, in any of your views, will break everything) -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: contrib admin and admindocs problem
I get this error, you can see a paste here: http://dpaste.com/83932/ The admin site doesn't work on production at all, on the testserver it works after a refresh. On Oct 11, 4:40 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 10, 2008 at 4:45 PM, Michael Graz <[EMAIL PROTECTED]>wrote: > > > > > Greetings, > > > The contrib.admin module depends on the contrib.admindocs module due to "{% > > url django-admindocs-docroot as docsroot %}" being part of the admin > > base.html template. However there is a problem with the following usage: > > > urlpatterns = patterns('', > > (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > (r'^admin/(.*)', admin.site.root), > > ) > > > The include('django.contrib.admindocs.urls') is done only on demand (a lazy > > evaluation). So if the "/admin" url is visited virst there is some kind of > > weird TemplateSyntaxError since admin template doesn't know about the named > > url from admindocs. But once the "/admin/doc" url is visited then the > > django.contrib.admindocs.urls are loaded and the url named > > django-admindocs-docroot springs into existence. Then from that point on > > the "/admin" will render successfully. > > > Is there a way to have the "/admin" url work right from the start without > > first having to visit the "/admin/doc" url? This problem occurs after every > > server restart. If the server is rarely restarted then the problem is > > lessened. However during development it happens every time the manage.py > > reloads due to a file being changed. > > I do not see this behavior. Specifics of the "weird TemplateSyntaxError" > might shed some light. I have the urls you specify in my config (and > 'django.contrib.admindocs' in INSTALLED_APPS) and can surely visit /admin > without problem before ever visiting the doc url. > > Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Blank and null values for a foreign key
Hi all! I have two models, Person and License. class License(models.Model): number = models.IntegerField(max_length=10) class Person(models.Model): name = models.CharField(max_length=30) license = models.ForeignKey(License,verbose_name="Centro di costo",blank=True,null=True) class PersonAdmin(admin.ModelAdmin): list_display = ('name', 'license') ordering = ('name','license') list_filter = ('name','license') As you can see, a new person can be added with no license at all: "blank=True,null=True" options. That's what I want. In my admin panel I get the list of all the persons I have added. I wish I could filter or order this list so that I get all the persons that have no license. The point is, if I use "blank=True,null=True" I'm not allowed to have this filtering/ordering in my admin panel. (The table I get in the admin panel can't be ordered by the column "license".) If I only use the "blank=True" option, then I am allowed to order by license but no "empty" values are then allowed when adding a new person. This way, each person must have a license, which is not the case. Well, I guess I could use a not-existing license number instead of null. For example 00 instead of NULL. But it seems tricky and I might need that number in the future. How can I solve this? Thanks, Fabio. -- Fabio Natali --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Possible pug with Model inheritence - Inserts instead of Update
My models.py class Foo(models.Model): name = models.CharField(max_length = 100) def save(self): self.id = None super(Foo, self).save() class Bar(Foo): created = models.DateTimeField(auto_now_add = 1) This gives me, In [1]: from djcalendar.models import Foo In [2]: shabda = Foo(name = 'Shabda') In [3]: shabda.save() In [4]: Foo.objects.all() Out[4]: [] In [5]: shabda.name = 'Shabda Raaj' In [6]: shabda.save() In [7]: Foo.objects.all() Out[7]: [, ] Which is what I expect. Now doing the same thing to Bar In [1]: from djcalendar.models import Bar In [2]: shabda = Bar(name = 'Shabda') In [3]: shabda.save() In [4]: shabda.name = 'Shabda Raaj' In [5]: shabda.save() In [6]: Bar.objects.all() Out[6]: [] Here I am expecting two objects, similar to what happened with Foo, but I get only one. Am I missing something, or is this a bug? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---