Accessing Child Meta Attributes from Abstract Model Class

2009-08-31 Thread Brett Epps
Hi, I've got an abstract base class like this: class Base(models.Model): class Meta: abstract = True def save(self, *args, **kwargs): print dir(self.Meta) super(Base, self).save(*args, **kwargs) and a child model class inheriting from it like this: class Child

Re: django.core.handlers.wsgi not found

2012-02-04 Thread Brett Epps
Sometimes it can help to print sys.path in your WSGI file. (The output should end up in the apache error log.) That should tell you where Python is looking for modules. If the Django install path is not listed, you may need to reinstall Django. How was Django installed originally? Brett On 2

Re: Dynamic settings variables (dynamic global variable)

2012-02-08 Thread Brett Epps
I'd recommend caching the data using Django's caching framework and either the local memory or memcached backend. To update the cache, write a management command that runs periodically as a cron job. (If you find yourself needing more sophisticated background task management, check out Celery.)

Re: Django setup on Win7 - can't import some things

2012-02-13 Thread Brett Epps
Hi Bob, It sounds like you're using the 1.3 or later version of the tutorial. Class-based generic views were added in 1.3. Try this link for the correct version: https://docs.djangoproject.com/en/1.2/intro/tutorial01/ (Note the 1.2 in the URL.) Hope that helps, Brett On 2/13/12 10:35 AM, "L

Re: What is the simplest way to install MySQL-python on Lion 10.7 with Xcode 4.3?

2012-02-27 Thread Brett Epps
I think your problem might be solved in this SO post: http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loade d-libmysqlclient-18-dylib By the way, I'd highly recommend using Homebrew instead of MacPorts and pip/virtualenv instead of sudo easy_install. Brett On 2/27/12 2:01

Re: How to generate common blocks?

2012-02-27 Thread Brett Epps
Consider writing custom template tags for the common parts (assuming they're dynamic). https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/ Brett On 2/27/12 2:25 PM, "Paul" wrote: >I have a question regarding the use of the template mechanism. > >Say i'm using a common website la

Re: Looking for a job in the Arctic Circle

2011-09-30 Thread Brett Epps
Might be too warm or too far south for you, but consider Wisconsin. We get plenty of snow here. Brett From: Kevin Renskers mailto:i...@bolhoed.net>> Reply-To: mailto:django-users@googlegroups.com>> Date: Fri, 30 Sep 2011 06:27:30 -0700 To: mailto:django-users@googlegroups.com>> Cc: <2...@weholt

Re: Simple input forms which show more than one row - easy/possible in django?

2011-10-05 Thread Brett Epps
Hi Chris, Once you've defined a model for your data, you can use a ModelForm [1] to automatically generate a form for that model. You might also want to check out the admin site [2], which displays data in a tabular format similar to what you describe. 1. https://docs.djangoproject.com/en/dev/to

Re: Combining Querysets from different, but similar models

2011-10-05 Thread Brett Epps
I had a similar need and solved it with a separate table of activity feed items. Here's the code for the Item model: class Item(models.Model): object_id = models.PositiveIntegerField(db_index=True) content_type = models.ForeignKey(ContentType) content_object = generic

Re: Registering a model in the admin

2011-10-05 Thread Brett Epps
Could you show us the contents of your admin.py file? Did you remember to call admin.site.register(ModelClass, ModelClassAdmin) for that model? Brett On 10/5/11 6:09 AM, "Haffi" wrote: >Hi, I'm registering a new model in the admin but it just won't show >up. I'm doing this in production, I ad

Re: encrypt and decrypt data in django.

2011-10-05 Thread Brett Epps
Hi Nghia, The common pattern is to extend django.contrib.auth.models.User by creating your own "profile" model with the fields you need [1]. Then you can set the AUTH_PROFILE_MODULE setting and access the profile from User objects through the User.get_profile method. The Python standard libra

Re: setting site-name variable

2011-10-05 Thread Brett Epps
Which "site-name" variable are you referring to? Usually you'll want to place global settings in your settings.py file. Then you can access them elsewhere like this: from django.conf import settings print settings.[name of setting] Also, you might be interested in the sites framework [1], which

Re: memcached not working with django

2011-10-07 Thread Brett Epps
Have you configured Django to use memcached in your CACHES setting? If so, can you post that? Also, what are you caching? Brett On 10/7/11 8:10 AM, "tino" wrote: >Hello, > >I am trying to implement memcached on my django site. ># telnet localhost 11211 >Trying 127.0.0.1... >Connected to loca

Re: memcached not working with django

2011-10-07 Thread Brett Epps
Disregard my reply, I see that you solved your problem already. (I missed the rest of the thread until now.) Brett On 10/7/11 10:40 AM, "Brett Epps" wrote: >Have you configured Django to use memcached in your CACHES setting? If >so, can you post that? Also, what are you c

Re: Help with implementing dynamic views/models

2011-10-10 Thread Brett Epps
I may be misunderstanding your question, but it sounds like you need to use Page.objects.get or Page.objects.filter (in your view function) to look up the particular objects that you want to send to the template. Brett On 10/10/11 9:53 AM, "xenses" wrote: >This may seem like a very simple ques

Re: Help with implementing dynamic views/models

2011-10-10 Thread Brett Epps
{{ variable_name }} where I need it? Because I tried that first and it >didn't work. So, maybe I'm just not sure what it is I'm doing >exactly ;) > >Thanks for any help! > >On Oct 10, 1:09 pm, Brett Epps wrote: >> I may be misunderstanding your question,

Re: Help with implementing dynamic views/models

2011-10-11 Thread Brett Epps
e, verbose\ >_name='300x250 Tag') >rectangle2 = models.TextField(max_length=500, null=True, >blank=True, verbos\ >e_name='Additional 300x250') > >def __unicode__(self): > return self.name > >I know that once I figure this out, I'm going to

