Re: How to import DoesNotExist exception ???
from tutorial part 03: from django.http import Http404 # ... def detail(request, poll_id): try: p = Poll.objects.get(pk=poll_id) except Poll.DoesNotExist: raise Http404 return render_to_response('polls/detail.html', {'poll': p}) but, you can use "get_object_or_404(, )" shortcut and catch a http404 exception... it's more clean =) Sergio Durand Info Cascade escreveu: > I just want to catch the exception thrown when the query returns nothing. > Thanks, that seems to have done the trick. > > [EMAIL PROTECTED] wrote: > >> I'm not sure where you got that code snippet from, but DoesNotExist is >> an attribute on model classes, so that shoul read: >> >> except Tag.DoesNotExist. >> >> On Dec 8, 2:52 pm, Info Cascade <[EMAIL PROTECTED]> wrote: >> >> >>> How do I import the DoesNotExist exception? >>> >>> This doesn't seem to work:> from django.db.models.query import DoesNotExist >>> >>> try: tag = Tag.objects.get(name=cat_name) except DoesNotExist: # do something else >>> Doesn't DoesNotExist exist? >>> >>> >>> >> >> > > > > > > --~--~-~--~~~---~--~~ 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: ' Change History' for audit, compliance
Hi, You can use AuditTrail[1] (i'm using now) or django-revision[2] (i'm planning use this). []'s Sergio Durand [1] http://code.djangoproject.com/wiki/AuditTrail [2] http://code.google.com/p/django-reversion/ Lincoln_Consulting escreveu: > Hello > > Every moden application needs 'Change History' for Audit and > Compliance purposes. > > > An application should provide information who changed what data, when > did they change the data , the old value and the new value etc > > > Can Django help automate this? > > > This will be a huge selling point of using Django in business > environments. > --~--~-~--~~~---~--~~ 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: DeprecationWarning: Non-ASCII character in models.py
Hi Nick, Insert the following code as first line of your models.py (and other .py files) # -*- coding: utf-8 -*- []'s Sergio Durand Nick escreveu: > Hi, > > I've recently noticed that I'm getting the following in my Apache > error log... > > DeprecationWarning: Non-ASCII character '\xc2' in file /var/www/django/ > newsite/web/models.py on line 101, but no encoding declared; see > http://www.python.org/peps/pep-0263.html for details > > Line 101 in my models.py file contains... > > price_per_week = models.CharField(max_length=100, blank=True, > help_text="Calculate average price per week. Include > £ prefix.Example: \"£150\", > \"£300-£320\", \"£100+\"") > > I'm guessing it's something to do with the help_text, specifically the > £ symbol. > > Can anybody shed some light on how I can fix this, presumably I need > to declare an encoding, or there is an encoding mismatch going on > somewhere? > > Thanks, > Nick > --~--~-~--~~~---~--~~ 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: where is my pythonpath
would be this you are looking for ? python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" []'s Sergio Durand KillaBee escreveu: > I need to edit my pythonpath, but where it? > > > > --~--~-~--~~~---~--~~ 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: Problems getting manage.py syncdb to work
hi, try to connect with postgres using psql utility: psql -h localhost -U -W if you don't have success login, the problem could be on postgres config. []'s Sergio Durand airjaw escreveu: > Hi, I'm having a bit of trouble getting past the "manage.py syncdb" > command. I am trying to setup : > Postgresql 8.3 > Django 1.0 > psycopg2 > > The error I get when I run syncdb is: > psycopg2.OperationalError: could not connect to server: No such file > or directory > Is the server running locally and accepting > connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432″? > > Everything is correct in my settings.py file. When I try manage.py > dbshell and enter the same user (ocdnet_admin) and pass, I can connect > to that db (ocdnet_db). > > I have restarted postgresql server numerous times. > I'm thinking it might be my pg_hba.conf settings, which look like this > (at the bottom) > > localall postgres ident sameuser > localocdnet_db ocdnet_admin md5 > # TYPE DATABASEUSERCIDR-ADDRESS METHOD > # "local" is for Unix domain socket connections only > #local all all ident sameuser > # IPv4 local connections: > hostall all 127.0.0.1/32 md5 > # IPv6 local connections: > hostall all ::1/128 md5 > > > > > Can anyone help me with this? Thank you. > > > > --~--~-~--~~~---~--~~ 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: Audit Trail
Hi Erick, It was working on r8339. I've updated django this morning to r8460 to and still working !! What is "history Manager" that you said ? look how i'm using audit trail: 1) i have my 'ordinary' model (without audit trail feature) 2) i get the audit trail code and drop it into site-packages python directory (it works if you put on root dir of your django project too) 3) put import line on your model 4) put an 'extra' attribute in your model (that i called 'history') to use audit trail. 5) and finnaly, run the magic command 'syncdb'.. or, sqlall , you should see all the sql generated by django. follows my (very) simple example: http://dpaste.com/hold/72943/ Try again with a simple example like that ... if did't work, send the error message... Good luck!!! ;) Sergio Durand erikcw escreveu: > Hi Sergio, > > I updated my code with your changes, and it still doesn't seem to be > working. I don't have the history Manager in my model. > > Is it working for you? Are you using the latest trunk? > > Thanks! > Erik > > On Aug 19, 12:15 pm, Sérgio Durand <[EMAIL PROTECTED]> wrote: > >> Hi people, >> >> Finally i've got Audit Trail [1] working again !!! :) >> I'm not a django/python expert (i've started studying 2 months ago), but >> after fighting with "python manage.py validate" and searching in google, >> i've got the solution... the problem basically was missing **kwargs >> arguments in some handler functions (because changes made in r8223). >> Maybe this problem is very simple (in fact i think it is), but i've >> spent several hours (and learned a lot of things too) to get this working. >> This was my first code contribution and i'm very glad for that!! >> >> Sergio Durand >> >> [1]:http://code.djangoproject.com/wiki/AuditTrail >> >> ps: i hope i didn't make a code mistake and sorry my english !!! ; >> --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Audit Trail
Hi people, Finally i've got Audit Trail [1] working again !!! :) I'm not a django/python expert (i've started studying 2 months ago), but after fighting with "python manage.py validate" and searching in google, i've got the solution... the problem basically was missing **kwargs arguments in some handler functions (because changes made in r8223). Maybe this problem is very simple (in fact i think it is), but i've spent several hours (and learned a lot of things too) to get this working. This was my first code contribution and i'm very glad for that!! Sergio Durand [1]: http://code.djangoproject.com/wiki/AuditTrail ps: i hope i didn't make a code mistake and sorry my english !!! ;) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---