django

Is there a template language for PHP that's almost similar to the Django template language?

Is there a template language for PHP that's almost similar to the Django template language? ...

Limiting results returned fromquery in django, python

I've just started to learn how to do queries in my Django application, and I have a query that gets me the list of new users filtered by the date joined: newUsers = User.objects.filter(is_active=True).order_by("-date_joined") This as I understand it gives me ALL the users, sorted by date joined. How would I best limit it to get me the...

Install mysqldb on snow leopard

I am trying to get started on working with Python on Django I am by profession a PHP developer and have been told to set up django and python on my current apache and mysql setup however I am having trouble getting the Mysqldb module for python to work, I must of followed about 6 different set of instructions, I am running snow leopard a...

Remove fields from ModelForm

Hi there, i have a simple ModelForm: class MyForm(ModelForm): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) del self.fields['name'] As you can see, I try to remove a field from the form's field list (the field definitively exists in the model), but I get an Exception: Templat...

Run Django with URL prefix ("subdirectory") - App works, but URLs broken?

Below are the relevant configuration files, also at http://dpaste.com/97213/ . The apache config is currently working, because accessing 'example.com/' shows me the index.html file I have placed at the document root. I'd like to serve Django/apps at the prefix '/d', so 'example.com/d/' would load the default app, 'example.com/d/app3' ...

Testing for cookie existence in Django

Simple stuff here... if I try to reference a cookie in Django via request.COOKIE["key"] if the cookie doesn't exist that will throw a key error. For Django's GET and POST, since they are QueryDict objects, I can just do if "foo" in request.GET which is wonderfully sophisticated... what's the closest thing to this for cookies tha...

Automatically create an admin user when running Django's ./manage.py syncdb

My project is in early development. I frequently delete the database and run manage.py syncdb to set up my app from scratch. Unfortunately, this always pops up: You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): Then you have supply a username, vali...

Django models - pass additional information to manager

Hello. I'm trying to implement row-based security checks for Django models. The idea is that when I access model manager I specify some additional info which is used in database queries so that only allowed instances are fetched from database. For example, we can have two models: Users and, say, Items. Each Item belongs to some User an...

Can't get div height when including javascript in Django template

I'm trying to use the flot plugin for jquery and it keeps on complaining that a div has a width/height of zero. I'm actually including the javascript for this in a Django template. So my template file looks like: <style> #graph { width: 100px; height: 100px; } </style> <script> $.plot(stuff) console.log($(#graph).width()) </...

Tons of false positives from Django's CSRF middleware?

I'm getting tons of false positives from Django's contrib CSRF middleware. Just from normal use of the site there will be a lot of cases where the CSRF just starts blocking requests as suspected forgery attacks. Does anyone else have issues like this? I'm using the SVN branch of Django so have the latest version of the CSRF middleware...

django registration module

i started to learn django using the official documentation tutorial and in turn created this registration form. i have the whole app setup but am stuck at how to process the data. i mean the documentation is a little tough to understand. if i can get some help, it would be great. this is how the models are setup: class user (models.Mo...

Using related objects after an object is saved?

I have a situation where I want to offload an xml fragment (an atom event) each time a model instance is saved, updated or deleted. The fragment needs to include information about related objects. I can't find an event that lets me use information from related objects after saving my object. The post_save signal seems o be triggered bef...

Tidy up complex URL dispatcher

I have two different kinds of objects that I'd like to live under the same URL. One group of objects needs to be passed to the view function 'foo' and another group needs to be passed to 'bar'. I'm currently doing this with a big long list of hardcoded URLs, like so... urlpatterns = patterns('project.views', (r'^a/$', 'foo'), (...

Django fixture not loading with loaddata.

I've created a json fixture, and put it in my myapp/fixtures/. I've added myapp/fixtures to settings.FIXTURE_DIRS. Here's the output of my attempt to load the fixture: jeff@jeff-linux:~/myapp$ ./manage.py loaddata --verbosity=2 default.json Loading 'default' fixtures... [...truncated checking default paths and installed apps/fixtures......

Django: ImportError: cannot import name Count

Hello, I just pulled from my github and tried to setup my application on my Ubuntu (I originally ran my app on a Mac at home). I re-created the database and reconfigured the settings.py -- also update the template locations, etc. However, when I run the server "python manage.py runserver" get an error that says: ImportError: cannot i...

Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi

Hello, I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already convinced that...

Compare TinyMCE and CKeditor for a Wiki

For a custom wiki django-wakawaka, i want to be able to add a WYSIWYG support. TinyMCE is obviously the most popular plugin, used even by Wordpress. But CK-editor seems more feature full. Those who have used either of these or both, which is better and why. Are there some better packages, that I am missing? Is there something that I ...

reverse ordering date queries in django python

In my quest to understand queries to Django models I've been trying to get the last 3 added valid Avatar models with a query like: newUserAv = Avatar.objects.filter(valid=True).order_by("date")[:3] However this gives me the first three avatars added ordered by date. I'm sure this is so simple but I've had trouble finding it in the Dja...

Django: disallow can_delete on GenericStackedInline

Hello, I've built this model which contains a generic foreign key: class MyModel(models.Model): content_type = models.ForeignKey(ContentType, verbose_name=_('content type')) object_id = models.PositiveIntegerField(_('object id')) content_object = generic.GenericForeignKey('content_type', 'object_id') Next I've made a gene...

Copying modules into Django, "No module named [moduleName]"

I run into this problem pretty consistently... keep in mind I am quite new to Django and a total Python amateur. It seems that, for example, whenever I check out my Django project on a new computer after a clean install of Python and Django, it can never find the project/apps I create or copy in. So right now I have an app that is work...