get_next_by_FIELD and alternate managers
In my blog I take advantage of get_next_by_FIELD (pub_date in this case) for navigation to older and newer stories in my entry detail view. I also have a flag in my entry model that says whether or not a blog entry is published. I defined an alternate manager called "published" to make it easier to pick out only published entries. My problem is that my older/newer navigation that uses entry.get_next_by_pub_date also picks up unpublished entries. Is there a way to tell get_next_by_pub_date to use the manager "published" instead of "objects?" Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: Advanced Admin Customization
On Fri, Sep 01, 2006 at 10:21:38AM -0700, mthorley wrote: > Table creation is handled by core.management. In it, a lookup is > preformed where it loads the dict DATA_TYPES (or something like that) > from db.backends..creation. Then it attempts a key matching the > field class name of each field in your model. So in order to create > your own fields, whether you subclass an existing one or not, you must > either overwrite the class name, or add your fieldtype to the list. This thread has peaked my interest so I did some code digging. I was thinking that overriding the class name didn't seem like a smart choice. I thought it would be nice if the creation code would check the parent class's name if it couldn't find the current class name in DATA_TYPES. Upon inspection of the code I found it was calling get_internal_type() for each field. If you look in db/models/fields/__init__.py you'll find that this is used in EmailField which subclasses CharField. class EmailField(CharField): ... def get_internal_type(self): return "CharField" Now I'll have to try creating some custom fields myself. :) Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: My blog is now Django -- source is available
On Tue, Aug 22, 2006 at 06:20:14AM -0700, Tim Shaffer wrote: > It looks like some of your views are very simple and could use generic > views, if you wanted. > > def home(request): > return render_to_response('home.html') > > could use django.views.generic.simple.direct_to_template I was leaving room for making that a more complex view later, but I may never get to that. > def entry(request, entry_id): > e = get_object_or_404(Entry, pk=entry_id) > return render_to_response('blog/entry.html', { 'entry': e }) > > could use django.views.generic.list_detail.object_detail I do. I probably can remove all of those views. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
My blog is now Django -- source is available
Since so many people are developing their own blogs in Django, I thought it would be good to announce that the source code to mine is now available. Mine is probably of most interest to people migrating from COREBlog or other Zope blogging software. Browse: http://refried.org/viewvc/viewvc.py/refriedorg svn co http://refried.org/svn/refriedorg My implementation is a very simple, multi-user blog. The most important feature to me was a complete migration from COREBlog. I was able to import all of my COREBlog entries, with images and comments. My to do list includes: - style the comment form - More blog centric admin interface - show unapproved comments - Make retagging entries easy - Ability to preview the entry while editting - Photo manager and gallery Nate P.S. I also have Jacob's sudoku app ported to magic-removal in there. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django covered in podcast with Guido
On Mon, Aug 07, 2006 at 12:46:57AM -0700, Dan Shafer wrote: > On 8/6/06, Alan Green <[EMAIL PROTECTED]> wrote: > > On 8/5/06, Simon Willison <[EMAIL PROTECTED]> wrote: > > > http://www.twit.tv/floss11 > > > > > > Django gets some good discussion about 50 minutes in. > > > > Guido sure says nice things about Django. Congratulations! > > I'd say! I mean he calls it his favorite Web app framework and declares > himself a satisfied user. He said he used parts of it. He was impressed with the speed of the templating system and made reference to the article on Django's speed vs RoR. I was pleased that he accurately recalled how Django got started. It was a great podcast. I recommend listening to it if you haven't already. There were some interesting insights on Python design, past and future. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: when is 1 != 1? (according to 'ifequal' in template)
On Mon, Aug 07, 2006 at 06:07:24PM -, hotani wrote: > I'm doing a comparison of a session variable and an id for a 'selected' > tag in a drop-down in a template. If I output both vars, they will both > be "1" yet 'ifequal' is still returning false. Has water stopped being > wet? Is one a string and the other an integer? Python 2.4.2 (#1, Feb 12 2006, 03:45:41) [GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 1 >>> b = '1' >>> a 1 >>> b '1' >>> a == b False >>> a != b True Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: Managing database privileges
On Tue, Jul 04, 2006 at 11:23:16PM -0300, Douglas Campos wrote: > you can specify what user/password to connect to database in > settings.py file, under your project dir > > http://www.djangoproject.com/documentation/tutorial1/#database-setup True, but that's not what I was asking. > On 7/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > How do people manage the user and privilege aspect of a Django > > deployment? Do you all access that database with the same user as > > created the database? Do you grant access to each table that the web > > server needs to query? So does your database only have one user created and you specify that in the settings file or whenever you want to inspect the database by hand? I'm under the impression that having a separate database user for the web server and the developer is the Right Thing To Do(tm). Unfortunately I don't find anything in the documentation, wiki, or archives to support that idea. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Managing database privileges
I am in the process of moving my Django project from using the development server to Apache and mod_python. I created the PostgreSQL databases as myself and ran the development server as myself. Now that I'm getting stuff going with mod_python, it'll start running as user "www-data" under Apache. I would like to allow "www-data" to access my development database while I verify everything works. I've found that I have to grant access to every table that Django wants to query. How do people manage the user and privilege aspect of a Django deployment? Do you all access that database with the same user as created the database? Do you grant access to each table that the web server needs to query? Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: Wiki or Blogs done with django
On Mon, May 29, 2006 at 09:48:11AM +0200, Giovanni Giorgi wrote: > I am planning to build a small personal web site. > I have used Plone CMS (Zope powered) but it is very slow and requires > a lot of memory. I'm coming from a similar camp. I've had a blog running on Zope with COREBlog for about a year and a half. I want to be able to move all of my content over without losing anything. The good news is that I've gotten most of the way. The bad news is that I still haven't switched over. I currently have a weblog implementation modelled after the COREBlog metadata. I have a migration tool that I run via the Django shell. It converts all of my entries and comments. I'm hung up on a few things. 1. Photo handling I have quite a few dozen entries with photos (out of 100+) and I want to add lots more. I currently crop the images down to an acceptable size and include them inline to the story. I would like to have some more advanced way of handling images so visitors can get full size images easily, so I can put up film-strips and slide shows. 2. Comments I like the ideas behind the comments API the ships with Django, but the metadata collected doesn't match up with what COREBlog was using. I started creating a new comments API that is a blend of Django and COREBlog, but I keep getting stuck and procrastinating. What has me hung up at the moment is that I want to store the IP address of the commentor. I don't want it edittable, but I want it displayed in the admin interface. I started hacking on this pre-magic removal and I have since removed most of the magic from my code. I always admired Zope, but Django seems a lot easier to get a long with. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: hack for file-browser
On Tue, May 02, 2006 at 02:47:33PM +0200, va:patrick.kranzlmueller wrote: > i?m working on a file-browser for/with the django-admin. > screenshots are here: > http://www.vonautomatisch.at/django/ftp/ Wow, that looks great! I would love to use that in my apps. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Manipulators and non-editable fields
Perhaps I'm going about this the wrong way... I'm trying to validate fields for a comments app I'm working on. As part of the model I have a few non-editable fields, IP address and date. Can non-editable fields be validated or even saved when using a manipulator? Here is the code I'm working with ATM. It is part of the post_comment view. manipulator = comments.AddManipulator() new_data = request.POST.copy() new_data['object_id'] = object_id new_data['content_type'] = content_type_id new_data['date'] = datetime.datetime.now() new_data['ipaddr'] = request.META.get('REMOTE_ADDR') #manipulator.do_html2python(new_data) nc = manipulator.save(new_data) Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: ImageField nightmares
On Sat, Mar 25, 2006 at 07:35:46AM -0800, sparkydeville wrote: > To clarify the use-case, consider an article like an image gallery, > wherein one article can have more than one image associated with it. > Further it would be helpful if the Article add/edit form could allow > users to add images while adding / editing articles. How are the images integrated into the articles? This is something I'm working on for my blog implementation. My current design has a model Entry to hold blog entries and a model Attachment so I can attach images to an Entry. class Entry(meta.Model): title = meta.CharField(maxlength=100) subtitle = meta.CharField(maxlength=100, blank=True) pub_date = meta.DateTimeField('date published') author = meta.ForeignKey(User) status = meta.CharField(maxlength=32, choices=STATUS_CHOICES, default='Draft', radio_admin=True) tags = meta.ManyToManyField(Tag) body = meta.TextField() format = meta.PositiveIntegerField(choices=FORMAT_CHOICES, default=4, radio_admin=True) class Attachment(meta.Model): entry = meta.ForeignKey(Entry, edit_inline=meta.TABULAR, num_in_admin=2) url = meta.CharField('URL', maxlength=200, core=True) file = meta.FileField('Attachment', upload_to='attachments') To display the attachments in an Entry I reference the URL of the attachment in the body of the entry. This worked for me on the detail page of the entry, but not a list of entries. :( After looking around the 'Net for ways people are referencing images in blogs and articles, it appears that everyone just dumps all of their images into one directory. This doesn't feel very clean to me, but I might have to give in. I haven't had any problems with the data base and the FileField I'm using. I see problems with the error handling in the edit_inline templates. It seems that the field groups were recently wrapped and now the templates can't find the error messages for edit_inline fields anymore. Yeah, I should file a bug on it. ;) Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: Advice on developing with django for a team of 10+
On Thu, Mar 23, 2006 at 09:23:30AM -0800, tonemcd wrote: > Oooh, now that's neat. My own tinkering with svn to ignore .pyc files > hasn't worked out so well... The way I did it was to edit my ~/.subversion/config file. There is a section, "[miscellany]" that includes a "global-ignores" option. Just add "*.pyc" to this space separated list. Unfortunately this is a per-user solution, but you could add this to the user skeleton or just tell everyone to adjust this setting. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: mod_python & devserver & apache restart
On Tue, Feb 21, 2006 at 08:12:30PM +0100, patrick k wrote: > 1. is the django development-server only meant for local use? i?m asking > because i tried to use it with dreamhost and it doesn?t seem to work. You need to specify the hostname and port with runserver. i.e. python manage.py runserver hostname:port It defaults to 127.0.0.1. Nate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---