Non-programmer looking to create more sophisticated site
I'm ok in CSS, HTML, I use a text editor to make sites, typically I've been using a wiki framework called pmwiki created in PHP and is pretty nice. But it doesn't have an RTF editor. I've been wanting to get into Python, thinking it could be good for certain interactivity which I haven't implemented really in my sites, DB access, forms. Things about Django I think I like, Clean URLs, Python seems like the best way to do a lot of things with shorter readable code. But I have a site design to do where the company rents corporate short- term housing. I want to create about 10 pages, a few of them editable, and maybe explore doing a properties database and multiple contact forms. Am I crazy to be thinking about using Django for this at my skill level? I installed Plone locally to play around, seems good, but maybe too much overhead. If I want to use Django, do I have to some up with some kind of database setup to list properties with a picture? Where might I begin to do this for the first time? Will I be able to quickly make the main HTML page template and add content to it, or is that not how this works? any help 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
www.200836.com---Peking 2008 olympic pin official licensed product
$www.200836.com--- why we buy Peking 2008 Olympic Games-- souvenirs 1 low price 2 best quality-- licensed products by Peking Organizing Committee 3 many products to choose 4 most precious--limited circulation 1 our website www.200836 was aimed at that all the people in the world can buy Olympic souvenirs anywhere anytime 2 our website www.200836 was exclusively authorized by BOCOG to sell licensed products of the Beijing Olympics 3 The website www.200836was exclusively authorized by BOCOG to sell licensed products of the Beijing Olympics. so all the products are best quality ! 4 We have exported our goods to many countries such as Russia, USA, England, Germany, France, Japan, Spain, Italy, Taiwan, Africa, just name a few here. We can deliver goods to any counties all over the world. 5 we give you discount based on your quantity,the more you buy ,the lower price is! 6 welcome to become our product-agent,we will give low discount if your quantity is enough! if you want to know any information about 2008 beijing Olympic games ,please contact me or visit : my website--www.200836.com MSN:[EMAIL PROTECTED] e-mail:[EMAIL PROTECTED] yahooID:[EMAIL PROTECTED] Skype:a200836 ICQ:391836515 or leave your e-mail or msn-number or other contact methods we can e-mail our souvenirs-list to you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Attribute Error on Dumpdata
I think I found my problem... I failed to add "objects = models.Manager()" into my models which would explain why that attribute isn't found. I'll try this out but if anyone has additional suggestions, I'm all ears. cheers, -ttk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Attribute Error on Dumpdata
Hello all, I'm getting an attribute error when I try running the dumpdata command on any of my apps. news = app name NewsEntry = model Output: = C:\someproject>manage.py dumpdata news Traceback (most recent call last): File "C:\someproject\manage.py", line 11, in execute_manager(settings) File "C:\Python25\lib\site-packages\django\core\management \__init__.py", line 277, in execute_manager utility.execute() File "C:\Python25\lib\site-packages\django\core\management \__init__.py", line 225, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python25\lib\site-packages\django\core\management\base.py", line 70, in run_from_argv self.execute(*args, **options.__dict__) File "C:\Python25\lib\site-packages\django\core\management\base.py", line 84, in execute output = self.handle(*args, **options) File "C:\Python25\lib\site-packages\django\core\management\commands \dumpdata.py", line 37, in handle objects.extend(model.objects.all()) AttributeError: type object 'NewsEntry' has no attribute 'objects' == I suspect this is related somehow my models setup. However, after searching, I couldn't find any one with a similar issue. Model class: from django.db import models from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.contrib.sites.managers import CurrentSiteManager class NewsEntry(models.Model): site = models.ForeignKey(Site) on_site = CurrentSiteManager() ... === So I use, for example: NewsEntry.on_site.all() INSTEAD OF NewsEntry.objects.all() This is all based off of the Django "Sites Framework" documentation (http://snipr.com/1uvnz). Any insight would be appreciated. Thanks much in advance, ttk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: loaddata problem with boolean null in fixture - anyone seen this?
On Thu, 2007-12-06 at 14:38 -0800, Shev wrote: [...] > Regardless, I don't see why the loaddata command should choke on a > null value for a Boolean if the models.py allows it. This is a mistaken assumption. Since some of the constraints specified in models.py are enforced at the database level, if your database column does not exactly match what is in models.py, you will see errors. Django cannot (will not) override the database in that respect. I don't know if your original error was raised from the database server or before it got to that point, but it's quite possible and normal for something to be impossible because the database column doesn't permit it, even if you've messed around with models.py to allow it. Malcolm -- Many are called, few volunteer. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ordering. missing FROM-clause entry for table "locations_location"
On Thu, 2007-12-06 at 21:21 +0530, Kenneth Gonsalves wrote: > > On 06-Dec-07, at 9:04 PM, Empty wrote: > > > http://www.mail-archive.com/django-users@googlegroups.com/ > > msg37967.html > > > > and this: > > > > http://www.djangoproject.com/documentation/db-api/#order-by-fields > > read it, implemented it - still get the same error The mail post that Michael pointed to includes a reference to ticket #2076. It looks a lot like the original poster has rediscovered that bug. Malcolm -- I intend to live forever - so far so good. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django deployment à lá Capistrano
I've made a quick and dirty howto about using capistrano with django : http://cyberdelia.tryphon.org/blog/2007/10/27/django-capistrano/ It should help us waiting for a more django and pythonic way to do it ;) Cheers, -- Timothée Peignier http://people.tryphon.org/~tim/ On Mon, 2007-09-10 at 11:26 +0100, David Reynolds wrote: > There are people using capistrano for django [0][1]. Would it not be > better to look at writing a django recipe for capistrano rather than > trying to re-implement it? > > Thanks, > > David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to add to DjangoResources?
On Dec 6, 5:29 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote: > Register yourself as a user and try Thank you. In case anyone else has the same problem, I didn't actually register and log in, I clicked "Settings" and put in my name and email there. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: loaddata problem with boolean null in fixture - anyone seen this?
If you mean, add the field/column - sort of. It was added to a database in use, I used dbmigration to handle the upgrade. Regardless, I don't see why the loaddata command should choke on a null value for a Boolean if the models.py allows it. On Dec 6, 4:25 pm, ashwoods <[EMAIL PROTECTED]> wrote: > did u add that after a syncdb maybe? > > On 6 Dez., 21:55, Shev <[EMAIL PROTECTED]> wrote: > > > One of my models has a field like this: > > > confirm = BooleanField(blank=True, null=true) > > > When I use Django's dumpdata command to export my data to a fixture, > > and then try to re-import with loaddata, I see an error message that > > looks like this: > > >Problem installing fixture '/foo/bar/datadump.json': > >[u'This value must be either True or False.'] > > > I hand-edited the fixture file to change all the "null" values for the > > confirm field to "false" and the fixture loads fine. But shouldn't > > loaddata allow null to be in a BooleanField if the model definition > > allows it? (though all my other usages of BooleanField have a > > "default=" attribute, except this one) Has anyone else seen this > > problem? > > > Shev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to add to DjangoResources?
Register yourself as a user and try It works On Dec 7, 2007 2:06 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > I am trying to add an app to > http://code.djangoproject.com/wiki/DjangoResources > > but when I submit I get > 500 Internal Server Error (Submission rejected as potential spam) > > How can I get this to work? I am trying to add this to the "Django > application components" section: > > * [http://blogcosm.com/media/blogmaker/release/README.html Blogmaker] > A full-featured, production-quality blogging application with support > for trackback, ping and comment honeypots > > Thanks, > Kent > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
x|add:-1 in templates doesn't work as I expect.
Hello. I'm trying to get a template to render previous and next links on a series of pages, as follows. Previous | Next And I've come across some unexpected behavior. The first line does not work (add:-1), while the second line does. The first line throws a TemplateSyntaxError ("add requires 1 arguments, 0 provided"). It works if I change it to {{ position|add:"-1" }}, but that strikes me as vaguely crappy, especially since the positive version works as an int. Also curious if this is the same issue as the one had by ifequal and ifnotequal in ticket #3670. Anybody else seen this issue? Cheers, Cliff --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: loaddata problem with boolean null in fixture - anyone seen this?
did u add that after a syncdb maybe? On 6 Dez., 21:55, Shev <[EMAIL PROTECTED]> wrote: > One of my models has a field like this: > > confirm = BooleanField(blank=True, null=true) > > When I use Django's dumpdata command to export my data to a fixture, > and then try to re-import with loaddata, I see an error message that > looks like this: > >Problem installing fixture '/foo/bar/datadump.json': >[u'This value must be either True or False.'] > > I hand-edited the fixture file to change all the "null" values for the > confirm field to "false" and the fixture loads fine. But shouldn't > loaddata allow null to be in a BooleanField if the model definition > allows it? (though all my other usages of BooleanField have a > "default=" attribute, except this one) Has anyone else seen this > problem? > > Shev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Specifying tables with schema names in models
On Dec 6, 7:59 am, Sprenger <[EMAIL PROTECTED]> wrote: > I've been trying to get django working with a legacy system which I > feel could benefit greatly from it, however I've managed to hit a > critical snag. Our setup is such that we have tables in multiple > schemas, so (for example) there might be one called "app_sys" and > another called "app_prod", with tables in each that need to be > accessed. > > Initially I had been working with 0.96 and managed to get things > working by specifying db_table values in class Meta with the schema > prefix... for example > > class Documents(models.Model): > documentid = models.IntegerField(primary_key=True, > db_column='documentid') > # ...etc > > class Meta: > db_table = 'app_prod.documents' > > However, I ended up upgrading to the SVN release (to try and see if > slicing query results worked, they don't seem to with Oracle in .96) > and now I see that table names are quoted. This means my trick doesn't > work anymore, because what gets put into the query is > > SELECT "APP_PROD.DOCUMENTS"."DOCUMENTID", >FROM "APP_PROD.DOCUMENTS" ...etc > > Of course with the quotes, Oracle is looking in the user's schema for > a table named with the period, which doesn't exist. Naturally, what I > was doing was pretty hackish, so I'm not bothered that this particular > approach doesn't work (it seemed pretty sketchy anyways), but on the > other hand if I can't figure out how to specify the full schema and > table name in SOME way, it seems to kill this effort completely. > > Does anyone have any ideas for a way around this? The solution we use where I work is to create synonyms in the Django schema to the tables we need from other schemas. Then we can just specify the synonym name in the model, and everything works. The major downside to this approach is that the Django introspection doesn't understand it, and so syncdb will generate erroneous sql for those models. This hasn't proven problematic for us yet, since we don't use syncdb to generate our schemas except in the early stages of development. It sounds like you're probably not using it to begin with (I imagine your approach would run into the same problem), so this may not be a problem for you either. Ultimately, a real solution would be to have a db_schema setting in the Meta class, but we're not there yet. Hope this helps, Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help debugging Django/MySQLdb exception
I am running with DEBUG = True. That's a good find. Thanks. I figured out the problem, but I think there is a bug here. The field from the data that I believed to be the primary key was really not a key, and duplicated itself. I had that field set as primary_key=True in the model. Thus, the "key" would repeat and the row would not be inserted. However, no exception was ever raised about a duplicate primary key on save(). I am puzzled by this. Why would it not complain about a primary key violation? On Dec 5, 12:29 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On 12/4/07, Brian Morton <[EMAIL PROTECTED]> wrote: > > > > > I'm not sure what could be causing this problem. This is a loader > > script that is loading a CSV and using the Django ORM to do lookups > > and inserts. This is on a workstation with 1GB of memory running > > Ubuntu Gutsy (the MySQL server is local also). I'm using MySQLdb > > 1.2.2 and there do not seem to be any relevant bugs fixed since then. > > Here is the traceback. > > > Out of memory (Needed 8164 bytes) > > Traceback (most recent call last): > > File "loader.py", line 66, in > > food = Food.objects.get(nutrient_databank_number=row[0]) > > How big is what your are loading? How long does it run before you hit the > out or memory error? Are you running the script with a settings file that > has DEBUG set to True? See: > > http://code.djangoproject.com/ticket/3711 > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Join Me Dear @@@@
http://www.all-foryou.com/community --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Join Me Dear @@@@
http://all-foryou.com/community --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
loaddata problem with boolean null in fixture - anyone seen this?
One of my models has a field like this: confirm = BooleanField(blank=True, null=true) When I use Django's dumpdata command to export my data to a fixture, and then try to re-import with loaddata, I see an error message that looks like this: Problem installing fixture '/foo/bar/datadump.json': [u'This value must be either True or False.'] I hand-edited the fixture file to change all the "null" values for the confirm field to "false" and the fixture loads fine. But shouldn't loaddata allow null to be in a BooleanField if the model definition allows it? (though all my other usages of BooleanField have a "default=" attribute, except this one) Has anyone else seen this problem? Shev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ANN: Blogmaker blogging application
PreFab Software has released Blogmaker (tm), a full-featured, production-quality blogging application for Django. It supports trackbacks, ping and comments with moderation and honeypot spam prevention. Blogmaker is free, open-source software licensed under a BSD license. Blogmaker powers the blogs at http://blog.blogcosm.com/ and http://prefabcosm.com/blog/. Full announcement: http://blog.blogcosm.com/2007/12/06/ Release page with the full feature list, download link and (limited) documentation: http://blogcosm.com/media/blogmaker/release/README.html Kent --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Strange FastCGI problems
No, not using @user_passes_test anywhere. Thanks though! On Dec 6, 1:43 pm, yml <[EMAIL PROTECTED]> wrote: > TP are you using @user_passes_test decorator with urlresolvers (url, > reverse ...). I had a problem similar to what you are describing and I > finally find out that this problem was infact related to the bug > described there:http://code.djangoproject.com/ticket/5925 > > I hope that help > > On Dec 6, 3:31 am, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > On Dec 6, 12:40 pm, TP <[EMAIL PROTECTED]> wrote: > > > > I thought I needed multiple Apache's since I frequently have several > > > concurrent requests. The actual dynamic python processing is quick, > > > but since clients could be connected for relatively long (slow > > > connections, etc), I thought I'd need multiple Apache's talking to > > > each. Since Django says it's not officially thread safe, I'm using the > > > prefork MPM in Apache. > > > Even in 'prefork' mode of Apache, there are multiple processes > > handling requests and so concurrent requests is not a problem. The > > problem with prefork though is that you can end up with lots of > > process, all consuming the maximum your Django application will use. > > > For memory constrained VPS systems, using 'worker' MPM is a better > > choice as you cut down on the number of Apache child processes and > > therefore memory, with concurrency then coming from multithreading, > > but also from fact that multiple processes still may also be running. > > > You might have a read of: > > > http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading > > > which talks about the different process/threading models that Apache > > provides and how mod_wsgi makes use of them and extends on them. > > > In respective of thread safety of Django, where does it say it is 'not > > officially thread safe'. I know that it is implied through fact they > > suggest prefork when using mod_python, but they also don't say to > > avoid mod_python on Windows, which is multithread, plus FASTCGI > > examples give examples using multithreading. So, there is actually > > conflicting information on the issue. > > > As explained in: > > > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > > the situation seems to be that there are no known current issues with > > Django itself in respect of multithreading. Thus, any multithread > > problems are more likely to come from the application built by a user > > using Django. So, it is just a matter of testing your application so > > you are satisfied that there isn't a problem. > > > > I looked at mod_wsgi and decided to try fastcgi since the Django docs > > > explicitly support it. But, given my problems perhaps I'll try > > > mod_wsgi next. > > > That there is nothing in Django documentation about mod_wsgi is more > > to do with no one offering up anything to add which mentions it. The > > Django documentation on mod_wsgi site is reasonably comprehensive and > > maybe even a link to that would be a good start. I haven't offered > > anything up myself for the Django site as believe that it has to be > > the Django developers/community that first need to work out whether > > they see it as a viable option and when they are happy add a link to > > it. > > > FWIW, people are using mod_wsgi quite happily with Django. I know of a > > couple of notable Django sites which are delaying looking at moving > > until mod_wsgi 2.0 is released as that will be the first version which > > allows Python code to be used to implement Apache HTTP authentication > > provider. For what those sites do, having that feature is critical and > > they can't move away from mod_python until mod_wsgi provides an > > equivalent mechanism. > > > Graham > > > > On Dec 5, 8:26 pm, Graham Dumpleton <[EMAIL PROTECTED]> > > > wrote: > > > > > On Dec 6, 12:04 pm, TP <[EMAIL PROTECTED]> wrote: > > > > > > I've been using Django for the past few months and had great results > > > > > with Apache and mod_python. However, I'd like to try and reduce the > > > > > amount of memory that is used by having multiple Apache's each with > > > > > their own copy of my application. I decided to try mod_fastcgi in > > > > > Apache and Django's FastCGI server capability. > > > > > Why have multiple Apache's if using mod_fastcgi. You should be able to > > > > hang multiple FASTCGI hosted applications hanging off the one Apache. > > > > > BTW, you might also want to look at mod_wsgi. Allows you to run Django > > > > in separate process of their own just like FASTCGI, but everything > > > > still managed by Apache without the need for you to separately start > > > > Django or use any supervisor system to keep it running. > > > > > 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 [EMAIL
Caching when caching is disabled
I have a template that extends another. Each template have variables in them. When the variable in the parent template changes the HTML is not updated. That is to say, a variable in the parent page is set to X I view the page for the first time and I see X. The vale of the variable changes to Y. I view the page and I see X. I am not using any Django caching libraries and I clear my browser cache in between invocations of the page. I am using Apache, Mod_Python, and trunk of the Django SVN. Below is a small example that demonstrates what I am talking about. urls.py (snippet) (r'^test/$', 'django.views.generic.simple.direct_to_template', {'extra_context':{"var":datetime.datetime.now(), "var2":datetime.datetime.now().second}, 'template':'test2.html'}), test1.html {{var2}}|{%block rep%}{%endblock%} test2.html {%extends "test1.html"%}{%block rep%}{{var}}{%endblock%} Is this problem caused by the caching of parsed templates? Should parent pages not contain variables? Thanks for any help you guys can give me. Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Strange FastCGI problems
TP are you using @user_passes_test decorator with urlresolvers (url, reverse ...). I had a problem similar to what you are describing and I finally find out that this problem was infact related to the bug described there: http://code.djangoproject.com/ticket/5925 I hope that help On Dec 6, 3:31 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Dec 6, 12:40 pm, TP <[EMAIL PROTECTED]> wrote: > > > I thought I needed multiple Apache's since I frequently have several > > concurrent requests. The actual dynamic python processing is quick, > > but since clients could be connected for relatively long (slow > > connections, etc), I thought I'd need multiple Apache's talking to > > each. Since Django says it's not officially thread safe, I'm using the > > prefork MPM in Apache. > > Even in 'prefork' mode of Apache, there are multiple processes > handling requests and so concurrent requests is not a problem. The > problem with prefork though is that you can end up with lots of > process, all consuming the maximum your Django application will use. > > For memory constrained VPS systems, using 'worker' MPM is a better > choice as you cut down on the number of Apache child processes and > therefore memory, with concurrency then coming from multithreading, > but also from fact that multiple processes still may also be running. > > You might have a read of: > > http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading > > which talks about the different process/threading models that Apache > provides and how mod_wsgi makes use of them and extends on them. > > In respective of thread safety of Django, where does it say it is 'not > officially thread safe'. I know that it is implied through fact they > suggest prefork when using mod_python, but they also don't say to > avoid mod_python on Windows, which is multithread, plus FASTCGI > examples give examples using multithreading. So, there is actually > conflicting information on the issue. > > As explained in: > > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > the situation seems to be that there are no known current issues with > Django itself in respect of multithreading. Thus, any multithread > problems are more likely to come from the application built by a user > using Django. So, it is just a matter of testing your application so > you are satisfied that there isn't a problem. > > > I looked at mod_wsgi and decided to try fastcgi since the Django docs > > explicitly support it. But, given my problems perhaps I'll try > > mod_wsgi next. > > That there is nothing in Django documentation about mod_wsgi is more > to do with no one offering up anything to add which mentions it. The > Django documentation on mod_wsgi site is reasonably comprehensive and > maybe even a link to that would be a good start. I haven't offered > anything up myself for the Django site as believe that it has to be > the Django developers/community that first need to work out whether > they see it as a viable option and when they are happy add a link to > it. > > FWIW, people are using mod_wsgi quite happily with Django. I know of a > couple of notable Django sites which are delaying looking at moving > until mod_wsgi 2.0 is released as that will be the first version which > allows Python code to be used to implement Apache HTTP authentication > provider. For what those sites do, having that feature is critical and > they can't move away from mod_python until mod_wsgi provides an > equivalent mechanism. > > Graham > > > On Dec 5, 8:26 pm, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > On Dec 6, 12:04 pm, TP <[EMAIL PROTECTED]> wrote: > > > > > I've been using Django for the past few months and had great results > > > > with Apache and mod_python. However, I'd like to try and reduce the > > > > amount of memory that is used by having multiple Apache's each with > > > > their own copy of my application. I decided to try mod_fastcgi in > > > > Apache and Django's FastCGI server capability. > > > > Why have multiple Apache's if using mod_fastcgi. You should be able to > > > hang multiple FASTCGI hosted applications hanging off the one Apache. > > > > BTW, you might also want to look at mod_wsgi. Allows you to run Django > > > in separate process of their own just like FASTCGI, but everything > > > still managed by Apache without the need for you to separately start > > > Django or use any supervisor system to keep it running. > > > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to tell generic create view about ForeignKey
Hello, I Have this model: class BlogComment(Model): blogEntry = ForeignKey(BlogEntry, edit_inline=STACKED, num_in_admin=1) author = CharField(max_length=100, core=True) authorMail = EmailField(blank=True) content = TextField(core=True) Now I want to use the generic.create_update.create_object to create an BlogComment. My question is how to define which BlogEntry object it uses as ForeignKey? Thanks, Florian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Combating submission form Spam
Ned Batchelder wrote: > I have been hoping, but not managing, to find the time to create a > Django implementation of my anti-spam technique: Stopping Spambots with > hashes and honeypots (http://nedbatchelder.com/text/stopbots.html). It > works very effectively without any extra work on the part of real humans. Today or tomorrow the company I work for (PreFab Software) will be releasing a blogging app for Django that includes a comment app implementing your honeypot ideas. Stay tuned here or at http://blog.blogcosm.com for an announcement. Kent > > --Ned. > > Darryl Ross wrote: >> Hey All, >> >> One of the websites I run has started getting spam via the contact form. >> >> What is the recommended way of dealing with this? Do I need to go the >> route of using something like django-captcha? >> >> Thanks for any insight. >> >> Regards >> Darryl >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom Feed Elements
Is there an easy way to add custom RSS elements using the syndication framework? I have a client who wants to use the Media RSS namespace: http://en.wikipedia.org/wiki/Media_RSS Thanks, J --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems saving values from SelectDateWidget
Hmm just to add on. This not only happen with SelectDateWidget. It happens with DateField with TextInput Widget too and also ModelChoiceField. Saving all other fields work fine. #these 2 >.< country = forms.ModelChoiceField(queryset=Country.objects.all() ) birth_date = forms.DateField() #When I save #get the particular object #save other fields, work fine as I tested it by disabling the 2 fields below in the forms and the model #save this 2 fail, both will fail user_profile.country = self.cleaned_data['country'] user_profile.birth_date = self.cleaned_data['birth_date'] user_profile.save() Integrity Error will occur telling me country.id cannot be null, birth_date cannot be null. Creating a form with form_for_instance or form_for_model work perfectly fine. I'm using pysqlite Hope this extra information helps Thanks from a newb. :) On Dec 6, 2:24 am, RajeshD <[EMAIL PROTECTED]> wrote: > On Dec 5, 10:31 am, Stupid Dustbin <[EMAIL PROTECTED]> > wrote: > > > Thanks for the reply. However, after updating to the latest SVN > > version of django. The same error still occurs. :( > > I am using the same constructs with Django rev #6652 in production. > Perhaps you want to downgrade to that revision and try it out one more > time? If that fails, it would be time to open a ticket. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ordering. missing FROM-clause entry for table "locations_location"
Hi, > "locations_location" is really missing in FROM-clause entry... why? Drop in to "manage.py shell", and try a query set with the ordering "locations_location.id". Does that work? If not, add a select_related() to your query set. Does that work? If not, verify that the Location table is in an app called locations (in other words, the table name is really locations_location in your DB and not somethingelse_location.) > How can I get ordering I need? If you just need ordering by location.id, you don't need Django to join in the location table at all. Just change this: ordering = ['locations_location.id', 'parent', 'id'] to this: ordering = ['location', 'parent', 'id'] -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: (solved) Re: Custom template tag and filters in resolve_variable
Nice Nice, i 'll add this to my django reference sheet On Dec 6, 3:34 pm, Empty <[EMAIL PROTECTED]> wrote: > Nice info. This was just asked on the IRC channel a couple nights > ago. I'll be sure to pass it on. > > Michael Trier > blog.michaeltrier.com > > On Dec 5, 2007 7:09 PM, Michal Ludvig <[EMAIL PROTECTED]> wrote: > > > > > Michal Ludvig wrote: > > > > for the project I'm working on I needed to create a custom template tag, > > > call it 'mytag'. > > > > If I use it as {% mytag something %} everything goes fine (where > > > 'something' is a string passed to the template). > > > However I can't add any filters to that 'something'. As soon as I do: > > > {% mytag something|upper %} > > > I get an exception: > > > VariableDoesNotExist at /test/ > > > Failed lookup for key [something|upper] > > > > That leads to a code in MytagNode.render() method: > > > actual_message = resolve_variable(self.message, context) > > > where self.message is the argument passed to the macro, in this case > > > it's a string 'something|upper'. > > > > Is there an easy way to run all the attached filters in MytagNode? > > > For the record: > > There is a FilterExpression class in django.template that does exactly > > what I need. So for the tag implementation, instead of: > > > === > > from django.template import resolve_variable > > > @register.tag > > def mytag(parser, token): > > tag_name, message = token.split_contents() > > [...] > > return MytagNode(message) > > > class MytagNode(template.Node): > > [...] > > def render(self, context): > > actual_message = resolve_variable(self.message, context) > > [...] > > === > > > I do it like this: > > > === > > from django.template import FilterExpression > > > @register.tag > > def mytag(parser, token): > > [...] > > filter_expression = FilterExpression(message, parser) > > return MytagNode(filter_expression) > > > class MytagNode(template.Node): > > [...] > > def render(self, context): > > actual_message = self.filter_expression.resolve(context) > > [...] > > === > > > The filter_expression.resolve(context) runs all the filters attached to > > the variable and things work as expected. The 'parser' argument even > > makes it aware of custom filters loaded through {% load ... %} tags. > > > Lesson learned, note taken. > > > Michal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ordering. missing FROM-clause entry for table "locations_location"
On 06-Dec-07, at 9:04 PM, Empty wrote: > http://www.mail-archive.com/django-users@googlegroups.com/ > msg37967.html > > and this: > > http://www.djangoproject.com/documentation/db-api/#order-by-fields read it, implemented it - still get the same error -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ Foss Conference for the common man: http://registration.fossconf.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ordering. missing FROM-clause entry for table "locations_location"
Read this: http://www.mail-archive.com/django-users@googlegroups.com/msg37967.html and this: http://www.djangoproject.com/documentation/db-api/#order-by-fields Michael Trier blog.michaeltrier.com On Dec 6, 2007 10:21 AM, sector119 <[EMAIL PROTECTED]> wrote: > > Hi! > > I use current trunk and I can't order by location field. When I try, > I'he get an error: missing FROM-clause entry for table > "locations_location" LINE 1: ... FROM > "organizations_organizationoffice" ORDER BY "locations... ^ > Exception Location: /home/sector119/devel/django_src/django/db/ > backends/util.py in execute, line 18 > > Traceback: > params [] > self > sql 'SELECT > "organizations_organizationoffice"."id","organizations_organizationoffice"."parent_id","organizations_organizationoffice"."location_id","organizations_organizationoffice"."name","organizations_organizationoffice"."bank","organizations_organizationoffice"."account","organizations_organizationoffice"."bic","organizations_organizationoffice"."code","organizations_organizationoffice"."in_testmode","organizations_organizationoffice"."day_is_open" > FROM "organizations_organizationoffice" ORDER BY > "locations_location"."id" ASC LIMIT 100 ' > start 1196954101.1103859 > stop1196954101.1115961 > > "locations_location" is really missing in FROM-clause entry... why? > How can I get ordering I need? > > class OrganizationOffice(models.Model): > parent = models.ForeignKey('self', verbose_name=_('The related > parent office.'), null=True, blank=True) > location = models.ForeignKey(Location, verbose_name=_('The related > location.')) > name = models.CharField(_('Office'), max_length=50) > > def __unicode__(self): > return self.name > > class Meta: > verbose_name = _('Office') > verbose_name_plural = _('Offices') > ordering = ['locations_location.id', 'parent', 'id'] > > class Admin: > pass > > Thanks! > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ordering. missing FROM-clause entry for table "locations_location"
Hi! I use current trunk and I can't order by location field. When I try, I'he get an error: missing FROM-clause entry for table "locations_location" LINE 1: ... FROM "organizations_organizationoffice" ORDER BY "locations... ^ Exception Location: /home/sector119/devel/django_src/django/db/ backends/util.py in execute, line 18 Traceback: params [] self sql 'SELECT "organizations_organizationoffice"."id","organizations_organizationoffice"."parent_id","organizations_organizationoffice"."location_id","organizations_organizationoffice"."name","organizations_organizationoffice"."bank","organizations_organizationoffice"."account","organizations_organizationoffice"."bic","organizations_organizationoffice"."code","organizations_organizationoffice"."in_testmode","organizations_organizationoffice"."day_is_open" FROM "organizations_organizationoffice" ORDER BY "locations_location"."id" ASC LIMIT 100 ' start 1196954101.1103859 stop1196954101.1115961 "locations_location" is really missing in FROM-clause entry... why? How can I get ordering I need? class OrganizationOffice(models.Model): parent = models.ForeignKey('self', verbose_name=_('The related parent office.'), null=True, blank=True) location = models.ForeignKey(Location, verbose_name=_('The related location.')) name = models.CharField(_('Office'), max_length=50) def __unicode__(self): return self.name class Meta: verbose_name = _('Office') verbose_name_plural = _('Offices') ordering = ['locations_location.id', 'parent', 'id'] class Admin: pass Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How can I show only related data on the admin page when using edit_inline?
Thanks Rajesh, I appreciate the reply. > That's because Django can not read your mind. At least, not yet :) > Ha, yes I was being a bit naive. Nevertheless, I thought that there may have been another flag that I could set to tell that that this was what I wanted. You've already answered that anyway: > If you have a real/serious application like that, you should consider > building out your own administrative views. The Admin is fantastic for > maintenance type activities, but once you start needing custom > filters, customer relationships, validations, workflows, it's best to > bite the bullet and create your own rather than trying to find > workarounds to make the Admin make your coffee so to speak. > Good advice, of course. It was cheeky of me to expect the Admin to provide the application functionality as well as a maintenance point :) Cheers, Mathew. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Specifying tables with schema names in models
I've been trying to get django working with a legacy system which I feel could benefit greatly from it, however I've managed to hit a critical snag. Our setup is such that we have tables in multiple schemas, so (for example) there might be one called "app_sys" and another called "app_prod", with tables in each that need to be accessed. Initially I had been working with 0.96 and managed to get things working by specifying db_table values in class Meta with the schema prefix... for example class Documents(models.Model): documentid = models.IntegerField(primary_key=True, db_column='documentid') # ...etc class Meta: db_table = 'app_prod.documents' However, I ended up upgrading to the SVN release (to try and see if slicing query results worked, they don't seem to with Oracle in .96) and now I see that table names are quoted. This means my trick doesn't work anymore, because what gets put into the query is SELECT "APP_PROD.DOCUMENTS"."DOCUMENTID", FROM "APP_PROD.DOCUMENTS" ...etc Of course with the quotes, Oracle is looking in the user's schema for a table named with the period, which doesn't exist. Naturally, what I was doing was pretty hackish, so I'm not bothered that this particular approach doesn't work (it seemed pretty sketchy anyways), but on the other hand if I can't figure out how to specify the full schema and table name in SOME way, it seems to kill this effort completely. Does anyone have any ideas for a way around this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How can I show only related data on the admin page when using edit_inline?
Hi Mathew, > class Party(models.Model): > > > class Partygoer(models.Model): > > party = models.ForeignKey(Party) > > class Conversation(models.Model): > party = models.ForeignKey(Party, edit_inline=models.TABULAR) > partygoer = models.ForeignKey(Partygoer, core=True) > subject = models.CharField(max_length=50) > Assuming that the database is full of Parties and Partygoers, I can then > go to the Party admin page and add a Conversation by selecting a > Partygoer in the drop down box. This all works OK - but the list of > Partygoers would be unnecessarily long. It should only show Partygoers > from that one Party - the one whose page I'm currently on. However, it > shows a complete list of Partygoers instead. That's because Django can not read your mind. At least, not yet :) At the point where you are creating inline Conversations under a Party, the Django Admin treats partygoer and subject as just additional regular fields. The Admin doesn't follow Conversation.partygoer back to a specific Party via the Foreign Key because it can't assume that all use-cases will always want that kind of restriction just because Conversation.partygoer somehow relates back to a Party through an intermediate object. There can easily be another use-case where all partygoers may be selected in the inline object. > > This seems quite pointless now, but my real application (nothing to do > with parties!) has quite a lot of data, and the drop-downs are filled > with hundreds of unnecessary entries. How can I restrict it to just the > applicable ones? Is there an edit_inline setting I'm missing, or is the > admin system just not built for this kind of relationship? > If you have a real/serious application like that, you should consider building out your own administrative views. The Admin is fantastic for maintenance type activities, but once you start needing custom filters, customer relationships, validations, workflows, it's best to bite the bullet and create your own rather than trying to find workarounds to make the Admin make your coffee so to speak. -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Order By Calculated Value??
On Dec 5, 5:17 pm, "Tane Piper" <[EMAIL PROTECTED]> wrote: > Here is my blog application, which contains the two models: Thanks. So, as I said in the post above, Entry.save() override won't work with your M2M categories. That's because the M2M objects are saved only after the Entry is saved and rightfully so. Besides the solutions I had listed in my first reply above, you might consider another one: Create an explicit M2M table instead of the one Django implicitly creates for an M2M field. With your own M2M class/table, you will be able to override its save() method and launch appropriate count calculations there. See here for an example of how this is intermediate M2M pattern is accomplished: http://www.djangoproject.com/documentation/models/m2m_intermediary/ -Rajesh Dhawan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How can I show only related data on the admin page when using edit_inline?
Hi all, I'm having trouble restricting the values of the drop-down boxes on an edit_inline admin section to reflect the value of the parent page that it's being edited in. For example (this is not my project, but something simpler I just thought of). Say, for some bizarre reason, I wanted to record the people I'd seen at parties, and the conversations I'd had with them. I'd have a Party model with some info, and a Partygoer model linked by FK to a Party. Then I'd have a Conversation model. class Party(models.Model): class Partygoer(models.Model): party = models.ForeignKey(Party) class Conversation(models.Model): party = models.ForeignKey(Party, edit_inline=models.TABULAR) partygoer = models.ForeignKey(Partygoer, core=True) subject = models.CharField(max_length=50) Now, I really only need a foreign key linking a Conversation with a Partygoer (because that would, in turn, link it to a party), but I want to be able to add conversations inline via the Party page instead, so I add an FK to Party as well, and set it to edit_inline. Assuming that the database is full of Parties and Partygoers, I can then go to the Party admin page and add a Conversation by selecting a Partygoer in the drop down box. This all works OK - but the list of Partygoers would be unnecessarily long. It should only show Partygoers from that one Party - the one whose page I'm currently on. However, it shows a complete list of Partygoers instead. This seems quite pointless now, but my real application (nothing to do with parties!) has quite a lot of data, and the drop-downs are filled with hundreds of unnecessary entries. How can I restrict it to just the applicable ones? Is there an edit_inline setting I'm missing, or is the admin system just not built for this kind of relationship? Many thanks, Mathew. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Order By Calculated Value??
Hi Darryl and Tane, > > [untested with Many2Many, but should work, it works for ForeignKeys] Actually, the approach below won't work for M2M even though it does for FKs. > In your Entry save() method call the save method of each of your related > categories after you do your super().save() > > {{{ > class Entry(models.Model): > ... > def save(self): > if not self.slug: > self.slug = slugify(self.title) > super(Entry, self).save() > for category in self.categories: > category.save() > ... Entry.save() is called /before/ the M2M category table is updated by Django. That means this save() can not iterate over Categories. This will work (albeit, incorrectly) when an existing Entry is being updated because it will already have some old M2M categories but it won't work when creating a new Entry as self.categories would not be available during this save(). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Combating submission form Spam
I have been hoping, but not managing, to find the time to create a Django implementation of my anti-spam technique: Stopping Spambots with hashes and honeypots (http://nedbatchelder.com/text/stopbots.html). It works very effectively without any extra work on the part of real humans. --Ned. Darryl Ross wrote: > Hey All, > > One of the websites I run has started getting spam via the contact form. > > What is the recommended way of dealing with this? Do I need to go the > route of using something like django-captcha? > > Thanks for any insight. > > Regards > Darryl > > -- Ned Batchelder, http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there a better way to do this with the DB API?
On Wed, 2007-12-05 at 20:02 -0800, globophobe wrote: [...] > class Stack(models.Model): > title = models.CharField(max_length=100) > description = models.TextField() > > def __unicode__(self): > return self.title > > class Card(models.Model): > stack = models.ForeignKey(Stack) > front = models.TextField(core=True) > back = models.TextField(core=True) > > class Meta: > ordering = ['id'] > > def __unicode__(self): > return self.id > > class Study(models.Model): > user = models.ForeignKey(User) > stack = models.ForeignKey(Stack) > card = models.ForeignKey(Card) > total_correct = models.IntegerField() > total_incorrect = models.IntegerField() > average_correct = models.FloatField() > > def __unicode__(self): > return self.id > > Basically, the Study model is a record of a users study history for a > card. It doesn't have a ForeignKey to a stack Yes it does. Right there in the second attribute (called "stack"). So what do you really mean? > as I only want rows to > be inserted after a study session i.e. I don't want to create a record > for each card for each user, even if it may be necessary eventually, > because the number of records in Study could quickly amount to the > tens or hundreds of thousands. > > A session has 20 or so cards which are sourced first from the Study > model and then from cards in the Stack that are not yet contained in > the Study model per user in question. I've tried to think about this for more than a few minutes and I don't understand what you're saying here. There seem to be a few problems with your models that just don't match what you're trying to do. Firstly, why is only one Card associated with each Study directly, but each Card can also belong to precisely one Stack and a Study can point to one Stack as well? That's a bit of an odd relationship pattern (after a while, most patterns of links between objects tend to fall into groups, so it might well be that you need this setup, but it looks a bit unusual). You also haven't explained what "study" is in your original query... it's something with a length, but it can't be a Study model instance (since they don't have lengths), so what is it? Malcolm -- Why be difficult when, with a little bit of effort, you could be impossible. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Order By Calculated Value??
Hi darryl, Ok I tried as you said above, but it gives me two problems: When I try to make my first category to use for entries I get this error: instance needs to have a primary key value before a many-to-many relationship can be used. So ok, it's looking for an Entry instance to exist, but the workflow should be to create a category first. So I did a manual insert into the database creating an 'Undefined' category with a pk of 1. However when I then try view the admin screen, I get 'Category matching query does not exist'. From the errors I can see it finds it in the result set, but when I look at the traceback in the kwargs the params are: {'id__exact' : 0} However that's just problem 1. Problem two is in the entry model. I create a first post, and the Undefined category shows up fine in my many to many list - when I try save the entry I get: 'ManyRelatedManager' object is not iterable I tried making your line: for category in self.categories.all, however this still doesn't work. Any ideas??? On 06/12/2007, Darryl Ross <[EMAIL PROTECTED]> wrote: > Hi Tane, > > [untested with Many2Many, but should work, it works for ForeignKeys] > > In your Entry save() method call the save method of each of your related > categories after you do your super().save() > > {{{ > class Entry(models.Model): > ... > def save(self): > if not self.slug: > self.slug = slugify(self.title) > super(Entry, self).save() > for category in self.categories: > category.save() > ... > }}} > > Then in the save method for your Category object you need to calculate > the number of entries in that category before you call super().save() > > {{{ > class Category(models.Model): > ... > def save(self): > if not self.slug: > self.slug = slugify(self.name) > self.num_entries = self.entry_set.count() > super(Category, self).save() > ... > }}} > > Hope that helps, or at least gives you a pointer. > > Regards > Darryl > > > > Tane Piper wrote: > > Here is my blog application, which contains the two models: > > > > from django.db import models > > from django.db.models import permalink > > from django.core import urlresolvers > > from django.contrib.auth.models import User > > from django.template.defaultfilters import slugify > > > > import datetime > > # Create your models here. > > > > class Category(models.Model): > > """ A Category is a way to manage the taxonomy of the site""" > > name=models.CharField(max_length=50) #The name of the category > > description=models.TextField() > > slug=models.CharField(max_length=75, null=True, blank=True) > > active=models.BooleanField() > > generate_feed=models.BooleanField() > > parent=models.ForeignKey('self', null=True, blank=True) > > def __unicode__(self): > > return self.name > > def save(self): > > if not self.slug: > > self.slug = slugify(self.name) > > super(Category, self).save() > > def num_entries(self): > > """Returns the number of entries in this category""" > > return self.entry_set.count() > > num_entries.short_description = "Number of Entries" > > def get_absolute_url(self): > > """Get the URL of this entry to create a permalink""" > > return ('cat-detail', (), { > > "slug": self.slug > > }) > > get_absolute_url = permalink(get_absolute_url) > > class Meta: > > verbose_name_plural = 'Categories' > > class Admin: > > fields = ( > > ('Category Details', {'fields': ('name', > > 'description', 'parent',)}), > > ('Category Settings', {'fields': ('active', > > 'generate_feed', 'slug',)}), > > ) > > list_display = ('name', 'slug', 'active', 'generate_feed', > > 'num_entries', 'parent',) > > search_fields = ['name','parent'] > > > > PUBLISHED_CHOICES = ( > > (0, 'Draft'), > > (1, 'Pending Review'), > > (2, 'Published'), > > (3, 'Archived'), > > ) > > > > class Entry(models.Model): > > title=models.CharField(max_length=255) > > body=models.TextField() > > user=models.ForeignKey(User) > > slug=models.CharField(max_length=75, null=True, blank=True) > > pub_date=models.DateTimeField('date published') > > published=models.IntegerField(max_length=1, > > choices=PUBLISHED_CHOICES, verbose_name="Publishing Status") > > front_page=models.BooleanField(default=True) > > sticky=models.BooleanField() > > allow_comments=models.BooleanField(default=True) > > truncate=models.BooleanField() > > categories=models.ManyToManyField(Category, limit_choices_to = > {'active':1}) > > def save(self): > > if not self.slug: > > self.slug = slugify(self.title) > > super(Entry, self).save() > > def __unicode__(self): > > return "%s" % self.title > > def