Re: Add to database

2011-10-11 Thread Brett Epps
I think you need to look up a specific Proyecto object before trying to add users to it. So: proyecto = Proyecto.objects.get(...) for i in request.POST.getlist('usuarios'): usuario = User.objects.get(id=i) proyecto.usuarios.add(usuario) Hope that helps, Brett On 10/11/11 4:15 AM, "jose

Re: Help with implementing dynamic views/models

2011-10-11 Thread Brett Epps
potential to need 3 attributes from each object in each >template, so the mapping may not be what I need. If I pass in a >context object, I thought that I should have handles for >object.attribute ? Or maybe I need to map the dict before passing it? > > > >On Tue, Oct 11, 2011 at 1

Re: django-admin py extension on fedora

2011-10-21 Thread Brett Epps
Perhaps Django is packaged differently on Fedora. Did you install it using yum? I'd recommend installing with pip to avoid such issues, and to ensure you're getting the latest version. Brett On 10/21/11 6:01 AM, "flebber" wrote: >Just want to double check something really minor. > >The djang

Re: Django as a Standalone Desktop Application

2011-10-21 Thread Brett Epps
Hi, Could you tell us more about the utility you want to create? It sounds like Django might not be the appropriate tool in this case. Brett From: Ivo Brodien mailto:i...@brodien.de>> Reply-To: mailto:django-users@googlegroups.com>> Date: Fri, 21 Oct 2011 19:46:49 +0200 To: Django users mailt

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Brett Epps
Try this: for friendof0 in Person0.friends.all(): for friendof1 in Person1.friends.all(): if friendof0 == friendof1: # Person 0 and Person 1 share a friend. else: # They have no shared friends. Brett On 10/28/11 12:59 PM, "Kevin" wrote: >Just though

Re: update other objects when saving an object:

2011-10-28 Thread Brett Epps
Hi Tim, The problem is your use of the self keyword when trying to get at the ChapterMembership manager. Instead of: chapters = self.objects.filter… Try: chapters = ChapterMembership.objects.filter… Hope that helps, Brett From: Tim mailto:jtim.arn...@gmail.com>> Reply-To: mailto:django-use

Re: Comparing two ManyToMany fields for same entries

2011-10-28 Thread Brett Epps
x27;Pers >>on0') >> This outputs "Person1", if I interchange Person0 with Person2, it >> outputs no results. If I use Person1 in both instances, it outputs >> 'Person1'. >> Does this QuerySet return the results I want, or should I use Brett&

Re: Reg. Basic django.db.models

2011-11-04 Thread Brett Epps
Hi Ganesh, Here are some examples: Filter: SELECT * FROM device WHERE locked = true - returns a QuerySet which can be evaluated as a list of Device objects Get: SELECT * FROM device WHERE id = (value of id variable) LIMIT 1 - returns a single Device object All: SELECT * FROM schedule - returns a

Re: firstof as

2011-11-07 Thread Brett Epps
Instead of adding a template tag, you could handle this in the class for obj. Just have get_votes() cache its result and use the cached value after the first time get_votes() is called. In the template, always call get_votes(). Brett On 11/7/11 4:12 PM, "Nikolas Stevenson-Molnar" wrote: >Ah,

Re: admindocs app - almost, but not, working

2011-11-07 Thread Brett Epps
If this is a bug in Django, you should file a Trac ticket for it here: https://code.djangoproject.com/newticket Brett On 11/7/11 3:40 PM, "lorin" wrote: >In case anybody else cares, there seems to be a mismatch between the >template and the urls for the admindocs module. I solved this problem

