Re: Multi select field with images
little more explanation is required On Wed, Jul 8, 2009 at 10:31 AM, djangou...@gmail.com wrote: > I have a modelform and I want to make one of my select multiple fields > choices be images and not text. > > ideas/suggestions appreciated > > -- Sent from my Palm Pre > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multi select field with images
I have a modelform and I want to make one of my select multiple fields choices be images and not text. ideas/suggestions appreciated -- Sent from my Palm Pre --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
Shit! Great thanks, Tracey! You are absolutely right! I've made a stupid mistake even for a beginner! I redifined send_mail in my app :(( 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Model inheritance and order_with_respect_to
Hello, I have so far not found any discussion of a particular problem I encountered. I'm not sure that isn't just me doing something incorrectly so would appreciate knowing if anyone else has seen this. I have a pair of models where one inherits from the other (Multi-table inheritance). The parent model in that relationship has a ForeignKey relation to a third model with an order_with_respect_to meta option set to that ForeignKey. Although I seem to be able to work with these models in the shell (create, save, list). If I use the dumpdata management command I get the following error. $ ./manage.py dumpdata myapp Traceback (most recent call last): File "./manage.py", line 12, in execute_manager(settings) File "/home/bdp/Checkouts/django-trunk/django/core/management/ __init__.py", line 362, in execute_manager utility.execute() File "/home/bdp/Checkouts/django-trunk/django/core/management/ __init__.py", line 303, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/bdp/Checkouts/django-trunk/django/core/management/ base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/home/bdp/Checkouts/django-trunk/django/core/management/ base.py", line 222, in execute output = self.handle(*args, **options) File "/home/bdp/Checkouts/django-trunk/django/core/management/ commands/dumpdata.py", line 76, in handle objects.extend(model._default_manager.all()) File "/home/bdp/Checkouts/django-trunk/django/db/models/query.py", line 83, in __len__ self._result_cache.extend(list(self._iter)) File "/home/bdp/Checkouts/django-trunk/django/db/models/query.py", line 238, in iterator for row in self.query.results_iter(): File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/ query.py", line 287, in results_iter for rows in self.execute_sql(MULTI): File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/ query.py", line 2360, in execute_sql sql, params = self.as_sql() File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/ query.py", line 397, in as_sql ordering, ordering_group_by = self.get_ordering() File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/ query.py", line 962, in get_ordering self.model._meta, default_order=asc): File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/ query.py", line 991, in find_ordering_name opts, alias, False) File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/ query.py", line 1737, in setup_joins "Choices are: %s" % (name, ", ".join(names))) django.core.exceptions.FieldError: Cannot resolve keyword '_order' into field. Choices are: category, id, item_ptr, name, notes If I comment out the order_with_respect_to meta option the message goes away. I first encountered this error running the release version if Django (as installed by easy_install) but I tried it with django- trunk and got the same thing. I simplified my models down to some basics which still cause the problem. class Category(models.Model): name = models.CharField(max_length=30, unique=True) class Meta: ordering = ['name'] class Item(models.Model): name = models.CharField(max_length=30, unique=True) category = models.ForeignKey(Category) class Meta: order_with_respect_to = 'category' class OtherItem(Item): notes = models.TextField(blank=True) Am I trying to do something that should not work? Or am I doing it the wrong way? Sincerely, Bradley Peters --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with admin after moving to another machine
Hi there, I started to have this error: http://dpaste.com/64355/ while trying to access my admin site, after I moved my website from one machine (my desktop) to the other (my laptop). I already restored my PostgreSQL database, and recreated the superuser (while trying to solve this problem), but I still cannot access the admin page... can it be something with the recent actions log? If so, how do I purge it? I don't need this log... Thanks! Diogo --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "django-notification" app installation
On Jul 7, 5:24 am, Karen Tracey wrote: > On Tue, Jul 7, 2009 at 12:32 AM, Anthony wrote: ... > > Grepping the Django source tree for "Skipping" doesn't show any hits that > look like they could result in that message, so it's coming from code > outside Django. Looking at the doc for the app you are attempting to use: > > http://github.com/jtauber/django-notification/blob/e04fdc9420306826b1... > > that message appears as part of a suggested way of creating Notice Types, > and from looking at the code the reason you would get the message is that > you have not included the app in your INSTALLED_APPS in settings.py. > Hi, Well, duh on me. I have no excuse, I just forgot to add it in there. Thanks for going over your process and taking the time to check. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
foreign key validation
Can anyone shed some light on how django validates foreign keys for me?? I have a model that I'm writing a whole lot of records in a single request. With the Foreign Key defined in the model it takes ages!!! Have about 100 records and it takes minutes. When I change the field to CharField, it completes in a matter of seconds. The database constraint is still active, and executing a query against the database to check if the key exists completes in under 10 milliseconds. I'm curious if anyone might know why the foreign key validation is taking so long to complete?!?! I'm thinking a cache tuning issue perhaps?? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: web程序员
电子邮箱��...@shining-tech.com h...@shining3d.com 公司网站:http://www.shining3d.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
[招聘]web程序员
岗位要求: 1、肯干肯学 2、熟悉web编程基本知识,有编程基础 3、深刻掌握面向对象编程,有django开发经验 4、熟用mysql或postgresql数据库、linux、js、html、局域网管理 岗位职责: 1、网站、内部管理系统开发、维护 2、现有系统、局域网维护 3、其它安排的工作 杭州先临三维科技股份有限公司是一批来自计算机视觉数字图形、机械等专业领域的国内外著名科研机构和高校的专家、学者及专业人员组建的新型科技企业。依 托国内外数家著名科研机构的雄厚的科研实力与丰富的研究资源,专注于三维成像技术的研究、开发、应用,成为世界上少数几家能自主研发高分辨率、高性能和 低价格的三维相机的公司之一,也能为广大客户提供高精度、高效率的三维成像方案。 公司采用多目视差法和光影梯度法(自主知识产权)研制出的三维成像系统具有成像速度快、精度高的突出优点,可一次性获得180度的立体模型。通过进一步 的软件开发,该三维系统可广泛应用于个性化礼品、整形、工业建模、数字娱乐等诸多领域。 根据三维成像系统的特性,及目前个性化水晶内雕礼品的市场需求状况,我公司推出三维人像水晶制作系统,包括三维扫描仪、三维图像处理软件3D- Vision和激光内雕机,结合公司专业设计师开发的水晶造型,专用于为顾客制作彰显个性的水晶内雕纪念品,是作为婚庆留影、毕业留念,生日祝福,颁奖 礼品,商务赠品的良好选择,可以令难以忘怀的经典时刻伴随水晶的纯洁成为永恒。 秉承进取、诚信、创新的精神,我们立志在三维成像领域不断发展,不断与相关领域的企业、团体、专家、个人进行合作,实现优势互补,力争成为世界范围内最 具创造力的三维成像科技公司。 地址:杭州市萧山区建设一路66号国际创业中心18楼 邮政编码:311210 传真:(0571)82999539 联 系 人:王小姐 电话:(0571)82999581 电子邮箱��...@shining3d.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: get_or_create() returns "no such savepoint" error
On Jul 7, 3:07 pm, Karen Tracey wrote: > > > > On Jun 29, 10:53 am, Steve Howell wrote: > > > Hi, I have created a management command that populates some tables in > > > a Postgres database, and I use the handy get_or_create() method in db/ > > > models/query.py. I tried running a command recently where I had > > > inadvertently left some foreign key references dangling around, > > Could you be a little more specific about what the error was in your code? Sorry I never reported the error, but, of course, part of my problem was that the error was caught by the try/except in Django code. I did the following sequence, conceptually: 1) I had a database with books and authors. 2) I received a new feed of books. 3) I cleaned the books table without cleaning the authors table. 4) When I tried to import the first book, there was still a stale author. 5) Instead of getting the normal integrity error, I got the red herring savepoint error. 6) When I went back and cleaned BOTH tables, everything worked fine. > From looking at the full get_or_create routine you include below it isn't > immediately obvious to me where it might be raising an IntegrityError before > the savepoint is created, yet it sounds like that is what is happening. We > need to understand how that is happening before figuring out what the right > fix is. > If memory serves correctly, it was this line that raised the original error: obj.save(force_insert=True) Here's the code in more context: try: params = dict([(k, v) for k, v in kwargs.items() if '__' not in k]) params.update(defaults) obj = self.model(**params) sid = transaction.savepoint() obj.save(force_insert=True) transaction.savepoint_commit(sid) return obj, True except IntegrityError, e: transaction.savepoint_rollback(sid) try: return self.get(**kwargs), False except self.model.DoesNotExist: raise e --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to handle HEAD method
On Jul 7, 10:52 pm, Andrew Fong wrote: > The exception is very definitely being raised by me trying to > distinguish things based on REQUEST_METHOD type. Here's the traceback: > > Traceback (most recent call last): > > File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", > line 92, in get_response > response = callback(request, *callback_args, **callback_kwargs) > > File "/home/andrew/djprj/helpers/request_handler.py", line 77, in > __call__ > raise NoMethodError(request.method) > > NoMethodError: The HEAD method is not allowed for this path > > > > The relevant code in helpers/request_handler.py is this: > > class RestHandler(object): > def __call__(self, request, *args, **kwargs): > method = request.method.upper() > if hasattr(self, method): > return getattr(self, method)(request, *args, **kwargs) > raise NoMethodError(request.method) > > class NoMethodError(Exception): > def __init__(self, method): > super(Exception, self).__init__( > "The %s method is not allowed for this path" % method) > > --- > > Graham, are you suggesting that if I receive a HEAD request, I should > behave exactly the same as if I received a GET request? That is, I > should assume Apache / mod_wsgi will take care of translating my > response into one appropriate for a HEAD request? Yes, but it is Apache that does what is needed, not mod_wsgi. Graham > -- Andrew > > On Jul 6, 7:28 pm, Graham Dumpleton > wrote: > > > > > On Jul 7, 2:14 am, Andrew Fong wrote: > > > > Thanks for the response. I'm using Apache/mod_wsgi and getting error > > > messages in production because my handlers don't know how to handle a > > > HEAD request. If the server is supposed to automatically translate the > > > HEAD requests into GETs, then I probably have something set up > > > incorrectly. Any idea where to start looking? > > > As I described, it doesn't always translate HEAD to GET and that > > shouldn't matter. Neither should it really matter in the Django layers > > either. If you in your code are trying to distinguish things based on > > REQUEST_METHOD type, then it is more likely to be in your code. > > > I would suggest you post the Python traceback so others can say > > whether it is an issue in Django layers to eliminate that, and then > > perhaps point at where problem may lie. Ie., in your code or > > elsewhere. > > > Graham > > > > -- Andrew > > > > On Jul 2, 7:16 pm, Graham Dumpleton > > > wrote: > > > > > On Jul 3, 4:55 am, Andrew Fong wrote: > > > > > > How exactly should I handle a HEAD request in Django? > > > > > > So ... assuming my view looks like this... > > > > > > def handle_request(request): > > > > > if request.method == 'POST': return do_post(request) > > > > > elif request.method == 'GET': return do_get(request) > > > > > elif request.method == 'HEAD': return do_head(request) > > > > > > ... what should the do_head method return? The W3 standard says "The > > > > > HEAD method is identical to GET except that the server MUST NOT return > > > > > a message-body in the response". > > > > > > How exactly do I not return a message body though? Do I just return > > > > > None? Do I return the response I would for a GET and then modify it > > > > > somehow? > > > > > You generally don't need to do anything different, the standard says > > > > 'the ***server***'. > > > > > So, for sane web servers, the underlying server will deal with this > > > > and the application doesn't need to. You should just do exactly what > > > > you would normally do for a GET request. The web server would then > > > > return all the headers but just throw the response content away and > > > > not return it to the client. > > > > > If you do act differently, you potentially break the requirement that > > > > response headers for the HEAD should match what would be returned for > > > > a GET request against same resource. Thus, the suggestion of returning > > > > an empty string could stuff up returned content length for a start. > > > > > FWIW, in Apache/mod_wsgi it will deliberately at times translate a > > > > HEAD into a GET when it is passed into the WSGI application. This will > > > > occur when there are Apache output filters registered that may want to > > > > change response headers and modify the content. For example, > > > > mod_deflate, which would compress the response. If this isn't done and > > > > the application acted differently for a HEAD, then the data received > > > > by Apache output filter would not be the same as for the GET and > > > > result returned to client would be different than what it should be. > > > > > Graham --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.c
Re: Apache with Django
Never mind... I figured it out. Because the location is at "/", I would not need the "PythonOption django.root / " part. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: get_or_create() returns "no such savepoint" error
On Tue, Jul 7, 2009 at 1:39 PM, Steve Howell wrote: > > Hi everybody, I posted the following about a week ago and did not get > a response. > > I'm hoping it was simply lost in the shuffle the first time, so maybe > it will get an answer now. > Yeah, a lot of people (including me) seem to be pretty busy these days and not having a whole lot of spare time for answering questions. > > If my questions didn't get a response due to some missing information > in my original post, maybe I can provide it now. > Please see below. > > On Jun 29, 10:53 am, Steve Howell wrote: > > Hi, I have created a management command that populates some tables in > > a Postgres database, and I use the handy get_or_create() method in db/ > > models/query.py. I tried running a command recently where I had > > inadvertently left some foreign key references dangling around, > Could you be a little more specific about what the error was in your code? >From looking at the full get_or_create routine you include below it isn't immediately obvious to me where it might be raising an IntegrityError before the savepoint is created, yet it sounds like that is what is happening. We need to understand how that is happening before figuring out what the right fix is. Karen > but > > instead of a useful error, I instead got the obscure error "no such > > savepoint." The code catches the original exception that would have > > helped me realize my own error, and instead raises a new exception > > about "no such savepoint." > > > > Here is the code with get_or_create() that obscures the error: > > > > except IntegrityError, e: > > transaction.savepoint_rollback(sid) > > > > In order to see actual errors, I think I need to something with > > management commands that allows the savepoint to be rolled back. Has > > anybody encountered this before? I've skimmed some long threads > > pertaining to Django/psycopg/Postgres interactions with respect to > > setting up transaction management, but I have to admit that most of > > the discussion has been over my head. > > > > Thanks, > > > > Steve > > > > P.S. Here is the entire method for get_or_create(), for more context: > > > > def get_or_create(self, **kwargs): > > """ > > Looks up an object with the given kwargs, creating one if > > necessary. > > Returns a tuple of (object, created), where created is a > > boolean > > specifying whether an object was created. > > """ > > assert kwargs, \ > > 'get_or_create() must be passed at least one keyword > > argument' > > defaults = kwargs.pop('defaults', {}) > > try: > > return self.get(**kwargs), False > > except self.model.DoesNotExist: > > try: > > params = dict([(k, v) for k, v in kwargs.items() if > > '__' not in k]) > > params.update(defaults) > > obj = self.model(**params) > > sid = transaction.savepoint() > > obj.save(force_insert=True) > > transaction.savepoint_commit(sid) > > return obj, True > > except IntegrityError, e: > > transaction.savepoint_rollback(sid) > > try: > > return self.get(**kwargs), False > > except self.model.DoesNotExist: > > raise e > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Include app urls from url root path
On Wed, Jul 8, 2009 at 12:12 AM, Daniel Roseman wrote: > > On Jul 7, 3:10 pm, Joshua Partogi wrote: > > Dear all, > > > > Because I want to plug a django app from urls.py as it is (without adding > > any suffix), is it possible to include the app urls with this scenario? > > > > # urls.py > > urlpatterns = patterns('', > > (r'^$', include('djapp.urls')), > > ) > > > > Leave off the $ - this will *only* match an empty URL. Aaah. Didn't think of that. Thanks heaps Daniel. -- Join Scrum8.com. http://blog.scrum8.com http://twitter.com/scrum8 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Server performance
On Jul 8, 4:16 am, Ramdas S wrote: > Hi, > > We have a web server where we are hosting around 12-15 django web sites most > of them attracting modest traffic, except a couple which sees spiikes on and > off. Together we estimate just about 20,000-40,000 page views. > > However we are expecting major spikes in traffic in the coming days and are > moving to a 8 GB RAM quad core server. > > We are also trying to optimize the django apps. > > Presently we have memcached mod-python instances running. The database > server is also running on the same server. > > What all should we do to ensure that such a server can handle huge volumes > of traffic? Don't use mod_python for a start. See: http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html Same issue can occur with mod_wsgi embedded mode, so use of mod_wsgi daemon mode is best to avoid the problem. > We are presently optimizing every site with whatever we can according to > what Yahoo! recommends for improving site performance. But that's only at > the client side. > > I am told that mod wsgi is more efficient than mod-python. How efficient? Do > your recommend moving all sites to modwsgi? Use of daemon mode certainly gives more predictable performance and memory usage. Although memory usage and performance with mod_wsgi is a bit better, in the context of a large fat Python web application using a database, you wouldn't normally see any significant difference to other similarly configured WSGI hosting mechanisms. This is because all the overhead and bottlenecks are going to be in your application and the database, not the server level. > What about nginx? Is it worth exploring Nginx as alternative to Apache? Using nginx as a front end proxy in front of Apache/mod_wsgi in order to handle static media, deal with slow clients and avoid keep alive resource issues in Apache is certainly a good idea. Using fastcgi with nginx is reasonable but may just make management harder as likely need a separate supervisor system to keep all the Django fastcgi processes running, something which Apache/mod_wsgi gives you for free. The mod_wsgi module for nginx should possibly be avoided as it has potential issues with blocking because of standard WSGI not being suited for hosting on top of an event driven system. See: http://blog.dscpl.com.au/2009/05/blocking-requests-and-nginx-version-of.html > Is there anything else we need to look at? Caching, caching and caching. Even if you are doing a measure of caching, look at what other caching you can do. This also need not be caching within the application, but could be front end caching proxies. As an example, for a lot of sites the bulk of traffic will be to the front page of the site. If rather than going to the database for all requests for that page you use cached data, you will speed up serving up that heavily trafficked page. Better still, avoid requests even going to the application for that page in the majority of cases by having a caching proxy cache it with an expiry time of a few minutes. Doing just this can in some cases dramatically reduce traffic actually hitting your application. Finally, if using mod_wsgi daemon mode, ensure you delegate different Django instances to different process groups. This way you can control the number of processes for each instance and for less trafficked sites give minimum number of processes/threads. For more heavily trafficked sites give more processes. This way you don't incur as much memory usage for the smaller trafficked sites. Graham > Thanks for the advices... > > Also what is the realistic number of page views/ simultaneous connections > that a Nehalem quad core Intel i-7 920, 8 GB RAM machine can handle? Any > statistical experiences. > > Thanks > > -- > Ramdas S --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
docstrings not rendering in ReST in admindocs
I've got some fairly basic docstrings in my models, and I just discovered the admindocs module, which does all sorts of useful introspection stuff. I had to install docutils before it would show, but I did that, and now I've got documentation. The problem is that my docstrings don't seem to be run through the ReST parser at all, and I can't find any documentation on admindocs at all. The closest I can find is James Bennett's article here: http://www.b-list.org/weblog/2007/nov/12/admin-documentation/ , and that doesn't give me any indication that I'm doing anything wrong. The docstrings render as expected in the online ReST renderer. Django 1.0.2. Any hints appreciated. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: edit form not working with imagefield
On Jul 7, 1:22 pm, Adam Jenkins wrote: > I know that Dojo allows one to upload files with Ajax. It uses an iframe as > a work around. >From what I remember from when I was doing something like this a good year ago, using an iframe is the accepted way of uploading files with ajax. You'll find tutorials, articles and blogposts all over the net about doing so with your favorite javascript library. In particular, take a look here: http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: edit form not working with imagefield
On Tue, Jul 7, 2009 at 3:19 PM, geraldcor wrote: > > Oh. That's a problem. Ok. Thanks. Am I going to have to scrap the ajax > idea if I want to edit the image? Any other workarounds? I know that Dojo allows one to upload files with Ajax. It uses an iframe as a work around. Maybe you can take something from that? http://ajaxian.com/archives/dojo-uploading-files-and-contents-with-ajax > > > Thanks for the reply. > > On Jul 7, 11:20 am, Alex Gaynor wrote: > > On Tue, Jul 7, 2009 at 12:16 PM, geraldcor wrote: > > > > > I have a form that is being added via jquery ajax. I can add a new > > > record, including images just fine. Works like a dream. However, when > > > I go to edit the form, every field will update except for the image > > > field. I choose a new image from the browse button, the filepath loads > > > up and when I submit the form, the image field does not change - the > > > table field filepath does not change. Any ideas on this one? > > > > > As as aside, in case anyone wants to tackle this one, I can't use the > > > success: portion of the jQuery.ajax() function. It just skips that > > > step. Could this be related to the imagefield not updating? > > > > > My view: > > > def edit_blog(request, blg_id): > > >a = Companyblog.objects.get(pk=blg_id) > > >if request.method == 'POST': > > >form=CompanyblogForm(request.POST, request.FILES, > > > instance=a) > > >if form.is_valid(): > > >form_data=form.save() > > >return HttpResponse("Success") > > >else: > > >form = CompanyblogForm(instance=a) > > >return render_to_response('blogedit.html', {'form': > form, > > > 'blg_id': > > > blg_id}) > > > > > I will add more code as needed. Thanks for any and all help. > > > > Ajax requests don't send file data. > > > > Alex > > > > -- > > "I disapprove of what you say, but I will defend to the death your right > to > > say it." --Voltaire > > "The people's good is the highest law."--Cicero > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: edit form not working with imagefield
Oh. That's a problem. Ok. Thanks. Am I going to have to scrap the ajax idea if I want to edit the image? Any other workarounds? Thanks for the reply. On Jul 7, 11:20 am, Alex Gaynor wrote: > On Tue, Jul 7, 2009 at 12:16 PM, geraldcor wrote: > > > I have a form that is being added via jquery ajax. I can add a new > > record, including images just fine. Works like a dream. However, when > > I go to edit the form, every field will update except for the image > > field. I choose a new image from the browse button, the filepath loads > > up and when I submit the form, the image field does not change - the > > table field filepath does not change. Any ideas on this one? > > > As as aside, in case anyone wants to tackle this one, I can't use the > > success: portion of the jQuery.ajax() function. It just skips that > > step. Could this be related to the imagefield not updating? > > > My view: > > def edit_blog(request, blg_id): > > a = Companyblog.objects.get(pk=blg_id) > > if request.method == 'POST': > > form=CompanyblogForm(request.POST, request.FILES, > > instance=a) > > if form.is_valid(): > > form_data=form.save() > > return HttpResponse("Success") > > else: > > form = CompanyblogForm(instance=a) > > return render_to_response('blogedit.html', {'form': form, > > 'blg_id': > > blg_id}) > > > I will add more code as needed. Thanks for any and all help. > > Ajax requests don't send file data. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Apache with Django
I think I found my problem. I thought that the httpd.exe is the application running in the Vista's control panel, but it was just the "ApacheMonitor.exe" not "httpd.exe". However, while my project worked in development, it is giving me TypeError. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Complex select
Tim Chase wrote: > but Django lets you drop to raw SQL pretty easily, > so it shouldn't be a big deal. Thanks. I think I will stop on raw SQL. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ANN: django-remember_me v0.1
Hello all, I have released django-remember_me v0.1 < http://code.google.com/p/django-remember-me/ >. django-remember_me is a Django application that provides a login form with a Remember Me checkbox. Use this in place of django.contrib.auth.views.login. This is a simple application but I hope you will find it of use and will save a few cycles of coding in your websites where you need Remember Me functionality. Toodle-l... creecode --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Server performance
On Tue, Jul 7, 2009 at 1:16 PM, Ramdas S wrote: > Hi, > > We have a web server where we are hosting around 12-15 django web sites > most of them attracting modest traffic, except a couple which sees spiikes > on and off. Together we estimate just about 20,000-40,000 page views. > > However we are expecting major spikes in traffic in the coming days and are > moving to a 8 GB RAM quad core server. > > We are also trying to optimize the django apps. > > Presently we have memcached mod-python instances running. The database > server is also running on the same server. > > What all should we do to ensure that such a server can handle huge volumes > of traffic? > > We are presently optimizing every site with whatever we can according to > what Yahoo! recommends for improving site performance. But that's only at > the client side. > > I am told that mod wsgi is more efficient than mod-python. How efficient? > Do your recommend moving all sites to modwsgi? > > What about nginx? Is it worth exploring Nginx as alternative to Apache? > > Is there anything else we need to look at? > > Thanks for the advices... > > Also what is the realistic number of page views/ simultaneous connections > that a Nehalem quad core Intel i-7 920, 8 GB RAM machine can handle? Any > statistical experiences. > > Thanks > > -- > Ramdas S > > > > > > Though scaling is not the exact same as performance: http://immike.net/files/scaling_django.pdf is a great resource and has lots of performance tips. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Server performance
On Tue, Jul 7, 2009 at 1:16 PM, Ramdas S wrote: > Hi, > > We have a web server where we are hosting around 12-15 django web sites > most of them attracting modest traffic, except a couple which sees spiikes > on and off. Together we estimate just about 20,000-40,000 page views. > > However we are expecting major spikes in traffic in the coming days and are > moving to a 8 GB RAM quad core server. > > We are also trying to optimize the django apps. > > Presently we have memcached mod-python instances running. The database > server is also running on the same server. > > What all should we do to ensure that such a server can handle huge volumes > of traffic? IIRC the Real World Django talk at pycon went over optimization. http://pycon.blip.tv/file/2083844/ also, some basic info with http://books.google.com/books?id=M9kXnUf841wC&lpg=PA471&ots=Jy8FjA5ZZy&dq=optimizing%20django&pg=PA471 > > > We are presently optimizing every site with whatever we can according to > what Yahoo! recommends for improving site performance. But that's only at > the client side. > > I am told that mod wsgi is more efficient than mod-python. How efficient? > Do your recommend moving all sites to modwsgi? > > What about nginx? Is it worth exploring Nginx as alternative to Apache? > > Is there anything else we need to look at? > > Thanks for the advices... > > Also what is the realistic number of page views/ simultaneous connections > that a Nehalem quad core Intel i-7 920, 8 GB RAM machine can handle? Any > statistical experiences. > > Thanks > > -- > Ramdas S > > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic App Creation
I ran across this django app and it seems to be what you want... I don't have any experience with it except to try the demo which seems to work as "advertised". http://projects.nickblundell.org.uk/wikidbase Thanks, Richard Shebora Information in this transmission is privileged and confidential. It is intended for the use of the individual or entity named above. Any review, dissemination, disclosure, alteration, printing, circulation or transmission of this email or it's attachments is prohibited and unlawful. On Tue, Jul 7, 2009 at 9:36 AM, Andrew Fong wrote: > > Generally speaking, dynamically altering the DB schema is difficult > and dangerous. SQL databases are not spreadsheets -- that is, you > shouldn't be frequently adding or removing columns to them. It makes > optimization difficult and it's very likely you'll accidentally lose > data in the process. AFAIK, the only way to get this working in Django > is to manually write your own SQL. > > Google App Engine might work better this for though. You can run a > tweaked version of Django on GAE I believe, and its non-SQL datastore > is more friendly to spreadsheet-like applications. Amazon's SimpleDB > might work too. > > -- Andrew > > On Jul 7, 8:37 am, Darren Mansell wrote: > > Hello. I'm looking into making a Django app that allows you to create > Django > > models. > > > > The idea is that you should be able to add fields and user workflows > using a > > web page that then creates a model, view, template and syncs the DB. > Users > > can then access these newly created apps separately. > > > > An example: > > > > An accounts department of a company wants to replace their Excel files > that > > they currently use for expenses, claims etc. with a web-based system. The > > web based system will have a page where you can create fields such as a > > field for name, field for dept, field for expense, tax etc. The page then > > creates a Django app with a model, view and template from this for > employees > > to fill in to submit expenses. > > The employees DB will have info about who is who's manager and will then > > allow the page creator to include workflows - e.g. employees enters > details > > and submits, their manager gets a mail to request authorisation, they > > authorise and their director then has to authorise etc. > > > > I think if something like this were to exist it would allow lots of > > businesses to replace static documents for workflow with web based > systems. > > > > Does anyone know of anything out there that already does this kind of > thing? > > > > Darren > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django Server performance
Hi, We have a web server where we are hosting around 12-15 django web sites most of them attracting modest traffic, except a couple which sees spiikes on and off. Together we estimate just about 20,000-40,000 page views. However we are expecting major spikes in traffic in the coming days and are moving to a 8 GB RAM quad core server. We are also trying to optimize the django apps. Presently we have memcached mod-python instances running. The database server is also running on the same server. What all should we do to ensure that such a server can handle huge volumes of traffic? We are presently optimizing every site with whatever we can according to what Yahoo! recommends for improving site performance. But that's only at the client side. I am told that mod wsgi is more efficient than mod-python. How efficient? Do your recommend moving all sites to modwsgi? What about nginx? Is it worth exploring Nginx as alternative to Apache? Is there anything else we need to look at? Thanks for the advices... Also what is the realistic number of page views/ simultaneous connections that a Nehalem quad core Intel i-7 920, 8 GB RAM machine can handle? Any statistical experiences. Thanks -- Ramdas S --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: get_or_create() returns "no such savepoint" error
Hi everybody, I posted the following about a week ago and did not get a response. I'm hoping it was simply lost in the shuffle the first time, so maybe it will get an answer now. If my questions didn't get a response due to some missing information in my original post, maybe I can provide it now. On Jun 29, 10:53 am, Steve Howell wrote: > Hi, I have created a management command that populates some tables in > a Postgres database, and I use the handy get_or_create() method in db/ > models/query.py. I tried running a command recently where I had > inadvertently left some foreign key references dangling around, but > instead of a useful error, I instead got the obscure error "no such > savepoint." The code catches the original exception that would have > helped me realize my own error, and instead raises a new exception > about "no such savepoint." > > Here is the code with get_or_create() that obscures the error: > > except IntegrityError, e: > transaction.savepoint_rollback(sid) > > In order to see actual errors, I think I need to something with > management commands that allows the savepoint to be rolled back. Has > anybody encountered this before? I've skimmed some long threads > pertaining to Django/psycopg/Postgres interactions with respect to > setting up transaction management, but I have to admit that most of > the discussion has been over my head. > > Thanks, > > Steve > > P.S. Here is the entire method for get_or_create(), for more context: > > def get_or_create(self, **kwargs): > """ > Looks up an object with the given kwargs, creating one if > necessary. > Returns a tuple of (object, created), where created is a > boolean > specifying whether an object was created. > """ > assert kwargs, \ > 'get_or_create() must be passed at least one keyword > argument' > defaults = kwargs.pop('defaults', {}) > try: > return self.get(**kwargs), False > except self.model.DoesNotExist: > try: > params = dict([(k, v) for k, v in kwargs.items() if > '__' not in k]) > params.update(defaults) > obj = self.model(**params) > sid = transaction.savepoint() > obj.save(force_insert=True) > transaction.savepoint_commit(sid) > return obj, True > except IntegrityError, e: > transaction.savepoint_rollback(sid) > try: > return self.get(**kwargs), False > except self.model.DoesNotExist: > raise e --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: edit form not working with imagefield
On Tue, Jul 7, 2009 at 12:16 PM, geraldcor wrote: > > I have a form that is being added via jquery ajax. I can add a new > record, including images just fine. Works like a dream. However, when > I go to edit the form, every field will update except for the image > field. I choose a new image from the browse button, the filepath loads > up and when I submit the form, the image field does not change - the > table field filepath does not change. Any ideas on this one? > > As as aside, in case anyone wants to tackle this one, I can't use the > success: portion of the jQuery.ajax() function. It just skips that > step. Could this be related to the imagefield not updating? > > My view: > def edit_blog(request, blg_id): >a = Companyblog.objects.get(pk=blg_id) >if request.method == 'POST': >form=CompanyblogForm(request.POST, request.FILES, > instance=a) >if form.is_valid(): >form_data=form.save() >return HttpResponse("Success") >else: >form = CompanyblogForm(instance=a) >return render_to_response('blogedit.html', {'form': form, > 'blg_id': > blg_id}) > > I will add more code as needed. Thanks for any and all help. > > > Ajax requests don't send file data. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Complex select
> Something like this: > Query = Comments.objects.all().sort_by("submit_date")[:5] Without having the models, it's a little difficult to judge what the OP is after. However, the difference is that your version gets you the top 5 *comments*. The OP appears to want the top 5 unique "object_pk" fields associated with those comments. If that object_pk were a unique/primary key on django_comments, your query would work. However, since it doesn't appear to have a uniqueness-constraint (from my look at the source-code), it looks like if the top 5 comments were all on the same object, you'd get different results -- your query would pull back those top 5 comments (and the .values().distinct() would bring back the one object) whereas the OPs code would find the top 5 commented-on things. I can't think there's a way to coerce the ORM to produce the OP's desired query, but Django lets you drop to raw SQL pretty easily, so it shouldn't be a big deal. -tkc --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
edit form not working with imagefield
I have a form that is being added via jquery ajax. I can add a new record, including images just fine. Works like a dream. However, when I go to edit the form, every field will update except for the image field. I choose a new image from the browse button, the filepath loads up and when I submit the form, the image field does not change - the table field filepath does not change. Any ideas on this one? As as aside, in case anyone wants to tackle this one, I can't use the success: portion of the jQuery.ajax() function. It just skips that step. Could this be related to the imagefield not updating? My view: def edit_blog(request, blg_id): a = Companyblog.objects.get(pk=blg_id) if request.method == 'POST': form=CompanyblogForm(request.POST, request.FILES, instance=a) if form.is_valid(): form_data=form.save() return HttpResponse("Success") else: form = CompanyblogForm(instance=a) return render_to_response('blogedit.html', {'form': form, 'blg_id': blg_id}) I will add more code as needed. Thanks for any and all 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Complex select
Something like this: Query = Comments.objects.all().sort_by("submit_date")[:5] -- Sent from my Palm Pre Viktor Semykin wrote: Hi everyone. I'm trying to create comment overview page. I want to select all content entries that were recently commented. The problem is that I don't know how to do that. In SQL I would run something like select distinct object_pk from (select * from django_comments order by submit_date desc) as all_comments limit 5; (PostgreSQL) but is there a way to do that in terms of django QuerySet without raw SQL? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: per-application middleware
On Tue, Jul 7, 2009 at 11:32 AM, Philip Zeyliger wrote: > Hi, > > I have a project made up of several applications, and one of those > applications needs some specific middleware, whereas the others don't. Is > there a way to enable middleware per-application? you can use a middleware as a decorator to a view function (and vice versa): from django.utils.decorators import decorator_from_middleware newview = decorator_from_middleware(middleware_class)(yourapp.someview) -- Javier --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
per-application middleware
Hi, I have a project made up of several applications, and one of those applications needs some specific middleware, whereas the others don't. Is there a way to enable middleware per-application? Thanks, -- Philip --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Complex select
Hi everyone. I'm trying to create comment overview page. I want to select all content entries that were recently commented. The problem is that I don't know how to do that. In SQL I would run something like select distinct object_pk from (select * from django_comments order by submit_date desc) as all_comments limit 5; (PostgreSQL) but is there a way to do that in terms of django QuerySet without raw SQL? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generic views problem
Ah, I get it now. I thought I've done the last step, changing my template files. Turns out I didn't. Andrew, thanks for your help! OJ Sent from my BlackBerry® smartphone from Sinyal Bagus XL, Nyambung Teruuusss...! -Original Message- From: Andrew Fong Date: Tue, 7 Jul 2009 06:44:09 To: Django users Subject: Re: Generic views problem Do you have any Poll objects in the database? If not, add some using the admin interface. Assuming you do however, can we see your index view function? The one from step 3 of the tutorial under "Write views that actually do something". -- Andrew On Jul 7, 6:39 am, "Owen Jeremiah" wrote: > I'm following the tutorial from django documentation and got to part 4 about > generic views. But I can't get the Poll objects in my dictionary, and the > result is 'No polls are available.' > > I'm running this in Ubuntu 9.04 with Python 2.6 and Django 1.0.2 installed. I > would appreciate it if somebody can point me into the right direction. > > TIA > > OJ > > Sent from my BlackBerry® smartphone from Sinyal Bagus XL, Nyambung > Teruuusss...! --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Senior Python/Django
We are looking for experienced Django / Python, patrones de diseño, UML, CSS, Ajax, Mysql desarrolladores para un trabajo de tiempo completo. Por favor enviar su CV con aspiraciones salariales. projetoec...@hotmail.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Overriding block tags in included templates?
On Tue, Jul 07, 2009 at 03:06:39AM -0700, Darren wrote: > > Hi guys, > > Chasing my tail a bit here, hoping you can help me. > > say I have a base.html: > > - > > {% include 'header.html' %} > > -- > > header.html: > - > {% block title %}Default title{% endblock title %} > - > > And a child detail.html > --- > {% extends 'base.html %} > {% block title %}Different title{% endblock title %} > --- > > When rendering detail.html, should the title block in header.html be > overridden? I'm guessing my understanding of how the template > including/inheritance understanding is wrong, so please correct me :) > I think your understanding is correct. :) It will get overriden. The result will be Different title It's just as if you wrote base.html like this: {% block title %}Default title{% endblock title %} -- You can learn many things from children. How much patience you have, for instance. -- Franklin P. Jones --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Efficiency of getting attribute values in templates
On Fri, Jul 03, 2009 at 09:04:37AM -0700, Rajesh D wrote: > > On Jul 3, 9:17 am, Nikola Pavlović wrote: > > Hello people, > > > > I'm writing my first Django application and would like to know what is > > considered more efficient: getting values of models' attributes in views > > or directly in templates? > > > > More precicely, say we have a Person model with name and id attributes, > > and these need to be shown on a page. > > > > Is it better for a view to "prepare" a context like this: > > > > # views.py > > # ... > > > > persons = [] > > > > for person in Person.objects.all(): > > persons.append({'id': person.id, 'name': person.name}) > > > > return render_to_response('some_template.html', persons) > > > > # some_template.html > > > > {% for p in persons %} > > Id: {{ p.id }}; Name: {{ p.name }} > > {% endfor %} > > > > or just pass a QuerySet in a context like this: > > # views.py > > # ... > > > > persons = Person.objects.all() > > return render_to_response('some_template.html', persons) > > > > and then let the template access attribute values directly? > > > > Does it make a difference in terms of performance? > > The second method avoids an extra loop and also keeps your code leaner > (less code == lesser chances of bugs). It's also the more commonly > used method. And if you are displaying just a handful of persons per > page, the performance differences should be negligible either way. Great, that was just what I wanted to know -- a 'Django best practices' kind of question. After a couple of hours of playing with this the other day, I came to the same ("obvious") conclusion (much simpler code), but I was just concerned if there was some significant overhead to accesing attributes in the rendering phase. Thanks! -- Two can Live as Cheaply as One for Half as Long. -- Howard Kandel --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Apache with Django
On Mon, Jul 06, 2009 at 06:27:54AM -0700, WilsonOfCanada wrote: > > @ Kenneth: If I do not use runserver, what command should I use to > run the python scripts for production servers? > It seems you got a bit confused about this runserver thing, so it's probably important this gets an explicit answer. As far as Django is concerned you don't run any command to start a production server. 'runserver' is there just to start a simple server that comes bundled with Django so you don't have to run a full-blown one on your development environment. In production you just configure Apache (as you did), or some other proper web server, to use Python and Django for your site and start the server with its own appropriate command. Again, this has nothing to do with 'runserver' -- on a production server you "forget" that command. In addition to what has already been said about ports, the reason you can't connect to the server may be that you didn't start it at all -- if you ran 'runserver' command you just started Django's developement server that got bound to localhost:8000 which means it is only listening to local connections (coming form the same machine) on port 8000. In that case Apache isn't running at all. To see how to start Apache on Windows you should read it's documentation. It's probably 'apachectl start' or something like that (I'm not sure, never used Apache on Windows). > @ Boštjan: I am not sure if I even setup a connection between them. > In httpd.conf, I only added: > > ServerName www.domainname.ca > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE Moo5.settings > PythonOption django.root / > PythonDebug On > PythonPath "['C:/Program Files/Apache Software Foundation/Apache2.2/ > htdocs/Moo5', 'C:/Program Files/Apache Software > Foundation/Apache2.2/htdocs', 'C:/Python25/Lib/site-packages/django- > trunk/', 'C:/Python25/Lib/site-packages/django-trunk/django/'] + > sys.path" > > Is there any reason why you use both of those first two paths in PythonPath? The second seems enough. Also, you *probably* don't need the other two paths (site-packages are probably already in sys.path). If this is for production you should set PythonDebug to 'off'. Cheers, nik -- It's more than magnificent -- it's mediocre. -- Sam Goldwyn --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Include app urls from url root path
On Jul 7, 3:10 pm, Joshua Partogi wrote: > Dear all, > > Because I want to plug a django app from urls.py as it is (without adding > any suffix), is it possible to include the app urls with this scenario? > > # urls.py > urlpatterns = patterns('', > (r'^$', include('djapp.urls')), > ) > Leave off the $ - this will *only* match an empty URL. -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Include app urls from url root path
Dear all, Because I want to plug a django app from urls.py as it is (without adding any suffix), is it possible to include the app urls with this scenario? # urls.py urlpatterns = patterns('', (r'^$', include('djapp.urls')), ) #djapp.urls urlpatterns = patterns('djblog.views', (r'^comment/preview', 'preview_comment'), (r'^comment/save', 'save_comment'), ) When I point the browser to: http://localhost:8080/comment/preview I receive a 404 error. Am I doing anything wrong? thank you in advance -- Join Scrum8.com. http://blog.scrum8.com http://twitter.com/scrum8 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using domain name as parameter..
request.get_host() On Jul 7, 9:42 am, Mirat Can Bayrak wrote: > i am building a site that like blogger.com i mean i have to use subdomains > as parameters :\ Is there any docs about django about doing this? or any > ideas? thank you very much. > > -- > Mirat Can Bayrak --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generic views problem
Do you have any Poll objects in the database? If not, add some using the admin interface. Assuming you do however, can we see your index view function? The one from step 3 of the tutorial under "Write views that actually do something". -- Andrew On Jul 7, 6:39 am, "Owen Jeremiah" wrote: > I'm following the tutorial from django documentation and got to part 4 about > generic views. But I can't get the Poll objects in my dictionary, and the > result is 'No polls are available.' > > I'm running this in Ubuntu 9.04 with Python 2.6 and Django 1.0.2 installed. I > would appreciate it if somebody can point me into the right direction. > > TIA > > OJ > > Sent from my BlackBerry® smartphone from Sinyal Bagus XL, Nyambung > Teruuusss...! --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
using domain name as parameter..
i am building a site that like blogger.com i mean i have to use subdomains as parameters :\ Is there any docs about django about doing this? or any ideas? thank you very much. -- Mirat Can Bayrak --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic App Creation
Generally speaking, dynamically altering the DB schema is difficult and dangerous. SQL databases are not spreadsheets -- that is, you shouldn't be frequently adding or removing columns to them. It makes optimization difficult and it's very likely you'll accidentally lose data in the process. AFAIK, the only way to get this working in Django is to manually write your own SQL. Google App Engine might work better this for though. You can run a tweaked version of Django on GAE I believe, and its non-SQL datastore is more friendly to spreadsheet-like applications. Amazon's SimpleDB might work too. -- Andrew On Jul 7, 8:37 am, Darren Mansell wrote: > Hello. I'm looking into making a Django app that allows you to create Django > models. > > The idea is that you should be able to add fields and user workflows using a > web page that then creates a model, view, template and syncs the DB. Users > can then access these newly created apps separately. > > An example: > > An accounts department of a company wants to replace their Excel files that > they currently use for expenses, claims etc. with a web-based system. The > web based system will have a page where you can create fields such as a > field for name, field for dept, field for expense, tax etc. The page then > creates a Django app with a model, view and template from this for employees > to fill in to submit expenses. > The employees DB will have info about who is who's manager and will then > allow the page creator to include workflows - e.g. employees enters details > and submits, their manager gets a mail to request authorisation, they > authorise and their director then has to authorise etc. > > I think if something like this were to exist it would allow lots of > businesses to replace static documents for workflow with web based systems. > > Does anyone know of anything out there that already does this kind of thing? > > Darren --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
On Tue, Jul 7, 2009 at 9:02 AM, alecs wrote: > > Environment: > > Request Method: POST > Request URL: http://172.16.23.33/alex/urlsend/ > Django Version: 1.0.2 final > Python Version: 2.6.2 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'filez.filezupload'] > Installed Middleware: > ('firepy.django.middleware.FirePHPMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > > Traceback: > File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in > get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py" > in __call__ > 67. return self.view_func(request, *args, **kwargs) > File "/var/www/filez/filezupload/views.py" in urlsend > 186. auth_user = 'u...@exmpl.com', auth_password = > 'gfhjkm_') > File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py" > in __call__ > 66. if self.test_func(request.user): > > Exception Type: AttributeError at /alex/urlsend/ > Exception Value: 'unicode' object has no attribute 'user' > > If comment out send_mail everythin works ok. > So your call to send_mail is jumping into one of the auth decorators. Do you perhaps have your own send_mail function that you have decorated with @login_required or something? You are not actually calling the send_mail function in django.core.mail, and the reason why lies somewhere in the parts of your file containing this code that you have not shown. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: changing apache mod python
Something else just crossed my mind as well. The issue, AFAIK, is that older versions of Ubuntu / Python 2.5 stored third-party libraries (e.g. stuff you easy_install) in /usr/lib/python2.5/site-packages. With the upgrade to Ubuntu 9.04 / Python 2.6, these packages are now stored in /usr/lib/python2.6/dist-packages. Note that the old site- packages path is missing from your PythonPath. It's not just as simple as adding the old site-packages directory to your python path though. The compiled pyc files (and possibly other things) in that directory are specific to the version they were compiled with and will likely cause more headaches. If Deportista is a third-party library that you used setup.py or easy_install to install, you might just want to try re-installing it using the same method. If, on the other hand, Deportista is something you manually plunked down into the site-packages dir (or symlinked into), then you'll just manually have to move it to some other directory in your Python path (e.g. /usr/lib/python2.6/dist-packages). Make sure to remove all the old pyc files in there though! -- Andrew On Jul 7, 9:10 am, Andrew Fong wrote: > Don't know if you tried this already, but the Ubuntu 9.04 Release > Notes mention something about this: > > http://www.ubuntu.com/getubuntu/releasenotes/904#python%20ImportError... > > """ > A bug in the python packages present in jaunty prior to the Ubuntu > 9.04 release candidate caused python modules to fail to be registered > for use with the current python version, python 2.6. This problem > appears as an import error, e.g: > > ImportError: No module named foo > even though the package providing the module package is installed. > > To correct this, run the command: > > sudo dpkg-reconfigure python-foo > for each python-foo package providing an affected module. > > """ > > -- Andrew > > On Jul 7, 7:43 am, Miguel wrote: > > > > > Thank you Aaron. I will try to follow your pieces of advices. Fortunately it > > is not my production enviroment. > > > Miguel > > > On Thu, Jul 2, 2009 at 12:47 AM, Aaron Maxwell wrote: > > > > Hm. It involves this module Deportista. I haven't heard of it, so I'm > > > assuming it's either a third-party library you are using, or one a module > > > made in house. > > > > You might try this: (assuming unixy environment) > > > > 1) At a shell prompt, set PYTHONPATH to the value you included in the > > > attached > > > error report page. (you know how to do this? If not, look up setting and > > > exporting environment variables.) > > > 2) Also set DJANGO_SETTINGS_MODULE > > > 3) Start a python interpreter > > > 4) type in "import entrenatech.views" > > > > Does this reproduce the Deportista importerror? If so, that is a good > > > clue. > > > > On Wednesday 01 July 2009 12:55:05 am Miguel wrote: > > > > The error is: > > > > ViewDoesNotExist at / Could not import entrenatech.views. Error was: No > > > > module named Deportista > > > > As you said, Django .96 might be incompatible somehow, but I have to > > > > keep > > > > it becasuse it is a little messy to updgrade the django version. Too > > > > much > > > > production code. > > > > -- > > > Aaron Maxwell > > >http://redsymbol.net/ --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: changing apache mod python
Don't know if you tried this already, but the Ubuntu 9.04 Release Notes mention something about this: http://www.ubuntu.com/getubuntu/releasenotes/904#python%20ImportError%20with%20systems%20upgraded%20before%20Ubuntu%209.04%20release%20candidate """ A bug in the python packages present in jaunty prior to the Ubuntu 9.04 release candidate caused python modules to fail to be registered for use with the current python version, python 2.6. This problem appears as an import error, e.g: ImportError: No module named foo even though the package providing the module package is installed. To correct this, run the command: sudo dpkg-reconfigure python-foo for each python-foo package providing an affected module. """ -- Andrew On Jul 7, 7:43 am, Miguel wrote: > Thank you Aaron. I will try to follow your pieces of advices. Fortunately it > is not my production enviroment. > > Miguel > > > > On Thu, Jul 2, 2009 at 12:47 AM, Aaron Maxwell wrote: > > > Hm. It involves this module Deportista. I haven't heard of it, so I'm > > assuming it's either a third-party library you are using, or one a module > > made in house. > > > You might try this: (assuming unixy environment) > > > 1) At a shell prompt, set PYTHONPATH to the value you included in the > > attached > > error report page. (you know how to do this? If not, look up setting and > > exporting environment variables.) > > 2) Also set DJANGO_SETTINGS_MODULE > > 3) Start a python interpreter > > 4) type in "import entrenatech.views" > > > Does this reproduce the Deportista importerror? If so, that is a good > > clue. > > > On Wednesday 01 July 2009 12:55:05 am Miguel wrote: > > > The error is: > > > ViewDoesNotExist at / Could not import entrenatech.views. Error was: No > > > module named Deportista > > > As you said, Django .96 might be incompatible somehow, but I have to keep > > > it becasuse it is a little messy to updgrade the django version. Too much > > > production code. > > > -- > > Aaron Maxwell > >http://redsymbol.net/ --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
Environment: Request Method: POST Request URL: http://172.16.23.33/alex/urlsend/ Django Version: 1.0.2 final Python Version: 2.6.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'filez.filezupload'] Installed Middleware: ('firepy.django.middleware.FirePHPMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py" in __call__ 67. return self.view_func(request, *args, **kwargs) File "/var/www/filez/filezupload/views.py" in urlsend 186. auth_user = 'u...@exmpl.com', auth_password = 'gfhjkm_') File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py" in __call__ 66. if self.test_func(request.user): Exception Type: AttributeError at /alex/urlsend/ Exception Value: 'unicode' object has no attribute 'user' If comment out send_mail everythin works ok. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Dynamic App Creation
Hello. I'm looking into making a Django app that allows you to create Django models. The idea is that you should be able to add fields and user workflows using a web page that then creates a model, view, template and syncs the DB. Users can then access these newly created apps separately. An example: An accounts department of a company wants to replace their Excel files that they currently use for expenses, claims etc. with a web-based system. The web based system will have a page where you can create fields such as a field for name, field for dept, field for expense, tax etc. The page then creates a Django app with a model, view and template from this for employees to fill in to submit expenses. The employees DB will have info about who is who's manager and will then allow the page creator to include workflows - e.g. employees enters details and submits, their manager gets a mail to request authorisation, they authorise and their director then has to authorise etc. I think if something like this were to exist it would allow lots of businesses to replace static documents for workflow with web based systems. Does anyone know of anything out there that already does this kind of thing? Darren --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: request body too long
On Tue, 2009-07-07 at 03:02 -0700, Xu Mingming wrote: > When i post a request to my django server with a body of 28000 > characters, i got a 413 response(request body too long), anymore knows > how to increase this limit? > > BTW, i run the server using: > ./manage.py runserver > > thanks > Simplest way is to not run it like that. Use fastcgi, wsgi or mod_python, and you won't have that issue. Cheers Tom --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
On Tue, Jul 7, 2009 at 2:45 AM, alecs wrote: > > I'm trying to send a e-mail, but getting this error. Don't know what > to do... Any ideas? > Thanks in advance. > > def urlsend(request, username): >if request.method == 'POST': >form = SendMailForm(request.POST) >if form.is_valid(): >subject = form.cleaned_data['subject'] >message = form.cleaned_data['message'] >to_email = form.cleaned_data['to_email'] >try: >send_mail(subject, message, 'u...@exmpl.com', > to_email, fail_silently = False, >auth_user = 'u...@exmpl.com', auth_password = > 'pass') >except Exception, e: >raise ValueError,e Why are you doing this with catching an Exception and raising a ValueError instead? In doing so you lose in the traceback the information about where the error really originated, since the traceback ends at your "raise ValueError, e", instead of ending at whatever code is actually trying to access the 'user' attribute of a unicode object. Get rid of this try/except/raise and the traceback will actually reflect where the problem is. Also, when you post tracebacks, please click the 'Switch to copy-and-paste view' link before copying the data. The full page is useful when seen in a broswer but the loss of formatting when pasted makes it virtually unusable. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to handle HEAD method
The exception is very definitely being raised by me trying to distinguish things based on REQUEST_METHOD type. Here's the traceback: Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/andrew/djprj/helpers/request_handler.py", line 77, in __call__ raise NoMethodError(request.method) NoMethodError: The HEAD method is not allowed for this path The relevant code in helpers/request_handler.py is this: class RestHandler(object): def __call__(self, request, *args, **kwargs): method = request.method.upper() if hasattr(self, method): return getattr(self, method)(request, *args, **kwargs) raise NoMethodError(request.method) class NoMethodError(Exception): def __init__(self, method): super(Exception, self).__init__( "The %s method is not allowed for this path" % method) --- Graham, are you suggesting that if I receive a HEAD request, I should behave exactly the same as if I received a GET request? That is, I should assume Apache / mod_wsgi will take care of translating my response into one appropriate for a HEAD request? -- Andrew On Jul 6, 7:28 pm, Graham Dumpleton wrote: > On Jul 7, 2:14 am, Andrew Fong wrote: > > > Thanks for the response. I'm using Apache/mod_wsgi and getting error > > messages in production because my handlers don't know how to handle a > > HEAD request. If the server is supposed to automatically translate the > > HEAD requests into GETs, then I probably have something set up > > incorrectly. Any idea where to start looking? > > As I described, it doesn't always translate HEAD to GET and that > shouldn't matter. Neither should it really matter in the Django layers > either. If you in your code are trying to distinguish things based on > REQUEST_METHOD type, then it is more likely to be in your code. > > I would suggest you post the Python traceback so others can say > whether it is an issue in Django layers to eliminate that, and then > perhaps point at where problem may lie. Ie., in your code or > elsewhere. > > Graham > > > > > -- Andrew > > > On Jul 2, 7:16 pm, Graham Dumpleton > > wrote: > > > > On Jul 3, 4:55 am, Andrew Fong wrote: > > > > > How exactly should I handle a HEAD request in Django? > > > > > So ... assuming my view looks like this... > > > > > def handle_request(request): > > > > if request.method == 'POST': return do_post(request) > > > > elif request.method == 'GET': return do_get(request) > > > > elif request.method == 'HEAD': return do_head(request) > > > > > ... what should the do_head method return? The W3 standard says "The > > > > HEAD method is identical to GET except that the server MUST NOT return > > > > a message-body in the response". > > > > > How exactly do I not return a message body though? Do I just return > > > > None? Do I return the response I would for a GET and then modify it > > > > somehow? > > > > You generally don't need to do anything different, the standard says > > > 'the ***server***'. > > > > So, for sane web servers, the underlying server will deal with this > > > and the application doesn't need to. You should just do exactly what > > > you would normally do for a GET request. The web server would then > > > return all the headers but just throw the response content away and > > > not return it to the client. > > > > If you do act differently, you potentially break the requirement that > > > response headers for the HEAD should match what would be returned for > > > a GET request against same resource. Thus, the suggestion of returning > > > an empty string could stuff up returned content length for a start. > > > > FWIW, in Apache/mod_wsgi it will deliberately at times translate a > > > HEAD into a GET when it is passed into the WSGI application. This will > > > occur when there are Apache output filters registered that may want to > > > change response headers and modify the content. For example, > > > mod_deflate, which would compress the response. If this isn't done and > > > the application acted differently for a HEAD, then the data received > > > by Apache output filter would not be the same as for the GET and > > > result returned to client would be different than what it should be. > > > > Graham --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'list' object has no attribute '_clone'
ummm, i can concat several queries with & and |. Doing this I play with queries instead of playing with list ... and then the object_list work properly. problem resolve. Miguel On Tue, Jul 7, 2009 at 1:38 PM, Miguel wrote: > Hello,I am trying to return an object_list to one of my templates. > > The point is that when a have a queryset, there is no problem to return the > object_list. > > But I need to concatenate several list that I get form different query set. > When I concatenate the two list I get the error: 'list' object has no > attribute '_clone' > > Here deportistas is two list or more. > > return object_list( > request, > deportistas, > template_name="entrenador/deportistas_list.html", > paginate_by=100, > extra_context=c, > allow_empty=True, > ) > > does anybody know how to solve this? > > > > > thank you in advance. The errror is as follows: > > > > AttributeError at /sportsound/entrenador/supervision/deportistas/ 'list' > object has no attribute '_clone' Request Method: POST Request URL: > http://192.168.6.217/sportsound/entrenador/supervision/deportistas/ Exception > Type: AttributeError Exception Value: 'list' object has no attribute > '_clone' > [..] > > > Miguel > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "django-notification" app installation
On Tue, Jul 7, 2009 at 12:32 AM, Anthony wrote: > [...] My problem now is > that when I do a syncdb, I get: > >Skipping creation of NoticeTypes as notification app not found > > > So, it looks like something related to the app is there, but the app > itself is missing (at least from the standpoint of creating the > database). Any help with this would be appreciated again. > > Grepping the Django source tree for "Skipping" doesn't show any hits that look like they could result in that message, so it's coming from code outside Django. Looking at the doc for the app you are attempting to use: http://github.com/jtauber/django-notification/blob/e04fdc9420306826b1b80623dfcad819813dc082/docs/usage.txt#L11 that message appears as part of a suggested way of creating Notice Types, and from looking at the code the reason you would get the message is that you have not included the app in your INSTALLED_APPS in settings.py. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Reusable Contact Form include error?
Ran into a slight problem implementing that one Rajesh - getting the form to submit the form data wasn't quite right with the simple contect processor you described. I then hit on the obvious solution: implement the redirection using the form HTML. Changing that snippet to use /contact/thanks/ did the trick. Thanks for allt he help! 1 On Jul 3, 4:52 pm, Rajesh D wrote: > On Jul 3, 8:57 am, 1angrycats > wrote: > > > > > Great suggestion Rajesh. > > > I've shifted everything into a custom context processor and > > everythign's runnign well, with the view showing and emailing from any > > page, however there's a final step I'm looking to resolve: returning > > the HttpResponseRedirect within the context processor fails silently. > > > The context_processor.py file is this: > > > def login_form(request): > > from website.contact.forms import ContactForm > > from django.core.mail import send_mail > > from django.http import HttpResponseRedirect > > if request.method == 'POST': > > form= ContactForm(request.POST) > > ifform.is_valid(): > > cd =form.cleaned_data > > send_mail( > > cd['subject'], > > cd['message'], > > cd.get('email', 'nore...@foo.com'), > > ['cont...@foo.com'], > > ) > > return HttpResponseRedirect('/contact/thanks/')#Not > > redirecting > > yet. > > else: > > form= ContactForm( > > initial={'subject': 'Here's a suggestion...'} > > ) > > return {'form':form} > > > There's little documentation I've found on this one. Any help > > appreciated. > > You need to break that into two pieces because the context processor > can not handle submissions (i.e. your POSTed data). > > 1. Leave the "defcontact(request)" view from your original post as > is. It should be able to handle posted data. > > 2. In yourcontactprocessor just return the initialformi.e. the > part of the "else" like this:form= ContactForm(initial={'subject': 'Here's a > suggestion...'}) > return {'form':form} > > In the template tag that renders theform, change the action attribute > to post to thecontactview from #1 above. > > In other words, you are using the context processor to add an emptyformto > each request's template context. But the postedformalways > goes to a fixed view that knows how to handle the post and do your > redirect. > > -RD --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: changing apache mod python
Thank you Aaron. I will try to follow your pieces of advices. Fortunately it is not my production enviroment. Miguel On Thu, Jul 2, 2009 at 12:47 AM, Aaron Maxwell wrote: > > Hm. It involves this module Deportista. I haven't heard of it, so I'm > assuming it's either a third-party library you are using, or one a module > made in house. > > You might try this: (assuming unixy environment) > > 1) At a shell prompt, set PYTHONPATH to the value you included in the > attached > error report page. (you know how to do this? If not, look up setting and > exporting environment variables.) > 2) Also set DJANGO_SETTINGS_MODULE > 3) Start a python interpreter > 4) type in "import entrenatech.views" > > Does this reproduce the Deportista importerror? If so, that is a good > clue. > > On Wednesday 01 July 2009 12:55:05 am Miguel wrote: > > The error is: > > ViewDoesNotExist at / Could not import entrenatech.views. Error was: No > > module named Deportista > > As you said, Django .96 might be incompatible somehow, but I have to keep > > it becasuse it is a little messy to updgrade the django version. Too much > > production code. > > > -- > Aaron Maxwell > http://redsymbol.net/ > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
'list' object has no attribute '_clone'
Hello,I am trying to return an object_list to one of my templates. The point is that when a have a queryset, there is no problem to return the object_list. But I need to concatenate several list that I get form different query set. When I concatenate the two list I get the error: 'list' object has no attribute '_clone' Here deportistas is two list or more. return object_list( request, deportistas, template_name="entrenador/deportistas_list.html", paginate_by=100, extra_context=c, allow_empty=True, ) does anybody know how to solve this? thank you in advance. The errror is as follows: AttributeError at /sportsound/entrenador/supervision/deportistas/ 'list' object has no attribute '_clone' Request Method: POST Request URL: http://192.168.6.217/sportsound/entrenador/supervision/deportistas/ Exception Type: AttributeError Exception Value: 'list' object has no attribute '_clone' [..] Miguel --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Generic views problem
I'm following the tutorial from django documentation and got to part 4 about generic views. But I can't get the Poll objects in my dictionary, and the result is 'No polls are available.' I'm running this in Ubuntu 9.04 with Python 2.6 and Django 1.0.2 installed. I would appreciate it if somebody can point me into the right direction. TIA OJ Sent from my BlackBerry?0?3 smartphone from Sinyal Bagus XL, Nyambung Teruuusss...! --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Overriding block tags in included templates?
Hi guys, Chasing my tail a bit here, hoping you can help me. say I have a base.html: - {% include 'header.html' %} -- header.html: - {% block title %}Default title{% endblock title %} - And a child detail.html --- {% extends 'base.html %} {% block title %}Different title{% endblock title %} --- When rendering detail.html, should the title block in header.html be overridden? I'm guessing my understanding of how the template including/inheritance understanding is wrong, so please correct me :) 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
request body too long
When i post a request to my django server with a body of 28000 characters, i got a 413 response(request body too long), anymore knows how to increase this limit? BTW, i run the server using: ./manage.py runserver 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: WSGIScriptAlias without access to apache config?
Hmm, that is a shame. I guess I'll try to get it working at my end and then ask them to add the wsgi file so their virtual host. Thanks for your 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
I've found a response for a similar problem: "Seems that the session middleware not active. It should append the user object to the request object." But can't understand how to solve the problem... Actually I'm getting to a page from which I'm sending a e-mail via GET: http://172.16.23.33/alex/send_mail/?fileurl=http://172.16.23.33/file/88165c9e3683b65c594dce33b4c3b2f48096ccaa7f65f68cc67cbb5a Maybe it's an important moment ? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
Tried to embrace in [] - no effect ... http://pastebin.com/m6437076d --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'unicode' object has no attribute 'user' when sending e-mail
On Jul 7, 7:45 am, alecs wrote: > I'm trying to send a e-mail, but getting this error. Don't know what > to do... Any ideas? > Thanks in advance. > > def urlsend(request, username): > if request.method == 'POST': > form = SendMailForm(request.POST) > if form.is_valid(): > subject = form.cleaned_data['subject'] > message = form.cleaned_data['message'] > to_email = form.cleaned_data['to_email'] > try: > send_mail(subject, message, 'u...@exmpl.com', > to_email, fail_silently = False, > auth_user = 'u...@exmpl.com', auth_password = > 'pass') > except Exception, e: > raise ValueError,e > return HttpResponseRedirect('/'+username+'/') > else: > sendMail = SendMailForm(request.POST) > variables = RequestContext(request, { > 'username': username, > 'form' : form, > }) > return render_to_response('send_mail.html', variables) > return HttpResponseRedirect('/'+username+'/') > else: > return HttpResponseRedirect('/'+username+'/') This is clearly not the code that is producing that error, as you're not using the attribute 'user' anywhere. Please can you post the actual traceback, including the lines of code that are triggering the error. One issue that I can see is that to_email should be a list, not a string. If you've only got one destination address, wrap it in a list like this: [to_email] -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---