Re: admin interface
Don't forget to add a __unicode__ method to your models. //Thomas 2008/11/29 mobil <[EMAIL PROTECTED]> > > How to make the admin interface display a list of table columns > instead of just a Users object > > Select users to change > >* Add users > > Users > Users object > Users object > Users object > > > --~--~-~--~~~---~--~~ 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: can't pass a parameter to my named url using {% url %} tag in template
Why don't write {% url delete-quote-page object.id %} ? HTH //Thomas On Nov 27, 2:19 pm, dash86no <[EMAIL PROTECTED]> wrote: > I'm trying to use a URL tag as following: > > delete > > my named url is here: > > url(r'^quote/delete/(?P\d+)/$', > 'django.views.generic.create_update.delete_object', dict(quote_info, > post_delete_redirect='/sam/'), name="delete-quote-page"), > > If I change the code to look like this: > > http://localhost:8000/sam/quote/delete/ > {{ object.id }}">delete > > The link works perfectly. > > Also, if I hard code code the parameter value like so: > > delete > > Then the link also works perfectly. > > However, when I do : > > delete > > I get the error: > > Caught an exception while rendering: Reverse for 'sam_project.delete- > quote-page,' with arguments '('',)' and keyword arguments '{}' not > found. > > If anyone has any hints they would be most appreciated. > > Many 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: Pagination of non-Django database
Am 26.11.2008 13:19 Uhr, huw_at1 schrieb: > A small part of my framework queries a non-Django db due to it being a > legacy db with primary keys already in use. My question is is there a > recognised way of applying pagination to non-Django db objects such > that I can paginate the sql select query on this database? > I am not shure I had understand your question correct. The Django paginator works with lists/tuples, so all you have to do is either let your "other DB" act like a list/tuple, or build a small wrapper that allows the [from:to] syntax and a count() or __len__() method. If that don't work you can of course overload the Paginator itself. I have done this [1] for CouchDB which has not yet any compatible wrapper and uses a completely different approach as it is an document-oriented database. My code is more a hack but it works well. I would recommend to use the first approach if possible. This is only my opinion and is of course not in any way official. //Thomas [1] http://www.djangosnippets.org/snippets/1208/ --~--~-~--~~~---~--~~ 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: Injecting stuff to an existing list?
I think David meant a method in the model not a field so nothing is stored. //Thomas 2008/11/25 Steve Holden <[EMAIL PROTECTED]> > > David Zhou wrote: > > On Tue, Nov 25, 2008 at 3:55 AM, sajal <[EMAIL PROTECTED]> wrote: > [...] > > > > Personally, if the current age of a person is something you'll be > > using often, I'd add it to the model. > > > That's not very good advice, as the current age of a person changes with > time, and you are introducing unnecessary redundancy into the data > model. When do you suggest the current age columns should be updated? > > regards > Steve > -- > Steve Holden+1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.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: How to deal with NTLM authentication
Am 16.11.2008 21:51 Uhr, Lee Connell schrieb: > ... What I want to do is allow the user of my django app to login just > once, then if the user wishes to access the "embeded site" and > recieves the WWW-Authentication : NTLM response, I can just pass the > user and pass so the user is allowed access transparently. How do I > go about doing this? I haven't been able to find anything definitive > online, help would be greatly Have you looked at: http://ntlmaps.sourceforge.net/ HTH, Thomas --~--~-~--~~~---~--~~ 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: simple python question
results.append({'URL': '/feed/%s/show/%s' % (item.rss, item.rssfeed),}) On Thu, Aug 21, 2008 at 23:29, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > hi. > > I'm trying to figure out how to dynamically replace things in a string > as follows: > > >results.append({'URL': '/feed/%s/show/%s' (%item.rss, > %item.rssfeed),}) > > > I think i'm close but it's not the right syntax. can anyone out there > help? > > > > > --~--~-~--~~~---~--~~ 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 Options for Admin Site
James, have a look here: http://www.djangoproject.com/documentation/model-api/#list-display //Thomas Am 22.04.2008 um 00:07 schrieb jwwest: > > Wow, awesome. Thank you! > > On the same subject, is there a way to display more information on the > record in the listing rather than just one column ? For instance, say > I have a 'sales table' and I want to list the sales number as the > first column, then the customer name and so forth. Do I need to edit > the template for this? > > - james > > On Apr 21, 4:58 pm, Thomas Kerpe <[EMAIL PROTECTED]> wrote: >> Hi James >> >> define a __str__ or better __unicode__ method within your model which >> returns the correct string. >> >> i.e. >> def __unicode__(self): >> return self.name >> >> //Thomas >> >> Am 21.04.2008 um 23:55 schrieb jwwest: >> >> >> >>> Hey all, >> >>> I'm not sure what I'm doing wrong in my models file, but when I >>> add a >>> record in admin, all records are titled [name of model] object. This >>> is a problem especially in related tables since there's no way to >>> tell >>> them apart. >> >>> What do I need to add and where? >> >>> Thanks >> >>> -James > > --~--~-~--~~~---~--~~ 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 Options for Admin Site
Hi James define a __str__ or better __unicode__ method within your model which returns the correct string. i.e. def __unicode__(self): return self.name //Thomas Am 21.04.2008 um 23:55 schrieb jwwest: > > Hey all, > > I'm not sure what I'm doing wrong in my models file, but when I add a > record in admin, all records are titled [name of model] object. This > is a problem especially in related tables since there's no way to tell > them apart. > > What do I need to add and where? > > Thanks > > -James > > --~--~-~--~~~---~--~~ 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: Django Installation Questions on Ubuntu
> Hi khayman, Replace: SetEnv DJANGO_SETTINGS_MODULE settings.py With: SetEnv DJANGO_SETTINGS_MODULE projectname.settings //Thomas Am 21.04.2008 um 23:06 schrieb khayman: > > I have installed Apache, modpython and Django via apt-get. Apache and > modpython are working (I can serve normal files and python script > output). However, I am unable to serve the initial Django project. > > Here is the httpd.conf: > > Code: > > >SetHandler python-program >PythonHandler django.core.handlers.modpython >SetEnv DJANGO_SETTINGS_MODULE settings.py >PythonDebug On >PythonPath "['/var/www/secure_html' , '/home/khayman218/ > python'] + sys.path" > > > The code for the project is in /home/khayman218/python/organik: > > Code: > > [EMAIL PROTECTED]:/var/www/secure_html/organik$ ls /home/khayman218/ > python/organik/ -l > total 20 > -rw-r--r-- 1 khayman218 khayman2180 Apr 21 13:17 __init__.py > -rw-r--r-- 1 khayman218 khayman218 141 Apr 21 13:18 __init__.pyc > -rwxr-xr-x 1 khayman218 khayman218 542 Apr 21 13:17 manage.py > -rw-r--r-- 1 khayman218 khayman218 2842 Apr 21 13:29 settings.py > -rw-r--r-- 1 khayman218 khayman218 1807 Apr 21 13:29 settings.pyc > -rw-r--r-- 1 khayman218 khayman218 227 Apr 21 13:17 urls.py > > When I attempt to access the /organik url, I get the following error: > HTML Code: > > MOD_PYTHON ERROR > > ProcessId: 9380 > Interpreter:'127.0.0.1' > > ServerName: '127.0.0.1' > DocumentRoot: '/var/www/secure_html' > > URI:'/organik/' > Location: '/organik/' > Directory: None > Filename: '/var/www/secure_html/organik/' > PathInfo: '' > > Phase: 'PythonHandler' > Handler:'django.core.handlers.modpython' > > Traceback (most recent call last): > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line > 1537, in HandlerDispatch >default=default_handler, arg=req, silent=hlist.silent) > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line > 1229, in _process_target >result = _execute_target(config, req, object, arg) > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line > 1128, in _execute_target >result = object(arg) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 177, in handler >return ModPythonHandler()(req) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 145, in __call__ >self.load_middleware() > > File "/var/lib/python-support/python2.5/django/core/handlers/ > base.py", line 22, in load_middleware >for middleware_path in settings.MIDDLEWARE_CLASSES: > > File "/var/lib/python-support/python2.5/django/conf/__init__.py", > line 28, in __getattr__ >self._import_settings() > > File "/var/lib/python-support/python2.5/django/conf/__init__.py", > line 55, in _import_settings >self._target = Settings(settings_module) > > File "/var/lib/python-support/python2.5/django/conf/__init__.py", > line 83, in __init__ >raise EnvironmentError, "Could not import settings '%s' (Is it on > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, > e) > > EnvironmentError: Could not import settings 'settings.py' (Is it on > sys.path? Does it have syntax errors?): No module named settings.py > > From what I have been able to find on the intarweb, it looks like > settings.py simply isn't being found. I have put every variation of > diretories in the PythonPath (in httpd.conf) and it still cannot find > it. > > I have tried copying the entire starter project into a subdir under > the www root (and changing the httpd.conf accordingly). I have also > tried chmod 777 on every file. Apache (or modpython) doesn't seem to > be able to find the settings file. > > Any ideas on what I am missing? > > 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: Serving binary files "through" django
Hi Eric Am 06.04.2008 um 06:49 schrieb Eric Abrahamsen: > > Guess I'll have to serve the files from django's apache, not my other > media server, but it seems like this will do it. That depends on your setup. You can also use a X-Sendfile or X-Accel-Redirect capable Server as your frontend-Proxy. So your request goes this way: 1. Frontend-Proxy and static file server (i.e. Nginx od lighttpd) if URL matches local file or rule: serve it else: request file from Backend-Server (i.e. Apache) 2. Backend Server handle urls as in urls.py or your resolving strategy and serve dynamic Data accordingly. In this way your Hostname is always the same. All Static files can be served from your frontend-proxy with X-Accel-Redirect even private data. You also can serve cached dynamic content directly from your proxy without hitting the apache. In larger setups the frontend-proxy also can handle the load-balancing stuff. //Thomas --~--~-~--~~~---~--~~ 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: Serving binary files "through" django
Hello Tim Am 05.04.2008 um 21:19 schrieb Tim Sawyer: > > I'd like to have a site that gives away and sells PDFs, and tracks > downloads > of those PDFs. I hope I got your question right. I have a little bit different aproach since django never serves the file directly. If you are using nginx as a frontend-proxy and static file serving just configure a protected-download-dir: location /protected-downloads/ { alias /var/protected/; internal; } The "internal" is to disallow regular gets so your file is not downloadable without the "OK" from your view. Now you can send a X-Accel-Redirect Header from your view to let the nginx send a file: @login_required def download(request, file=None): response = HttpResponse() response['Content-Type'] = 'application/octet-stream' response['X-Accel-Redirect'] = '/protected-downloads/' + file return response Of course you can do additional processing in download as storing the IP and download count to your database. This soulution has the advantage that your files can be served very quickly from your proxy instead of a relatively slow mod_python-apache. If you are using Apache or lighttpd as a frontend-proxy you can use a similar aproach with: X-Sendfile. Or you use Amazon s3 etc... Greets, Thomas Kerpe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---