NEED HELP
Help! I am trying out Django but I get this error in my console C:\DjangoProj\UserApp>python manage.py syncdb Error: Couldn't install apps, because there were errors in one or more models: UserApp.UserProfile: invalid syntax (models.py, line 12) --- C:\DjangoProj\UserApp\UserProfile\models.py 1. from django.db import models 2. from django.contrib.auth.models import User 3. 4. GENDER_CHOICES = ( 5. ('M', 'Male'), 6. ('F', 'Female'), 7. ) 8. 9. # Create your models here. 10. class UserProfile(models.Model): 11.user_id = models.CharField('User ID', max_length=5, primary_key=True) 12. user_fname = models.CharField('First Name', max_length=30) user_lname = models.CharField('Last Name', max_length=50) user_email = models.EmailField('Email Address', blank=True) user_gndr = models.CharField(max_length=1, choices=GENDER_CHOICES) user_headshot = models.ImageField(upload_to='img', blank=True, null=True) user_bday = models.DateField('Birthday') user_uname = models.ForeignKey(User, unique=True) def __str__(self): return self.user_id --- Thanks Myles --~--~-~--~~~---~--~~ 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: ImportError: No module named django.core.management
Thanks for the reply Karen. I think I'll upgrade to an SVN checkout of Django, as you advised. Thanks a lot for your advice. :-) On Jul 13, 9:54 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Mon, Jul 14, 2008 at 12:40 AM, tampler_knight <[EMAIL PROTECTED]> wrote: > > > Thank you so much for the reply, Karen. Greatly appreciated. > > > I am using Django-0.96.2 which is installed in the C drive of my > > machine (running Windows XP SP2). > > > As advised in the documentation, I tried to use 'setup.py install' but > > I get the following error: > > > C:\Django-0.96.2>setup.py install > > running install > > running build > > running build_py > > error: package directory '\django' does not exist > > > Can you please advise me how I can get rid of this error. > > Honestly I'd recommend upgrading to an SVN checkout of django. That error, > along with other Windows-specific problems with setup.py have been fixed in > the current code. Plus you get over a years worth of bug fixes and > significant improvements (unicode, autoescape, queryset improvements). > Unless you have pre-existing code that you don't want to adjust for > backwards-incompatible changes since 0.96, I see no reason to stick with an > 0.96.x release. > > If you really need to use an 0.96 release, pull just the current setup.py > from SVN. You can download it from > here:http://code.djangoproject.com/browser/django/trunk/setup.py(there are > download links at the bottom of the page) and use it instead of the one that > comes with 0.96. > > 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 -~--~~~~--~~--~--~---
capture http code 413 (file size too large)
I have used the LimitRequestBody directive in the apache conf to set it to 1 mb. so, any files biggers than 1 mb should be rejected. while testing it however, i found that when i try to upload a file larger than 1 mb, it ends up displaying my custom 500.html page.. how can I display another custom error page ? i also tried with this directive in apache conf file: ErrorDocument 413 http://www./413error/ and then defined the 413error in urls.py and tried to display a custom template. but no luck. any ideas ? --~--~-~--~~~---~--~~ 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: ANNOUNCE: Django search with Lucene.
Hi, Ben. I already knew that project, djangosearch and at first my first candidate to use lucene in django is also djangosearch :) but it is under early stage of development and I need the one, which is /* more integrated with django queryset */, not raw lucene query, so I determined to write my own lucene search in django. As you said, PyLucene has threading problems in some circumstance, but with the latest PyLucene(with JCC), which is used in Django search with Lucene I did not found any problems on Threading, but more detailed and sophiscated testing will be needed. Thanks. On Jul 16, 10:32 am, Ben Firshman <[EMAIL PROTECTED]> wrote: > You might be interesting in my GSoC project! > > http://code.google.com/p/djangosearch/ > > Apparently PyLucene has problems with threading, which is why it is > not a priority for djangosearch. Have you run into anything like that? > > Ben > > On 15 Jul 2008, at 06:45, Spike^ekipS wrote: > > > > > Hi, django users and developers. > > > I'm happy to let you know my django application, Django search with > > Lucene(DSL). I try > > to tighly integrate the Lucene with Django, so I find the way to use > > lucene easily in Django. > > > Django search with Lucene(DSL) supports, > > * indexing object automatically when object is saved(update, delete > > also applied in index) > > * search indexed document by django filtering expression > Person.objects_search.filter(name="spike", age=10) > > * indexing the existing object like this, > Person.objects.filter(pk__gte=100).create_index() > > * etc. > > > Make a story short, this is examples, > > === > > person = Person.objects.create( > > name_first="Spike", > > name_last="Ekips", > > ) > > > person.name_first = "New Spike" > > person.name_last = "New Ekips" > > person.save() > Person > .objects > .objects_search > (name_first="Spike").exclude(name_last="ekips").order_by("- > time_added") > Person.objects_search(name_first__icontains="pike").order_by("- > time_added") > Person..objects_search( > > time_added__lte=(datetime.datetime.now() - > > datetime.timedelta(days=10)) > > ) > result = Person.objects_search( > > time_added__lte=(datetime.datetime.now() - > > datetime.timedelta(days=10)) > > ) > > for i in result : > > print i.get("name_first") > > print i.name_first > > print i.pk > > print i.get("__uid__") > > print i.get("name_last") > > === > > object automatically indexed when saved and analyzed and we can digg > > the index db with django model filtering expression. > > > For more information, visit the project > > page,http://code.google.com/p/django-search-lucene/ > > or see the short document > > athttp://django-search-lucene.googlecode.com/files/django-search-lucene... > > . > > > 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: ANNOUNCE: Django search with Lucene.
mark it. thanks for your share. -- Vince Lombardi - "Winning is habit. Unfortunately, so is losing." --~--~-~--~~~---~--~~ 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: ANNOUNCE: Django search with Lucene.
You might be interesting in my GSoC project! http://code.google.com/p/djangosearch/ Apparently PyLucene has problems with threading, which is why it is not a priority for djangosearch. Have you run into anything like that? Ben On 15 Jul 2008, at 06:45, Spike^ekipS wrote: > > Hi, django users and developers. > > I'm happy to let you know my django application, Django search with > Lucene(DSL). I try > to tighly integrate the Lucene with Django, so I find the way to use > lucene easily in Django. > > Django search with Lucene(DSL) supports, > * indexing object automatically when object is saved(update, delete > also applied in index) > * search indexed document by django filtering expression Person.objects_search.filter(name="spike", age=10) > * indexing the existing object like this, Person.objects.filter(pk__gte=100).create_index() > * etc. > > Make a story short, this is examples, > === > person = Person.objects.create( >name_first="Spike", >name_last="Ekips", > ) > > person.name_first = "New Spike" > person.name_last = "New Ekips" > person.save() Person .objects .objects_search (name_first="Spike").exclude(name_last="ekips").order_by("- time_added") Person.objects_search(name_first__icontains="pike").order_by("- time_added") Person..objects_search( >time_added__lte=(datetime.datetime.now() - > datetime.timedelta(days=10)) > ) result = Person.objects_search( >time_added__lte=(datetime.datetime.now() - > datetime.timedelta(days=10)) > ) > for i in result : >print i.get("name_first") >print i.name_first >print i.pk >print i.get("__uid__") >print i.get("name_last") > === > object automatically indexed when saved and analyzed and we can digg > the index db with django model filtering expression. > > For more information, visit the project page, > http://code.google.com/p/django-search-lucene/ > or see the short document at > http://django-search-lucene.googlecode.com/files/django-search-lucene.pdf > . > > 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 -~--~~~~--~~--~--~---
Question
Is there a way to put all models in one directory and all forms in another directory? I like to organize the placement of the files. Or is there are a better way to do it? Or standard placement? Like MyApp | | Models || ||mdlInventory ||mdlItems | | | Forms || ||trnsReceiveStock ||trnsReturnStock ||trnsTransfrStock | | Images || ||this is where I put the images | -- Lib Thanks Myles --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Unique Case Sensitivity
I've run into a strange situation. I have a MySQL database with a table called Feature, with a unique column called text. Given some text, I want to save a new record if hasn't been entered, or retrieve the existing record if it already exists. Oddly enough, this code fails if the current text has already been entered with a different case (e.g. 'abc' vs 'ABC'). try: ftr = Feature(text=text) ftr.save() except MySQLdb.IntegrityError, e: ftr = Feature.objects.get(text=text) As the default behavior, this seems misleading, since whether or not the ORM is case-sensitive, I'd expect the creation and retrieval function to be consistent. If save() fails to insert "Abc" because "abc" has already been inserted, then I'd expect get(text="Abc") to return the record for "abc". Is this the fault of Django's ORM, or some obscure MySQL setting? Regards, Chris --~--~-~--~~~---~--~~ 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: Complex queryset construction
How about: Item.objects.filter(categories__watching__user=request.user).distinct() I haven't tested it, but if it works it would return all items watched by the user. Then, to display items by category, I would use the regroup tag [1] in the template. [1] http://www.djangoproject.com/documentation/templates/#regroup On Jul 16, 6:51 am, Burr Settles <[EMAIL PROTECTED]> wrote: > Hey fellow djanglers, > > I am trying to construct a view that's a bit complicated, and > struggling to create the proper queryset. Hopefully some of you have > done something like this before, or otherwise have some ideas on how > to tackle it efficiently. > > Imagine we have something like these models: > > class Category(models.Model): > name = models.CharField(max_length=100) > slug = models.SlugField(unique=True) > > class Watching(models.Model): > user = models.ForeignKey(User) > category = models.ForeignKey(Category) > priority = models.IntegerField() > > class Item(models.Model): > name = models.CharField(max_length=100) > description = models.TextField(blank=True) > categories = models.ManyToManyField(Category) > > What I want to do is create a view at "http://example.com/watchlist/; > that will show all *items* belonging to all categories which the > logged-in user is "watching." So, the queryset needs to be a set of > Item objects, but needs to follow a conditional chain like this: Item -> > Category -> Watching -> User -> "ME." This involves a mix of foreign- > > key and many-to-many relationships, since users can be watching > multiple categories, and items can also belong to multiple categories > (which can, in turn, have multiple items). It should also deal with > duplicates in case an item belongs to multiple categories that are all > being watched by the user. (Hopefully that all makes sense!) > > Anyway, this particular kind of queryset construction is a little > unclear to me from the Django DB API documentation. > > Any ideas? > > --B --~--~-~--~~~---~--~~ 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: url (reverse) as a filter
I guess you would have to preprocess the text with the template system, reversing all the URLs, and then pass it to markdown processing. So, you'd have: ({% url mylink %} "Check this link") On Jul 16, 3:11 am, gzy <[EMAIL PROTECTED]> wrote: > Hi, > > I like the idea of seperating the.. "address space" of a website from > the templates. On the other > hand I'm keeping most of the content in the db and displaying through > the markup filter. > So I'm looking for a way to feed the url_bit in markdown's [link] > (url_bit "Title") to Django's {% url %} tag. > > Has anybody done sth similiar? If not, what implementation would you > suggest? > > ...or maybe a markdown extension is the way to go? > > grzes --~--~-~--~~~---~--~~ 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: PATH problem?
Awesome Daniel. That was the one. I've got the development server running on the deployment machine. However, there is another PATH problem with Apache / mod_python complaining about missing modules, even if those are on the spot: ImproperlyConfigured: Error importing middleware satchmo.shop.SSLMiddleware: "No module named satchmo.shop.SSLMiddleware" mod_python traceback: http://dpaste.com/65217/ vhost.conf: http://dpaste.com/65219/ Folder "httpdocs" contains a symlink "satchmo" to "/usr/lib/python2.5/ site-packages/satchmo" What could be wrong here? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
legacy site in php
I have what is a very naive question though I didn't find a close enough post that answered what I think is a very general question. I work at a museum and inherited a site done in php (the coding is very problematic but this is not the issue). I will overhaul the site and would like to use Python and Django (I am being asked to make small desktop apps and collective intelligence type interactions so I would rather use a general purpose language across the board suited for all needs). (I have used codeIgniter in php for other projects but the site I inherited uses no php framework) Having never used django or mixed languages on a site, I wonder if there's a way for me to maintain some of the folders I have on the site while using the django framework? These are exhibition websites in their own folders so I would like the following root(django) |_ folder pyA (containg py files) .. I use the term "folder," but know it is controller/view |_ folder pyB (containg py files) |_ folder a (containing php files).. Existing folder on site |_ folder b (containing php files)..existing folder on site Mind you, I don't want to mix the languages at all in single files. I would prefer to use Python, yet would not be able to redo all the smaller exhibition sites My question is, would there be an issue in setting up a structure like above or should I face facts and realize that the site has to continue with php in order to maintain everything integrated? --~--~-~--~~~---~--~~ 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: PATH problem?
On Jul 15, 8:38 pm, Frantisek Malina <[EMAIL PROTECTED]> wrote: > Project is in the folder httpdocs, in this folder there is a symlink > to satchmo. > settings.py, manage.py, urls.py... files are placed in the httpdocs > folder. > > Can I set a project name to something else? > Have you got a blank __init__.py file in the httpdocs folder? You need this for Python to recognise it as a module. -- 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: documentation offline, which CSS?
hi David that looks nice, thanks. hope you can make it work again. thanks André On Tue, Jul 15, 2008 at 6:59 PM, David Larlet <[EMAIL PROTECTED]> wrote: > > > Le 15 juil. 08 à 11:58, Andre Meyer a écrit : > > > hi all > > > > like other people, i tried to get an offline copy of the django > > docs. so, running rst2html from docutils works fine, but there is a > > problem with the links (directing to the site instead of the local > > docs) and it looks a lot less appealing. when using the original CSS > > from the site it looks pretty weird and is hardly readable. > > > > does somebody have a better CSS that matches the site's look and a > > solution for the link problem? could not find anything, so far, > > except for a seemingly dead project. > > > > thanks > > André > > André, > > You can generate the documentation with sphinx[0], once it's installed > you just have to run: > $ sphinx-build django_src/docs/ django_src/docs/_build/ > And then point your browser to the index.html file generated in _build > with a neat css. > > Unfortunately, it seems that it's not possible anymore to build the > docs this way, I'll try to get that feature back in trunk. > > Cheers, > David > > [0] http://sphinx.pocoo.org > > > > > --~--~-~--~~~---~--~~ 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: Quick question about switching to newforms-admin branch....
I assumed that trunk would be moving in the newforms-admin direction, so I've switched already. I would rather do it now than have to backport stuff later... Thanks! Jon Brisibn http://jbrisbin.com On Jul 15, 2008, at 3:50 PM, Dan wrote: > Should I start with the nfa branch or with trunk and update the code > when it is merged? Is there risks of breakage in nfa? Other issues? > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Complex queryset construction
Hey fellow djanglers, I am trying to construct a view that's a bit complicated, and struggling to create the proper queryset. Hopefully some of you have done something like this before, or otherwise have some ideas on how to tackle it efficiently. Imagine we have something like these models: class Category(models.Model): name = models.CharField(max_length=100) slug = models.SlugField(unique=True) class Watching(models.Model): user = models.ForeignKey(User) category = models.ForeignKey(Category) priority = models.IntegerField() class Item(models.Model): name = models.CharField(max_length=100) description = models.TextField(blank=True) categories = models.ManyToManyField(Category) What I want to do is create a view at "http://example.com/watchlist/; that will show all *items* belonging to all categories which the logged-in user is "watching." So, the queryset needs to be a set of Item objects, but needs to follow a conditional chain like this: Item - > Category -> Watching -> User -> "ME." This involves a mix of foreign- key and many-to-many relationships, since users can be watching multiple categories, and items can also belong to multiple categories (which can, in turn, have multiple items). It should also deal with duplicates in case an item belongs to multiple categories that are all being watched by the user. (Hopefully that all makes sense!) Anyway, this particular kind of queryset construction is a little unclear to me from the Django DB API documentation. Any ideas? --B --~--~-~--~~~---~--~~ 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: Quick question about switching to newforms-admin branch....
Should I start with the nfa branch or with trunk and update the code when it is merged? Is there risks of breakage in nfa? Other issues? --~--~-~--~~~---~--~~ 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: ImportError: No module named core
> I've been trying to setup Django on Dreamhost and I haven't had much > luck. My latest error / problem is this: > > django-admin.py > Traceback (most recent call last): > File "/home/username/projects/django/trunk/django/bin/django- > admin.py", line 2, in ? > from django.core import management > ImportError: No module named core > > and here is that file: > > #!/usr/bin/env python > from django.core import management > > if __name__ == "__main__": > management.execute_from_command_line() > > I'm using the setup tutorial located > at:http://www.gordontillman.info/Development/DjangoDreamhost > > If you can point me in the right direction I would appreciate it. Seems like a PYTHONPATH problem; what is it set to?. Either that, or you quite literally used 'username' in your paths, as above in the error message (which makes it appear odd that you can actually run django-admin.py). --~--~-~--~~~---~--~~ 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 error in admin interface when adding a new record (core.js and RelatedObjectLookups.js?)
Disregard. Odd issue with my ADMIN_MEDIA_PREFIX. On Jul 15, 2:13 pm, Huuuze <[EMAIL PROTECTED]> wrote: > When I click the button to add a new Person object (one of my objects, > not the User object) in the admin interface, I receive the following > error in my console window: > > ERROR: invalid input syntax for integer: "static_media/admin/js/ > core.js" > STATEMENT: SELECT "person_person"."id", "person_person"."first_name", > "person_person"."last_name" FROM "person_person" WHERE > "person_person"."id" = E'static_media/admin/js/core.js' > ERROR: invalid input syntax for integer: "static_media/admin/js/ > core.js" > STATEMENT: SELECT "person_person"."id", "person_person"."first_name", > "person_person"."last_name" FROM "person_person" WHERE > "person_person"."id" = E'static_media/admin/js/core.js' > ERROR: current transaction is aborted, commands ignored until end of > transaction block > STATEMENT: SELECT "person_person"."id", "person_person"."first_name", > "person_person"."last_name" FROM "person_person" > [15/Jul/2008 17:57:54] "GET /admin/person/person/static_media/admin/js/ > core.js/ HTTP/1.1" 500 89312 > [15/Jul/2008 17:57:54] "GET /admin/person/person/static_media/admin/js/ > admin/RelatedObjectLookups.js HTTP/1.1" 301 0 > ERROR: invalid input syntax for integer: "static_media/admin/js/admin/ > RelatedObjectLookups.js" > STATEMENT: SELECT "person_person"."id", "person_person"."first_name", > "person_person"."last_name" FROM "person_person" WHERE > "person_person"."id" = E'static_media/admin/js/admin/ > RelatedObjectLookups.js' > ERROR: invalid input syntax for integer: "static_media/admin/js/admin/ > RelatedObjectLookups.js" > STATEMENT: SELECT "person_person"."id", "person_person"."first_name", > "person_person"."last_name" FROM "person_person" WHERE > "person_person"."id" = E'static_media/admin/js/admin/ > RelatedObjectLookups.js' > ERROR: current transaction is aborted, commands ignored until end of > transaction block > STATEMENT: SELECT "person_person"."id", "person_person"."first_name", > "person_person"."last_name" FROM "person_person" > > The page still renders fine and the admin interface works, but it's > odd that this error just started appearing. Any thoughts? For what > it's worth, here is my Model and I'm using Postgresql: > > class Person(models.Model): > first_name = models.CharField(max_length=30, blank=True, > null=True) > last_name = models.CharField(max_length=30, blank=True, null=True) > > def __unicode__(self): > return ' '.join([self.first_name, self.last_name]) > > class Admin: > list_display = ('first_name', 'last_name') --~--~-~--~~~---~--~~ 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: Dynamic form not running
Cleaned and documented the views.py file: http://dpaste.com/hold/65184/ Joshua Jonah wrote: > Ok, here we go. I'm using the previous form to display lists of > categories of checkboxes *breath*. > > Here it is: http://www.hftvnetwork.com/ProIn/ > > I'm having problems getting it to only show the amount of blanks it > needs, it looks like it closes the last column div and then outputs > even more blanks. > > Here's the view: > > http://dpaste.com/hold/65175/ > > It's a little crazy, but when looking at the page, you understand why. > > Any ideas on why it can't seem to divide by four correctly? > > > Joshua Jonah wrote: >> You're the man, and about the float() thing, i couldn't get it to >> work before and that fixed it believe it or not. >> >> I'm still having trouble with this but in another area, I'll dpaste a >> bunch and post it. >> >> Marty Alchin wrote: >>> On Tue, Jul 15, 2008 at 2:19 PM, joshuajonah <[EMAIL PROTECTED]> wrote: >>> White forever, never loads in the browser. I have changed it today, but i cannot figure out what i screwed up. http://dpaste.com/hold/65163/ It makes a ton of checkboxes in four columns, it then adds blank fields for new options until it is divisible by 4 so that it fits the 4 column layout right. >>> >>> >From what I can tell, your "divisiblebyfour" function is your problem. >>> Namely, you're usign "is" in a way it's not supposed to be used. >>> >>> "is" is Python's way of determining if two references point to the >>> same object, not whether two objects are equivalent. This is typically >>> used with complex objects that define a method to deal with it, but >>> it's a little tricky for things like numbers. Consider the following >>> interactive interpreter session: >>> >>> >> 0 is 0 >> >>> True >>> >> 0.0 is 0.0 >> >>> True >>> >> 0.0 is 0 >> >>> False >>> >> test = 0 >> test is 0 >> >>> True >>> >> test = 0.0 >> test is 0.0 >> >>> False >>> >>> And, to be clear about your specific case: >>> >>> >> float(8) % float(4) >> >>> 0.0 >>> >> float(8) % float(4) is 0.0 >> >>> False >>> >> float(8) % float(4) is 0 >> >>> False >>> >>> Because you're using "is not" in your function, that expression will >>> *always* be True, and your function will *always* return False, >>> regardless of what input you give it. Since you looping over it "while >>> not divisiblebyfour(...)", that test will *always* succeed and your >>> loop will *never* end. However, look what happens when we use the >>> appropriate operator, "==". >>> >>> >> 0.0 == 0.0 >> >>> True >>> >> 0 == 0 >> >>> True >>> >> 0.0 == 0 >> >>> True >>> >> float(8) % float(4) == 0.0 >> >>> True >>> >> float(8) % float(4) == 0 >> >>> True >>> >> 8 % 4 == 0 >> >>> True >>> >> 7.5 % 2.5 == 0 >> >>> True >>> >> 10 % 2.5 == 0 >> >>> True >>> >>> Note those last ones, too. You don't need to cast to floats for the >>> modulo to work properly, so it's a bit unnecessary. Also, any number >>> other than zero evaluates to True on its own anyway, so you don't even >>> need that if block in the function. Better yet, with those things >>> taken out, that function gets so small that you can just get rid of it >>> if you want: >>> >>> while not (len(templist) + amountofblanks) % 4: >>> amountofblanks += 1 >>> >>> That'll work quite well for what you're doing, without dealing with an >>> extra function and all the hassle. Hope this helps. >>> >>> -Gul >>> >>> >>> >>> >> >> >> > > > > --~--~-~--~~~---~--~~ 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 access the label of a model instance
On Tue, Jul 15, 2008 at 2:08 PM, Arien <[EMAIL PROTECTED]> wrote: > Oh, I see, you want the verbose_name of each field. I suppose you > could write a templatetag that you could use like this: > > {% verbose_name layer.heating_temperature %} > {{ layer.heating_temperature }} > > After parsing the templatetag's argument, you'd resolve the model > instance and insert this in the template: > > model_instance._meta.get_field(field_name).verbose_name The basic idea (and only that): class VerboseNameNode(template.Node): def __init__(self, model, field): self.model, self.field = model, field def render(self, context): model = template.Variable(self.model).resolve(context) return model._meta.get_field(self.field).verbose_name def do_verbose_name(parser, token): tag_name, var = token.split_contents() model, field = var.split('.') return VerboseNameNode(model, field) Arien --~--~-~--~~~---~--~~ 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: Quick question about switching to newforms-admin branch....
On Jul 15, 3:30 pm, Jason <[EMAIL PROTECTED]> wrote: > ...and it is: if I were to switch my current django project over to > newforms-admin branch, would it break all of the old admin pages? Yes. > Or > is there legacy support built in? It isn't. But the following snippet might help create quick starting points for your new admin.py files from your old Admin inner class definitions: http://www.djangosnippets.org/snippets/603/ --~--~-~--~~~---~--~~ 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: PATH problem?
Project is in the folder httpdocs, in this folder there is a symlink to satchmo. settings.py, manage.py, urls.py... files are placed in the httpdocs folder. Can I set a project name to something else? On 15. Júl, 20:48 h., Joshua Jonah <[EMAIL PROTECTED]> wrote: > In your httpd.conf, there's this line: > > SetEnv DJANGO_SETTINGS_MODULE httpdocs.settings > > Is your project named "httpdocs"? thats should be the name of the > project. I'm guessing it should be "satchmo". > > Frantisek Malina wrote: > > settings.py > >http://dpaste.com/65171/ > > > vhost.conf > >http://dpaste.com/65172/ > > > Not that these are short and sweet, but I am running a similar setup > > on the local machine. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Quick question about switching to newforms-admin branch....
...and it is: if I were to switch my current django project over to newforms-admin branch, would it break all of the old admin pages? Or is there legacy support built in? Thanks mucho in advance! --~--~-~--~~~---~--~~ 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: Dynamic form not running
Ok, here we go. I'm using the previous form to display lists of categories of checkboxes *breath*. Here it is: http://www.hftvnetwork.com/ProIn/ I'm having problems getting it to only show the amount of blanks it needs, it looks like it closes the last column div and then outputs even more blanks. Here's the view: http://dpaste.com/hold/65175/ It's a little crazy, but when looking at the page, you understand why. Any ideas on why it can't seem to divide by four correctly? Joshua Jonah wrote: > You're the man, and about the float() thing, i couldn't get it to work > before and that fixed it believe it or not. > > I'm still having trouble with this but in another area, I'll dpaste a > bunch and post it. > > Marty Alchin wrote: >> On Tue, Jul 15, 2008 at 2:19 PM, joshuajonah <[EMAIL PROTECTED]> wrote: >> >>> White forever, never loads in the browser. I have changed it today, >>> but i cannot figure out what i screwed up. >>> >>> http://dpaste.com/hold/65163/ >>> >>> It makes a ton of checkboxes in four columns, it then adds blank >>> fields for new options until it is divisible by 4 so that it fits the >>> 4 column layout right. >>> >> >> >From what I can tell, your "divisiblebyfour" function is your problem. >> Namely, you're usign "is" in a way it's not supposed to be used. >> >> "is" is Python's way of determining if two references point to the >> same object, not whether two objects are equivalent. This is typically >> used with complex objects that define a method to deal with it, but >> it's a little tricky for things like numbers. Consider the following >> interactive interpreter session: >> >> > 0 is 0 > >> True >> > 0.0 is 0.0 > >> True >> > 0.0 is 0 > >> False >> > test = 0 > test is 0 > >> True >> > test = 0.0 > test is 0.0 > >> False >> >> And, to be clear about your specific case: >> >> > float(8) % float(4) > >> 0.0 >> > float(8) % float(4) is 0.0 > >> False >> > float(8) % float(4) is 0 > >> False >> >> Because you're using "is not" in your function, that expression will >> *always* be True, and your function will *always* return False, >> regardless of what input you give it. Since you looping over it "while >> not divisiblebyfour(...)", that test will *always* succeed and your >> loop will *never* end. However, look what happens when we use the >> appropriate operator, "==". >> >> > 0.0 == 0.0 > >> True >> > 0 == 0 > >> True >> > 0.0 == 0 > >> True >> > float(8) % float(4) == 0.0 > >> True >> > float(8) % float(4) == 0 > >> True >> > 8 % 4 == 0 > >> True >> > 7.5 % 2.5 == 0 > >> True >> > 10 % 2.5 == 0 > >> True >> >> Note those last ones, too. You don't need to cast to floats for the >> modulo to work properly, so it's a bit unnecessary. Also, any number >> other than zero evaluates to True on its own anyway, so you don't even >> need that if block in the function. Better yet, with those things >> taken out, that function gets so small that you can just get rid of it >> if you want: >> >> while not (len(templist) + amountofblanks) % 4: >> amountofblanks += 1 >> >> That'll work quite well for what you're doing, without dealing with an >> extra function and all the hassle. Hope this helps. >> >> -Gul >> >> >> >> > > > > --~--~-~--~~~---~--~~ 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 access the label of a model instance
On Tue, Jul 15, 2008 at 1:22 PM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > Arien writes: >> You'll have to make layer._meta.verbose_name available to the >> template under some other name. > > Unfortunately, I use model polymorphism and model inheritance in > this case and can't pass anything but the common base class to the > template. How about sticking this on the base class then? @property def verbose_name(self): return self._meta.verbose_name > Therefore, I collect all verbose_names in an "all_labels" dict in my > models.py: > > all_labels = {} > for cls in [cls for cls in _globals.values() if inspect.isclass(cls) and > issubclass(cls, models.Model)]: >local_labels = {} >for field in cls._meta.local_fields: >local_labels[field.name] = field.verbose_name >all_labels[cls.__name__] = local_labels Oh, I see, you want the verbose_name of each field. I suppose you could write a templatetag that you could use like this: {% verbose_name layer.heating_temperature %} {{ layer.heating_temperature }} After parsing the templatetag's argument, you'd resolve the model instance and insert this in the template: model_instance._meta.get_field(field_name).verbose_name Arien --~--~-~--~~~---~--~~ 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: writing unit tests for views?
For what it's worth, I finally came up with a simple working test for views. My tests were written correctly all along, I just had to take care of those errors related to the project settings. It never occurred me to just set constants at the top of the test file, but that's what worked. import os from django.test import Client, TestCase os.environ['MEDIA_LOCATION'] = '/Users/bshaurette/myproject/public' INTERNAL_IPS = ('127.0.0.1',) class ViewTests(TestCase): def setUp(self): self.client = Client() def test_login(self): response = self.client.post('/accounts/login/', {'username': 'bshaurette', 'password': 'bshaurette'}) self.assertEqual(response.status_code, 200) def tearDown(self): self.client.post('/accounts/logout/') (we have a pattern in the base project urls.py that looks for that env variable 'MEDIA_LOCATION' as the location for site media ... hence ... ) --~--~-~--~~~---~--~~ 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: Dynamic form not running
You're the man, and about the float() thing, i couldn't get it to work before and that fixed it believe it or not. I'm still having trouble with this but in another area, I'll dpaste a bunch and post it. Marty Alchin wrote: > On Tue, Jul 15, 2008 at 2:19 PM, joshuajonah <[EMAIL PROTECTED]> wrote: > >> White forever, never loads in the browser. I have changed it today, >> but i cannot figure out what i screwed up. >> >> http://dpaste.com/hold/65163/ >> >> It makes a ton of checkboxes in four columns, it then adds blank >> fields for new options until it is divisible by 4 so that it fits the >> 4 column layout right. >> > > >From what I can tell, your "divisiblebyfour" function is your problem. > Namely, you're usign "is" in a way it's not supposed to be used. > > "is" is Python's way of determining if two references point to the > same object, not whether two objects are equivalent. This is typically > used with complex objects that define a method to deal with it, but > it's a little tricky for things like numbers. Consider the following > interactive interpreter session: > > 0 is 0 > True > 0.0 is 0.0 > True > 0.0 is 0 > False > test = 0 test is 0 > True > test = 0.0 test is 0.0 > False > > And, to be clear about your specific case: > > float(8) % float(4) > 0.0 > float(8) % float(4) is 0.0 > False > float(8) % float(4) is 0 > False > > Because you're using "is not" in your function, that expression will > *always* be True, and your function will *always* return False, > regardless of what input you give it. Since you looping over it "while > not divisiblebyfour(...)", that test will *always* succeed and your > loop will *never* end. However, look what happens when we use the > appropriate operator, "==". > > 0.0 == 0.0 > True > 0 == 0 > True > 0.0 == 0 > True > float(8) % float(4) == 0.0 > True > float(8) % float(4) == 0 > True > 8 % 4 == 0 > True > 7.5 % 2.5 == 0 > True > 10 % 2.5 == 0 > True > > Note those last ones, too. You don't need to cast to floats for the > modulo to work properly, so it's a bit unnecessary. Also, any number > other than zero evaluates to True on its own anyway, so you don't even > need that if block in the function. Better yet, with those things > taken out, that function gets so small that you can just get rid of it > if you want: > > while not (len(templist) + amountofblanks) % 4: > amountofblanks += 1 > > That'll work quite well for what you're doing, without dealing with an > extra function and all the hassle. Hope this helps. > > -Gul > > > > > --~--~-~--~~~---~--~~ 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: PATH problem?
In your httpd.conf, there's this line: SetEnv DJANGO_SETTINGS_MODULE httpdocs.settings Is your project named "httpdocs"? thats should be the name of the project. I'm guessing it should be "satchmo". Frantisek Malina wrote: > settings.py > http://dpaste.com/65171/ > > vhost.conf > http://dpaste.com/65172/ > > Not that these are short and sweet, but I am running a similar setup > on the local machine. > > > > --~--~-~--~~~---~--~~ 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: Dynamic form not running
On Tue, Jul 15, 2008 at 2:19 PM, joshuajonah <[EMAIL PROTECTED]> wrote: > White forever, never loads in the browser. I have changed it today, > but i cannot figure out what i screwed up. > > http://dpaste.com/hold/65163/ > > It makes a ton of checkboxes in four columns, it then adds blank > fields for new options until it is divisible by 4 so that it fits the > 4 column layout right. >From what I can tell, your "divisiblebyfour" function is your problem. Namely, you're usign "is" in a way it's not supposed to be used. "is" is Python's way of determining if two references point to the same object, not whether two objects are equivalent. This is typically used with complex objects that define a method to deal with it, but it's a little tricky for things like numbers. Consider the following interactive interpreter session: >>> 0 is 0 True >>> 0.0 is 0.0 True >>> 0.0 is 0 False >>> test = 0 >>> test is 0 True >>> test = 0.0 >>> test is 0.0 False And, to be clear about your specific case: >>> float(8) % float(4) 0.0 >>> float(8) % float(4) is 0.0 False >>> float(8) % float(4) is 0 False Because you're using "is not" in your function, that expression will *always* be True, and your function will *always* return False, regardless of what input you give it. Since you looping over it "while not divisiblebyfour(...)", that test will *always* succeed and your loop will *never* end. However, look what happens when we use the appropriate operator, "==". >>> 0.0 == 0.0 True >>> 0 == 0 True >>> 0.0 == 0 True >>> float(8) % float(4) == 0.0 True >>> float(8) % float(4) == 0 True >>> 8 % 4 == 0 True >>> 7.5 % 2.5 == 0 True >>> 10 % 2.5 == 0 True Note those last ones, too. You don't need to cast to floats for the modulo to work properly, so it's a bit unnecessary. Also, any number other than zero evaluates to True on its own anyway, so you don't even need that if block in the function. Better yet, with those things taken out, that function gets so small that you can just get rid of it if you want: while not (len(templist) + amountofblanks) % 4: amountofblanks += 1 That'll work quite well for what you're doing, without dealing with an extra function and all the hassle. Hope this helps. -Gul --~--~-~--~~~---~--~~ 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: PATH problem?
settings.py http://dpaste.com/65171/ vhost.conf http://dpaste.com/65172/ Not that these are short and sweet, but I am running a similar setup on the local machine. --~--~-~--~~~---~--~~ 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: PATH problem?
settings.py http://dpaste.com/65171/ vhost.conf http://dpaste.com/65172/ Not that these are short and sweet, but I am running a similar setup on the local machine. --~--~-~--~~~---~--~~ 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: PATH problem?
Post your settings.py and the changes you made in the httpd.conf/vhost.conf Frantisek Malina wrote: > Correct link to mod_python error: > http://dpaste.com/65168/ > > > > --~--~-~--~~~---~--~~ 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 group by two fields simultaneously.
On Tue, 2008-07-15 at 11:24 -0700, Alex wrote: [...] > So my view throws out a list of teams, filtered to the person and my > template looks like this: > > {% for t in teams %} > {% for s in t.getStats %} > ** I WANT TO NOW DO SOMETHING LIKE: ** > {% for v in s.getStatValues(Person,s) %) > ** EXCEPT THAT I CAN'T PASS ARGS IN A TEMPLATE. ** > > But if I don't pass in those arguments I'll get all the statValues for > everyone on the team, not just the person I'm looking at. One fairly normal solution is to write a method that returns the results you want (in a format you can use). For example, you're passing in "s" as an argument to a method on "s", which is usually redundant. So you can write a method that works on "self" there by default. And that method could also know that it should work with "Person" (whatever that is). So, it's a custom method for this case. Alternatively, if the method is purely presentational and not particularly related to whatever object "s" is, write a filter function. Filters can take arguments. So something like: {% for v in s|getStats:"person" %} That way, the getStats() function is divorced from s, but it takes "s" and "person" as two arguments. Regards, Malcolm. --~--~-~--~~~---~--~~ 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: PATH problem?
Correct link to mod_python error: http://dpaste.com/65168/ --~--~-~--~~~---~--~~ 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 group by two fields simultaneously.
I have the following: Model Person Model Stat Model Stat Value Model Team A Team has a set of Stats relevant to it. A person is on multiple teams, and has stats for his/her performance on that team which are stored as Stat Values. Stat values are unique by Person, Stats, and Team. I want to build a view that will show team overviews from the point if view of a single specific person. All his/teams, and the associated stats. So my view throws out a list of teams, filtered to the person and my template looks like this: {% for t in teams %} {% for s in t.getStats %} ** I WANT TO NOW DO SOMETHING LIKE: ** {% for v in s.getStatValues(Person,s) %) ** EXCEPT THAT I CAN'T PASS ARGS IN A TEMPLATE. ** But if I don't pass in those arguments I'll get all the statValues for everyone on the team, not just the person I'm looking at. I wouldn't retrieve it all and then put an {% if v.person=p %} or similar in the template would I? This must be something fairly common. What am I doing wrong? It's an easy SQL statement to write, but how to do it Django style? --~--~-~--~~~---~--~~ 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 access the label of a model instance
Hallöchen! Arien writes: > On Tue, Jul 15, 2008 at 12:00 PM, Torsten Bronger > <[EMAIL PROTECTED]> wrote: >> >> Arien writes: >> >>> On Tue, Jul 15, 2008 at 10:53 AM, Torsten Bronger >>> <[EMAIL PROTECTED]> wrote: >>> In a display template (not a form, just display), I write the following: {% trans 'Temperature:' %} {{ layer.heating_temperature }} I'd like to use the verbose_name of the model instance instead of hard-wiring the label in the template. How can I access it? >>> >>> The verbose_name is at layer._meta.verbose_name. You can't >>> access it like that from your template, though. >> >> Okay, thanks! However, then what is the "official" way to do it? > > [...] > > You'll have to make layer._meta.verbose_name available to the > template under some other name. Unfortunately, I use model polymorphism and model inheritance in this case and can't pass anything but the common base class to the template. Therefore, I collect all verbose_names in an "all_labels" dict in my models.py: all_labels = {} for cls in [cls for cls in _globals.values() if inspect.isclass(cls) and issubclass(cls, models.Model)]: local_labels = {} for field in cls._meta.local_fields: local_labels[field.name] = field.verbose_name all_labels[cls.__name__] = local_labels This I pass to the template, too, so that I can write: {{ all_labels.SixChamberDeposition.heating_temperature }} {{ layer.heating_temperature }} Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
PATH problem?
I am trying to deploy my app on the production server, however I am having some issues. The development server says: http://dpaste.com/65164/ Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 270, in execute_manager project_directory = setup_environ(settings_mod) File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 251, in setup_environ project_module = __import__(project_name, {}, {}, ['']) ImportError: No module named httpdocs mod_python says: http://dpaste.com/65166/ This is very weird, because I can import settings from the python interpreter without tracebacks. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic form not running
White forever, never loads in the browser. I have changed it today, but i cannot figure out what i screwed up. http://dpaste.com/hold/65163/ It makes a ton of checkboxes in four columns, it then adds blank fields for new options until it is divisible by 4 so that it fits the 4 column layout right. Any idea what is messing up here? I've gone through it for an hour but not finding anything --~--~-~--~~~---~--~~ 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: .pyc files not being created
Ok I think I got it now. Well, now to figure out why my application is eating up over 200mb's of memory without any users... Thanks, Dana On Jul 15, 11:08 am, Jeff Anderson <[EMAIL PROTECTED]> wrote: > Dana wrote: > > @Evert > > > Thanks for the information, Ill be looking into all that today. > > > @Graham, > > > So there is no speed increase in using compiled python than using just > > strait python? So why is python ever compiled in the first place? > > There is a speed increase-- it's just not that big in this situation. It > still compiles it, it just doesn't write out the compiled bytecode in > your case. It will compile it the first time it is accessed, and then > stay in active memory. If the .pyc files were being created on the fly, > it would save that initial request a very small amount of time. You > would see a huge slowdown if you were using python to run cgi, and > python had to load itself into memory, compile the code, and run it for > each and every request. Fortunately with mod_python, this isn't the case. > > Hopefully this makes a little more sense now. > > Cheers! > > Jeff Anderson > > signature.asc > 1KDownload --~--~-~--~~~---~--~~ 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 with Forms (Dynamic Fields)
You have to pass the data into the form when instantiating it, eg: form = MyForm(request.POST) However, that means (for your example), the fields wouldn't exist yet-- move them into __init__ instead. Some other things to note: you don't need to "title" and "email" to the form dynamically--might as well put them in the MyForm class definition. Unless you're planning to upload files, you don't need the enctype attribute in the form tag. -Jeff On Jul 15, 9:54 am, Srik <[EMAIL PROTECTED]> wrote: > Hi Djangoers, > > I'm trying to generate a form dynamically using MyForm (Form class), > but I'm stuck with validating or populating data. > > Form Class, View and template Code here:http://dpaste.com/65080/(not > too many lines I guess :) ) > > Good thing is I can see form (generating dynamically, based on the > category I chose as expected), but I'm not able to do anything after > that . > > When I submit form with empty values, its returning empty form no > matter I enter data or not and also it won't throw any errors(like > field required) > > Thanks, > Srikanth --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Strange error in admin interface when adding a new record (core.js and RelatedObjectLookups.js?)
When I click the button to add a new Person object (one of my objects, not the User object) in the admin interface, I receive the following error in my console window: ERROR: invalid input syntax for integer: "static_media/admin/js/ core.js" STATEMENT: SELECT "person_person"."id", "person_person"."first_name", "person_person"."last_name" FROM "person_person" WHERE "person_person"."id" = E'static_media/admin/js/core.js' ERROR: invalid input syntax for integer: "static_media/admin/js/ core.js" STATEMENT: SELECT "person_person"."id", "person_person"."first_name", "person_person"."last_name" FROM "person_person" WHERE "person_person"."id" = E'static_media/admin/js/core.js' ERROR: current transaction is aborted, commands ignored until end of transaction block STATEMENT: SELECT "person_person"."id", "person_person"."first_name", "person_person"."last_name" FROM "person_person" [15/Jul/2008 17:57:54] "GET /admin/person/person/static_media/admin/js/ core.js/ HTTP/1.1" 500 89312 [15/Jul/2008 17:57:54] "GET /admin/person/person/static_media/admin/js/ admin/RelatedObjectLookups.js HTTP/1.1" 301 0 ERROR: invalid input syntax for integer: "static_media/admin/js/admin/ RelatedObjectLookups.js" STATEMENT: SELECT "person_person"."id", "person_person"."first_name", "person_person"."last_name" FROM "person_person" WHERE "person_person"."id" = E'static_media/admin/js/admin/ RelatedObjectLookups.js' ERROR: invalid input syntax for integer: "static_media/admin/js/admin/ RelatedObjectLookups.js" STATEMENT: SELECT "person_person"."id", "person_person"."first_name", "person_person"."last_name" FROM "person_person" WHERE "person_person"."id" = E'static_media/admin/js/admin/ RelatedObjectLookups.js' ERROR: current transaction is aborted, commands ignored until end of transaction block STATEMENT: SELECT "person_person"."id", "person_person"."first_name", "person_person"."last_name" FROM "person_person" The page still renders fine and the admin interface works, but it's odd that this error just started appearing. Any thoughts? For what it's worth, here is my Model and I'm using Postgresql: class Person(models.Model): first_name = models.CharField(max_length=30, blank=True, null=True) last_name = models.CharField(max_length=30, blank=True, null=True) def __unicode__(self): return ' '.join([self.first_name, self.last_name]) class Admin: list_display = ('first_name', 'last_name') --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Question about a custom inclusion tag
Hi, is there a way to pass an argument from urls.py to inclusion tag? For example, if I have a custom inclusion tag that prints some links to some pages and I don't want it to print the link to the page I'm currently visiting, how would I do it? Let's say that I'm visiting a page /posts/2008. On the bottom of this page, there are links (produced by this inclusion tag) to /posts/2007 and /posts/2006 but also to /posts/2008 since it doesn't know I'm already visiting this page. I was thinking about passing argument from urls (2008) and make it not print this link, but I don't know how? Does anyone have any suggestion how to solve this? Thanks, Matic --~--~-~--~~~---~--~~ 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: escape filter
El mar, 15-07-2008 a las 10:33 -0700, Malcolm Tredinnick escribió: > > I'm definitely not saying you definitely don't need this, but make sure > that you're doing it for the right reasons. Sending UTF-8 in all of it's > non-entity-encoded glory is very normal practice. OK, 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: .pyc files not being created
Dana wrote: @Evert Thanks for the information, Ill be looking into all that today. @Graham, So there is no speed increase in using compiled python than using just strait python? So why is python ever compiled in the first place? There is a speed increase-- it's just not that big in this situation. It still compiles it, it just doesn't write out the compiled bytecode in your case. It will compile it the first time it is accessed, and then stay in active memory. If the .pyc files were being created on the fly, it would save that initial request a very small amount of time. You would see a huge slowdown if you were using python to run cgi, and python had to load itself into memory, compile the code, and run it for each and every request. Fortunately with mod_python, this isn't the case. Hopefully this makes a little more sense now. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: escape filter
El mar, 15-07-2008 a las 12:30 -0500, Arien escribió: > Why do you need to use HTML entities for accented characters? What is > the problem you're trying to solve? > Aren't you suposed to display accented chars and stuff like ¡ or ¿ as html entities? --~--~-~--~~~---~--~~ 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: .pyc files not being created
@Evert Thanks for the information, Ill be looking into all that today. @Graham, So there is no speed increase in using compiled python than using just strait python? So why is python ever compiled in the first place? Thanks! On Jul 15, 6:27 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Jul 15, 8:29 am, blis102 <[EMAIL PROTECTED]> wrote: > > > Hey all, > > > On my Ubuntu server with Apache2 +mod_python, I cant seem to get > > the .py files to compile like they should (I see no .pyc files in my > > "src" folder like I do locally). I believe I have proper permissions > > set (775), but am by no means an expert in this matter. What would > > cause .pyc files to not compile other than the file permissions. Also > > what is the recommended permissions settings for source folders/files, > > and media folders/files? > > Because Apache/mod_python processes are persistent, and py file > loading only happens first time it is required by a process, you don't > actually gain that much in trying to ensure that .pyc/.pyo files > exist. If you were using CGI where every request is a new process, > then it would be an issue. > > In other words, you may be wasting time trying to work this out for > next to no benefit. > > 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 -~--~~~~--~~--~--~---
Re: how to use PythonAuthzHandler with django?
shyt, I was looking for these docs this morning! thanks for the poinger Graham, it seems to be very detailed, and once I forget the hassles I've survived today with mod_python, I'll probably give it a try btw, is there any reason why this documentation can't be found under http://www.djangoproject.com/documentation/install/ or http://www.djangoproject.com/documentation/apache_auth/ ? thanks for your help! V On Jul 15, 3:23 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > FWIW, authen/authz for Apache is much easier done in mod_wsgi. See: > > http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms > > I have given up trying to help people with mod_python authen/authz > because it is such a PITA. :-) > > Graham > > On Jul 15, 9:29 pm, "Viktor Nagy" <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I've set up apache to validate my users using PythonAuthenHandler as > > described in the documentation > > (http://www.djangoproject.com/documentation/apache_auth/). This part > > works like charm :), but I would like to get a more fine grained > > control over the accessed url (not served by django). > > > According tomod_python'sdocs this should be possible using > > PythonAuthzHandler, but in my case it just doesn't work. > > > I have the following in my virtualhost directive > > > > > AuthType Basic > > AuthName 'CooSci' > > AuthUserFile /dev/null > > AuthBasicAuthoritative Off > > Require valid-user > > > SetEnv DJANGO_SETTINGS_MODULE coosci.settings > > PythonAuthenHandler django.contrib.auth.handlers.modpython > > PythonAuthzHandler myproject.auth.modpython > > PythonOption DjangoRequireStaffStatus 0 > > > > > then I use the following modpython.py to test if the setting works > > > frommod_pythonimport apache > > import os > > > def authzhandler(req, **kwargs): > > ''' > > Authentication handler that checks if the given repository can be > > accessed by the authenticated user > > @param req: the Apache request object, > > seehttp://modpython.org/live/mod_python-3.3.1/doc-html/pyapi-mprequest.html > > @type req: object > > ''' > > #mod_pythonfakes the environ, and thus doesn't process SetEnv. This > > fixes > > # that so that the following import works > > os.environ.update(req.subprocess_env) > > > settings_module = req.get_options().get('DJANGO_SETTINGS_MODULE', None) > > if settings_module: > > os.environ['DJANGO_SETTINGS_MODULE'] = settings_module > > > # test if it works > > apache.log_error('authzhandler') > > req.log_error('authzhandler from request with user %s at %s' % > > (req.user, req.uri)) > > > from django.contrib.auth.models import User > > from webapp.models import Editor > > from django import db > > db.reset_queries() > > > # run this at the end > > db.connection.close() > > return apache.OK > > > Any ideas why this doesn't show up in my Apache log files? > > I have Apache 2.2.0 > > > In the meantime I was thinking about other solutions as well. > > Especially as the docs of PythonAuthzHandler says that > > PythonAuthenHander is "more often than not it is done right in the > > AuthenHandler". So it might be a good idea to allow a callback in > > AuthenHandler to get a more fine-grained control over the accessed > > uri. (Of course, this at least partially mixes up things, as the > > authenhandler is supposed to authenticate the user, and it's the > > authzhandler who should allow/deny access of the (already > > authenticated) user to a given uri.) > > > what would be your recommendation? do you see any reason to patch > > django.contrib.auth.handlers.modpython to allow for a callback? > > > Thanks for your help! > > V --~--~-~--~~~---~--~~ 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: Seperate project in a subdirectory (Apache 2.2 & mod_python)
On Jul 15, 12:30 pm, V <[EMAIL PROTECTED]> wrote: > First of all Apache will look through all the directives, > and the later ones overwrite the former ones. So you should definitely > put the more precise one at the bottom. > > Probably your media files work, because you've added something like > urlpatterns += patterns('', > (r'^media/(?P.*)$', > 'django.views.static.serve', > {'document_root': os.path.join(PROJECT_PATH, 'htdocs', > 'media')}), > ) > to you urls.py, weren't you? No I have not. I am not serving static files through Django, they are purely served by Apache. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ImportError: No module named core
I've been trying to setup Django on Dreamhost and I haven't had much luck. My latest error / problem is this: django-admin.py Traceback (most recent call last): File "/home/username/projects/django/trunk/django/bin/django- admin.py", line 2, in ? from django.core import management ImportError: No module named core and here is that file: #!/usr/bin/env python from django.core import management if __name__ == "__main__": management.execute_from_command_line() I'm using the setup tutorial located at: http://www.gordontillman.info/Development/DjangoDreamhost If you can point me in the right direction I would appreciate it. Thanks, Jason --~--~-~--~~~---~--~~ 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: escape filter
On Tue, 2008-07-15 at 19:22 +0200, Fernando Rodríguez wrote: > El mar, 15-07-2008 a las 12:25 -0400, Ned Batchelder escribió: > > > You're misunderstanding the role of the escape filter. It isn't meant > > to create HTML entities for accented characters. All it does is escape > > characters that could be dangerous for XSS attacks (" ' < > &). And by > > the way, in the latest code, escaping is automatic, so you may not need > > it at all. > > OK, thanks. That makes sense. > > However, I still need to convert those accented character into html > entities. Is there any pre-built filter for this? I checked the > refrence in "The definitive guide to django" but saw none. > > I can't be the first one in need of this... Well, you probably aren't, but it's worth realising why this isn't something Django does automatically (or is likely to include in core): HTML supports UTF-8 and has done pretty much forever, which means such conversion to entities isn't required on an HTML or browser-level. The main reason for requiring such a conversion in the "good old days" was so that the source file was encoded in 7-bit ASCII. Here in the 21st century, saving non-ASCII files (and non-ASCII data in databases) is pretty much a solved problem in everyday systems, so it's become much less of a requirement. I'm definitely not saying you definitely don't need this, but make sure that you're doing it for the right reasons. Sending UTF-8 in all of it's non-entity-encoded glory is very normal practice. Regards, Malcolm --~--~-~--~~~---~--~~ 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: Don't see form errors in template
> First of all, I want to say that I do not understand the relationship > between forms and models in Django. A form to ask and a model to > store? How to pass the form data to a model? Have I to pass it in > order to validate? There is not necessarily a relationship between the two. You are correct - forms are for gathering user input and models are for storing application data. Django does provide a ModelForm which is meant to provide a convenience of generating a Form based on a Model. However, try not to get too hung up on this. In practice it can be rare that our web forms match exactly with a particular Model definition. Rather it is often the case that a particular web form will collect fields that map to fields on multiple models. In this case you want to build a custom Form containing exactly the fields you need to collect. The act of doing this is meant to save you time in the generation of the actual HTML and in writing validation code. Now that you have your form, a typical use pattern is: 1. In your view, on a GET request you'll instantiate the form without any data and pass if off to the render context. 2. On a POST request (form submit), you'll instantiate the form with the POST data. 3. Call is_valid() on your form to determine if the data validates 4. If the form data is valid, you will then instantiate or lookup your required model(s), update the model fields with the appropriate cleaned_data fields from the form, and save() your models. 5. If the form did not validate, you will again pass it to the render context and this time it will contain the user's submitted values as well as errors. > > The problem with this code is that when I do not enter the name field > it says the form is invalid but the name field is optional. And the > second problem is that when I enter invalid data I don't see the > errors in each field. Are you referring to "name" on your registration form? You would need to add a "required=False" attribute in order for that to be the case. However, the biggest problem with your code is that you are not using your Registration form to validate the data. Your template is rendering the Registration form, however you have never populated it with data or called is_valid() on it. Also, form_for_model is being deprecated - use ModelForms if you choose to go that route. Hope that helps -Brian > > This is the template used: > > {% block title %}Registration form{% endblock %} > {% block content %} > {{ message }} > > > > > Username: > {{ uForm.username }} > {{ uForm.username.errors }} > > > Password: > {{ uForm.password }} > {{ uForm.password.errors }} > > > Name: > {{ uForm.name }} > {{ uForm.name.errors }} > > > Email: > {{ uForm.email }} > {{ uForm.email.errors }} > > > > > {% endblock %} --~--~-~--~~~---~--~~ 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: Seperate project in a subdirectory (Apache 2.2 & mod_python)
First of all Apache will look through all the directives, and the later ones overwrite the former ones. So you should definitely put the more precise one at the bottom. Probably your media files work, because you've added something like urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': os.path.join(PROJECT_PATH, 'htdocs', 'media')}), ) to you urls.py, weren't you? you might try to specify the PythonPath for the testproject more precisely as well, as mod_python's path handling already surprised me a couple of times. I hope these help cheers, V On Jul 15, 5:32 pm, "Chris H." <[EMAIL PROTECTED]> wrote: > On Jul 14, 8:23 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > What order are you including them in the Apache configuration? > > > Have you tried switching the order? > > > Graham > > I have tried. I thought if I placed the testproject directive first > it would short circuit things, but it didn't seem to have that > effect. Further confusing this for me is that i do have a /media > location directive as well that doesn't seem to be served by Apache, > so why does that short circuit but /testproject does not? > > -C --~--~-~--~~~---~--~~ 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: escape filter
On Tue, Jul 15, 2008 at 12:22 PM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote: > > El mar, 15-07-2008 a las 12:25 -0400, Ned Batchelder escribió: > >> You're misunderstanding the role of the escape filter. It isn't meant >> to create HTML entities for accented characters. All it does is escape >> characters that could be dangerous for XSS attacks (" ' < > &). And by >> the way, in the latest code, escaping is automatic, so you may not need >> it at all. > > OK, thanks. That makes sense. > > However, I still need to convert those accented character into html > entities. Is there any pre-built filter for this? I checked the > refrence in "The definitive guide to django" but saw none. (I assumed you wanted to escape the characters < > & " ' in your flatpages for some reason, but that doesn't seem to be the case.) Why do you need to use HTML entities for accented characters? What is the problem you're trying to solve? Arien --~--~-~--~~~---~--~~ 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: Multi-level template blocks
Thanks for the reply. It does work! Doh! I had a stupid error. In the middle template of the real templates, I had (%block layer_special %) instead of {%block layer_special%}. Parens instead of curly brace. Arg. Once again, thanks for the help. To know that it SHOULD work helped me find the actual mistake. Gregg --~--~-~--~~~---~--~~ 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: timesince truncating
On Tue, 2008-07-15 at 00:38 -0700, Shantp wrote: > Hi all, > > This seems like it will have an obvious answer but I did a lot of > searching and can't find the answer. The timesince template tag > returns 2 outputs like "2 days, 3 hours". How can I limit the output > to only 1 thing? By writing your own template tag. It's easy, try it. The timesince filter works in one way that is useful in a number of situations. It's not worth making something that simple take a number of config options, since writing a version that does exactly what you want is very simple. Regards, Malcolm --~--~-~--~~~---~--~~ 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: Modules Imported Multiple Times
On Mon, 2008-07-14 at 23:30 -0700, django-m712 wrote: [...] > Has anyone else experienced this problem? There are a few places in Django where we need to access all the models in an app, for example. So we use __import__(), since that's the safest way to do this. This is the same as calling reload() from the Python interactive prompt if the module is already imported. In this case, what you're seeing is probably django.db.models.loading.get_apps() doing its thing, but there are other places it can happen as well. > Is there a way to fix this? The premise there is that it's something that needs to be fixed. :-) Modules can be imported multiple times. That's just a fact of life. It can happen both through the use of __import__ and because of things like an Apache process restarting and thus it needs to load modules (which isn't the same as reloading into the same process space, but if you're doing something which should only happen once externally, you need to take measures). For better or worse, your code needs to handle the possibility that things (app packages, model modules, URL config files) could be imported multiple times. Regards, Malcolm --~--~-~--~~~---~--~~ 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: escape filter
El mar, 15-07-2008 a las 12:25 -0400, Ned Batchelder escribió: > You're misunderstanding the role of the escape filter. It isn't meant > to create HTML entities for accented characters. All it does is escape > characters that could be dangerous for XSS attacks (" ' < > &). And by > the way, in the latest code, escaping is automatic, so you may not need > it at all. OK, thanks. That makes sense. However, I still need to convert those accented character into html entities. Is there any pre-built filter for this? I checked the refrence in "The definitive guide to django" but saw none. I can't be the first one in need of this... > --Ned. > http://nedbatchelder.com > > Fernando Rodríguez wrote: > > Hi, > > > > I'm using this simple template with flatpages: > > > > > > > > {{ flatpage.title|escape }} > > > > > > > > {{flatpage.title|escape}} > > {{ flatpage.content|escape }} > > > > > > > > > > I was expecting to see all accented chars in title and contents to be > > displayed properly escaped, however, I'm seing the "raw" chars. What am > > I doing wrong? > > > > OTOH, is there a way to isntruct flatpages to *always* escape text > > before displaying it? > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to access the label of a model instance
On Tue, Jul 15, 2008 at 12:00 PM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > > Hallöchen! > > Arien writes: > >> On Tue, Jul 15, 2008 at 10:53 AM, Torsten Bronger >> <[EMAIL PROTECTED]> wrote: >> >>> In a display template (not a form, just display), I write the >>> following: >>> >>>{% trans 'Temperature:' %} >>>{{ layer.heating_temperature }} >>> >>> I'd like to use the verbose_name of the model instance instead of >>> hard-wiring the label in the template. How can I access it? >> >> The verbose_name is at layer._meta.verbose_name. You can't access >> it like that from your template, though. > > Okay, thanks! However, then what is the "official" way to do it? Sorry for being unclear. What I meant was that you can't use layer._meta.verbose_name in the template, because template variables and attributes can't start with an underscore. You'll have to make layer._meta.verbose_name available to the template under some other name. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
url (reverse) as a filter
Hi, I like the idea of seperating the.. "address space" of a website from the templates. On the other hand I'm keeping most of the content in the db and displaying through the markup filter. So I'm looking for a way to feed the url_bit in markdown's [link] (url_bit "Title") to Django's {% url %} tag. Has anybody done sth similiar? If not, what implementation would you suggest? ...or maybe a markdown extension is the way to go? grzes --~--~-~--~~~---~--~~ 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 access the label of a model instance
Hallöchen! Arien writes: > On Tue, Jul 15, 2008 at 10:53 AM, Torsten Bronger > <[EMAIL PROTECTED]> wrote: > >> In a display template (not a form, just display), I write the >> following: >> >>{% trans 'Temperature:' %} >>{{ layer.heating_temperature }} >> >> I'd like to use the verbose_name of the model instance instead of >> hard-wiring the label in the template. How can I access it? > > The verbose_name is at layer._meta.verbose_name. You can't access > it like that from your template, though. Okay, thanks! However, then what is the "official" way to do it? Putting it in the template as in the above snippet? This smells like DRY-violation to me. Should I create a ModelForm instance although there is no ? Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: documentation offline, which CSS?
Le 15 juil. 08 à 11:58, Andre Meyer a écrit : > hi all > > like other people, i tried to get an offline copy of the django > docs. so, running rst2html from docutils works fine, but there is a > problem with the links (directing to the site instead of the local > docs) and it looks a lot less appealing. when using the original CSS > from the site it looks pretty weird and is hardly readable. > > does somebody have a better CSS that matches the site's look and a > solution for the link problem? could not find anything, so far, > except for a seemingly dead project. > > thanks > André André, You can generate the documentation with sphinx[0], once it's installed you just have to run: $ sphinx-build django_src/docs/ django_src/docs/_build/ And then point your browser to the index.html file generated in _build with a neat css. Unfortunately, it seems that it's not possible anymore to build the docs this way, I'll try to get that feature back in trunk. Cheers, David [0] http://sphinx.pocoo.org --~--~-~--~~~---~--~~ 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: escape filter
On Tue, Jul 15, 2008 at 11:00 AM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm using this simple template with flatpages: > > > >{{ flatpage.title|escape }} > > > >{{flatpage.title|escape}} >{{ flatpage.content|escape }} > > > > > I was expecting to see all accented chars in title and contents to be > displayed properly escaped, however, I'm seing the "raw" chars. What am > I doing wrong? You can use the force_escape filter to escape <, >, quotes and ampersands. Arien --~--~-~--~~~---~--~~ 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: Trying to install django
Brillant, it all works now. Thanks Arien, you are a star. Ralph On Jul 15, 6:02 pm, Arien <[EMAIL PROTECTED]> wrote: > On Tue, Jul 15, 2008 at 9:58 AM, Arien <[EMAIL PROTECTED]> wrote: > > On Tue, Jul 15, 2008 at 9:27 AM, Ralph <[EMAIL PROTECTED]> wrote: > > >> I'm trying to install django for the first time. > [...] > > What I do is this: > > > 1. check out the svn version to some directory, for example > > c:\svn\django-trunk. From the command-line: > > > svn cohttp://code.djangoproject.com/svn/django/trunk/c:\svn\django-trunk > > > (that should be one line) > > > 2. create a file called django.pth in the site-packages directory and > > enter the path of the directory you used in step 1. > > > In your case you should end up with the file > > > C:\Python25\Lib\site-packages\django.pth > > > which contains > > > c:\svn\django-trunk > > > (or whatever path you used in step 1.) > > Using TortoiseSVN, step 1 would be: select "SVN Checkout..." from the > context menu, fill inhttp://code.djangoproject.com/svn/django/trunk/ > for URL of the repository and c:\svn\django-trunk (or whatever you > want to use) for the checkout directory. > > Arien- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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: newbie help
Thanks Joshua! I'll fetch the dev version of Django instead. I guess I was confused by the phrases "SVN release" and "official release". I just thought the SVN release would be the official release :p Thanks a log again - Original Message From: Joshua Jonah <[EMAIL PROTECTED]> To: django-users@googlegroups.com Sent: Monday, July 14, 2008 11:58:18 PM Subject: Re: newbie help maxlength was changed in the trunk to max_length. You are probably using an older version of Django, the tutorial you were following refers to the latest version: http://code.djangoproject.com/ticket/6457 As for the returning the text thing, same deal. If you go to this page: http://www.djangoproject.com/documentation/tutorial01/ and look at where it explains to do that, it has a little note below it explaining that this wil happen in the older version. If i were you, I'd either upgrade your Django, or start following the 0.96 tutorial from here. Joshua Mario Zorz wrote: Hello all, I'm following the Django tutorial [1] I'm using windows xp, python 2.5 and SQLite. For some reason I found these 2 things not being appropiate as followed in the tutorial: 1) When tried "python manage.py sql polls" I got this TypeError: __init__() got an unexpected keyword argument 'max_length'. I could only run it successfully by changing the linea question = models.CharField(max_length=200) to question = models.CharField(maxlength=200) (stripped off the undrescore in "max_length") 2) Continuing down to the "Playing with the API" section, and once I saved some poll objects to the DB, etc I executed the following command as specified in the tutorial: Poll.objects.all() For some reason, the result I get from the shell is >>> Poll.objects.all() [] Even when I inserted the __unicode__() method in models.py as follows: class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question Anything I'm doing wrong? Thanks a lot regards Mario [1] http://www.djangoproject.com/documentation/tutorial01/ --~--~-~--~~~---~--~~ 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: newbie help
thanks a lot Matt! I'll fetch the dev version of Django instead. I guess I was confused by the phrases "SVN release" and "official release". I just thought the SVN release would be the official release :p Thanks a log again - Original Message From: Matt McClanahan <[EMAIL PROTECTED]> To: Django usersSent: Monday, July 14, 2008 11:18:52 PM Subject: Re: newbie help On Jul 14, 3:46 pm, Mario Zorz <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm following the Django tutorial [1] I'm using windows xp, python 2.5 and > SQLite. For some reason I found these 2 things not being appropiate as > followed in the tutorial: > > 1) When tried "python manage.py sql polls" I got this > TypeError: __init__() got an unexpected keyword argument 'max_length'. > 2) Continuing down to the "Playing with the API" section, and once I saved > some poll objects to the DB, etc I executed the following command as > specified in the tutorial: You are attempting to use the tutorial that targets current development code with one of the Django releases (0.95, 0.96..). As the tutorial notes in several places, there are differences between the releases and current development. In fact, both of the problems you've encountered are specifically addressed in the document you linked to. You should either fetch the development version of Django, or use the tutorial targeted for your Django version, which are linked at the top of each documentation page. Matt --~--~-~--~~~---~--~~ 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: escape filter
You're misunderstanding the role of the escape filter. It isn't meant to create HTML entities for accented characters. All it does is escape characters that could be dangerous for XSS attacks (" ' < > &). And by the way, in the latest code, escaping is automatic, so you may not need it at all. --Ned. http://nedbatchelder.com Fernando Rodríguez wrote: > Hi, > > I'm using this simple template with flatpages: > > > > {{ flatpage.title|escape }} > > > > {{flatpage.title|escape}} > {{ flatpage.content|escape }} > > > > > I was expecting to see all accented chars in title and contents to be > displayed properly escaped, however, I'm seing the "raw" chars. What am > I doing wrong? > > OTOH, is there a way to isntruct flatpages to *always* escape text > before displaying it? > > > > > > > -- 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: How to access the label of a model instance
On Tue, Jul 15, 2008 at 10:53 AM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > > Hallöchen! > > In a display template (not a form, just display), I write the > following: > >{% trans 'Temperature:' %} >{{ layer.heating_temperature }} > > I'd like to use the verbose_name of the model instance instead of > hard-wiring the label in the template. How can I access it? The verbose_name is at layer._meta.verbose_name. You can't access it like that from your template, though. Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
escape filter
Hi, I'm using this simple template with flatpages: {{ flatpage.title|escape }} {{flatpage.title|escape}} {{ flatpage.content|escape }} I was expecting to see all accented chars in title and contents to be displayed properly escaped, however, I'm seing the "raw" chars. What am I doing wrong? OTOH, is there a way to isntruct flatpages to *always* escape text before displaying it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: integer digit limit
> some_field = forms.IntegerField(widget=forms.TextInput(attrs={'maxlength': PERFECT! I missed that attrs dictionary in the form widgets... man that is really awesome! --~--~-~--~~~---~--~~ 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 access the label of a model instance
Hallöchen! In a display template (not a form, just display), I write the following: {% trans 'Temperature:' %} {{ layer.heating_temperature }} I'd like to use the verbose_name of the model instance instead of hard-wiring the label in the template. How can I access it? Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: integer digit limit
On Tue, Jul 15, 2008 at 10:30 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > I've got an IntegerField setup with a max_value of 20. I'm > wondering how to limit the initial input on the form field to no more > than 6 characters. You can pass the fields widget an optional attrs keyword argument (a dictionary) for HTML attributes of the widget. The HTML attribute you're looking for is maxlength: some_field = forms.IntegerField(widget=forms.TextInput(attrs={'maxlength': 6})) Arien --~--~-~--~~~---~--~~ 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: Seperate project in a subdirectory (Apache 2.2 & mod_python)
On Jul 14, 8:23 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > What order are you including them in the Apache configuration? > > Have you tried switching the order? > > Graham I have tried. I thought if I placed the testproject directive first it would short circuit things, but it didn't seem to have that effect. Further confusing this for me is that i do have a /media location directive as well that doesn't seem to be served by Apache, so why does that short circuit but /testproject does not? -C --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
integer digit limit
hi I've got an IntegerField setup with a max_value of 20. I'm wondering how to limit the initial input on the form field to no more than 6 characters. They can enter 20 characters for example. When they hit the submit button of course it will error out but i'd like to limit the initial length to no more than 6 characters. Is this possible on an integerfield ? --~--~-~--~~~---~--~~ 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: Trying to install django
On Tue, Jul 15, 2008 at 9:58 AM, Arien <[EMAIL PROTECTED]> wrote: > On Tue, Jul 15, 2008 at 9:27 AM, Ralph <[EMAIL PROTECTED]> wrote: >> >> I'm trying to install django for the first time. [...] > What I do is this: > > 1. check out the svn version to some directory, for example > c:\svn\django-trunk. From the command-line: > > svn co http://code.djangoproject.com/svn/django/trunk/ c:\svn\django-trunk > > (that should be one line) > > 2. create a file called django.pth in the site-packages directory and > enter the path of the directory you used in step 1. > > In your case you should end up with the file > > C:\Python25\Lib\site-packages\django.pth > > which contains > > c:\svn\django-trunk > > (or whatever path you used in step 1.) Using TortoiseSVN, step 1 would be: select "SVN Checkout..." from the context menu, fill in http://code.djangoproject.com/svn/django/trunk/ for URL of the repository and c:\svn\django-trunk (or whatever you want to use) for the checkout directory. Arien --~--~-~--~~~---~--~~ 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: Trying to install django
On Tue, Jul 15, 2008 at 9:27 AM, Ralph <[EMAIL PROTECTED]> wrote: > > I'm trying to install django for the first time. > > I've read through at least 3 tutorials on how to install django and by > using parts of all three I managed to get the django files installed, > but I followed this command > import django > > I get > > Traceback > File "", line 1, in > ImportError: No module named django > > > I'm using > Vista > Python25 > > The directory structure is like this:- > Python25\Lib\site-packages\django\django\bin If you check out a svn version to your site-packages, you should have a path like this: Python25\Lib\site-packages\django\bin What I do is this: 1. check out the svn version to some directory, for example c:\svn\django-trunk. From the command-line: svn co http://code.djangoproject.com/svn/django/trunk/ c:\svn\django-trunk (that should be one line) 2. create a file called django.pth in the site-packages directory and enter the path of the directory you used in step 1. In your case you should end up with the file C:\Python25\Lib\site-packages\django.pth which contains c:\svn\django-trunk (or whatever path you used in step 1.) Arien --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Trying to install django
I'm trying to install django for the first time. I've read through at least 3 tutorials on how to install django and by using parts of all three I managed to get the django files installed, but I followed this command >>> import django I get Traceback File "", line 1, in ImportError: No module named django I'm using Vista Python25 The directory structure is like this:- Python25\Lib\site-packages\django\django\bin The system path is this %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C: \Program Files\TortoiseSVN\bin;C:\Python25\Tools\Scripts;C:\Python25;C: \Python25\Lib\site-packages\django\django\bin I also used TortoiseSVN to export from django repositories. Can anyone see where I might have gone wrong? Thanks in advance Ralph --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Don't see form errors in template
Hello, I have a model Investor associated with a model User. Now I'm implementing the registration form. I want to store the name of the Investor in the Investor model and the rest of information in the User model. So I have username, password, name and email. I have a registration form in order to input this information: class RegisterForm(forms.Form): username = forms.CharField(max_length=30) password = forms.CharField(max_length=20, widget=forms.PasswordInput()) name = forms.CharField(max_length=50) email = forms.EmailField(max_length=30) Now I have a view to show this form, retrive the data, validate it and store it in Investor and in User: def register_user(request): register_form = RegisterForm() message = "User Registration" if request.POST.get('submit') == 'Register': postDict = request.POST.copy() UserForm = forms.form_for_model(User) user_form = UserForm(postDict) if user_form.is_valid(): try: user_form.save() message = "User registered succesfully" except: message = "Database error" invDict = {} invDict['name'] = postDict.get('name', '') invDict['userID'] = user_form.id InvestorForm = forms.form_for_model(Investor) iForm = InvestorForm(invDict) if iForm.is_valid(): try: i = iForm.save() message = "User registered succesfully" return render_to_response('Authentication/login.html', { 'lForm': LoginForm(), 'message': message }) except: message = 'Database Error' user.delete() else: message = 'You entered invalid data in the form' user.delete() else: message = "You entered invalid data in the form" return render_to_response('Authentication/register.html', {'uForm': register_form, 'message': message}) First of all, I want to say that I do not understand the relationship between forms and models in Django. A form to ask and a model to store? How to pass the form data to a model? Have I to pass it in order to validate? The problem with this code is that when I do not enter the name field it says the form is invalid but the name field is optional. And the second problem is that when I enter invalid data I don't see the errors in each field. This is the template used: {% block title %}Registration form{% endblock %} {% block content %} {{ message }} Username: {{ uForm.username }} {{ uForm.username.errors }} Password: {{ uForm.password }} {{ uForm.password.errors }} Name: {{ uForm.name }} {{ uForm.name.errors }} Email: {{ uForm.email }} {{ uForm.email.errors }} {% endblock %} --~--~-~--~~~---~--~~ 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: Request object in template HTML
On Jul 15, 2008, at 9:55 PM, Nazmi ZORLU wrote: > Hi, > > I wonder if I can access request object in html template or absolute > page url that currently rendering. If you're not using generic views, you can pass "context_instance=RequestContext(request)" as a third argument to render_to_response to get access to a 'request' variable (and a bunch else) in your templates. More details here: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext Yours, Eric --~--~-~--~~~---~--~~ 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: Inquiry
On Tue, Jul 15, 2008 at 8:40 AM, Marty Alchin <[EMAIL PROTECTED]> wrote: > Is it really > that bad a thing that users are in control of how they use your web > site? Exactly. Users can change the URL more easily than they can delete a cookie, so that one is effectively out (for his criteria). And as you noted, IPs change and don't really identify any one single user, and thus aren't a good way to handle sessions at all. Brett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Request object in template HTML
Hi, I wonder if I can access request object in html template or absolute page url that currently rendering. Thanks, Nazmi --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help with Forms (Dynamic Fields)
Hi Djangoers, I'm trying to generate a form dynamically using MyForm (Form class), but I'm stuck with validating or populating data. Form Class, View and template Code here: http://dpaste.com/65080/ (not too many lines I guess :) ) Good thing is I can see form (generating dynamically, based on the category I chose as expected), but I'm not able to do anything after that . When I submit form with empty values, its returning empty form no matter I enter data or not and also it won't throw any errors(like field required) Thanks, Srikanth --~--~-~--~~~---~--~~ 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: Site wide date format
Thank you for the quick response - I think I'm going to go with the custom filter for maximum flexability On Jul 15, 9:25 am, "Brett Hoerner" <[EMAIL PROTECTED]> wrote: > On Tue, Jul 15, 2008 at 8:14 AM, Adam Peacock <[EMAIL PROTECTED]> wrote: > > Is this possible? > > Not with the current date filter. You could make your own templatetag > that just wraps the existing one, though. > > http://www.djangoproject.com/documentation/templates_python/#writing-... > > Brett --~--~-~--~~~---~--~~ 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: Inquiry
On Mon, Jul 14, 2008 at 8:48 PM, Kadusale, Myles <[EMAIL PROTECTED]> wrote: > I don't want to use cookies because they can be disabled by the user. The alternatives I'm aware of are: * recording the session ID directly in the URL of every page, which just opens you up[1] to all sorts of problems. * Using REMOTE_ADDR to identify incoming IPs, which will not only make it impossible to identify one browser window or tab from another, it won't even be able to tell one browser from another. Worse yet, for the many people out there with multiple PCs hooked up through a router to a single net connection, your site won't be able to tell any of their machines apart. * I suppose you could technically use a combination of REMOTE_ADDR and the User Agent string, but that only helps if users are using different browsers. Multiple users using th esame browser version would probably still have problems, and a single user using multiple windows or tabs will most certainly still have problems. Cookies are certainly your best bet here. They were created as a solution to real problems, so by asking to avoid them, you're essentially asking for those other problems. Yes, users can disable cookies. They can also disable CSS and JavaScript, and even opt out of using the web entirely. Is it really that bad a thing that users are in control of how they use your web site? -Gul [1] http://en.wikipedia.org/wiki/Session_fixation --~--~-~--~~~---~--~~ 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: Site wide date format
On Tue, Jul 15, 2008 at 8:14 AM, Adam Peacock <[EMAIL PROTECTED]> wrote: > > I'm looking for a consistent way to format dates across my site, > without having to put the format into every template. Is it possible > to set a default date format for the "date" filter? For example, I > want {{ var.date|date }} to format to {{ var.date|date:"l, F j Y" }} > unless I specify otherwise, but still have the ability to format it > differently in some cases. Is this possible? Use the DATE_FORMAT setting: http://www.djangoproject.com/documentation/settings/#date-format Arien --~--~-~--~~~---~--~~ 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: .pyc files not being created
On Jul 15, 8:29 am, blis102 <[EMAIL PROTECTED]> wrote: > Hey all, > > On my Ubuntu server with Apache2 +mod_python, I cant seem to get > the .py files to compile like they should (I see no .pyc files in my > "src" folder like I do locally). I believe I have proper permissions > set (775), but am by no means an expert in this matter. What would > cause .pyc files to not compile other than the file permissions. Also > what is the recommended permissions settings for source folders/files, > and media folders/files? Because Apache/mod_python processes are persistent, and py file loading only happens first time it is required by a process, you don't actually gain that much in trying to ensure that .pyc/.pyo files exist. If you were using CGI where every request is a new process, then it would be an issue. In other words, you may be wasting time trying to work this out for next to no benefit. 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 -~--~~~~--~~--~--~---
Re: Site wide date format
On Tue, Jul 15, 2008 at 8:14 AM, Adam Peacock <[EMAIL PROTECTED]> wrote: > Is this possible? Not with the current date filter. You could make your own templatetag that just wraps the existing one, though. http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags Brett --~--~-~--~~~---~--~~ 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 use PythonAuthzHandler with django?
FWIW, authen/authz for Apache is much easier done in mod_wsgi. See: http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms I have given up trying to help people with mod_python authen/authz because it is such a PITA. :-) Graham On Jul 15, 9:29 pm, "Viktor Nagy" <[EMAIL PROTECTED]> wrote: > Hello, > > I've set up apache to validate my users using PythonAuthenHandler as > described in the documentation > (http://www.djangoproject.com/documentation/apache_auth/). This part > works like charm :), but I would like to get a more fine grained > control over the accessed url (not served by django). > > According tomod_python'sdocs this should be possible using > PythonAuthzHandler, but in my case it just doesn't work. > > I have the following in my virtualhost directive > > > AuthType Basic > AuthName 'CooSci' > AuthUserFile /dev/null > AuthBasicAuthoritative Off > Require valid-user > > SetEnv DJANGO_SETTINGS_MODULE coosci.settings > PythonAuthenHandler django.contrib.auth.handlers.modpython > PythonAuthzHandler myproject.auth.modpython > PythonOption DjangoRequireStaffStatus 0 > > > then I use the following modpython.py to test if the setting works > > frommod_pythonimport apache > import os > > def authzhandler(req, **kwargs): > ''' > Authentication handler that checks if the given repository can be > accessed by the authenticated user > @param req: the Apache request object, > seehttp://modpython.org/live/mod_python-3.3.1/doc-html/pyapi-mprequest.html > @type req: object > ''' > #mod_pythonfakes the environ, and thus doesn't process SetEnv. This fixes > # that so that the following import works > os.environ.update(req.subprocess_env) > > settings_module = req.get_options().get('DJANGO_SETTINGS_MODULE', None) > if settings_module: > os.environ['DJANGO_SETTINGS_MODULE'] = settings_module > > # test if it works > apache.log_error('authzhandler') > req.log_error('authzhandler from request with user %s at %s' % > (req.user, req.uri)) > > from django.contrib.auth.models import User > from webapp.models import Editor > from django import db > db.reset_queries() > > # run this at the end > db.connection.close() > return apache.OK > > Any ideas why this doesn't show up in my Apache log files? > I have Apache 2.2.0 > > In the meantime I was thinking about other solutions as well. > Especially as the docs of PythonAuthzHandler says that > PythonAuthenHander is "more often than not it is done right in the > AuthenHandler". So it might be a good idea to allow a callback in > AuthenHandler to get a more fine-grained control over the accessed > uri. (Of course, this at least partially mixes up things, as the > authenhandler is supposed to authenticate the user, and it's the > authzhandler who should allow/deny access of the (already > authenticated) user to a given uri.) > > what would be your recommendation? do you see any reason to patch > django.contrib.auth.handlers.modpython to allow for a callback? > > Thanks for your help! > V --~--~-~--~~~---~--~~ 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: Inquiry
On Mon, Jul 14, 2008 at 7:48 PM, Kadusale, Myles <[EMAIL PROTECTED]> wrote: > I don't want to use cookies because they can be disabled by the user. Can you name a method of maintaining a session can't be altered or changed by the user? Brett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Site wide date format
I'm looking for a consistent way to format dates across my site, without having to put the format into every template. Is it possible to set a default date format for the "date" filter? For example, I want {{ var.date|date }} to format to {{ var.date|date:"l, F j Y" }} unless I specify otherwise, but still have the ability to format it differently in some cases. Is this possible? --~--~-~--~~~---~--~~ 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: wsgi and os.environ
On Jul 15, 9:54 pm, "Ian Lawrence" <[EMAIL PROTECTED]> wrote: > Hi, > I am experimenting with wsgi. I saw that this can be one way to enable it: > > os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' > > this seems a little strange to me setting something global to your > process. Is this best practice on the mod_wsgi world? Some see it as acceptable some don't. The downside of relying on global data like this, is that one can't host two instances of Django within the same Python interpreter. This means you have to run them in separate processes, or use the ability of mod_python or mod_wsgi to create distinct sub interpreters within a process and run Django instances in the distinct sub interpreters. Either way, the result is two copies in memory of all common code modules. In contrast, look at Trac which is regarded as being more WSGI friendly, and you can specify its configuration settings through the per request WSGI environment. Because of that and because they avoid other global data, or at least have it keyed off per request configuration, it is possible to host multiple Trac project instances in same interpreter, thus getting a saving of memory through use of common loaded code modules etc. 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 -~--~~~~--~~--~--~---
Re: Setting the time on a datetimefield
On Tue, Jul 15, 2008 at 7:25 AM, Tim Sawyer <[EMAIL PROTECTED]> wrote: > In my form I have: > > datetime = > forms.DateField(widget=forms.TextInput({'class' : > 'date-pick'}),label="Available > date") > > yet it's a DateTimeField in the model. Why not use a DateTimeField in your form and change the widget instead? For example: datetime = forms.DateTimeField( widget=forms.DateTimeInput(format='%Y-%m-%d', attrs={'class' : 'date-pick'}), label="Available date" ) (Note the attrs={...} for the class.) > This means that the reason that the value fetched from the form is only a date > is because of the type in the form. Assigning this date only value from the > form to the model attribute means I can't use replace(hour=23) on it any > more. I don't really understand why, but I'm sure there's a logical > explanation! The logical explanation is that adjusting the hour of a date doesn't make sense, because a date doesn't have any hour. ;-) Arien --~--~-~--~~~---~--~~ 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: delete or update a model
If you're talking about modifying your model definitions and then having those changes present in the backend database schema I don't believe you'll be able to do that with Django automatically but you can do it manually Start with the section titled "Making Changes to a Database Schema" on this page of the Django book: http://www.djangobook.com/en/1.0/chapter05/ On Jul 15, 4:50 am, "Alfredo Alessandrini" <[EMAIL PROTECTED]> wrote: > Hi, > > How can I update or delete a model? > > Alfredo --~--~-~--~~~---~--~~ 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: Logging in with emails longer than 30 characters
Julien Phalip pisze: > - create my own login view (duplicating the standard auth login view > and replacing all the references to AuthenticationForm with my own > custom form). This will be easiest way IMO. > None of these 2 options seem to satisfy me completely... What do you > think is the best practice here? This is workaround for Django's auth application deficiency, so expect it will be as any other workaround (rather ugly). -- We read Knuth so you don't have to. -- Tim Peters Jarek Zgoda re:define --~--~-~--~~~---~--~~ 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: Setting the time on a datetimefield
On Tuesday 15 Jul 2008, Arien wrote: > On Tue, Jul 15, 2008 at 4:57 AM, Tim Sawyer <[EMAIL PROTECTED]> wrote: > > In my code, I did this: > > > > self.datetime = pForm.cleaned_data['datetime'] > > > > the datetime parameter passed from the form only contained the date, with > > no time, so I assume the value in datetime then was only a date. > > This shouldn't happen: a DateTimeField normalizes to a > datetime.datetime object. Are you sure you're not using a DateField > in your form? Well spotted. In my form I have: datetime = forms.DateField(widget=forms.TextInput({'class' : 'date-pick'}),label="Available date") yet it's a DateTimeField in the model. This means that the reason that the value fetched from the form is only a date is because of the type in the form. Assigning this date only value from the form to the model attribute means I can't use replace(hour=23) on it any more. I don't really understand why, but I'm sure there's a logical explanation! Tim. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
wsgi and os.environ
Hi, I am experimenting with wsgi. I saw that this can be one way to enable it: os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' this seems a little strange to me setting something global to your process. Is this best practice on the mod_wsgi world? thx Ian -- http://ianlawrence.info --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
working with database
I must select a column from my database. I've try with: from PLAYER.models import Player player = Player.objects.all() email = Player.objects.values('email') ok, work fine, but in the Django Book I read: "This method is useful when you know you're only going to need values from a small number of the available fields and you won't need the functionality of a model instance object. It's more efficient to select only the fields you need to use." Is there another method for select a single column? I must utilise the data of this column and import it by a string whithin an application write in Python. It's more efficient utilise the Django API for the database or the Python API, when my database must interact with an application write in Python? thanks in advance, Alfredo --~--~-~--~~~---~--~~ 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: Logging in with emails longer than 30 characters
Sorry, I forgot to give the link: [1] http://www.djangosnippets.org/snippets/74/ On Jul 15, 9:04 pm, Julien Phalip <[EMAIL PROTECTED]> wrote: > Hi, > > On my site users must login with their email address. I'm successfully > using a custom authentication backend based on [1]. > > The problem is with email addresses longer than 30 characters. At the > moment, these addresses can't log in because the > django.contrib.auth.forms.AuthenticationForm's username field has a > maxlength of 30 and therefore validation always fails before even > hitting the auth backend. > > To go around that, I can see 2 options: > - patch Django and put 75 as the AuthenticationForm username field's > max_length. > - create my own login view (duplicating the standard auth login view > and replacing all the references to AuthenticationForm with my own > custom form). > > None of these 2 options seem to satisfy me completely... What do you > think is the best practice here? > > Thanks a lot, > > Julien > > PS: I'm using a fresh checkout of newforms-admin --~--~-~--~~~---~--~~ 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 use PythonAuthzHandler with django?
Hello, I've set up apache to validate my users using PythonAuthenHandler as described in the documentation (http://www.djangoproject.com/documentation/apache_auth/). This part works like charm :), but I would like to get a more fine grained control over the accessed url (not served by django). According to mod_python's docs this should be possible using PythonAuthzHandler, but in my case it just doesn't work. I have the following in my virtualhost directive AuthType Basic AuthName 'CooSci' AuthUserFile /dev/null AuthBasicAuthoritative Off Require valid-user SetEnv DJANGO_SETTINGS_MODULE coosci.settings PythonAuthenHandler django.contrib.auth.handlers.modpython PythonAuthzHandler myproject.auth.modpython PythonOption DjangoRequireStaffStatus 0 then I use the following modpython.py to test if the setting works from mod_python import apache import os def authzhandler(req, **kwargs): ''' Authentication handler that checks if the given repository can be accessed by the authenticated user @param req: the Apache request object, see http://modpython.org/live/mod_python-3.3.1/doc-html/pyapi-mprequest.html @type req: object ''' # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes # that so that the following import works os.environ.update(req.subprocess_env) settings_module = req.get_options().get('DJANGO_SETTINGS_MODULE', None) if settings_module: os.environ['DJANGO_SETTINGS_MODULE'] = settings_module # test if it works apache.log_error('authzhandler') req.log_error('authzhandler from request with user %s at %s' % (req.user, req.uri)) from django.contrib.auth.models import User from webapp.models import Editor from django import db db.reset_queries() # run this at the end db.connection.close() return apache.OK Any ideas why this doesn't show up in my Apache log files? I have Apache 2.2.0 In the meantime I was thinking about other solutions as well. Especially as the docs of PythonAuthzHandler says that PythonAuthenHander is "more often than not it is done right in the AuthenHandler". So it might be a good idea to allow a callback in AuthenHandler to get a more fine-grained control over the accessed uri. (Of course, this at least partially mixes up things, as the authenhandler is supposed to authenticate the user, and it's the authzhandler who should allow/deny access of the (already authenticated) user to a given uri.) what would be your recommendation? do you see any reason to patch django.contrib.auth.handlers.modpython to allow for a callback? Thanks for your help! V --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Logging in with emails longer than 30 characters
Hi, On my site users must login with their email address. I'm successfully using a custom authentication backend based on [1]. The problem is with email addresses longer than 30 characters. At the moment, these addresses can't log in because the django.contrib.auth.forms.AuthenticationForm's username field has a maxlength of 30 and therefore validation always fails before even hitting the auth backend. To go around that, I can see 2 options: - patch Django and put 75 as the AuthenticationForm username field's max_length. - create my own login view (duplicating the standard auth login view and replacing all the references to AuthenticationForm with my own custom form). None of these 2 options seem to satisfy me completely... What do you think is the best practice here? Thanks a lot, Julien PS: I'm using a fresh checkout of newforms-admin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---