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
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
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.)
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
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
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
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
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
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
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
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
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
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
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
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
{{ 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,
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
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
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
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
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
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
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
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&
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
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,
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
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
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
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
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
>>
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
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
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
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
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:
>
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.
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
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
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
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_
42 matches
Mail list logo