Re: DKIM Email

2010-04-23 Thread mjlissner
This snippet looks just about right, and the timing of Atwood's post was perfect for me, as I am building such a system right now. I'll post over on the snippet if I discover any problems getting the code to work. Thanks for putting this together. On Apr 21, 8:16 pm, Simon Meers wrote: > For any

form class

2010-04-23 Thread xpanta
Hi, I wanted to ask if I am somehow "obliged" to use the form class provided by Django framework. I can see its use on "static" forms (eg. registration forms or account forms) but most of the forms I write are "dynamic" (forms that are dynamically created depending on the user, whith input fields

Re: I have a problem with the pagination with haystack and apache solr

2010-04-23 Thread Ray McBride
You should have defined the fields yourself in you search_indexes.py file in your app http://docs.haystacksearch.org/dev/searchindex_api.html#quick-start Solr knows about these because you copy your generated schema.xml file into the conf folder Ray On Apr 22, 6:46 pm, Ariel wrote: > I don't k

Re: Any way to do select_related() moving backward?

2010-04-23 Thread Daniel Roseman
On Apr 23, 12:03 am, Continuation wrote: > Is there any way to do something similar to select_related() when > following a foreign key relationship backward? > > For example, > b = Blog.objects.get(id=1) > e = b.entry_set.all() > > Any way to retrieve both b and e in one single DB query? No, not

Re: add permission to new model instances

2010-04-23 Thread Adonis
FYI, I have been looking to django authority as well http://packages.python.org/django-authority/index.html Which apparently supports per-object-permissions (row-level). I just can't get it to work yet... Regards, On Apr 22, 6:04 pm, Shawn Milochik wrote: > What you're describing is more of a r

Sending email via SMTP in a unit test

2010-04-23 Thread Vasil Vangelovski
Is there a way to run unit tests in such a way that email will be sent via the SMTP email backend when there's a call to send_mail in the unit test? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us..

Re: Why doesn't my isinstance() work?

2010-04-23 Thread David De La Harpe Golden
On 22/04/10 04:34, Lachlan Musicman wrote: I presume this will make you all wince, but while appreciating the discussion I've caused I've solved it thusly: views.py def index(request): all_authors = Author.objects.all() all_origAuthors = [] all_translators = Transl

Re: Sending email via SMTP in a unit test

2010-04-23 Thread Russell Keith-Magee
On Fri, Apr 23, 2010 at 6:27 PM, Vasil Vangelovski wrote: > Is there a way to run unit tests in such a way that email will be sent > via the SMTP email backend when there's a call to send_mail in the > unit test? In 1.1; no. In 1.1, Django has a single mail API, and the test setup code replaces t

Re: Sending email via SMTP in a unit test

2010-04-23 Thread Vasil Vangelovski
Yes, I'm using trunk (1.2). Thanks Russell, that helped. On Fri, Apr 23, 2010 at 1:59 PM, Russell Keith-Magee wrote: > On Fri, Apr 23, 2010 at 6:27 PM, Vasil Vangelovski > wrote: >> Is there a way to run unit tests in such a way that email will be sent >> via the SMTP email backend when there's

Re: Should Django handle uploaded files in PUT as well as POST?

2010-04-23 Thread Chester (Carlos Duarte do Nascimento)
This is a somewhat old topic, but a workaround for those (such as myself) who need to process parameters from the request body on non-POST methods (such as PUT) is to write: body_params = QueryDict(request.raw_post_data, encoding=request.encoding) and use this dictionary (body_params) in the same

Re: form class

2010-04-23 Thread George Sakkis
On Apr 23, 9:52 am, xpanta wrote: > Hi, > > I wanted to ask if I am somehow "obliged" to use the form class > provided by Django framework. I can see its use on "static" forms (eg. > registration forms or account forms) but most of the forms I write are > "dynamic" (forms that are dynamically crea

problem with apache and wsgi

2010-04-23 Thread Kenneth Gonsalves
hi, using django trunk on svn and the latest ubuntu with python 2.6. The setup is this: MEDIA_ROOT = /home/user/media/ MEDIA_URL = http://mysite/smedia/ apache has: Alias /smedia/ /home/user/media/ the uloaded file is in /home/user/media/images/pic.jpg apache cannot find the file. Page source

Re: form class

2010-04-23 Thread Daniel Roseman
On Apr 23, 8:52 am, xpanta wrote: > Hi, > > I wanted to ask if I am somehow "obliged" to use the form class > provided by Django framework. I can see its use on "static" forms (eg. > registration forms or account forms) but most of the forms I write are > "dynamic" (forms that are dynamically crea

temp url with time limit

2010-04-23 Thread Faizan
Wondering if there is a good way to generate temporary URLs that expire in X days. Would like to email out a URL that the recipient can click to access a part of the site that then is inaccessible via that URL after some time period. Thanks, Faizian -- You received this message because you are s

Altering Model instance before returning it to the caller?

2010-04-23 Thread Giulio Paoli
Greetings, my django app has to read values from 2 external tables: - the first table (log) is a sort of log, with many fields. some of these fields are digit coded (i.e.: 0 = input, 1 = output etc). The keys for the fields lay in the second table; - the second table (codes) is composed of an auto

New with Django

2010-04-23 Thread Mehul
Hi, Last two days i am trying to set up django on my window machine. I had installed 1>python25.msi on d drive(d:/Python25). 2>django at location :D:\Python25\Lib\site-packages\django. It showing a successful message on IP : http://127.0.0.1:8000/ 3>Apache 2.2 4>mod_python-3.3.1.win32-py2.5-Apach

Re: problem with apache and wsgi

2010-04-23 Thread Massimiliano della Rovere
does apache have the rights to open the file and enter the directories smedia and images? On Fri, Apr 23, 2010 at 10:45, Kenneth Gonsalves wrote: > hi, > > using django trunk on svn and the latest ubuntu with python 2.6. The setup is > this: > > MEDIA_ROOT = /home/user/media/ > MEDIA_URL = http:/

Re: problem with apache and wsgi

2010-04-23 Thread Lakshman Prasad
Did you try: Alias /smedia /home/user/media On Fri, Apr 23, 2010 at 2:15 PM, Kenneth Gonsalves wrote: > hi, > > using django trunk on svn and the latest ubuntu with python 2.6. The setup > is > this: > > MEDIA_ROOT = /home/user/media/ > MEDIA_URL = http://mysite/smedia/ > apache has: > Alias /sm

Re: Altering Model instance before returning it to the caller?

2010-04-23 Thread Shawn Milochik
This is pretty standard behavior in Django. Have something like this in your models.py: LOG_CODES = ( ('Input', 1), ('Output', 2), ) Then, the model field should have this in its definition: choices = LOG_CODES If you name that field name, say, _transaction_type, then yo

Re: New with Django

2010-04-23 Thread Anand Agarwal
You can write a file xyz.wsgi with following content in your application import os import sys sys.path.append("D:\\workspace\\python\\sspl\\src") sys.path.append("D:\\workspace\\python\\sspl\\src\\ssplsite") os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi appl

Re: danjgo authentification

2010-04-23 Thread Wiiboy
Shouldn't the form in fac_login.html target /login/? ... Even if not, that dot in the action attribute should _not_ be there, I don't think. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@goog

Re: django files based sessions

2010-04-23 Thread Tmr
See workaround here -> http://code.djangoproject.com/ticket/9084 On 3 апр, 08:10, Pradnya wrote: > I am using windows XP and Python with django > 1. changed the SESSION_ENGINE to > 'django.contrib.sessions.backends.file' > 2. SESSION_FILE_PATH = 'd:/tmp' > 3. In view.py defined 2 methods/views as

Re: temp url with time limit

2010-04-23 Thread daniels
Take a look at this Lighttpd module: http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModSecDownload You could implement something based on what the module above is doing. On Apr 23, 12:26 pm, Faizan wrote: > Wondering if there is a good way to generate temporary URLs that > expire in X d

Re: temp url with time limit

2010-04-23 Thread Nick Serra
Just create a model that stores the url and the expiration time. If the url is hit past the expiration time, delete it, if it's still within the time limit, display whatever you want to display. Obviously this is for a small system, since you would be waiting to delete until the url is hit, but its

Re: import request ? - django debugsqlshell

2010-04-23 Thread Nick Serra
Request is an object that django passes view functions that includes post data, meta data, and data about the request taking place. Not sure what your test function is doing, but to start, python is complaining because you are referencing the variable before it has been declared. You need to define

Autocomplete with two tables

2010-04-23 Thread Pep
Hi everybody ! I have two tables on my database : one for the products (named Product) and one for my clients (name Client). In Client, there is a row named 'products' where I put all the client products with a list and a dictionnary. For exemple : list = ["prod1": {"name"="product1", "price"=2},

Re: New with Django

2010-04-23 Thread Nick Serra
Whenever I use django on my windows box, i use XAMPP, which is a all in one installer that gets apache and mysql. So I: - install XAMPP - install python - svn checkout django in the site-packages folder - install mysql bindings for python - install python image library and I think you need to add

Re: temp url with time limit

2010-04-23 Thread Bill Freeman
Another possibility, if you don't care what the url looks like, is to encode the date and a md5 (or other, your choice) checksum in the url. The checksum is formed by putting a 'secret' where the checksum goes (at the end?) and checksuming that. When you get a request back, first check the date,

Re: get_next_by title?

2010-04-23 Thread Javier Guerra Giraldez
On Fri, Apr 23, 2010 at 1:29 AM, ChrisR wrote: >        def get_prev_by_title(self): >                get_prev = Product.objects.order_by('- > title').filter(title__lt=self.title) >                try: >                        return get_prev[0] >                except IndexError: >              

Re: I have a problem with the pagination with haystack and apache solr

2010-04-23 Thread Ariel
What I do here in search_indexes.py is this: from haystack import site from atl_cms.content_type.models import News, Document site.register(News) site.register(Document) On Fri, Apr 23, 2010 at 4:18 AM, Ray McBride wrote: > You should have defined the fields yourself in you search_indexes.p

Re: get_next_by title?

2010-04-23 Thread ChrisR
Awesome, even better! Thanks Javier. I'll look into adding this instead, or at least hang onto it for future reference. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsu

Re: I have a problem with the pagination with haystack and apache solr

2010-04-23 Thread Ariel
Where does the apache solr save the index ??? On Fri, Apr 23, 2010 at 1:23 PM, Ariel wrote: > What I do here in search_indexes.py is this: > > from haystack import site > from atl_cms.content_type.models import News, Document > > site.register(News) > site.register(Document) > > > > > > On Fri,

Filtering for an object that is modified in memory loses those modifications?

2010-04-23 Thread Margie Roginski
I have a situation where I have a handle to a db object and I've modified a field in it. Then I later end up executing a filter that finds that same object (among others) and saves all of the objects it finds. In this situation the modified fields do not get saved out. It's like the filter is get

Performing an action on model.save() but not on update

2010-04-23 Thread Jim N
Hi, I have overridden the default save() on a model so that I can update some counts every time a save occurs. Unfortunately, I don't want to perform these actions every time the model is updated, which seems to happen. Is there another approach I can take that distinguishes between save and upd

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Skylar Saveland
On Apr 23, 3:27 pm, Jim N wrote: > Hi, > > I have overridden the default save() on a model so that I can update > some counts every time a save occurs.  Unfortunately, I don't want to > perform these actions every time the model is updated, which seems to > happen. > > Is there another approach

Re: Filtering for an object that is modified in memory loses those modifications?

2010-04-23 Thread Skylar Saveland
Yes. The filter method returns a queryset which is a lazy database object that will query the database to get the queryset. You would have to save the object for the queryset to return it. You could however get all of the objects which are not your select objects MyModel.objects.exclude(pk__i

auto generate "dummy" content (e.g. Lorem ipsum generator for Django)

2010-04-23 Thread Brad Buran
Is there any easy way of generating dummy content for models in Django? As I'm learning how to use Django, I often find myself deleting the sqlite database and running syncdb each time (rather than dealing with the issues of manual schema migration each time I make a change to my models). As part

Re: Autocomplete with two tables

2010-04-23 Thread Skylar Saveland
http://docs.djangoproject.com/en/dev/topics/db/queries/ On Apr 23, 11:11 am, Pep wrote: > Hi everybody ! > > I have two tables on my database : one for the products (named > Product) and one for my clients (name Client). > In Client, there is a row named 'products' where I put all the client > p

Re: auto generate "dummy" content (e.g. Lorem ipsum generator for Django)

2010-04-23 Thread Skylar Saveland
http://docs.djangoproject.com/en/dev/ref/contrib/webdesign/#ref-contrib-webdesign On Apr 23, 3:41 pm, Brad Buran wrote: > Is there any easy way of generating dummy content for models in Django?  As > I'm learning how to use Django, I often find myself deleting the sqlite > database and running sy

Re: Filtering for an object that is modified in memory loses those modifications?

2010-04-23 Thread Bill Freeman
This is correct behavior. You do not have a handle on a db row. You have a reference to an instance of a python class whose attributes contain data copied from the (set of foreign key and/or join table related )db row(s). Filter is a means of preparing a new query to run against the db. When tha

Re: Filtering for an object that is modified in memory loses those modifications?

2010-04-23 Thread Margie Roginski
Thanks for the clarification Skylar and Bill. That all makes sense. Margie On Apr 23, 12:48 pm, Bill Freeman wrote: > This is correct behavior.  You do not have a handle on a db row. > You have a reference to an instance of a python class whose > attributes contain data copied from the (set of

Oracle cursor.execute problem

2010-04-23 Thread Tim Sawyer
Hello. This code works fine: >>> import cx_Oracle >>> lDsn = cx_Oracle.makedsn(lDatabaseHost, int(lDatabasePort), lDatabaseName) >>> lConnectString = "%s/%...@%s" % (lDatabaseUsername, lDatabasePassword, lDsn) >>> lConnection = cx_Oracle.connect(lConnectString) >>> cursor = lConnection.cursor

Re: I have a problem with the pagination with haystack and apache solr

2010-04-23 Thread Ray McBride
You have no SearchIndex class. see the quick start guide in the link I sent you R On 23 Apr, 18:23, Ariel wrote: > What I do here in search_indexes.py is this: > > from haystack import site > from atl_cms.content_type.models import News, Document > > site.register(News) > site.register(Document)

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Nick Serra
A post save signal seems better suited for this. The post save signal has an attribute 'created' that will be true or false depending on if the object is being created or updated. Check out the post_save documentation: http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.post

Re: form class

2010-04-23 Thread xpanta
Thank you for the answers. The link provided by George is an excellent resource and I should thank him for that. However my task is a bit simpler. Let's say I own a car company and I have dealers in various cities. By clicking on each city name I get a list of cars this city's dealer sells. This

Re: error with forms

2010-04-23 Thread Mike
I'm not completely sure, but it looks as though your variable 'body': body = forms.CharField(widget = forms.Textarea()) should be: body = forms.CharField(widget=forms.Textarea) with next area not as a function. http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Form.widget On

Re: I have a problem with the pagination with haystack and apache solr

2010-04-23 Thread Ray McBride
usually in a folder called data as defined in the solrconfig.xml but I dont think looking in the data folder will help you. Ray On 23 Apr, 18:32, Ariel wrote: > Where does the apache solr save the index ??? > > > > > > On Fri, Apr 23, 2010 at 1:23 PM, Ariel wrote: > > What I do here in search_i

Re: Oracle cursor.execute problem

2010-04-23 Thread Skylar Saveland
Looking at the source for execute on django-trunk in django.db.backends.oracle If you have a param, you will have an arg for the query (type: string). http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly ... your params should be a list of things to interpolate into

Re: Oracle cursor.execute problem

2010-04-23 Thread Ian
On Apr 23, 1:59 pm, Tim Sawyer wrote: > Hello. > > This code works fine: > >  >>> import cx_Oracle >  >>> lDsn = cx_Oracle.makedsn(lDatabaseHost, int(lDatabasePort), > lDatabaseName) >  >>> lConnectString = "%s/%...@%s" % (lDatabaseUsername, > lDatabasePassword, lDsn) >  >>> lConnection = cx_Oracl

Re: Oracle cursor.execute problem

2010-04-23 Thread Skylar Saveland
Ah, I guess it's only %s and strings for execute? At anyrate, the third argument to connection.execute(self, query, parms=None), params, is a list of strings, each member of the list should have a '%s' placeholder in the query. The string-formatting link is a not really germane .. On Apr 23, 4:3

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Skylar Saveland
Yeah, and I think my suggestion fails for a user-defined rather than auto-incrementing pk. On Apr 23, 4:21 pm, Nick Serra wrote: > A post save signal seems better suited for this. The post save signal > has an attribute 'created' that will be true or false depending on if > the object is being cr

Re: Oracle cursor.execute problem

2010-04-23 Thread Ian
On Apr 23, 2:44 pm, Ian wrote: > Django cursors universally use the 'format' dbapi paramstyle rather > than the 'named' style natively used by cx_Oracle [1].  To convert > your query, replace the parameter markers with %s and pass the > parameters as a list rather than a dictionary. > > If you ins

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Nick Serra
I didn't even think of that. It's not very common to be specifying pk's on create anyway, so yours would probably be fine. I just think signals are cleaner and use them when I can :) On Apr 23, 4:47 pm, Skylar Saveland wrote: > Yeah, and I think my suggestion fails for a user-defined rather than

Re: Oracle cursor.execute problem

2010-04-23 Thread Ian
On Apr 23, 2:45 pm, Skylar Saveland wrote: > Ah, I guess it's only %s and strings for execute?  At anyrate, the > third argument to connection.execute(self, query, parms=None), params, > is a list of strings, each member of the list should have a '%s' > placeholder in the query.  The string-format

Re: SCORM(Sharable Content Object Reference Model) Compliant for Django?

2010-04-23 Thread Mario Garcia
Hi Zeal Django I dont know about a SCORM module for django. As I remember there is a SCORM module for Plone , I dont know about a LMS developed in django. Mario Garcia On Apr 22, 2:05 am, Zeal wrote: > Hi, All, > > Does anyone has the experience on SCORM(Sharable Content Object > Reference Mod

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Jim N
OK, that makes total sense. I've implemented it like so: def _hook_post_save_answer(instance, sender, **kwargs): if 'created' in kwargs and kwargs['created'] == True: if instance.user: quser = instance.user.get_profile() quser.increment_answers() inst

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Nick Serra
Try this out and see what happens: def _hook_post_save_answer(instance, created, sender, **kwargs): if created: if instance.user: quser = instance.user.get_profile() quser.increment_answers() instance.question.increment_responses() post_save.connect(_ho

Re: DKIM Email

2010-04-23 Thread mjlissner
Looking over this snippet, I see that it's set up to use the SMTP backend. Will it also work for the other email backends, or is that asking too much? On Apr 23, 12:13 am, mjlissner wrote: > This snippet looks just about right, and the timing of Atwood's post > was perfect for me, as I am buildin

Re: SCORM(Sharable Content Object Reference Model) Compliant for Django?

2010-04-23 Thread Skylar Saveland
I was about to need to do something along these lines, so I used inspectdb to look at Moodle. I was going to connect django and moodle to the same DB since moodle was going to be a certainty in the position that I didn't end up taking: http://github.com/skyl/django-moodle This is a really basic,