django

How do you guys protect django admin site?

I thought I might restrict it to show only on some IPs, but I have some freelance workers without static IPs that should be able to login to admin site. I rolled out a big project and I am looking for some ways to protect the admin site fom unwanted eyes. ...

How to write this class for Django's data model (converting from Propel's YML format)

I am converting a web project that currently uses the Propel ORM, to a django project. My first task is to 'port' the model schema to django's. I have read the django docs, but they do not appear to be in enough detail. Case in point, how may I 'port' a (contrived) table defined in the Propel YML schema as follows: demo_ref_country:...

django: dynamically populate nav elements

I am writing a blog application as a part of a larger website. I want to have a main (static) nav bar for the site navigation, but I want to have a sub nav that allows the user to filter the blog posts by other criteria when viewing the blog. Something like Latest | Popular | Category | Author | Date | Tag |-> News ...

Running multiple Django projects under mod_python, without using VirtualHosts

I have two django projects on the same machine. They are set up using the standard django/apache/mod_python configuration, basically: <Location "/mysite"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonOption django.root /mysite PythonDebug ...

libgeos_c-1.dll can't be loaded by Python

I'm building my first GeoDjango project but I'm kinda desperate. I'v installed PostgreSQL 9 and PostGis 1.5 through one-click installer on Windows. So everthing is there. I set GEOS_LIBRARY_PATH to the full path of libgeos_c-1.dll in settings.py. But when I run manage.py syncdb, I encounter the following errors: File "C:\Python25\lib...

Django using a newly create object in reverse redirect

I am trying to pull the id from the newly created project object so I can redirect the user to the page containing the new project. Right now I get "'ProjectAddForm' object has no attribute 'id'". I have read online that this should work but for some reason it's not. if request.method == 'POST': form = ProjectAddForm(request.P...

How to use {% with %} along with {% include %} -- Django

For example, I have a template file called: filter.html {{ title }} code... What I'd like to do is, on a separate template: {% with "Filter by Types" as title %} {% include "filter.html" %} {% endwith %} Currently it can't be done. Could someone explain why that is and an alternative way to achieve this? Background context: T...

Calling a method on a model from a template

I am trying to call a method in a model from a template and I have come to the conclusion that this cannot be done. This is my code {% if request.user.is_authenticated %} {% if a_story.is_story_liked(request.user.id) %} <a class="story_like" data-id="{{ a_story.id }}" href="#">Like</a> {% endif %} {% else %} <a c...

OAUTH for twitter and django

Hi, I am using django-twitter oauth . But i can not understand what is CONSUMER_KEY and CONSUMER_SECTRET? is it username , password or not ! Please anyone help me. Nazmul ...

django.contrib.admin like application for cherrypy

Is there a django.contrib.admin like app / module for cherrypy? I really like the simplicity of cherrypy, but it would be nice, to have the user authentication and password management type things taken care of... Or is it possible to run a cherrypy application behind the django admin app ? ...

Limitations on forking from a GIT repo created with GIT-SVN?

Many open-source projects (e.g. django) have GIT mirrors which are, in turn, forked for private or public development. GIT mirrors are kept up to date with git svn rebase. But the Pro Git Book contains this unequivocal recommendation: Ahh, but the bliss of rebasing isn’t without its drawbacks, which can be summed up in a single ...

Django 1.2: login issue (GET parameter: next)

Hello, I have a new question about django (I post a lost of them these days^^). Here is my situation : I have a custom login view (registered as login url in the settings) where I authenticate the users. I chose to do a custom view to be able to add messages and logging. The authentication works well, but I have a problem with the GET ...

Celery, Django.. making a Task / thread launch sub-task / threads?

I'm using celery with django and am trying to get a Task, like the one below: class task1 (Task) def run (self): launch_some_other_task.delay() But it doesn't seem to be working, I can go into more detail as far as my code but figured I would just ask first if this sort of thing will work as doesn't seem to be working for me....

Error when redirecting after login in Django 1.2

I've been getting this error: The requested admin page does not exist. I've got a view at the URL /members/ which is protected by @login_required. When I'm not logged-in and visit the /members/ URL, I get redirected to: http://127.0.0.1:8000/admin/login/?next=/members/ When I enter my login credentials and click "Log in", I g...

Django - What's a good way to handle manytomany with intermediary table in forms and views

Suppose I have the following models - class Item(models.Model): name = models.CharField(max_length=150) value = models.DecimalField(max_digits=12,decimal_places=2) class Organization(models.Model): name = models.CharField(max_length=150) items = models.ManyToManyField(Item, through='Customizable') class Customizable(m...

What are the full implications of not using the default 'id' primary_key in your Django model?

Consider the case where a CHAR field primary_key is required in order to define a ForeignKey relationship. After some initial investigation I have identified the following possibilities, each with their own drawbacks: 1) Using 'primary_key=True'. Example 1: class Collection(models.Model): code = models.CharField(primary_key=True,...

Different sessions for admin and application in Django

Hi Folks, I'd like to have different sessions for Django admin interface part and application itself to be able to login as admin to admin interface and as usual user to application part. Any ideas how to archive that? Thanks. P.S. Sure, I can use 2 different web browser instances, any other ways? ...

Import from a Django project with a different top-level folder name

I recently setup a deployment solution for my Django project using Fabric. The basic workflow being: Check out the latest source from git on the server. Copy it to a 'releases' directory and add a timestamp to the directory name. Update the 'current' symlink to point to the latest build. This works just fine, only problem is, since t...

django: Adding simple captcha to django comments

I am trying to understand how it's possible to use http://code.google.com/p/django-simple-captcha/ with django comments. I have done all as described here: http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/ So my forms in custom comment app looks like this: from django import forms from django.contrib.comments.forms impo...

Django regroup not working as expected

Guys I have the following view in my django application def ViewSale( request ): salecur = Sale.objects.filter(user=2).order_by('sale_date') return render_to_response('myapp/sale.html',{'salecur':salecur}) my template looks like this {% regroup salecur by sale_date as sale_list %} <ul> {% for sale_date in sale_list %} ...