Re: Wiki/CMS app?
Hi, I just tested your demo. Somehow there were some 500 pages (internal server error). Nevertheless it looks to have most features I need. I the top, I would not display "home.html" but only "home". And the subpages should be a tree. But I guess that can be customized or hacked somehow. How can you upload files? Thomas Tim Kersten schrieb: > Yes, quite correct, it doesn't require a database. I wanted to keep > the requirements as minimal as possbile and thought it would be good > to let something designed for keeping revisions do the heavy lifting. > I know I have a good way to go with timiki yet, but it's already in > heavy use and therefor under improvement. > > I can understand you prefering a database solution and it was a > difficult decision not to use a database. In the end I wanted > something that would be easy to deal with in the case of something > going wrong. The urls have a 1-to-1 mapping with the files on the file > system, so backups, restores and exporting/importing any data should > be simple as the entire content is pure (x)html. > > I just set up a demo page here so that progress can be viewed: > http://timikidemo.io41.com/ > > Tim ^,^ > > > -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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: cannot import name parse_lookup
Thank You Karen , for your instant reply!! Work as if you have no need of the money. Love as if nobody ever made you suffer. Dance as if nobody is watching you. Sing as if nobody is hearing you. Live as if the Paradise were on this Earth. Krishnaprasad Varma [EMAIL PROTECTED] [EMAIL PROTECTED] +919744111281 --~--~-~--~~~---~--~~ 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 handle platform dependent settings?
On Aug 27, 2008, at 8:12 PM, Gremmie wrote: > > I test my code locally on my PC using the XAMPP package, and deploy > the real site on Linux with Apache. My code is all common, except for > settings.py and urls.py. I'd rather not have 2 versions of these files > and try to manage that in my SVN repository. ... > Is there a better way? Does this cause a performance hit, or is > settings.py and urls.py processed only once? If it's mostly paths that you need to change, check out: http://rob.cogit8.org/blog/2008/Jun/20/django-and-relativity/ --- David Zhou [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: site using Django/mod_python/apache2 randomly showing "It worked!" page
On Aug 27, 2008, at 9:18 PM, Richard Simões wrote: > I have non-root access to a server with apache2 and mod_python. I > installed django with svn to a location in my home directory and > created a test project. When I go to a URL defined with urls.py and > views.py, 9/10 times the expected page is shown. The remaining 1/10 > times the "It worked!" page pops up. Searching for this problem seems > a bit difficult. Any idea on what could be happening? Did you restart the server after making your changes? --- David Zhou [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: About Site in django
On Thu, Aug 28, 2008 at 8:27 AM, PENPEN <[EMAIL PROTECTED]> wrote: > I have a question on the site concept. > While reading the source code, I found that there is the site related > statement in django.contrib.auth.views.login: > >if Site._meta.installed: >current_site = Site.objects.get_current() >else: >current_site = RequestSite(request) > > I'm not clear about "Site._meta.installed". I tried in my project, and > found it is already True. But I could not find a way to toggle its > value. Could anybody explain how this variable is assigned? It's already set probably because INSTALLED_APPS includes 'django.contrib.sites' by default. More info: http://docs.djangoproject.com/en/dev/ref/contrib/sites/ Ronny --~--~-~--~~~---~--~~ 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: Another django db memory leak?
I wanted to point this out primarily to see if anyone was experiencing similar problems, or if there are any other general comments. I also am somewhat wondering if there should be bugs reported? Or am I outside the expected use cases for the db api? When I can free up time, I would be happy to investigate further and potentially contribute fixes or at least characterize the problems. With this I just wanted to start a dialog; I'm not asking for any help with a fixing the problem. I have temporarily fixed this problem by using some straight sql through a django.db.connection.query object in one case, and sequestering some db api client code in subprocs to keep the memory under control. Works fine, but may be not too DRY or portable, oh well. Bottom line: Django rocks, and I understand it's young, and supported by volunteers. all the best. thanks! On Aug 28, 12:13 pm, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > For some reason, when I do > > x.save() over an over, it takes about 200k, too. > > either I have something really messed up, or there is a real problem > with this api. > > On Aug 28, 10:34 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > To summarize - I double checked that DEBUG=False and ran all the tests > > again: > > > # 20k per call > > x = Page.objects.filter( > > #(Q(type='P') & (Q(status='N') | > > Q(status='R'))) & > > #(Q(last_action_datetime__isnull=True) | > > Q(last_action_datetime__lt=cut_off))).count() > > > # 4K-12K > > x= Page.objects.filter(type='P', status='N').count() > > > # 4K-12K > > x = Page.objects.filter(type='P').count() > > > # 4K-12K > > x = Page.objects.filter(status='N').count() > > > # 0K > > x = Page.objects.all().count() > > > # 0k > > x = Page.objects.extra(where= > > ["(type='P' and (status='N' or status='R') and > > \ > > (last_action_datetime is null or > > last_action_datetime < '2009-1-1'))"]).count() > > > On Aug 28, 10:17 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > > Previously I found get_or_create() to be leaky, so I stopped using > > > it. Now I'm seeing filter() to be leaky. > > > > First, yes, I have DEBUG=False, and I have double checked that > > > connection.queries is empty. > > > > Suppose the following model > > > > class Page(models.Model): > > > type = models.CharField(max_length=1,default='P') > > > status = models.CharField(max_length=2,default='N') > > > last_action_datetime = models.DateTimeField(null=True) > > > > All memory checked by looking for VmRSS: in /proc/{pid}/status - on > > > linux (Resident) > > > > If I call the following using filter() and Q() > > > > x = Page.objects.filter( > > > (Q(type='P') & (Q(status='N') | > > > Q(status='R'))) & > > > (Q(last_action_datetime__isnull=True) | > > > Q(last_action_datetime__lt=cut_off))).count() > > > > repeatedly, memory climbs by about 50KB / loop. > > > > Suspecting Q, I tried this > > > > x = Page.objects.filter(type='P', status='N').count() > > > > which increases at about 4-16KB per / loop > > > > as does > > > x = Page.objects.filter(type='P').count(), and > > > x = Page.objects.filter(status='N').count() > > > > If I change it to > > > > x = Page.objects.all().count() > > > > Memory stays constant, but that isn't filtering enough. So I tried > > > > x = Page.objects.extra(where= > > > ["(type='P' and (status='N' or status='R') and \ > > > (last_action_datetime is null or last_action_datetime < > > > '2009-1-1'))"]).count() > > > > Memory stays constant for this one too. Although this isn't the best > > > DRY form, it doesn't seem to leak. > > > > At this point, I figure that if you plan on making lots of calls that > > > would use filter() probably use extra instead. > > > > Clearly, I'm taking the django db layer, probably initially designed > > > to support webdev, and I'm using it to do heavy scripting. It works > > > great, other than these memory problems. And since we are also > > > building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Marking form field label as safe?
I am trying to do raw HTML output in a form field's label. I've tried using mark_safe on the string being passed as the label argument, but it is still escaped. Can anyone point me in the right direction please? --~--~-~--~~~---~--~~ 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: Problem with reverse lookups in Weblog example
OK, I solved my problem. I now understand reverse lookups well enough to be embarrassed by the code below. Sorry to have bothered you. Rodney On Aug 27, 10:39 am, Rodney Topor <[EMAIL PROTECTED]> wrote: > Hi. Sorry to botther the group again. I'm working through the Weblog > example in 'Practical Django Projects'. Yet again, reverse URL lookup > errors prove to be the hardest to debug. In class Entry I have > defined > > def get_absolute_url(self): > return "/weblog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d"), > self.slug) > > (Not good style, I know, but you have to start somewhere.) > > In template entry_archive.html, I've tried the following three ways of > getting the URL for a particular entry: > > Read full entry... a> > d",entry.slug %}">Read full entry... > {{ entry.slug }}/">Read full entry... > > The first of these fails with the error message: > > TemplateSyntaxError at /weblog/ > Caught an exception while rendering: Reverse for > 'weblog.entry.get_absolute_url' not found. > > The second fails with a similar entry. But the third method works. > (I know it's bad style - hence my question.) > > So can anyone explain what I am doing wrong, please? > > I have defined the app Coltrane at the same level in the file system > as the project Weblog. Is it significant that the error message > refers ti weblog.entry and not coltrane.entry? That also looks wrong > to me. > > This is with version 1.0-beta_1-SVN-8430. > > Thanks. > Rodney --~--~-~--~~~---~--~~ 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 using Django/mod_python/apache2 randomly showing "It worked!" page
I have non-root access to a server with apache2 and mod_python. I installed django with svn to a location in my home directory and created a test project. When I go to a URL defined with urls.py and views.py, 9/10 times the expected page is shown. The remaining 1/10 times the "It worked!" page pops up. Searching for this problem seems a bit difficult. Any idea on what could be happening? Thanks in advance, Richard Simões --~--~-~--~~~---~--~~ 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: Wiki/CMS app?
On Tue, Aug 26, 2008 at 12:23 PM, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > Hi, > > I search a Wiki/CMS application to manage a homepage. > > This application should: > - look like a homepage, not like a Wiki > - Content can be HTML and wiki like markup. > - No anonymous editing > - history: Who has edited which page, Diff between versions, reverting. > - Nice URLs http://.../about/ http://.../projects/save-earth/... (not > /projects/1234/) > - URLs, breadcrumbs and menu-structure use the same hierarchy (That is > what most >wikis don't do) > - Tracking of internal back links: Warning, if you try to delete a page > which > is still linked (Needs parsing of HTML) > - Access control is no issue for me. All users can edit everything. > - liberal licence (at best BSD-like) > - of course: Django based. > > is there already something like this? Take a look at django-wikiapp. http://code.google.com/p/django-wikiapp/ https://edge.launchpad.net/django-wikiapp -- Eduardo de Oliveira Padoan http://djangopeople.net/edcrypt/ http://whoisi.com/p/514 http://pinax.hotcluboffrance.com/profiles/edcrypt/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
About Site in django
Hi there, I have a question on the site concept. While reading the source code, I found that there is the site related statement in django.contrib.auth.views.login: if Site._meta.installed: current_site = Site.objects.get_current() else: current_site = RequestSite(request) I'm not clear about "Site._meta.installed". I tried in my project, and found it is already True. But I could not find a way to toggle its value. Could anybody explain how this variable is assigned? Many thanks BRs/PP --~--~-~--~~~---~--~~ 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: Problem with i18n - "en_US" locale translations coming through for "en"
I've raised the following ticket for this issue: http://code.djangoproject.com/ticket/8626 Have also confirmed on latest from svn, 1.0-beta_2-SVN-8643. The ticket includes all the files needed to reproduce the problem. On Aug 27, 5:35 pm, "Fran O'Reilly" <[EMAIL PROTECTED]> wrote: > Hi all, > > I've got a situation where even though the user has selected language > "en", the "en_US" translations are being rendered. My setup has three > languages - "en", "en-us" and "en-gb". I also have three locale > translations corresponding, i.e. "en", "en_GB" and "en_US". > > Anyone seen a similar problem before? > > My settings file has the following: > > LANGUAGE_CODE = 'en' > > ugettext = lambda s: s > LANGUAGES = ( > ('en', ugettext('English (Default)')), > ('en-us', ugettext('English (American)')), > ('en-gb', ugettext('English (British)')), > ) > > I have created translations for each of the three locales above using > the normal django-admin.py commands: > > % django-admin.py makemessages -l en > % django-admin.py makemessages -l en-gb > % django-admin.py makemessages -l en-us > > ... then filled in the django.po files with the translations (for this > test, I made sure to use text that was different for each locale so I > could tell which translations were coming through), then : > > % django-admin.py compilemessages > > then restart my server to pick them up. > > I also have locale middleware setup so that LANGUAGE_CODE is available > on the request. Here's my settings.py: > > MIDDLEWARE_CLASSES = ( > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.middleware.locale.LocaleMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware', > 'django.middleware.transaction.TransactionMiddleware', > ) > > Here's a snippet from my template. It lives at /index.html/ and has a > dropdown control that allows the user to select the default language. > It's basically just a homepage where the user chooses their preferred > language setting with a dropdown form and submit button. It hooks into > the django set-language view (django.conf.urls.i18n) being mapped to > the url /i18n/setlang/. It has a h1 element that is translated as well > as a debug print of the value of request.LANGUAGE_CODE. The "Homepage" > text is translated in each of the locale's django.po files with text > like "Homepage (en)", "Homepage (en-gb)" or "Homepage (en-us)" so I > can tell which translation is coming through to the template. > > --snip-- > > > {% trans "Current selected native language/dialect" > %} > > {% for lang in LANGUAGES %} > %}selected {% endifequal %}>{{ lang.1 }} > {% endfor %} > > > > > LANGUAGE_CODE={{ request.LANGUAGE_CODE }} > > {% trans "Homepage" %} > --snip-- > > So when I select the language "en", the template renders the "en_US" > values in the template which is wrong - expect "en" locale. If I > switch to "en-gb" or "en-us", it works as you'd expect, pulling back > the en_GB or en_US locale translations. Just with "en", for some > reason, it pulls back the "en_US" translations, but obviously I'd > expect the "en" translation to come back. > > Also very odd: If I take out the "en_US" locale and language code from > the above, the "en" and "en_GB" locales now work correctly! It's as if > there were something special about the "en_US" locale in the code > somewhere?! > > I'm running django svn 8015, about a month old or thereabouts. Haven't > had time to try this on the latest svn. > > Any help appreciated, > > Fran O'Reilly. --~--~-~--~~~---~--~~ 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: Another django db memory leak?
For some reason, when I do x.save() over an over, it takes about 200k, too. either I have something really messed up, or there is a real problem with this api. On Aug 28, 10:34 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > To summarize - I double checked that DEBUG=False and ran all the tests > again: > > # 20k per call > x = Page.objects.filter( > #(Q(type='P') & (Q(status='N') | > Q(status='R'))) & > #(Q(last_action_datetime__isnull=True) | > Q(last_action_datetime__lt=cut_off))).count() > > # 4K-12K > x= Page.objects.filter(type='P', status='N').count() > > # 4K-12K > x = Page.objects.filter(type='P').count() > > # 4K-12K > x = Page.objects.filter(status='N').count() > > # 0K > x = Page.objects.all().count() > > # 0k > x = Page.objects.extra(where= > ["(type='P' and (status='N' or status='R') and > \ > (last_action_datetime is null or > last_action_datetime < '2009-1-1'))"]).count() > > On Aug 28, 10:17 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > > > Previously I found get_or_create() to be leaky, so I stopped using > > it. Now I'm seeing filter() to be leaky. > > > First, yes, I have DEBUG=False, and I have double checked that > > connection.queries is empty. > > > Suppose the following model > > > class Page(models.Model): > > type = models.CharField(max_length=1,default='P') > > status = models.CharField(max_length=2,default='N') > > last_action_datetime = models.DateTimeField(null=True) > > > All memory checked by looking for VmRSS: in /proc/{pid}/status - on > > linux (Resident) > > > If I call the following using filter() and Q() > > > x = Page.objects.filter( > > (Q(type='P') & (Q(status='N') | > > Q(status='R'))) & > > (Q(last_action_datetime__isnull=True) | > > Q(last_action_datetime__lt=cut_off))).count() > > > repeatedly, memory climbs by about 50KB / loop. > > > Suspecting Q, I tried this > > > x = Page.objects.filter(type='P', status='N').count() > > > which increases at about 4-16KB per / loop > > > as does > > x = Page.objects.filter(type='P').count(), and > > x = Page.objects.filter(status='N').count() > > > If I change it to > > > x = Page.objects.all().count() > > > Memory stays constant, but that isn't filtering enough. So I tried > > > x = Page.objects.extra(where= > > ["(type='P' and (status='N' or status='R') and \ > > (last_action_datetime is null or last_action_datetime < > > '2009-1-1'))"]).count() > > > Memory stays constant for this one too. Although this isn't the best > > DRY form, it doesn't seem to leak. > > > At this point, I figure that if you plan on making lots of calls that > > would use filter() probably use extra instead. > > > Clearly, I'm taking the django db layer, probably initially designed > > to support webdev, and I'm using it to do heavy scripting. It works > > great, other than these memory problems. And since we are also > > building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ 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 handle platform dependent settings?
I test my code locally on my PC using the XAMPP package, and deploy the real site on Linux with Apache. My code is all common, except for settings.py and urls.py. I'd rather not have 2 versions of these files and try to manage that in my SVN repository. I was thinking about doing something like this: if platform.system() == "Windows": MEDIA_ROOT = 'something for windows' MEDIA_URL = 'xyz' # more stuff here... else: MEDIA_ROOT = 'something for linux' MEDIA_URL = 'abc' # more stuff here... Is there a better way? Does this cause a performance hit, or is settings.py and urls.py processed only once? --~--~-~--~~~---~--~~ 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 URL
Also, convention seems to be to spell out the field names. Because of a different namespaces, you shouldn't have to worry about too much name clashing. And if you don't provide an ID for your model, one is automatically created for you. For example: class Category(models.Model): name = models.CharField(max_length=20) description = models.CharField(max_length=200) def __unicode__(self): return u'%s' % self.name On Aug 27, 7:45 pm, djandrow <[EMAIL PROTECTED]> wrote: > I'm trying to create a situation where you can bring up all the blog > entries in a category through the URL. I've got this in my urls.py: > > from django.conf.urls.defaults import * > from akonline.views import current_datetime > > urlpatterns = patterns('', > > (r'^test/$', 'address.blog.views.blog'), > (r'^blog/(?P\w+)/$', > 'address.blog.views.category_entry'), > ) > > - > > then this is the category_entry in my views: > > def category_entry(request, category): > entries_in_cat = Entry.objects.filter(entry_cat=category) > return render_to_response('blog/index.html', locals()) > > - > > then this is my pretty simple template: > > > {% for object in entries_in_cat %} > {{ object.entry_title }} {% endfor %} > > > - > > then these models: > > from django.db import models > > class Category(models.Model): > cat_id = models.AutoField(primary_key=True) > cat_name = models.CharField(max_length=20) > cat_desc = models.CharField(max_length=200) > > def __unicode__(self): > return self.cat_name > > class Entry(models.Model): > > entry_id = models.AutoField(primary_key=True) > entry_date = models.DateField(auto_now_add=True) > entry_title = models.CharField(max_length=70) > entry_content = models.TextField(max_length=5000) > entry_cat = models.ManyToManyField(Category) > > def __unicode__(self): > return self.entry_title > > - > > I don't get an error, its just it returns a blank page, so i'd guess > either category isn't being read in correctly or the filter statement > is incorrect. I'd appericiate any help > > Thanks, > > Andrew --~--~-~--~~~---~--~~ 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 URL
Your problem is here: def category_entry(request, category): entries_in_cat = Entry.objects.filter(entry_cat=category) return render_to_response('blog/index.html', locals()) Remember, the value of "category" is a string. One way or another you need adjust the filter. Something like this should do the trick. entries_in_cat = Entry.objects.filter(entry_cat__name=category) -or- thecat = Category.objects.get(cat_name=category) entries_in_cat = Entry.objects.filter(entry_cat=thecat) I prefer the first... HTH Keith On Aug 27, 7:45 pm, djandrow <[EMAIL PROTECTED]> wrote: > I'm trying to create a situation where you can bring up all the blog > entries in a category through the URL. I've got this in my urls.py: > > from django.conf.urls.defaults import * > from akonline.views import current_datetime > > urlpatterns = patterns('', > > (r'^test/$', 'address.blog.views.blog'), > (r'^blog/(?P\w+)/$', > 'address.blog.views.category_entry'), > ) > > - > > then this is the category_entry in my views: > > def category_entry(request, category): > entries_in_cat = Entry.objects.filter(entry_cat=category) > return render_to_response('blog/index.html', locals()) > > - > > then this is my pretty simple template: > > > {% for object in entries_in_cat %} > {{ object.entry_title }} {% endfor %} > > > - > > then these models: > > from django.db import models > > class Category(models.Model): > cat_id = models.AutoField(primary_key=True) > cat_name = models.CharField(max_length=20) > cat_desc = models.CharField(max_length=200) > > def __unicode__(self): > return self.cat_name > > class Entry(models.Model): > > entry_id = models.AutoField(primary_key=True) > entry_date = models.DateField(auto_now_add=True) > entry_title = models.CharField(max_length=70) > entry_content = models.TextField(max_length=5000) > entry_cat = models.ManyToManyField(Category) > > def __unicode__(self): > return self.entry_title > > - > > I don't get an error, its just it returns a blank page, so i'd guess > either category isn't being read in correctly or the filter statement > is incorrect. I'd appericiate any help > > Thanks, > > Andrew --~--~-~--~~~---~--~~ 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 URL
I'm trying to create a situation where you can bring up all the blog entries in a category through the URL. I've got this in my urls.py: from django.conf.urls.defaults import * from akonline.views import current_datetime urlpatterns = patterns('', (r'^test/$', 'address.blog.views.blog'), (r'^blog/(?P\w+)/$', 'address.blog.views.category_entry'), ) - then this is the category_entry in my views: def category_entry(request, category): entries_in_cat = Entry.objects.filter(entry_cat=category) return render_to_response('blog/index.html', locals()) - then this is my pretty simple template: {% for object in entries_in_cat %} {{ object.entry_title }} - then these models: from django.db import models class Category(models.Model): cat_id = models.AutoField(primary_key=True) cat_name = models.CharField(max_length=20) cat_desc = models.CharField(max_length=200) def __unicode__(self): return self.cat_name class Entry(models.Model): entry_id = models.AutoField(primary_key=True) entry_date = models.DateField(auto_now_add=True) entry_title = models.CharField(max_length=70) entry_content = models.TextField(max_length=5000) entry_cat = models.ManyToManyField(Category) def __unicode__(self): return self.entry_title - I don't get an error, its just it returns a blank page, so i'd guess either category isn't being read in correctly or the filter statement is incorrect. I'd appericiate any help Thanks, Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems With The Tutorial
Make sure your typing the command without the quotes too. Example: python manage.py runserver Tim ^,^ On Wed, Aug 27, 2008 at 11:42 PM, Sonny <[EMAIL PROTECTED]> wrote: > > When I type ' python manage.py runserver' bash says no file or > directory found. > I'm running ubuntu 7.02? > Thanks for any help you can give. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems With The Tutorial
If manage.py is not in your PATH (it most likely isn't), you need to qualify the location. You can just use this command from within your project directory: ./manage.py runserver ./ means current directory. HTH Keith On Aug 27, 6:42 pm, Sonny <[EMAIL PROTECTED]> wrote: > When I type ' python manage.py runserver' bash says no file or > directory found. > I'm running ubuntu 7.02? > Thanks for any help you can give. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems With The Tutorial
On Wed, 27 Aug 2008 15:42:08 -0700 (PDT), Sonny <[EMAIL PROTECTED]> wrote: > > When I type ' python manage.py runserver' bash says no file or > directory found. > I'm running ubuntu 7.02? > Thanks for any help you can give. Hi Sonny, Did you do a: django-admin.py startproject mysite then cd mysite is there a "manage.py" file in that directory? Regards, Ray Smith http://RaymondSmith.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 -~--~~~~--~~--~--~---
Problems With The Tutorial
When I type ' python manage.py runserver' bash says no file or directory found. I'm running ubuntu 7.02? Thanks for any help you can give. --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
Hi Karen, for me it seems very very strange. The code I used is so simple and theoretical does not contain any bugs. I deleted every file that I uploaded in a former trial, so I dont have any file with the - for test purposes static - filename test.txt in my media-directory. What happens is what was described in the ticket: django thinks the file already exists and therfore appends an underscore. Anyway it must be something that is specific to my computer and configuration. I use the newest revision, I dont have any file with that name in the target-directory, I even took a look on the rights of the target folderso theoretical it might work - but practical it doesnt. I will try to test this tomorrow on another computer - I know this is not a logical approach to fix this, but the problem itself does not seem logical to me. Anyway, I thank you very much for your help. If you ll have any ideas - please let me know. If I found what my problem was I will post it here. Thanks Toni --~--~-~--~~~---~--~~ 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: Another django db memory leak?
To summarize - I double checked that DEBUG=False and ran all the tests again: # 20k per call x = Page.objects.filter( #(Q(type='P') & (Q(status='N') | Q(status='R'))) & #(Q(last_action_datetime__isnull=True) | Q(last_action_datetime__lt=cut_off))).count() # 4K-12K x= Page.objects.filter(type='P', status='N').count() # 4K-12K x = Page.objects.filter(type='P').count() # 4K-12K x = Page.objects.filter(status='N').count() # 0K x = Page.objects.all().count() # 0k x = Page.objects.extra(where= ["(type='P' and (status='N' or status='R') and \ (last_action_datetime is null or last_action_datetime < '2009-1-1'))"]).count() On Aug 28, 10:17 am, "ristretto.rb" <[EMAIL PROTECTED]> wrote: > Previously I found get_or_create() to be leaky, so I stopped using > it. Now I'm seeing filter() to be leaky. > > First, yes, I have DEBUG=False, and I have double checked that > connection.queries is empty. > > Suppose the following model > > class Page(models.Model): > type = models.CharField(max_length=1,default='P') > status = models.CharField(max_length=2,default='N') > last_action_datetime = models.DateTimeField(null=True) > > All memory checked by looking for VmRSS: in /proc/{pid}/status - on > linux (Resident) > > If I call the following using filter() and Q() > > x = Page.objects.filter( > (Q(type='P') & (Q(status='N') | > Q(status='R'))) & > (Q(last_action_datetime__isnull=True) | > Q(last_action_datetime__lt=cut_off))).count() > > repeatedly, memory climbs by about 50KB / loop. > > Suspecting Q, I tried this > > x = Page.objects.filter(type='P', status='N').count() > > which increases at about 4-16KB per / loop > > as does > x = Page.objects.filter(type='P').count(), and > x = Page.objects.filter(status='N').count() > > If I change it to > > x = Page.objects.all().count() > > Memory stays constant, but that isn't filtering enough. So I tried > > x = Page.objects.extra(where= > ["(type='P' and (status='N' or status='R') and \ > (last_action_datetime is null or last_action_datetime < > '2009-1-1'))"]).count() > > Memory stays constant for this one too. Although this isn't the best > DRY form, it doesn't seem to leak. > > At this point, I figure that if you plan on making lots of calls that > would use filter() probably use extra instead. > > Clearly, I'm taking the django db layer, probably initially designed > to support webdev, and I'm using it to do heavy scripting. It works > great, other than these memory problems. And since we are also > building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Party in Montreal?
Nice. Any other people? Do you have any preference about where we should go? On Wed, Aug 27, 2008 at 9:26 AM, didier rano <[EMAIL PROTECTED]> wrote: > One more ! > > 2008/8/27, Dan <[EMAIL PROTECTED]>: >> >> Are there other people in the Montreal area that would like to celebrate >> the 1.0 release? >> >> >> >> --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Another django db memory leak?
Previously I found get_or_create() to be leaky, so I stopped using it. Now I'm seeing filter() to be leaky. First, yes, I have DEBUG=False, and I have double checked that connection.queries is empty. Suppose the following model class Page(models.Model): type = models.CharField(max_length=1,default='P') status = models.CharField(max_length=2,default='N') last_action_datetime = models.DateTimeField(null=True) All memory checked by looking for VmRSS: in /proc/{pid}/status - on linux (Resident) If I call the following using filter() and Q() x = Page.objects.filter( (Q(type='P') & (Q(status='N') | Q(status='R'))) & (Q(last_action_datetime__isnull=True) | Q(last_action_datetime__lt=cut_off))).count() repeatedly, memory climbs by about 50KB / loop. Suspecting Q, I tried this x = Page.objects.filter(type='P', status='N').count() which increases at about 4-16KB per / loop as does x = Page.objects.filter(type='P').count(), and x = Page.objects.filter(status='N').count() If I change it to x = Page.objects.all().count() Memory stays constant, but that isn't filtering enough. So I tried x = Page.objects.extra(where= ["(type='P' and (status='N' or status='R') and \ (last_action_datetime is null or last_action_datetime < '2009-1-1'))"]).count() Memory stays constant for this one too. Although this isn't the best DRY form, it doesn't seem to leak. At this point, I figure that if you plan on making lots of calls that would use filter() probably use extra instead. Clearly, I'm taking the django db layer, probably initially designed to support webdev, and I'm using it to do heavy scripting. It works great, other than these memory problems. And since we are also building a webapp, it follows the DRY model to data access. --~--~-~--~~~---~--~~ 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 a form to invalid after having called form.is_valid()
Thanks, that works great! I didn't know about 'from django.core.files.images import get_image_dimensions'. Where can I find documentation about that? I've tried a custom 'clean_image' before using PIL, but that was just plain ugly. I never knew about 'get_image_dimensions'. 2B > It's much simpler (and more appropriate) to do this in your form > itself. Specifically, add a clean_image method to your form and check > the image dimensions there. Then raise a forms.ValidationError on the > appropriate condition. Something along these lines would be a start: > > def clean_image(self): > from django.core.files.images import get_image_dimensions > image = self.cleaned_data['image'] > w, h = get_image_dimensions(image) > if w > 640: > raise forms.ValidationError(u'That image is too wide.') > return image > > -Rajesh D --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
an easy was to overwrite the submit_row templatetag
Hi! I am writing my first custom admin page where I would like to add an extra button (action). I think the easiest would be if I could simply overwrite the submit_row templatetag or just the template it calls (submit_line.html) defined in contrib.admin.templatetags.admin_modify is there a simple way to do this? I've tried to create a custom submit_line.html under my templates/ admin/application/model directory, but (unlike for the "main" admin templates) this didn't work have a nice day! 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: running Django on a very small VPS
You could also check out westhost.com. They offer VPS pretty cheap too. I successfully set up Django there a number of times already. I usually use the development (SVN) version, but since an svn client isn't installed there, I just "svn update" locally then FTP the tarball up there when I want to update. I have seen some forum posts out there that discuss setting up an svn client there. I just haven't done it yet... Other than that, works great. On Aug 27, 4:14 pm, Edwin W <[EMAIL PROTECTED]> wrote: > I was just wondering whether anyone out there has experience with > running a Django application on a really small VPS. I'm using Django > for small personal projects and experimentation, and I found vpslink > which has a plan with 2.5 GB of disk space but only 64 MB RAM. I know > that it won't work out of the box and that I'll have to do some tuning > to Apache to get it to work, I found this link which suggests it's > possible: > > http://brizzled.clapper.org/id/73 > > I also came across this discussion in the group: > > http://groups.google.com/group/django-users/browse_thread/thread/19b9... > > So am I crazy to try to push the limits this low? Any additional tips > would be appreciated as well! --~--~-~--~~~---~--~~ 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 question - import conflicts
Thank you for coming back on this. Tim - The structure is organised as you say. James - Thanks for confirming it is simply a path situation, which is all it could be i guess, but for some reason things haven't been working out which has been making me think something else might have been going on. From what you say putting the project dir on the python path will sort it ( i thought i tried that but i must, and hopefully, made a mistake). i'll come back at it tomorrow for another shot. On 27 Aug 2008, at 21:23, James Matthews wrote: > > Make the structer > > sitedir (manage.py urls.py,settings.py)->app(models.py views.py) > And import it accordingly If your code is running in the sitedir then > it should be able to import it. > > On Wed, Aug 27, 2008 at 12:34 PM, Tim Kersten <[EMAIL PROTECTED]> wrote: >> >> Your app folder must be in the current directory, iirc, or in the >> python path for the import to work. Because the project is in the >> python path you'll always be able to import project.app. Rather than >> trying to "import something from app" - which as you said fails, you >> could try "import something", as long as your script is in the same >> folder. >> >> I'm not sure the above works as I'm writing from memory. >> >> Tim ^,^ >> >> >> >> >> On Wed, Aug 27, 2008 at 7:49 PM, [EMAIL PROTECTED] >> <[EMAIL PROTECTED]> wrote: >>> >>> All apps works fine in the local development environment, upload >>> it to >>> the server run syncdb and bang! import conflicts all over the place >>> 'cannot import xxx'. Django apps and standalone apps are fine, it's >>> only with the import statements amongst inter-related models in the >>> project's own apps that the trouble begins. I'm using django SVN and >>> postgresql 8.3.3. >>> >>> I'm sure there is some real simple noobie answer probably related to >>> the pythonpath here i've missed. >>> >>> The actual import statements refer only to the app ( ie. 'from app >>> import model', rather than 'from project.app import model'.) Adding >>> the project name to the statements does solve this. But what's the >>> cleaner one-stop path solution? >>> >>> Thanks in advance. >>> >>> >>> >> >>> >> > > > > -- > http://www.goldwatches.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 -~--~~~~--~~--~--~---
Django ORM-level Caching
Greetings from SF! Here's a bit from one of our internal projects. Does something like this already exist? If so, does it work well? If not, would anyone be interested in this? We now have this working (well, at least limping) with Django 0.96 and memcached. MOTIVATION: - Suppose the following is very expensive: MyStuff.objects.filter() We commonly use caching to avoid doing this operation often, which can leave our code littered with the following: cached = cache.get() if cached: return cached else: x = MyStuff.objects.filter() cache.set(,x,) return x We seek to unify the Django ORM and caching in a natural way. USE CASES: - To cache QuerySets, append .cache() to the end of the Django ORM call. This will cache the given object for seconds provided that the cachekey is not already in the cache. - Example: MyStuff.objects.filter(extra_type=4).cache(3600) - This should return all MyStuff objects with an id greater than 10 and should store the result to the cache for 3600 seconds (1 hour). - To force caching (even if the cachekey already exists), provide the force argument (e.g., .cache(,force=True)). - Example: MyStuff.objects.filter(mass=20).cache(3600,force=True) - This should return all MyStuff objects with a mass of 20 and should cache the result for 3600 seconds even if it would over-write a previously-cached result. - To ensure that a cached value is not used, use .nocache() before any specific call. - Example: MyStuff.objects.nocache().filter(user__id=7) - This should return all MyStuff objects with a User whose id is 7 and should not use a previously-cached value even if it exists. Thanks 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: running Django on a very small VPS
I know this isn't exactly on topic, but I signed up for http://djangohosting.ch/ today and was rather impressed. It's not a VPS, but quite impressive all the same. Tim ^,^ On Wed, Aug 27, 2008 at 9:57 PM, Erik Allik <[EMAIL PROTECTED]> wrote: > > You should check out > http://lincolnloop.com/blog/2008/mar/25/serving-django-cherrypy/ > or simply google for "django cherrypy". Looks cool to me, I'm > planning on using this in WebFaction which has 80MB RAM for the > cheapest plan. > > Erik > > On 27.08.2008, at 23:14, Edwin W wrote: > >> >> I was just wondering whether anyone out there has experience with >> running a Django application on a really small VPS. I'm using Django >> for small personal projects and experimentation, and I found vpslink >> which has a plan with 2.5 GB of disk space but only 64 MB RAM. I know >> that it won't work out of the box and that I'll have to do some tuning >> to Apache to get it to work, I found this link which suggests it's >> possible: >> >> http://brizzled.clapper.org/id/73 >> >> I also came across this discussion in the group: >> >> http://groups.google.com/group/django-users/browse_thread/thread/19b9d007eba5fefd/7582c8e0e214864d?lnk=gst&q=ram#7582c8e0e214864d >> >> So am I crazy to try to push the limits this low? Any additional tips >> would be appreciated as well! >> > > > > > > --~--~-~--~~~---~--~~ 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: running Django on a very small VPS
You should check out http://lincolnloop.com/blog/2008/mar/25/serving-django-cherrypy/ or simply google for "django cherrypy". Looks cool to me, I'm planning on using this in WebFaction which has 80MB RAM for the cheapest plan. Erik On 27.08.2008, at 23:14, Edwin W wrote: > > I was just wondering whether anyone out there has experience with > running a Django application on a really small VPS. I'm using Django > for small personal projects and experimentation, and I found vpslink > which has a plan with 2.5 GB of disk space but only 64 MB RAM. I know > that it won't work out of the box and that I'll have to do some tuning > to Apache to get it to work, I found this link which suggests it's > possible: > > http://brizzled.clapper.org/id/73 > > I also came across this discussion in the group: > > http://groups.google.com/group/django-users/browse_thread/thread/19b9d007eba5fefd/7582c8e0e214864d?lnk=gst&q=ram#7582c8e0e214864d > > So am I crazy to try to push the limits this low? Any additional tips > would be appreciated as well! > > --~--~-~--~~~---~--~~ 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: droplist pre set selected
In addition .. I just seen this one: field1 = forms.ModelChoiceField(..., initial=1,...) But i'm using this in the template: {{ form.as_table }} In combination with the ModelForm class: class ProjectForm(ModelForm): class Meta: model = Project Thanx again. Regards, Gerard. Gerard Petersen wrote: > Hi All, > > I'm trying to preset a dropdown list in a template. On a customer detail page > I have a link to add a project. I got as far that the customer_id is already > in the project_add method. What do I pass on to the template so that the > dropdown list (with customers) has the customer with the related id already > selected? > > The clarifying snippets: > > Link in the customer page: New > Project > > The url: (r'^project/add/(?P\d+)$', 'project_add') > > The view: > > def project_add(request, customer_id): > print customer_id # <<< this contains the id > form = ProjectForm() > return render_to_response(template+'/project_add.html', {'form': form}) > > Thanx a lot! > > Regards, > > Gerard. > -- urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
droplist pre set selected
Hi All, I'm trying to preset a dropdown list in a template. On a customer detail page I have a link to add a project. I got as far that the customer_id is already in the project_add method. What do I pass on to the template so that the dropdown list (with customers) has the customer with the related id already selected? The clarifying snippets: Link in the customer page: New Project The url: (r'^project/add/(?P\d+)$', 'project_add') The view: def project_add(request, customer_id): print customer_id # <<< this contains the id form = ProjectForm() return render_to_response(template+'/project_add.html', {'form': form}) Thanx a lot! Regards, Gerard. -- urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } --~--~-~--~~~---~--~~ 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 a form to invalid after having called form.is_valid()
Whoops I pressed send too soon. In your forms code create a method called clean_imageForm and add your custom error code there. On Wed, Aug 27, 2008 at 1:33 PM, James Matthews <[EMAIL PROTECTED]> wrote: > In your forum code you can add the clean_imageForm and add your cleaning > code in there. > > On Wed, Aug 27, 2008 at 11:39 AM, Rajesh Dhawan <[EMAIL PROTECTED]> > wrote: > > > > Hi, > > > >> I have an image upload form and I want to INvalidate the form if the > >> uploaded image it too big. How can I get an error message in the form > >> saying the uploaded image is too big? > >> > >> ===Model== > >> class Image(models.Model): > >> image = models.ImageField(upload_to='imageupload') > >> > >> ===View=== > >> if imageForm.is_valid(): > >> inst = imageForm.save(commit=False) > >> if inst.image.width > 640: > >> #TODO: set the error message of this form to 'image is too > >> big' > > > > It's much simpler (and more appropriate) to do this in your form > > itself. Specifically, add a clean_image method to your form and check > > the image dimensions there. Then raise a forms.ValidationError on the > > appropriate condition. Something along these lines would be a start: > > > > def clean_image(self): > >from django.core.files.images import get_image_dimensions > >image = self.cleaned_data['image'] > >w, h = get_image_dimensions(image) > >if w > 640: > >raise forms.ValidationError(u'That image is too wide.') > >return image > > > > -Rajesh D > > > > > > > > > > -- > http://www.goldwatches.com/ > > -- http://www.goldwatches.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: setting a form to invalid after having called form.is_valid()
In your forum code you can add the clean_imageForm and add your cleaning code in there. On Wed, Aug 27, 2008 at 11:39 AM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > Hi, > >> I have an image upload form and I want to INvalidate the form if the >> uploaded image it too big. How can I get an error message in the form >> saying the uploaded image is too big? >> >> ===Model== >> class Image(models.Model): >> image = models.ImageField(upload_to='imageupload') >> >> ===View=== >> if imageForm.is_valid(): >> inst = imageForm.save(commit=False) >> if inst.image.width > 640: >> #TODO: set the error message of this form to 'image is too >> big' > > It's much simpler (and more appropriate) to do this in your form > itself. Specifically, add a clean_image method to your form and check > the image dimensions there. Then raise a forms.ValidationError on the > appropriate condition. Something along these lines would be a start: > > def clean_image(self): >from django.core.files.images import get_image_dimensions >image = self.cleaned_data['image'] >w, h = get_image_dimensions(image) >if w > 640: >raise forms.ValidationError(u'That image is too wide.') >return image > > -Rajesh D > > > -- http://www.goldwatches.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: FileUploadHandler does strange things
On Wed, Aug 27, 2008 at 1:16 PM, mwebs <[EMAIL PROTECTED]> wrote: > > Thanks for your help. > > Datafile is a model and just contains a CharField, a FileField a > ForeignKey and some Booleanfields. > --- > class DataFile(models.Model): >name = models.CharField(max_length=255, null = True) >file = models.FileField(upload_to="data", blank = True, null=True) >experiment = models.ForeignKey(Experiment) >ready = models.BooleanField(null = True)# indicates if > file is already labeled >uploading = models.BooleanField(null = True)# indicates if > file is still uploading > -- > > In my view I just try to use the temporaryFileUploadHandler(). Former > I used my own Subclass, but to be sure I just > used the django-native one. This is how I perform the upload: > - > > def upload(request, id): >form = FileForm() >experiment = get_object_or_404(Experiment, pk=id) > >request.upload_handlers = [TemporaryFileUploadHandler()] > >if request.method == 'POST' and request.FILES: >form = FileForm(request.POST, request.FILES) >if form.is_valid(): >datafile = DataFile(experiment = experiment, >name = "test", > file = form.cleaned_data['file']) > datafile.file.save('test.txt', request.FILES['file'], > save=False) >datafile.save() > --- > > I am using revision 1.0 beta 2 -8626 (XP SP2). The code is realy > simple. The only thing I am doing is to use the > TemporaryUploadHandler. And as result I have the >200 files in my > media-directory. > > When I wrote the first post, I had the old djangoversion and with that > I got the windows-error(because the filename was longer than 215). > > With the new version I dont get this error, but it seems as if the > server gets stuck in an endlessloop. It just idles there. > Further I tried to change FILE_UPLOAD_TEMP_DIR = PROJECT_HTDOCS + '/ > media/temp/' > Same result, more than 200 copies in my directory. > > I cannot recreate this behavior with a view I built along the lines you describe. I am able to upload a file fine. The 2nd file I upload has an underscore appended to its name since "test.txt" already exists and that name is hardcoded in the view. Likewise the 3rd gets two underscores, 4th 3, etc. So I can see maybe a problem if you already have all those files and the upload handler never succeeds in finding a name that works? So -- did you clean out all those extra files with underscores after updating to the latest Django and before trying the upload again? 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 -~--~~~~--~~--~--~---
Re: newbie question - import conflicts
Make the structer sitedir (manage.py urls.py,settings.py)->app(models.py views.py) And import it accordingly If your code is running in the sitedir then it should be able to import it. On Wed, Aug 27, 2008 at 12:34 PM, Tim Kersten <[EMAIL PROTECTED]> wrote: > > Your app folder must be in the current directory, iirc, or in the > python path for the import to work. Because the project is in the > python path you'll always be able to import project.app. Rather than > trying to "import something from app" - which as you said fails, you > could try "import something", as long as your script is in the same > folder. > > I'm not sure the above works as I'm writing from memory. > > Tim ^,^ > > > > > On Wed, Aug 27, 2008 at 7:49 PM, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: >> >> All apps works fine in the local development environment, upload it to >> the server run syncdb and bang! import conflicts all over the place >> 'cannot import xxx'. Django apps and standalone apps are fine, it's >> only with the import statements amongst inter-related models in the >> project's own apps that the trouble begins. I'm using django SVN and >> postgresql 8.3.3. >> >> I'm sure there is some real simple noobie answer probably related to >> the pythonpath here i've missed. >> >> The actual import statements refer only to the app ( ie. 'from app >> import model', rather than 'from project.app import model'.) Adding >> the project name to the statements does solve this. But what's the >> cleaner one-stop path solution? >> >> Thanks in advance. >> >> >> > >> > > > > -- http://www.goldwatches.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: running Django on a very small VPS
Use sqllite instead of a regular DB Server. Also set a usage limit on Apache. You Should be fine. Many people run Django in a shared environment. like Webfaction and Dreamhost. Where you have a limit on the memory you can use. On Wed, Aug 27, 2008 at 1:14 PM, Edwin W <[EMAIL PROTECTED]> wrote: > > I was just wondering whether anyone out there has experience with > running a Django application on a really small VPS. I'm using Django > for small personal projects and experimentation, and I found vpslink > which has a plan with 2.5 GB of disk space but only 64 MB RAM. I know > that it won't work out of the box and that I'll have to do some tuning > to Apache to get it to work, I found this link which suggests it's > possible: > > http://brizzled.clapper.org/id/73 > > I also came across this discussion in the group: > > http://groups.google.com/group/django-users/browse_thread/thread/19b9d007eba5fefd/7582c8e0e214864d?lnk=gst&q=ram#7582c8e0e214864d > > So am I crazy to try to push the limits this low? Any additional tips > would be appreciated as well! > > > -- http://www.goldwatches.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 -~--~~~~--~~--~--~---
running Django on a very small VPS
I was just wondering whether anyone out there has experience with running a Django application on a really small VPS. I'm using Django for small personal projects and experimentation, and I found vpslink which has a plan with 2.5 GB of disk space but only 64 MB RAM. I know that it won't work out of the box and that I'll have to do some tuning to Apache to get it to work, I found this link which suggests it's possible: http://brizzled.clapper.org/id/73 I also came across this discussion in the group: http://groups.google.com/group/django-users/browse_thread/thread/19b9d007eba5fefd/7582c8e0e214864d?lnk=gst&q=ram#7582c8e0e214864d So am I crazy to try to push the limits this low? Any additional tips would be appreciated as well! --~--~-~--~~~---~--~~ 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: Bug in ImageFieldFile.save() ?
Thanks for the clarification. I will definitely look forward to having file-like objects work this way. I'll keep my eye out for the commit. On Aug 27, 7:23 am, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 12:37 AM, Brian Morton <[EMAIL PROTECTED]> wrote: > > The docs (and an analysis of the code) indicate that the second > > argument to save should be the content. > > >http://docs.djangoproject.com/en/dev/ref/files/file/#ref-files-file > > > I am assuming this is binary or text content to be written to the file > > in question. ImageFieldFile calls get_image_dimensions(content) in > > save, and get_image_dimensions assumes that the input is a file or > > path that can be open()ed by the file module. > > Yeah, looks like the documentation needs to be clearer there, because > your assumption is incorrect. The "content" argument to > FieldFile.save() is expected to be a File object itself, since it's > usually an UploadedFile. There's been talk about updating it to accept > any file-like object, which I'm working on, but it's not yet > available. > > If you need to pass in raw content like that, you can use > django.core.files.base.ContentFile to make a suitable File for use > with .save(). > > So, yes, there's a mismatch there, but it's the documentation that's > incomplete in this case. > > -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: Django svn 8631
Hi Hernan, I'm sure it has something to do with newforms-admin. You probably use something like this in your admin-definition: item = models.ForeignKey(Item, related_name='photos', edit_inline=models.STACKED) I don't know if you are aware of the changes that have been made to the way the admin has to be configured in Django, but there have been considerable changes. I guess you might find more info here: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Inlineediting Best Regards, Jesaja Everling On Wed, Aug 27, 2008 at 9:44 PM, Hernan Olivera <[EMAIL PROTECTED]> wrote: > > Hello > > My app crashes when I update to the last svn version 8631 with this error: > > ImproperlyConfigured: Error while importing URLconf 'dataentry.urls': > 'module' object has no attribute 'STACKED' > > Obviously, my app were ok before that. > > 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: Django svn 8631
On Wed, Aug 27, 2008 at 4:44 PM, Hernan Olivera <[EMAIL PROTECTED]> wrote: > > Hello > > My app crashes when I update to the last svn version 8631 with this error: > > ImproperlyConfigured: Error while importing URLconf 'dataentry.urls': > 'module' object has no attribute 'STACKED' > > Obviously, my app were ok before that. > > Ideas? edit_inline has been replaced with InlineModelAdmin objects: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects Following the new version of part 2 of the tutorial will be also of help: http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 If you are using Django from SVN and updating it periodically you *should* wlways read the [1]BackwardsIncompatibleChanges page, in your case http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Mergednewforms-adminintotrunk Good luck 1. http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges -- Ramiro Morales --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django svn 8631
Hello My app crashes when I update to the last svn version 8631 with this error: ImproperlyConfigured: Error while importing URLconf 'dataentry.urls': 'module' object has no attribute 'STACKED' Obviously, my app were ok before that. 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: newbie question - import conflicts
Your app folder must be in the current directory, iirc, or in the python path for the import to work. Because the project is in the python path you'll always be able to import project.app. Rather than trying to "import something from app" - which as you said fails, you could try "import something", as long as your script is in the same folder. I'm not sure the above works as I'm writing from memory. Tim ^,^ On Wed, Aug 27, 2008 at 7:49 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > All apps works fine in the local development environment, upload it to > the server run syncdb and bang! import conflicts all over the place > 'cannot import xxx'. Django apps and standalone apps are fine, it's > only with the import statements amongst inter-related models in the > project's own apps that the trouble begins. I'm using django SVN and > postgresql 8.3.3. > > I'm sure there is some real simple noobie answer probably related to > the pythonpath here i've missed. > > The actual import statements refer only to the app ( ie. 'from app > import model', rather than 'from project.app import model'.) Adding > the project name to the statements does solve this. But what's the > cleaner one-stop path solution? > > Thanks 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: HowTo: Django view as a class
V: Defining a __call__ method will make *instances* of the class callable. Calling the class itself will still just instantiate it. On Tue, Aug 26, 2008 at 7:00 AM, V <[EMAIL PROTECTED]> wrote: > > Hi! > > Interesting solution. > > Another possibility if you would like to stick with a class is to > simply define a __call__ method on the class. Of course, this doesn't > have to do anything with RESTfulness. > > V > > On Aug 26, 3:07 am, zvoase <[EMAIL PROTECTED]> wrote: > > Hey Django users, just a quick suggestion which might help a few > > people. > > I have come up with a way of writing a Django view as a class. I've > > done this as part of an effort to write easier-to-understand RESTful > > apps, as this allows the grouping of similar views as different types > > of operation on a resource. Essentially, the solution goes something > > like this: > > > > * Views have to be callables which return HttpResponse objects. > > * The problem with views as classes is that calling a view class > > returns an instance of the view class, not HttpResponse. > > * Solution: have the VC (view class) a subclass of HttpResponse. > > This way, 'calling' the class will return a HttpResponse instance. > > > > I've written a general class, Resource, which performs a dispatch on > > the request method, so that a resource can be retrieved, created/ > > updated and deleted by writing 'get', 'put' and 'delete' methods on a > > subclass of Resource. > > > > A sample resource may look like this: > > > > # CODE START # > > > > class Book(Resource): > > def get(self, request, book_name): > > book = myapp.models.Book.objects.get(name=book_name) > > return render_to_response('book_template.html', {'book': > > book}) > > > >def put(self, request, book_name): > > new_book, created = get_or_create(myapp.models.Book, > > name=book_name) > > new_book.data = request.raw_post_data > > if created: > > return HttpResponse(status=201) > > return HttpResponse(status=200) > > > > def delete(self, request, book_name): > > book = myapp.models.Book.objects.get(name=book_name) > > book.delete() > > return HttpResponse() > > > > # CODE END # > > > > You can see how these methods correspond to GET, PUT and DELETE > > request methods, and the dispatch is performed in the __init__ method > > defined in the Resource class. HttpResponse instances can be returned > > from these methods, and their data will be merged with 'self' by > > __init__. > > > > Okay, so here's the code I've written: > > > > # CODE START # > > > > class Resource(HttpResponse): > > def __init__(self, request, *args, **kwargs): > > HttpResponse.__init__(self) > > if hasattr(self, request.method.lower()): > > value = getattr(self, > request.method.lower())(request, *args, > > **kwargs) > > if isinstance(value, HttpResponse): > > self.update(value) > > elif hasattr(self, 'run'): > > value = self.run(request, *args, **kwargs) > > if isinstance(value, HttpResponse): > > self.update(value) > > > > def update(self, response): > > self._charset = response._charset > > self._is_string = response._is_string > > self._container = response._container > > self._headers.update(response._headers) > > self.cookies.update(response.cookies) > > self.status_code = response.status_code > > > > def render_to_response(self, *args, **kwargs): > > self.update(render_to_response(*args, **kwargs)) > > > > # CODE END # > > > > I hope people find this useful. > > > > Regards, > > Zack > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
newbie question - import conflicts
All apps works fine in the local development environment, upload it to the server run syncdb and bang! import conflicts all over the place 'cannot import xxx'. Django apps and standalone apps are fine, it's only with the import statements amongst inter-related models in the project's own apps that the trouble begins. I'm using django SVN and postgresql 8.3.3. I'm sure there is some real simple noobie answer probably related to the pythonpath here i've missed. The actual import statements refer only to the app ( ie. 'from app import model', rather than 'from project.app import model'.) Adding the project name to the statements does solve this. But what's the cleaner one-stop path solution? Thanks 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: setting a form to invalid after having called form.is_valid()
Hi, > I have an image upload form and I want to INvalidate the form if the > uploaded image it too big. How can I get an error message in the form > saying the uploaded image is too big? > > ===Model== > class Image(models.Model): > image = models.ImageField(upload_to='imageupload') > > ===View=== > if imageForm.is_valid(): > inst = imageForm.save(commit=False) > if inst.image.width > 640: > #TODO: set the error message of this form to 'image is too > big' It's much simpler (and more appropriate) to do this in your form itself. Specifically, add a clean_image method to your form and check the image dimensions there. Then raise a forms.ValidationError on the appropriate condition. Something along these lines would be a start: def clean_image(self): from django.core.files.images import get_image_dimensions image = self.cleaned_data['image'] w, h = get_image_dimensions(image) if w > 640: raise forms.ValidationError(u'That image is too wide.') return image -Rajesh D --~--~-~--~~~---~--~~ 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: database relationships
Yup that did it. I could have sworn I tried that, but I guess not. Thanks again. Charlie On Aug 27, 1:27 pm, lingrlongr <[EMAIL PROTECTED]> wrote: > Try this is the template: > > {% for albumart in album.albumart_set.all %} > {{ albumart.image }} > {% endfor %} > > On Aug 27, 11:58 am, nek4life <[EMAIL PROTECTED]> wrote: > > > Well this works great while using the generic detail view, but when I > > return a list view the relationships won't work. > > > in my view > > > def album_list(request, page=0): > > return list_detail.object_list( > > request, > > queryset = Album.objects.select_related().all(), > > paginate_by = 20, > > page = page, > > template_object_name = 'album', > > ) > > > in my template > > > {% for albumart in album.albumart_set.all %} > > {{ album.albumart.image }} > > {% endfor %} > > > Is this not supported in list_detail.object_list? I can't find > > information on this anywhere, may have to change my database around. > > > On Aug 22, 11:44 am, nek4life <[EMAIL PROTECTED]> wrote: > > > > Awesome. I got it to work using this code in my view. > > > > def artist_detail(request, slug): > > > album_list = Album.objects.all() > > > return list_detail.object_detail( > > > request, > > > queryset = Artist.objects.all(), > > > slug = slug, > > > template_object_name = 'artist', > > > extra_context={'album_list': album_list} > > > ) > > > > But the way you're doing it only calls the database once instead of > > > twice. Beautiful! Thank you. I'm going to try the query you > > > suggested. > > > > queryset=Artist.objects.select_related().all() > > > > I'd like to just pull in the albums, artwork, and tracks related to > > > the particular artist in the url slug, for > > > instancehttp://www.example.com/artists/artist-name > > > > You've been a huge help. Thanks a ton! > > > > Charlie > > > > On Aug 22, 11:20 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > Also note, if your intentions were to grab all that information and > > > > just send the artist to the template, I think you'd get better > > > > performance if your queryset in the view looked like this: > > > > > queryset=Artist.objects.select_related().all() > > > > > Keith > > > > > On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > Super easy :) Just to show you another way to implement generic > > > > > views, I used custom view that returns a generic view. > > > > > > # urls.py > > > > > from myapp.views import artist > > > > > ... > > > > > (r'^artist/(?P\w+)/$', artist), > > > > > ... > > > > > > #views.py > > > > > from django.views.generic.list_detail import object_detail > > > > > def artist(request, slug): > > > > > return object_detail( > > > > > request, > > > > > queryset=Artist.objects.all(), > > > > > slug = slug, > > > > > template_object_name = 'artist' > > > > > ) > > > > > > # //artist_list.html > > > > > {{ artist }} > > > > > Albums > > > > > > > > > > {% for album in artist.album_set.all %} > > > > > {{ album.name }} > > > > > > > > > > {% for track in album.track_set.all %} > > > > > {{ track.name }} > > > > > {% endfor %} > > > > > > > > > > {% endfor %} > > > > > > > > > > > Django makes traversing relationships easy... > > > > > > HTH > > > > > > Keith > > > > > > On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote: > > > > > > > So if I sent the artist to the template and wanted to grab the list > > > > > > of > > > > > > albums with all the album tracks how would I go about that. Would I > > > > > > have to pull in all the data with a custom view? So far I've only > > > > > > been using generic views. It definitely makes sense pulling in the > > > > > > information through the track back up through the album to the > > > > > > artist, > > > > > > how could I reverse the process so I can get all the artist vars > > > > > > plus > > > > > > the data I need from the track and album tables? Thanks a bunch, > > > > > > you've been very helpful already. > > > > > > > Charlie > > > > > > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > > > One more note. You wouldn't NEED to explicitly grab all those > > > > > > > vars, > > > > > > > as you can get them in a template too. I just wanted to show you > > > > > > > the > > > > > > > relation. > > > > > > > If you sent the track to the template, you can get the artist by > > > > > > > using: > > > > > > > > {{ track.album.artist }} > > > > > > > > Keith > > > > > > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > > > > The only part you have that is redundant is the "artist" in your > > > > > > > > "Track" class. You can find out the artist because a track is > > > > > > > > related > > > > > > > > to an album, which in turn, is related to an artist. > > > > > > > > > Some of the code you'd maybe see in a view
Re: Complex, somewhat formula...
> TEAM > name > nickname > win > loss > rating > rank > > GAMES > date > away_team (fk) > home_team (fk) > away_score > home_score Shooting from the hip, with no actual data to experiment with, and not knowing your back-end SQL server, the SQL could look something like SELECT Team.*, Coalesce(home.wins, 0) AS Home_Wins, Coalesce(away.wins, 0) AS Away_Wins, Coalesce(home.wins, 0) + Coalesce(away.wins, 0) AS Total_Wins Coalesce(home.played, 0) AS Home_Played, Coalesce(away.played, 0) AS Away_Played, Coalesce(home.played, 0) + Coalesce(away.played, 0) AS Total_Played FROM Team LEFT OUTER JOIN ( SELECT home_team AS Team, Sum( -- NB: not sure non-GROUP-BY values -- can be referenced here. CASE WHEN home_score > away_score THEN 1 ELSE 0 END) AS wins, Count(*) AS played FROM Games GROUP BY home_team ) Home ON Home.team = Team.id LEFT OUTER JOIN ( SELECT away_team AS team, Sum( CASE WHEN home_score < away_score THEN 1 ELSE 0 END) AS wins, Count(*) AS played FROM Games GROUP BY home_team ) Away ON Away.team = Team.id Alternatively, it could look like SELECT Team.*, ( SELECT Count(*) FROM Games WHERE ( home_team = Team.id AND home_score > away_score ) OR ( away_team = Team.id AND home_score < away_score ) ) / ( SELECT Count(*) FROM Games WHERE away_team = Team.id OR home_team = Team.id ) AS Score FROM Team WHERE EXISTS ( SELECT 0 FROM Games WHERE away_team = Team.id OR home_team = Team.id ) which would just give you the raw score (you may need to Convert()/Cast() there bits into non-integer format for a meaningful number) however, it only returns Teams that have played games. Hope this gives you some leads, -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 -~--~~~~--~~--~--~---
Re: Many to One Relationship
Thanks, now is working fine. On 27 ago, 19:22, lingrlongr <[EMAIL PROTECTED]> wrote: > The error is generated because you have two fields in the Swap model > that refer to the User model, and two that refer to the Shifts model. > As the error states you need to specify the related_name value for > those ForeignKeys. Take a look at the documentation for related_name > here:http://www.djangoproject.com/documentation/model-api/#many-to-one-rel... > > class Swaps(models.Model): > origin_shift = models.ForeignKey(Shifts, > related_name='origin_shift') > origin_user = models.ForeignKey(User, > related_name='origin_user') > destination_shift = models.ForeignKey(Shifts, > related_name='destination_shift') > state = models.CharField(maxlength=25) > swap_user = models.ForeignKey(User, related_name='swap_user') > > HTH > > Keith > > On Aug 27, 11:42 am, "Daniel A." <[EMAIL PROTECTED]> wrote: > > > Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with > > something I thing should be easy but for some reason I can't find the > > error. > > > I'm trying to define a model to manage shifts for volunteers. I have > > three diferent models, Shifts, Users and Swaps. A User have many > > Shifts and a Shift have many Swaps, while a Shift only have one User, > > and a Swap only have one Shift. A Shift have two users. Well, then I > > wrote something like this: > > > from django.db import models > > from django.contrib.auth.models import User > > > # Create your models here. > > class Shifts(models.Model): > > date = models.DateField() > > user_1 = models.ForeignKey(User) > > user_2 = models.ForeignKey(User) > > turno = models.IntegerField() > > > class Swaps(models.Model): > > origin_shift = models.ForeignKey(Shifts) > > origin_user = models.ForeignKey(User) > > destination_shift = models.ForeignKey(Shifts) > > state = models.CharField(maxlength=25) > > swap_user = models.ForeignKey(User) > > > Does anybody knows what I'm doing wrong? I get messages of validation > > like this: > > > turno.shifts: Accessor for field 'user_1' clashes with related field > > 'User.shifts_set'. Add a related_name argument to the definition for > > 'user_1'. > > turno.shifts: Accessor for field 'user_2' clashes with related field > > 'User.shifts_set'. Add a related_name argument to the definition for > > 'user_2'. > > turno.swaps: Accessor for field 'origin_shift' clashes with related > > field 'Shifts.swaps_set'. Add a related_name argument to the > > definition for 'origin_shift'. > > turno.swaps: Accessor for field 'origin_user' clashes with related > > field 'User.swaps_set'. Add a related_name argument to the definition > > for 'origin_user'. > > turno.swaps: Accessor for field 'destination_shift' clashes with > > related field 'Shifts.swaps_set'. Add a related_name argument to the > > definition for 'destination_shift'. > > turno.swaps: Accessor for field 'swap_user' clashes with related field > > 'User.swaps_set'. Add a related_name argument to the definition for > > 'swap_user'. > > > Thanks 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: database relationships
Try this is the template: {% for albumart in album.albumart_set.all %} {{ albumart.image }} {% endfor %} On Aug 27, 11:58 am, nek4life <[EMAIL PROTECTED]> wrote: > Well this works great while using the generic detail view, but when I > return a list view the relationships won't work. > > in my view > > def album_list(request, page=0): > return list_detail.object_list( > request, > queryset = Album.objects.select_related().all(), > paginate_by = 20, > page = page, > template_object_name = 'album', > ) > > in my template > > {% for albumart in album.albumart_set.all %} > {{ album.albumart.image }} > {% endfor %} > > Is this not supported in list_detail.object_list? I can't find > information on this anywhere, may have to change my database around. > > On Aug 22, 11:44 am, nek4life <[EMAIL PROTECTED]> wrote: > > > Awesome. I got it to work using this code in my view. > > > def artist_detail(request, slug): > > album_list = Album.objects.all() > > return list_detail.object_detail( > > request, > > queryset = Artist.objects.all(), > > slug = slug, > > template_object_name = 'artist', > > extra_context={'album_list': album_list} > > ) > > > But the way you're doing it only calls the database once instead of > > twice. Beautiful! Thank you. I'm going to try the query you > > suggested. > > > queryset=Artist.objects.select_related().all() > > > I'd like to just pull in the albums, artwork, and tracks related to > > the particular artist in the url slug, for > > instancehttp://www.example.com/artists/artist-name > > > You've been a huge help. Thanks a ton! > > > Charlie > > > On Aug 22, 11:20 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > Also note, if your intentions were to grab all that information and > > > just send the artist to the template, I think you'd get better > > > performance if your queryset in the view looked like this: > > > > queryset=Artist.objects.select_related().all() > > > > Keith > > > > On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > Super easy :) Just to show you another way to implement generic > > > > views, I used custom view that returns a generic view. > > > > > # urls.py > > > > from myapp.views import artist > > > > ... > > > > (r'^artist/(?P\w+)/$', artist), > > > > ... > > > > > #views.py > > > > from django.views.generic.list_detail import object_detail > > > > def artist(request, slug): > > > > return object_detail( > > > > request, > > > > queryset=Artist.objects.all(), > > > > slug = slug, > > > > template_object_name = 'artist' > > > > ) > > > > > # //artist_list.html > > > > {{ artist }} > > > > Albums > > > > > > > > {% for album in artist.album_set.all %} > > > > {{ album.name }} > > > > > > > > {% for track in album.track_set.all %} > > > > {{ track.name }} > > > > {% endfor %} > > > > > > > > {% endfor %} > > > > > > > > > Django makes traversing relationships easy... > > > > > HTH > > > > > Keith > > > > > On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote: > > > > > > So if I sent the artist to the template and wanted to grab the list of > > > > > albums with all the album tracks how would I go about that. Would I > > > > > have to pull in all the data with a custom view? So far I've only > > > > > been using generic views. It definitely makes sense pulling in the > > > > > information through the track back up through the album to the artist, > > > > > how could I reverse the process so I can get all the artist vars plus > > > > > the data I need from the track and album tables? Thanks a bunch, > > > > > you've been very helpful already. > > > > > > Charlie > > > > > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > > One more note. You wouldn't NEED to explicitly grab all those vars, > > > > > > as you can get them in a template too. I just wanted to show you > > > > > > the > > > > > > relation. > > > > > > If you sent the track to the template, you can get the artist by > > > > > > using: > > > > > > > {{ track.album.artist }} > > > > > > > Keith > > > > > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > > > The only part you have that is redundant is the "artist" in your > > > > > > > "Track" class. You can find out the artist because a track is > > > > > > > related > > > > > > > to an album, which in turn, is related to an artist. > > > > > > > > Some of the code you'd maybe see in a view would be: > > > > > > > > # views.py > > > > > > > from django.shortcuts import get_object_or_404 > > > > > > > from models import Album, Track > > > > > > > > def album(request, slug): > > > > > > > album = get_object_or_404(Album, slug=slug) > > > > > > > artist = album.artist > > > > > > > tracks = album.track_set.all() > > > > > > > ...etc... return a response... > > > > > > > > def track(request, slug):
Re: Django and CSS
MEDIA_URL: Says what is the RELATIVE PATH to media files. So it is relative to the root dir in server. Used when referring links in templates. I.E: http://{{MEDIA_URL}}img/img.jpg. It has many other uses but the most important is the one before. MEDIA_ROOT: Says what is the ABSOLUTE PATH to media files. So, it is relative to a LOCAL dir (in server or not). Used to say the exact dir (not relative to any server) where media is. I hope u to understand the difference better. Up Django! 2008/8/27 jgomo3 <[EMAIL PROTECTED]> > > I have no problem serving static content, but i'm still confused about > the MEDIA_ROOT and MEDIA_URL. > > Why the ROOT if i have the URL? > how do you actually use those variables? > > In production and in develpment server i havent used them, i simply > serve the statics content in some virtual server for that (avoiding > the use of django.views.static.serve becuase it force many changes > when passing thr project from the develpment server to apache). > > Are they used to avoid hard code the URL when referencing to things > like css? (example, to avoid 'href="http://example.com/css/site.css";' > and use 'href="http://%s/css/site.css' % MEDIA_URL). > If that then: > Why the MEDIA_ROOT? > For accessing the media files vie the filesystem on views or > someting? > If that then: >It is confusing the comment on the setting file in the variable > MEDIA_URL wich says "This URL handles the media served from > MEDIA_ROOT" because the media files accessed via the MEDIA_URL doesn't > have to be in the same machine. So, is intended that the two variables > refer to the same files? > > > -- --- Juan M.A.N. --- --~--~-~--~~~---~--~~ 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: Many to One Relationship
The error is generated because you have two fields in the Swap model that refer to the User model, and two that refer to the Shifts model. As the error states you need to specify the related_name value for those ForeignKeys. Take a look at the documentation for related_name here: http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships class Swaps(models.Model): origin_shift = models.ForeignKey(Shifts, related_name='origin_shift') origin_user = models.ForeignKey(User, related_name='origin_user') destination_shift = models.ForeignKey(Shifts, related_name='destination_shift') state = models.CharField(maxlength=25) swap_user = models.ForeignKey(User, related_name='swap_user') HTH Keith On Aug 27, 11:42 am, "Daniel A." <[EMAIL PROTECTED]> wrote: > Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with > something I thing should be easy but for some reason I can't find the > error. > > I'm trying to define a model to manage shifts for volunteers. I have > three diferent models, Shifts, Users and Swaps. A User have many > Shifts and a Shift have many Swaps, while a Shift only have one User, > and a Swap only have one Shift. A Shift have two users. Well, then I > wrote something like this: > > from django.db import models > from django.contrib.auth.models import User > > # Create your models here. > class Shifts(models.Model): > date = models.DateField() > user_1 = models.ForeignKey(User) > user_2 = models.ForeignKey(User) > turno = models.IntegerField() > > class Swaps(models.Model): > origin_shift = models.ForeignKey(Shifts) > origin_user = models.ForeignKey(User) > destination_shift = models.ForeignKey(Shifts) > state = models.CharField(maxlength=25) > swap_user = models.ForeignKey(User) > > Does anybody knows what I'm doing wrong? I get messages of validation > like this: > > turno.shifts: Accessor for field 'user_1' clashes with related field > 'User.shifts_set'. Add a related_name argument to the definition for > 'user_1'. > turno.shifts: Accessor for field 'user_2' clashes with related field > 'User.shifts_set'. Add a related_name argument to the definition for > 'user_2'. > turno.swaps: Accessor for field 'origin_shift' clashes with related > field 'Shifts.swaps_set'. Add a related_name argument to the > definition for 'origin_shift'. > turno.swaps: Accessor for field 'origin_user' clashes with related > field 'User.swaps_set'. Add a related_name argument to the definition > for 'origin_user'. > turno.swaps: Accessor for field 'destination_shift' clashes with > related field 'Shifts.swaps_set'. Add a related_name argument to the > definition for 'destination_shift'. > turno.swaps: Accessor for field 'swap_user' clashes with related field > 'User.swaps_set'. Add a related_name argument to the definition for > 'swap_user'. > > Thanks 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: Optimizing Django ORM SQL queries when in a loop
user_id_list=User.objects.filter(whatever).values_list('id', flat=True) posts=Post.objects.filter(user__id__in=user_id_list) Would that work? --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
Thanks for your help. Datafile is a model and just contains a CharField, a FileField a ForeignKey and some Booleanfields. --- class DataFile(models.Model): name = models.CharField(max_length=255, null = True) file = models.FileField(upload_to="data", blank = True, null=True) experiment = models.ForeignKey(Experiment) ready = models.BooleanField(null = True)# indicates if file is already labeled uploading = models.BooleanField(null = True)# indicates if file is still uploading -- In my view I just try to use the temporaryFileUploadHandler(). Former I used my own Subclass, but to be sure I just used the django-native one. This is how I perform the upload: - def upload(request, id): form = FileForm() experiment = get_object_or_404(Experiment, pk=id) request.upload_handlers = [TemporaryFileUploadHandler()] if request.method == 'POST' and request.FILES: form = FileForm(request.POST, request.FILES) if form.is_valid(): datafile = DataFile(experiment = experiment, name = "test", file = form.cleaned_data['file']) datafile.file.save('test.txt', request.FILES['file'], save=False) datafile.save() --- I am using revision 1.0 beta 2 -8626 (XP SP2). The code is realy simple. The only thing I am doing is to use the TemporaryUploadHandler. And as result I have the >200 files in my media-directory. When I wrote the first post, I had the old djangoversion and with that I got the windows-error(because the filename was longer than 215). With the new version I dont get this error, but it seems as if the server gets stuck in an endlessloop. It just idles there. Further I tried to change FILE_UPLOAD_TEMP_DIR = PROJECT_HTDOCS + '/ media/temp/' Same result, more than 200 copies in my directory. Thanks for your help, Toni --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and CSS
I have no problem serving static content, but i'm still confused about the MEDIA_ROOT and MEDIA_URL. Why the ROOT if i have the URL? how do you actually use those variables? In production and in develpment server i havent used them, i simply serve the statics content in some virtual server for that (avoiding the use of django.views.static.serve becuase it force many changes when passing thr project from the develpment server to apache). Are they used to avoid hard code the URL when referencing to things like css? (example, to avoid 'href="http://example.com/css/site.css";' and use 'href="http://%s/css/site.css' % MEDIA_URL). If that then: Why the MEDIA_ROOT? For accessing the media files vie the filesystem on views or someting? If that then: It is confusing the comment on the setting file in the variable MEDIA_URL wich says "This URL handles the media served from MEDIA_ROOT" because the media files accessed via the MEDIA_URL doesn't have to be in the same machine. So, is intended that the two variables refer to the same files? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with i18n - "en_US" locale translations coming through for "en"
Hi all, I've got a situation where even though the user has selected language "en", the "en_US" translations are being rendered. My setup has three languages - "en", "en-us" and "en-gb". I also have three locale translations corresponding, i.e. "en", "en_GB" and "en_US". Anyone seen a similar problem before? My settings file has the following: LANGUAGE_CODE = 'en' ugettext = lambda s: s LANGUAGES = ( ('en', ugettext('English (Default)')), ('en-us', ugettext('English (American)')), ('en-gb', ugettext('English (British)')), ) I have created translations for each of the three locales above using the normal django-admin.py commands: % django-admin.py makemessages -l en % django-admin.py makemessages -l en-gb % django-admin.py makemessages -l en-us ... then filled in the django.po files with the translations (for this test, I made sure to use text that was different for each locale so I could tell which translations were coming through), then : % django-admin.py compilemessages then restart my server to pick them up. I also have locale middleware setup so that LANGUAGE_CODE is available on the request. Here's my settings.py: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.middleware.transaction.TransactionMiddleware', ) Here's a snippet from my template. It lives at /index.html/ and has a dropdown control that allows the user to select the default language. It's basically just a homepage where the user chooses their preferred language setting with a dropdown form and submit button. It hooks into the django set-language view (django.conf.urls.i18n) being mapped to the url /i18n/setlang/. It has a h1 element that is translated as well as a debug print of the value of request.LANGUAGE_CODE. The "Homepage" text is translated in each of the locale's django.po files with text like "Homepage (en)", "Homepage (en-gb)" or "Homepage (en-us)" so I can tell which translation is coming through to the template. --snip-- {% trans "Current selected native language/dialect" %} {% for lang in LANGUAGES %} {{ lang.1 }} {% endfor %} LANGUAGE_CODE={{ request.LANGUAGE_CODE }} {% trans "Homepage" %} --snip-- So when I select the language "en", the template renders the "en_US" values in the template which is wrong - expect "en" locale. If I switch to "en-gb" or "en-us", it works as you'd expect, pulling back the en_GB or en_US locale translations. Just with "en", for some reason, it pulls back the "en_US" translations, but obviously I'd expect the "en" translation to come back. Also very odd: If I take out the "en_US" locale and language code from the above, the "en" and "en_GB" locales now work correctly! It's as if there were something special about the "en_US" locale in the code somewhere?! I'm running django svn 8015, about a month old or thereabouts. Haven't had time to try this on the latest svn. Any help appreciated, Fran O'Reilly. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Many to One Relationship
Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with something I thing should be easy but for some reason I can't find the error. I'm trying to define a model to manage shifts for volunteers. I have three diferent models, Shifts, Users and Swaps. A User have many Shifts and a Shift have many Swaps, while a Shift only have one User, and a Swap only have one Shift. A Shift have two users. Well, then I wrote something like this: from django.db import models from django.contrib.auth.models import User # Create your models here. class Shifts(models.Model): date = models.DateField() user_1 = models.ForeignKey(User) user_2 = models.ForeignKey(User) turno = models.IntegerField() class Swaps(models.Model): origin_shift = models.ForeignKey(Shifts) origin_user = models.ForeignKey(User) destination_shift = models.ForeignKey(Shifts) state = models.CharField(maxlength=25) swap_user = models.ForeignKey(User) Does anybody knows what I'm doing wrong? I get messages of validation like this: turno.shifts: Accessor for field 'user_1' clashes with related field 'User.shifts_set'. Add a related_name argument to the definition for 'user_1'. turno.shifts: Accessor for field 'user_2' clashes with related field 'User.shifts_set'. Add a related_name argument to the definition for 'user_2'. turno.swaps: Accessor for field 'origin_shift' clashes with related field 'Shifts.swaps_set'. Add a related_name argument to the definition for 'origin_shift'. turno.swaps: Accessor for field 'origin_user' clashes with related field 'User.swaps_set'. Add a related_name argument to the definition for 'origin_user'. turno.swaps: Accessor for field 'destination_shift' clashes with related field 'Shifts.swaps_set'. Add a related_name argument to the definition for 'destination_shift'. turno.swaps: Accessor for field 'swap_user' clashes with related field 'User.swaps_set'. Add a related_name argument to the definition for 'swap_user'. Thanks 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: How to create a Generic Show View ?
Hi Koen, I think your code snippet will work fine in my application too. But, how instantiate the DisplayModelForm directly in my urls.py showed below? (r'^core/user/show/(?P\d+)/$', 'object_detail', dict(queryset=User.objects.all(), template_name="baseshow.html", extra_context={'model_entity':'user'})) Should I use the 'django.views.generic.create_update.create_object' view? I want only to use the urls.py without write in views.py to instantiate the form. Is it possible? Thanks. Mario Hozano. On Wed, Aug 27, 2008 at 3:34 AM, koenb <[EMAIL PROTECTED]> wrote: > > Hi Mario, > > a few months ago I posted a snippet on djangosnippets [1] that kind of > does something like this: it takes a form (can be the same one you use > for editing) and displays it as read-only. The disadvantage is it uses > the entire form machinery just to display some values, which is a lot > of overhead, the advantage is I have quick and dirty display of data > without much extra work (I have my own generic view wrapped around > this). > It needs a lot of improvement, but it works ok for me for now. > > Koen > > [1]: http://www.djangosnippets.org/snippets/758/ > > On 26 aug, 20:00, Mario Hozano <[EMAIL PROTECTED]> wrote: > > Hi People. > > > > I am new in Django and I am using the django support to create generic > > views (CRUD) in my app. To handle Create and Show actions, i have > > written 2 main pages with the code snippets described below. > > > > baseform.html > > {% for field in form %} > > {{ field.label_tag }}{% if field.field.required %}*{% > endif > > %} > > {{ field }} > > {% if field.help_text %}{{ field.help_text }}{% > endif %} > > {% if field.errors %}{{ field.errors > }} > dd>{% endif %} > > {% endfor %} > > > > baseshow.html. > > {% for key, value in object.as_dict.items %} > > {{ key.capitalize }} > > {{ value }} > > {% endfor %} > > > > These pages are called directly from my urls.py that uses the Generic > > views supported by django. In this sense, the baseform.html can be > > used by all model classes, because the ModelForm handles the > > presentation of each model attribute (excluding id) transparently. > > > > In baseshow.html I need to show the same attributes of a given model > > class, as done in baseform.html. In this case, the attributes > > (excluding id) must be presented in a read-only mode, with html labels > > instead of input widgets. To do it, i've implemented a "as_dict" > > method in each model class. This method only returns the > > "self.__dict__" attribute of the model classes, hence, the private > > attributes cannot be acessed from templates. > > > > The solution presented works, but it is ugly, because the id attribute > > must be verified on template and it needs to adjust the model class to > > work fine. > > > > Does Django offer another way to present the model attributes in a > > Show view? Is it possible to use a ModelForm class to show the > > attribute values in html labels? > > > > Thanks. > > Mario Hozano > > > -- Mário Hozano Lucas de Souza Embedded and Pervasive Computing Laboratory - embedded.ufcg.edu.br Electrical Engineering and Informatics Center - CEEI Federal University of Campina Grande - UFCG - www.ufcg.edu.br PGP: 0xAEA0ACBD --~--~-~--~~~---~--~~ 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: database relationships
Well this works great while using the generic detail view, but when I return a list view the relationships won't work. in my view def album_list(request, page=0): return list_detail.object_list( request, queryset = Album.objects.select_related().all(), paginate_by = 20, page = page, template_object_name = 'album', ) in my template {% for albumart in album.albumart_set.all %} {{ album.albumart.image }} {% endfor %} Is this not supported in list_detail.object_list? I can't find information on this anywhere, may have to change my database around. On Aug 22, 11:44 am, nek4life <[EMAIL PROTECTED]> wrote: > Awesome. I got it to work using this code in my view. > > def artist_detail(request, slug): > album_list = Album.objects.all() > return list_detail.object_detail( > request, > queryset = Artist.objects.all(), > slug = slug, > template_object_name = 'artist', > extra_context={'album_list': album_list} > ) > > But the way you're doing it only calls the database once instead of > twice. Beautiful! Thank you. I'm going to try the query you > suggested. > > queryset=Artist.objects.select_related().all() > > I'd like to just pull in the albums, artwork, and tracks related to > the particular artist in the url slug, for > instancehttp://www.example.com/artists/artist-name > > You've been a huge help. Thanks a ton! > > Charlie > > On Aug 22, 11:20 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > Also note, if your intentions were to grab all that information and > > just send the artist to the template, I think you'd get better > > performance if your queryset in the view looked like this: > > > queryset=Artist.objects.select_related().all() > > > Keith > > > On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > Super easy :) Just to show you another way to implement generic > > > views, I used custom view that returns a generic view. > > > > # urls.py > > > from myapp.views import artist > > > ... > > > (r'^artist/(?P\w+)/$', artist), > > > ... > > > > #views.py > > > from django.views.generic.list_detail import object_detail > > > def artist(request, slug): > > > return object_detail( > > > request, > > > queryset=Artist.objects.all(), > > > slug = slug, > > > template_object_name = 'artist' > > > ) > > > > # //artist_list.html > > > {{ artist }} > > > Albums > > > > > > {% for album in artist.album_set.all %} > > > {{ album.name }} > > > > > > {% for track in album.track_set.all %} > > > {{ track.name }} > > > {% endfor %} > > > > > > {% endfor %} > > > > > > > Django makes traversing relationships easy... > > > > HTH > > > > Keith > > > > On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote: > > > > > So if I sent the artist to the template and wanted to grab the list of > > > > albums with all the album tracks how would I go about that. Would I > > > > have to pull in all the data with a custom view? So far I've only > > > > been using generic views. It definitely makes sense pulling in the > > > > information through the track back up through the album to the artist, > > > > how could I reverse the process so I can get all the artist vars plus > > > > the data I need from the track and album tables? Thanks a bunch, > > > > you've been very helpful already. > > > > > Charlie > > > > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > One more note. You wouldn't NEED to explicitly grab all those vars, > > > > > as you can get them in a template too. I just wanted to show you the > > > > > relation. > > > > > If you sent the track to the template, you can get the artist by > > > > > using: > > > > > > {{ track.album.artist }} > > > > > > Keith > > > > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote: > > > > > > > The only part you have that is redundant is the "artist" in your > > > > > > "Track" class. You can find out the artist because a track is > > > > > > related > > > > > > to an album, which in turn, is related to an artist. > > > > > > > Some of the code you'd maybe see in a view would be: > > > > > > > # views.py > > > > > > from django.shortcuts import get_object_or_404 > > > > > > from models import Album, Track > > > > > > > def album(request, slug): > > > > > > album = get_object_or_404(Album, slug=slug) > > > > > > artist = album.artist > > > > > > tracks = album.track_set.all() > > > > > > ...etc... return a response... > > > > > > > def track(request, slug): > > > > > > track = get_object_or_404(Track, slug=slug) > > > > > > album = track.album > > > > > > artist = album.artist > > > > > > ..etc.. > > > > > > > HTH > > > > > > > Keith > > > > > > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote: > > > > > > > > I'm trying to set up my first Django application and I'm trying to > > > > > > > figure out the database relationships. I want to
Re: Wiki/CMS app?
Yes, quite correct, it doesn't require a database. I wanted to keep the requirements as minimal as possbile and thought it would be good to let something designed for keeping revisions do the heavy lifting. I know I have a good way to go with timiki yet, but it's already in heavy use and therefor under improvement. I can understand you prefering a database solution and it was a difficult decision not to use a database. In the end I wanted something that would be easy to deal with in the case of something going wrong. The urls have a 1-to-1 mapping with the files on the file system, so backups, restores and exporting/importing any data should be simple as the entire content is pure (x)html. I just set up a demo page here so that progress can be viewed: http://timikidemo.io41.com/ Tim ^,^ On Wed, Aug 27, 2008 at 4:24 PM, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > Tim Kersten schrieb: >> At present it uses the webserver for user authentication instead of >> django's built in user system. I'll haven't added support for this >> yet. >> > This should be easy to fix. > >> It does look like a homepage, and not a wiki. >> Content is pure html. No wiki markup. >> Has breadcrum navigation. >> Has customizablble sidebar. (I use it for navigation) >> History, Diffs, Reverting etc are possible as the wiki stores it's >> pages in a bazaar repository and uses bzr to do the heavy lifting, but >> I have not yet made it possible to do this via a webinterface. >> >> > You use bazaar. I guess your app does not need a database. > Somehow I would prefer a database solution. > >> The other features you mentioned are being worked on. >> >> The licence is AGPL so that may not be whan you need. I would also say >> that it's far from being mature or production ready, but is usable and >> I'm actively working on it. (I only started development about 2 or 3 >> weeks ago.) >> >> See http://launchpad.net/timiki for getting the code. It's only in a >> bzr repository for now as it's not release worthy yet. >> >> > I will look at it. > > Thomas > > -- > Thomas Guettler, http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de > > > > > --~--~-~--~~~---~--~~ 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: Wiki/CMS app?
Tim Kersten schrieb: > At present it uses the webserver for user authentication instead of > django's built in user system. I'll haven't added support for this > yet. > This should be easy to fix. > It does look like a homepage, and not a wiki. > Content is pure html. No wiki markup. > Has breadcrum navigation. > Has customizablble sidebar. (I use it for navigation) > History, Diffs, Reverting etc are possible as the wiki stores it's > pages in a bazaar repository and uses bzr to do the heavy lifting, but > I have not yet made it possible to do this via a webinterface. > > You use bazaar. I guess your app does not need a database. Somehow I would prefer a database solution. > The other features you mentioned are being worked on. > > The licence is AGPL so that may not be whan you need. I would also say > that it's far from being mature or production ready, but is usable and > I'm actively working on it. (I only started development about 2 or 3 > weeks ago.) > > See http://launchpad.net/timiki for getting the code. It's only in a > bzr repository for now as it's not release worthy yet. > > I will look at it. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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, somewhat formula...
On 27 Sie, 14:41, [EMAIL PROTECTED] wrote: > I have a system that I created a few years back in PHP (it actually > started in VB with Excel) that goes through all the college football > games, compute a team's win/loss record, then a "power rating" which > is based on their winning percentage and their opponents winning > percentage. > > Could I do this with Django? This is a job for a relational database. Learn some SQL first. Time for django will come later. --~--~-~--~~~---~--~~ 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: cannot import name parse_lookup
On Wed, Aug 27, 2008 at 8:09 AM, --- [EMAIL PROTECTED] --- <[EMAIL PROTECTED]>wrote: > > I am also following the Apress book and am trying to implement that > coltrane stuff . > am using the latest django from svn > i got the ""ImportError: cannot import name parse_lookup "" error > initially when i used "tagging-0.2.1" > > as told above i tried to check out the latest tagging code from svn > > and now i simply cant run > python setup.py install > it says > > File "setup.py", line 49, in ? >version_tuple = __import__('tagging').VERSION > File "/home/krishna/Projects/djangoTuts/tagging-r133/tagging/ > __init__.py", line 3, in ? >from tagging.managers import ModelTaggedItemManager, TagDescriptor > File "/home/krishna/Projects/djangoTuts/tagging-r133/tagging/ > managers.py", line 5, in ? >from django.contrib.contenttypes.models import ContentType > File "/usr/lib/python2.4/site-packages/django/contrib/contenttypes/ > models.py", line 1, in ? >from django.db import models > File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line > 9, in ? >if not settings.DATABASE_ENGINE: > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > line 28, in __getattr__ >self._import_settings() > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > line 57, in _import_settings >raise ImportError("Settings cannot be imported, because > environment variable %s is undefined." % ENVIRONMENT_VARIABLE) > ImportError: Settings cannot be imported, because environment variable > DJANGO_SETTINGS_MODULE is undefined. > instead of running the setup file i copied the tagging directory to a > python path . > > while i run python manage.py validate , i get > Error: No module named validators > > Django has been moving very fast in the last few weeks, making it hard to use latest SVN with any 3rd party app. django.core.validators was removed from Django in a commit about 8 hours ago (r8616). django-tagging will need to be updated to account for that. The right place to file an issue for that or see if someone else has already posted a patch is the django-tagging project page: http://code.google.com/p/django-tagging/ Alternatively, you can try backing up your SVN checkout to one from before that particular piece was removed, but I'm not sure what other backwards-incompatible changes you might run into. 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 -~--~~~~--~~--~--~---
setting a form to invalid after having called form.is_valid()
I have an image upload form and I want to INvalidate the form if the uploaded image it too big. How can I get an error message in the form saying the uploaded image is too big? ===Model== class Image(models.Model): image = models.ImageField(upload_to='imageupload') ===View=== if imageForm.is_valid(): inst = imageForm.save(commit=False) if inst.image.width > 640: #TODO: set the error message of this form to 'image is too big' = Thanks, 2B --~--~-~--~~~---~--~~ 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 locate the OS currently logged in user??
Did you look at the information attached to ticket 689 [1] ? This is about using the credentials provided by the webserver. Typical use case is having apache authenticate the user (eg via mod_ntlm, mod_auth_sspi or another authentication system), pass the username into the django app and use this info in django to authenticate (and authorise) the user. I am not sure this is what you are looking for, because I did not quite understand your explanations. Just giving you the pointer. Koen [1]: http://code.djangoproject.com/ticket/689 --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
On Wed, Aug 27, 2008 at 4:30 AM, mwebs <[EMAIL PROTECTED]> wrote: > > Hm, > > now I have the newest Revision 8618, but still the missbehaviour that > the file is copied in an endless loop. > any ideas? > That fix was tested pretty extensively so I'm pretty sure it fixed the base problem. I do not know what "DataFile" is from your original post. Is this something from your code...I can't find any reference to such a class in Django? I think we need more details on exactly what DataFile is and how it operates to figure out what is causing this problem for you. 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 -~--~~~~--~~--~--~---
Re: how to locate the OS currently logged in user??
2008/8/27 PeteDK <[EMAIL PROTECTED]>: > On 21 Aug., 16:25, "Guillaume Lederrey" <[EMAIL PROTECTED]> > wrote: >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: >> > On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]> >> > wrote: >> >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: >> >> I'm still not clear on how your user log into the server. Via SSH, >> >> HTTP Auth, other ? >> >> > Sorry i failed to answer your question. I must admit i don't know >> > exactly how the user logs in. I will try to get that information :-) >> >> I'm pretty sure we will be able to give you more meaningful answers >> with that piece of information ... ;-) > > I now have some new information. I now believe that what i need is the > visitors information. > > On another system on the same network(written in Perl) it is done this > way: > $loginbruger=uc($ENV{AUTHENTICATE_SAMACCOUNTNAME}); > > (loginbruger is danish for loginuser) > > can i do the same thing in python?? get the visitors username? Again, without understanding how the users log into the server, we can only guess ... SAMACCOUNTNAME makes me think about Windows (SAM = Security Account Manager), but that's just based on the name, and that name could well mean something else in your context. >From what I understand, the name is stored in an environment variable (but I dont know how it gets there). Usually, the environment of a process isnt changed from the outside after creation. And Django is a long running process, so it should not pick up users logging in after startup. But I can be completely wrong on that one ... Assuming I am wrong above, you should be able to access the same environment variable from python code with : import os loginbruger = os.environ['AUTHENTICATE_SAMACCOUNTNAME'] More infos on http://docs.python.org/lib/os-procinfo.html The real problem I see there is that if there is multiple users connected to the server, I dont see how the right user could be associated with an HTTP session ... Good luck, and please, try to get the info on how the login process works ! -- Jabber : [EMAIL PROTECTED] Skype : Guillaume.Lederrey Projects : * http://rwanda.ledcom.ch/ * http://trock.ch/ Others : * http://kiva.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: Template inherite and direct_to_template
You have assumed that child templates also inherit any context that is passed to the parent templates. Unfortunately, this is not the case. This is not a limitation, but in fact makes sense -- passing the context happens when templates are rendered (in your case, in URLconf where you use direct_to_template), when you render a child template and do not pass it the same context, there is no means for the template to access that context because it wasn't passed to it. It can't simply investigate every line that's passing context to base.html and somehow figure it out. Hope this clears things up for you. Erik On 26.08.2008, at 22:38, Chatchai Neanudorn wrote: > Yes, it looks like extra_context is not available for rendering. > > Don't know how to fix, finally use templatetag to do this task. > > Thanks, Chachai > > 2008/8/27 Malcolm Tredinnick <[EMAIL PROTECTED]> > > > On Tue, 2008-08-26 at 07:10 -0700, chatchai wrote: > > Hi , > > > > It's not easy to explain so please look at codes below, > > > > #url.py > > base_context = { > > 'books' : Book.objects.all(), > > } > > > > urlpatterns = patterns('', > > (r'^$', direct_to_template, {'extra_context': base_context, > > 'template': 'base.html' }), > > (r'^books/', include('book.urls')), > > ) > > - > > > > #base.html > > > > ... > > {% block content %} > > ... > > {% endblock %} > > > > Books > > {% for book in books%} > > {{ book.title }} > > {% endfor %} > > > > - > > > > #book_detail.html > > {% extends "base.html" %} > > {% block content %} > > {{ object.title }} > > {% endblock %} > > > > - > > I want book_detail inherite book list from base.html and let them > > render block content by themself. Code above should work but not. > > It's not clear what the problem is, since you just say "it doesn't > work" > without giving details of what actually happens. However, I can see at > least two problems: > > If you're expecting book_detail.html to be rendered, then the > problem is > that it isn't mentioned in the URL configuration. You are telling > Django > to render book.html, not book_detail.html. > > If the problem is that the results aren't changing when you update the > book lists, this is because the queryset is only going to be evaluated > once. Read the introductory section of the generic views documentation > to see how to change that. > > 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: Complex, somewhat formula...
Here's how I had it setup with PHP, and the process of solving the ratings... TEAM name nickname win loss rating rank GAMES date away_team (fk) home_team (fk) away_score home_score With the PHP file, the first thing it does is loop through all the games with scores and computes the outcome of the game and assigns the winning team a win and the losing team a loss. Then it would loop through all the teams and compute their winning percentage and modified winning percentage. Then it would loop through all the games again and start awarding points for the outcome of the game towards the rating and save the rating in the db. Then it would order the teams from best rating to worst, insert their rank (1-119). On Aug 27, 9:02 am, Tim Chase <[EMAIL PROTECTED]> wrote: > > I have a system that I created a few years back in PHP (it > > actually started in VB with Excel) that goes through all the > > college football games, compute a team's win/loss record, then > > a "power rating" which is based on their winning percentage > > and their opponents winning percentage. > > > Could I do this with Django? > > This could be done either with Python or SQL -- depending on > traffic volume and data volume, I'd recommend doing it in SQL. > Fortunately, Django makes it quite easy to insert SQL into a > query-set, or just executing raw SQL via a cursor. > > The SQL might end up being a bit advanced, but with a little hint > about your model structure, you might get a more helpful response > from the list. > > -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 -~--~~~~--~~--~--~---
Re: Django Party in Montreal?
One more ! 2008/8/27, Dan <[EMAIL PROTECTED]>: > > Are there other people in the Montreal area that would like to celebrate > the 1.0 release? > > > > > -- Didier Rano [EMAIL PROTECTED] http://www.jaxtr.com/didierrano --~--~-~--~~~---~--~~ 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, somewhat formula...
> I have a system that I created a few years back in PHP (it > actually started in VB with Excel) that goes through all the > college football games, compute a team's win/loss record, then > a "power rating" which is based on their winning percentage > and their opponents winning percentage. > > Could I do this with Django? This could be done either with Python or SQL -- depending on traffic volume and data volume, I'd recommend doing it in SQL. Fortunately, Django makes it quite easy to insert SQL into a query-set, or just executing raw SQL via a cursor. The SQL might end up being a bit advanced, but with a little hint about your model structure, you might get a more helpful response from the list. -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 -~--~~~~--~~--~--~---
Re: Complex, somewhat formula...
Thnx. I'm half tempted, just to leave it as is in PHP to compute the stuff, then dump it into a DB and use Django to display everything... On Aug 27, 8:42 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 7:41 AM, <[EMAIL PROTECTED]> wrote: > > Could I do this with Django? > > You could do it with Python, and then use Django to make it visible > over the Web, yes. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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, somewhat formula...
On Wed, Aug 27, 2008 at 7:41 AM, <[EMAIL PROTECTED]> wrote: > Could I do this with Django? You could do it with Python, and then use Django to make it visible over the Web, yes. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ANN: Django 1.0 beta 2 released
As part of the run up to the final Django 1.0 release (scheduled for next week!), tonight we've pushed out Django 1.0 beta 2, including the final new features for 1.0 (mainly a refactoring of django.contrib.comments). As a beta release, we of course don't recommend it for production use, but if you'd like to test it and help us squash bugs for the final release, feel free to grab a copy and pitch in. Release notes: http://docs.djangoproject.com/en/dev/releases/1.0-beta-2/ Download: http://www.djangoproject.com/download/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django Party in Montreal?
Are there other people in the Montreal area that would like to celebrate the 1.0 release? --~--~-~--~~~---~--~~ 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, somewhat formula...
I have a system that I created a few years back in PHP (it actually started in VB with Excel) that goes through all the college football games, compute a team's win/loss record, then a "power rating" which is based on their winning percentage and their opponents winning percentage. Could I do this with Django? --~--~-~--~~~---~--~~ 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: cannot import name parse_lookup
I am also following the Apress book and am trying to implement that coltrane stuff . am using the latest django from svn i got the ""ImportError: cannot import name parse_lookup "" error initially when i used "tagging-0.2.1" as told above i tried to check out the latest tagging code from svn and now i simply cant run python setup.py install it says File "setup.py", line 49, in ? version_tuple = __import__('tagging').VERSION File "/home/krishna/Projects/djangoTuts/tagging-r133/tagging/ __init__.py", line 3, in ? from tagging.managers import ModelTaggedItemManager, TagDescriptor File "/home/krishna/Projects/djangoTuts/tagging-r133/tagging/ managers.py", line 5, in ? from django.contrib.contenttypes.models import ContentType File "/usr/lib/python2.4/site-packages/django/contrib/contenttypes/ models.py", line 1, in ? from django.db import models File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line 9, in ? if not settings.DATABASE_ENGINE: File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 28, in __getattr__ self._import_settings() File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 57, in _import_settings raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. instead of running the setup file i copied the tagging directory to a python path . while i run python manage.py validate , i get Error: No module named validators any one please help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Uploadhandler exceptions not raised
Hello, I wrote a custum Uploadhandler for processing the chunks of an uploaded file during upload. class MyFileUploadHandler(MemoryFileUploadHandler): ... def receive_data_chunk(...): convert_data(raw_data) ___ def convert_data(...): raise Exception() The exceptions I raise here never "bubble to the surface". The server just seems to stand still. Why that`? 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: Bug in ImageFieldFile.save() ?
On Wed, Aug 27, 2008 at 12:37 AM, Brian Morton <[EMAIL PROTECTED]> wrote: > The docs (and an analysis of the code) indicate that the second > argument to save should be the content. > > http://docs.djangoproject.com/en/dev/ref/files/file/#ref-files-file > > I am assuming this is binary or text content to be written to the file > in question. ImageFieldFile calls get_image_dimensions(content) in > save, and get_image_dimensions assumes that the input is a file or > path that can be open()ed by the file module. Yeah, looks like the documentation needs to be clearer there, because your assumption is incorrect. The "content" argument to FieldFile.save() is expected to be a File object itself, since it's usually an UploadedFile. There's been talk about updating it to accept any file-like object, which I'm working on, but it's not yet available. If you need to pass in raw content like that, you can use django.core.files.base.ContentFile to make a suitable File for use with .save(). So, yes, there's a mismatch there, but it's the documentation that's incomplete in this case. -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: Web hosting control panel with django
I also keep meaning to look at Pinax but I was rather put off by the apparent focus on social apps (in which I don't currently have much of an interest). I would like to see a some documentation about their proposed standard architecture. Does this exist other than in the current source code? Currently there seems to be rather too-many-ways-to-do-it in Django as regards integrating apps into a site so the more documented conventions we get the better. I'm currently forming bad habits of my own and not reading enough of other people's source code! On Aug 12, 11:20 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Justin Fagnani wrote: > > You know, many of the components of a control panel, for both private > > servers and co-hosting, would be very useful in other applications. > > File browsers, support ticket systems, email, user and database > > management, etc. would be great to have in many situations. > > > Rather than have a monolithic control panel app, it'd be great to have > > pluggable applications, where "pluggable" goes beyond the normal > > Django sense and includes conventions about the template hierarchy, > > markup structure, navigation, settings, and assets like CSS and JS. > > That way an application could be added with little-to-no modification > > of templates, CSS, etc. > > > It's very similar to CMS applications like blogs, wikis, galleries or > > forums. I've been developing a CMS and business apps for a while and > > trying to develop a good set of conventions at the same time. I'd love > > to collaborate with some other Django'ers who'd like to "standardize" > > some of these concepts as a high-level layer to sit above Django. As I > > imagine it, it'd be similar to a Drupal for Django in some ways. Of > > course, not being an official Django standard, there could be choices > > between standards that use different JS libraries, markup and template > > block structure, and CSS conventions. > > > I think, besides a CMS, a control panel would be a really good place > > to use this. I'm hoping there will be some like-minded people at > > Djangocon to discuss this with. > > > -Justin > > > On Tue, Aug 12, 2008 at 1:38 PM, Ramdas S <[EMAIL PROTECTED]> wrote: > >>http://code.google.com/p/zmaj/ > > >> On Wed, Aug 13, 2008 at 12:39 AM, mike171562 <[EMAIL PROTECTED]> > >> wrote: > >>> Nice, how far along is it? Will it be opensourced? Any tips on how to > >>> go about it? > > >>> On Aug 12, 2:01 pm, "Juan Hernandez" <[EMAIL PROTECTED]> wrote: > i am currently developing one... Im calling it PyISP > > On Wed, Aug 13, 2008 at 2:18 PM, mike171562 > <[EMAIL PROTECTED]>wrote: > > > I was thinking of building a web hosting control panel using django. > > Anybody have any thoughts on this, or heard of anyone else doing this? > > Have you seen the work that's been done on Pinax? > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Nice representation for Querying with ForeignKeys
Hi, This should be a simple question but I just couldn't seem to find the answer. I have a simple 2 model relationship: class B(models.Model): bfield = models.CharField(...) class A(models.Model): afield = models.CharField(...) bfieldFK = models.ForeignKey(B) what is the best way to query for example A.objects.filter(pk=1) such that the representation is something like: [{'id':1, 'afield':'a', 'bfield':'b'}] and not: [{'id':1, 'afield':'a', 'bfieldFK_id':2}] # eg. using .values() the objective is to serialize it (if it makes a difference), but the key idea is to have the output fields represented as if B were never a separate model. thank you so much, Johnny --~--~-~--~~~---~--~~ 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 locate the OS currently logged in user??
On 21 Aug., 16:25, "Guillaume Lederrey" <[EMAIL PROTECTED]> wrote: > 2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > > > > > > > > On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]> > > wrote: > >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>: > > >> > The server is running Debian Linux and they are logging on to the > >> > server using the username and password stored in the active directory > >> > on one of the other servers. > > >> I'm still not clear on how your user log into the server. Via SSH, > >> HTTP Auth, other ? > > > Sorry i failed to answer your question. I must admit i don't know > > exactly how the user logs in. I will try to get that information :-) > > I'm pretty sure we will be able to give you more meaningful answers > with that piece of information ... ;-) > > MrG > > -- > Jabber : [EMAIL PROTECTED] > Skype : Guillaume.Lederrey > Projects : > *http://rwanda.ledcom.ch/ > *http://trock.ch/ > Others : > *http://kiva.org/ I now have some new information. I now believe that what i need is the visitors information. On another system on the same network(written in Perl) it is done this way: $loginbruger=uc($ENV{AUTHENTICATE_SAMACCOUNTNAME}); (loginbruger is danish for loginuser) can i do the same thing in python?? get the visitors username? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
TemporaryFileUploadHandler missbehaviour
Hello, I already posted a message describing this problem. For me solving this problem is very important because I cant proceed for hours. http://code.djangoproject.com/ticket/8333 in a few words: when I want to upload a file with temporaryFileUploadHandler than in fact I have 215 copies of the file in my media-directory. It seems that there is an endless loop that says FileAlreadyExists and so appends a _. In the end the file looks like this: filename..txt I dont know where the problem is. any ideas? 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 -~--~~~~--~~--~--~---
Nice representation for Querying with ForeignKeys
Hi, This should be a simple question but I just couldn't seem to find the answer. I have a simple 2 model relationship: class B(models.Model): bfield = models.CharField(...) class A(models.Model): afield = models.CharField(...) modelB = models.ForeignKey(B) what is the best way to query for example A.objects.filter(pk=1) such that the representation is something like: [{'id':1, 'afield':'a', 'bfield':'b'}] and not: [{'id':1, 'afield':'a', 'bfield_id':2}] # eg. using .values() the objective is to serialize it (if it makes a difference), but the key idea is to have the output fields represented as if B were never a separate model. thank you so much, Johnny --~--~-~--~~~---~--~~ 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 Question - Regex Field to deal with Feet/Inches
On Wed, Aug 27, 2008 at 3:13 AM, bkev <[EMAIL PROTECTED]> wrote: > I'm working on a site that has several imperial measurements (feet and > inches) and I'd like to implement a field in my model that uses a > regular expression like: > ^(\d{1,5})\'((\s?)(-?)(\s?)([0-9]|(1[0-1]))\")?$ > to parse off the feet and inches and save them in a sortable manner > (I'm guessing the best way would be to convert them and save them as a > decimal number, but the list and admin display needs to in x'-y" > format. Anyone have any ideas as to how I might accomplish that? (or > where I should look for more information)? I use the following method in one of my projects: def feetinch_to_cm(length): """convert US style (feet-inch) length to metric (cm)""" if length == u'' or length is None: return None m = re.match(r'(?P\d+)[\'`]( *(?P\d+)(?P.)?("|\'\'))?', length) if m is None: raise Exception("unable to parse length: %s" % length,) feet = int(m.group('feet')) inch = int(m.group('inch') or 0) half = int(m.group('half') == u'\xbd') return (30.48 * feet) + (2.54 * inch) + (1.27 * half) I save the length in centimeters in database, then I can reformat it as needed in the template or admin using a custom filter. Ronny --~--~-~--~~~---~--~~ 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: custom field: clean-method not called ...
ah, thanks a lot. this is it ... defaults = {'max_length': self.max_length} defaults['form_class'] = FileBrowseFormField defaults['widget'] = FileBrowseWidget(attrs=attrs) patrick. On Aug 27, 11:11 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-08-27 at 01:42 -0700, patrickk wrote: > > I´m just trying to write a custom field for the django filebrowser (a > > filebrowsefield). the __init__ method of the form-field is called, but > > the clean method is not ... instead the clean method of > > forms.CharField is called, which is strange, because a) I´ve made a > > model field (FileBrowseField) with defaults = {'form_class': > > FileBrowseFormField(attrs=attrs)} and b) the FileBrowseFormFields > > __init__ method is called. > > [..] > > > THE FILEBROWSEFIELD: > > class FileBrowseField(Field): > [...] > > def formfield(self, **kwargs): > > attrs = {} > > attrs["initial_directory"] = self.initial_directory > > attrs["extensions_allowed"] = self.extensions_allowed > > defaults = {'max_length': self.max_length} > > defaults = {'form_class': FileBrowseFormField(attrs=attrs)} > > defaults = {'widget': FileBrowseWidget(attrs=attrs)} > > These lines keep declaring a new dictionary every time. So the final > "defaults" variable won't contain "form_class". > > 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: custom field: clean-method not called ...
On Wed, 2008-08-27 at 01:42 -0700, patrickk wrote: > I´m just trying to write a custom field for the django filebrowser (a > filebrowsefield). the __init__ method of the form-field is called, but > the clean method is not ... instead the clean method of > forms.CharField is called, which is strange, because a) I´ve made a > model field (FileBrowseField) with defaults = {'form_class': > FileBrowseFormField(attrs=attrs)} and b) the FileBrowseFormFields > __init__ method is called. [..] > THE FILEBROWSEFIELD: > class FileBrowseField(Field): [...] > def formfield(self, **kwargs): > attrs = {} > attrs["initial_directory"] = self.initial_directory > attrs["extensions_allowed"] = self.extensions_allowed > defaults = {'max_length': self.max_length} > defaults = {'form_class': FileBrowseFormField(attrs=attrs)} > defaults = {'widget': FileBrowseWidget(attrs=attrs)} These lines keep declaring a new dictionary every time. So the final "defaults" variable won't contain "form_class". 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 -~--~~~~--~~--~--~---
custom field: clean-method not called ...
I´m just trying to write a custom field for the django filebrowser (a filebrowsefield). the __init__ method of the form-field is called, but the clean method is not ... instead the clean method of forms.CharField is called, which is strange, because a) I´ve made a model field (FileBrowseField) with defaults = {'form_class': FileBrowseFormField(attrs=attrs)} and b) the FileBrowseFormFields __init__ method is called. THE FILEBROWSEFORMFIELD: class FileBrowseFormField(forms.Field): default_error_messages = { 'max_length': _(u'Ensure this value has at most %(max)d characters (it has %(length)d).'), 'min_length': _(u'Ensure this value has at least %(min)d characters (it has %(length)d).'), } def __init__(self, max_length=None, min_length=None, attrs=None, *args, **kwargs): self.max_length, self.min_length = max_length, min_length super(FileBrowseFormField, self).__init__(*args, **kwargs) def clean(self, value): "Validates max_length and min_length. Returns a Unicode object." super(FileBrowseFormField, self).clean(value) ... THE FILEBROWSEFIELD: class FileBrowseField(Field): __metaclass__ = models.SubfieldBase def get_manipulator_field_objs(self): return [oldforms.TextField] def get_internal_type(self): return "CharField" def formfield(self, **kwargs): attrs = {} attrs["initial_directory"] = self.initial_directory attrs["extensions_allowed"] = self.extensions_allowed defaults = {'max_length': self.max_length} defaults = {'form_class': FileBrowseFormField(attrs=attrs)} defaults = {'widget': FileBrowseWidget(attrs=attrs)} defaults.update(kwargs) return super(FileBrowseField, self).formfield(**defaults) def __init__(self, *args, **kwargs): self.initial_directory = kwargs['initial_directory'] self.extensions_allowed = kwargs['extensions_allowed'] del kwargs['initial_directory'] del kwargs['extensions_allowed'] return super(FileBrowseField, self).__init__(*args, **kwargs) --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
Hm, now I have the newest Revision 8618, but still the missbehaviour that the file is copied in an endless loop. 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: Optimizing Django ORM SQL queries when in a loop
Hi Malcolm, Thanks very much for your help! I was (up until a few weeks ago) running off of the trunk, but I've stopped at an earlier revision (7922, I think). I kept updating but things kept breaking so I thought I'd just finalise the revision. I did actually give it a go using Q objects yesterday, but it still seems to be generating the extra queries. I'll try updating to the latest Django release, then I will make sure for certain that there are only two queries being run for that particular aspect of the code. I'll let you know how I get on! Thanks again for your help. Regards, Mike. On Aug 26, 6:36 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-08-26 at 08:05 -0700, [EMAIL PROTECTED] wrote: > > Hi guys, > > > I'm trying to optimize one of my views that is doing a rather (naive?) > > query like this: > > > ... > > post_stream = Post.objects.filter(poster=some_user) > > for other_user in other_user_queryset: > > post_stream = post_stream | Post.objects.filter(poster=other_user) > > ... > > [...] > > > The ORM generates a SQL query for each of the additional piped OR > > queries (this becomes a large number very quickly!). > > Which version of Django are you using? Because this isn't true for the > current subversion code. How are you determining that a query is run > esach time? > > Querysets are only evaluated when you first access their results and > "or"-ing together two querysets doesn't access the results, so it > constructs a single SQL query. The above loop should execute two > queries: one for the other_user_queryset (since you're accessing the > results there) and then one when you access the results of post_stream. > > A more concise, and probably clearer, way to write the above loop is to > use Q() objects: > > post_filter = Q(poster=some_user) > for user in other_queryset: > post_filter = post_filter | Q(poster=user) > post_stream = Post.objects.filter(post_filter) > > That's a little bit more lightweight at the Python level, since it's not > constructing and copying a QuerySet object each time around. From a > style point of view it's also focusing on constructing the filter, which > is the significant thing the loop does, rather than the queryset, which > is just a way to get at the results which are filtered. > > 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: formset issue
anyone? On Aug 26, 12:19 pm, patrickk <[EMAIL PROTECTED]> wrote: > scenario: users are uploading documents (e.g. images, files, ...). > these documents are saved in a model "Attachment" assigned to the > currently logged-in "User". now, every user has the possibility to > attach documents to a blog-entry. these attachments are saved in a > model "BlogEntryAttachment" assigned to a "BlogEntry". > the best way to achieve this is probably using formsets. when writing > a BlogEntry, the user has the option to attach his/her documents to > that BlogEntry. to achieve this, I have to limit the choices (of a > select-field) to the currenlty logged-in User. > > questions & notes: > ### how can I limit the choices of a select-field using formsets? > ### I've tried inlineformset_factory, but there's no argument > "initial". besides that, I´m not sure how to use "initial" for > limiting a queryset ... > ### with using formset_factory on the other hand, I could use a > ModelChoiceField with queryset=Attachment.objects.filter(user=user), > but how do I get the "user" there? > ### Overriding __init__ within BlogEntryAttachmentForm and passing the > currently logged-in user seems possible, but then I also have to > override the BaseFormSets __init__ and _construct_form, which just > seems ugly and far too complicated. > > MODELS: > > class Attachment(models.Model): > > user = models.ForeignKey('auth.User') > title = models.CharField('Title', max_length=100, blank=True, > null=True) > filename = models.CharField('Filename', max_length=100, > blank=True, null=True) > path = models.CharField('Path', max_length=200, blank=True, > null=True) > ... > > class BlogEntryAttachment(models.Model): > > blogentry = models.ForeignKey(BlogEntry) > attachment = models.ForeignKey(Attachment) > --~--~-~--~~~---~--~~ 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: dictionary from object
Wiadomość napisana w dniu 2008-08-27, o godz. 07:25, przez Vance Dubberly: > So I want to do something I'd think would be extremely common and > simple. > > user = User.objects.get(pk=data['id']) > > I want a dictionary of the model attributes/values from user. > > user_dict = { 'first_name' : 'foo', .. > > Am I asking to much or reading to little? You can see at user.__dict__. This is standard Python feature of class instances. -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R&D, Redefine [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: Web hosting control panel with django
Wiadomość napisana w dniu 2008-08-12, o godz. 20:48, przez mike171562: > > I was thinking of building a web hosting control panel using django. > Anybody have any thoughts on this, or heard of anyone else doing this? djangohosting.ch has account administrative panel build with Django. You can register with them (free) to see it working, no charges are applied until actual order is placed. -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R&D, Redefine [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 -~--~~~~--~~--~--~---