Re: setting up openlayers proxy.cgi

2011-11-14 Thread Brett Epps
Django itself won't run a CGI script for you. You'll need to run it with another web server like Apache or nginx. (Usually the default installation of Apache has a cgi-bin directory where you can place CGI scripts.) You can run one of these servers at the same time as running manage.py run serve

Re: Django + ajax waiting page, can not redirect to result page

2011-12-14 Thread Brett Epps
I think the problem is that your tag is incorrect. You're using the same one to load jQuery and to add your code, so your JavaScript is not getting run. The file "please_wait.html" should look like this: Please wait. Re: Django a Turnkey Linux -- I need your experience.
You'll need to do some research to find out how Turnkey Linux deploys your Django app. There are multiple methods, but the one recommended in the Django docs is to use Apache + mod_wsgi. If Turnkey Linux uses this method, Apache should be configured with a virtual host that points at a WSGI fi

Re: Django a Turnkey Linux -- I need your experience.

nux -- I need your experience. Thanks, Brett, "Brett Epps" wrote... > You'll need to do some research to find out how Turnkey Linux > deploys your Django app. There are multiple methods, but > the one recommended in the Django docs is to use Apache + mod_wsgi. > If

Re: Django + ajax waiting page, can not redirect to result page

knowledge on ajax, so is there something I need to >install or import in my projects? and how can I test if codes in > ... really invoked? > >Thanks, > >On 12月14日, 下午1时47分, Brett Epps wrote: >> I think the problem is that your tag is incorrect. You're using >>

Re: Django + ajax waiting page, can not redirect to result page

Change this: def run_DHM(request): xx = {'ok':'TRUE'} #return HttpResponse("OK") return xx To this: def run_DHM(request): return HttpResponse("{'ok': true}") You were getting that error because views should always return HttpResponse objects. Brett On 12/16/11 5:18 PM, "yun

Re: Admin interface does not save routine object

Hi Andy, Could you send us a traceback from the 500 error page? (If you don't see one, you need to set DEBUG = True in settings.py.) Brett On 1/4/12 8:29 AM, "Andy Oram" wrote: >I am pasting in a pretty basic models.py here. It is fairly classic (I >actually started with Poll tutorial exampl

Re: Admin interface does not save routine object

Oh, I think the problem is in the __unicode__() method of your Quiz8 model. You're returning self.document, which is a Document8 object and not a unicode string. Try returning unicode(self.document) or something like '%d' % document.id. Brett On 1/4/12 5:07 PM, "Andy Oram" wrote: >Thanks, Bi

Re: virtualenv wrecked my Django+modules install

It sounds like you installed the Django/Satchmo/other packages globally. If you switch out of the virtualenv by running c:\path\to\virtualenv\bin\deactivate, those packages should be available again. I try to never install packages globally, with tools like pip or hg being the only exceptions. I a

Re: {% url 'admin:jsi18n' as jsi18nurl %} error as urls.py

I don't see an obvious problem with your urls.py file. Have you tried checking that you're not mixing tabs and spaces in that file's whitespace? Brett On 1/6/12 8:48 AM, "MikeKJ" wrote: >This is probably an oldie and I remember coming across it before but >damned if I remember the solution: >

Re: Is the django coummity converging on a preferred REST API package?

I used Tastypie for a project recently and was pretty happy with it. I think Piston was the preferred package before Tastypie came about, but Piston hasn't seen as much development recently. Then again, Piston seems to be good enough for Bitbucket, so it's probably good enough for many projects.

Re: mac vs windows installation /deployment

You need two things: - Xcode (available in the Mac App Store) - this will give you the tools needed to build software from source - Homebrew (http://mxcl.github.com/homebrew/) - this is similar to fink or MacPorts, but IMHO much better Then do something like: > sudo easy_install pip > sudo pip i

Re: Mediawiki access with Django

MediaWiki has a pretty nice HTTP API that you can use to access content stored within it. I've used that API with the wikitools Python package and it worked pretty well. Brett On 1/23/12 7:35 AM, "krumru...@googlemail.com" wrote: >Hello, > >I use mediawiki as semantic wiki for saving articles

Re: retrieve model instance from database without model instance

Check out the content types framework[1]. You can do something like: ct = ContentType.objects.get(app_label='products', model='product') obj = ct.get_object_for_this_type(name='Venezuelan Beaver Cheese') However, as you can see in the example, you'll need to know the name of the app so that Djan

Re: How do you pass dissimilar data from view to template?

It sounds like you're confused about how to add more than one piece of information to a template. When you render a template, the template is given a context, which is a Python dict object. A dict is a bunch of key-value pairs. So, right now, you're probably doing something like: return render_