django

Django "Error: cannot import name escape" on windows

I cannot run the dev server because of this error ("Error: cannot import name escape"). I assume its because of modifications I've done to the project, but i have no idea how to find where the error is originating from to fix it. I don't import anything called escape anywhere. Update Using django-admin.py rather than the projects man...

migrating from one framework to another in python

I'm having trouble deciding which python framework to use for my website. So I've decided to bite the bullet and use Django. My question is how easy (or difficult) will it be to migrate to a different framework in future if I have issues with Django ? ...

Using valid HTML 4.01 Strict with Django

I've found a similar question here, but I'm looking for more general solutions. As it is now, when Django generates anykind of HTML for you (this mainly happens when generating forms), it uses self-closing tags by default i.e. <br /> instead of <br>. <br /> is valid XHTML and I think HTML5 also, but it's not valid HTML4. Is there any c...

How does django insert a row into a database where one of the columns is NOT NULL?

In the django admin I inserted a row by specifying 2 columns ( firstName, lastName ) and the description column had blank=True set. I then tried mimicing this with fixtures because I have to import data from a legacy sql dump but I can't seem to avoid filling in a value for description. What is django doing different? Does it specify a...

How can I access django admin's transliterator for slugs when using fixtures?

In the admin, if you enter in a slug two things are applied through JS: The string is made slug-friendly The string is transliterated if the language is not English, so for example Cyrillic Russian text gets converted into Transliterated Russian ( typed out in English ) I'm basically inserting a couple thousand rows and I need to acc...

In Django, what is the best way to manage both a mobile and desktop site?

I'd like everything to function correctly, except when it's mobile, the entire site will used a set of specific templates. Also, I'd like to autodetect if it's mobile. If so, then use that set of templates throughout the entire site. ...

Implementing a login in django

In my base.html I placed this: {% if user.is_authenticated %} you are logged in! {% else %} <h3>Login</h3> <form action="/login/" method="post" accept-charset="utf-8"> <label for="username">Username</label><input type="text" name="username" value="" id="username" /> <label for="password">Password</label><input type="password" name="pass...

import strategy whithin django applications

I would like to know what is the best import strategy whithin django reusable applications. Say I have an application called usefulapp. Inside my app, I will need to access, say, the models. Should I use an explicit import as: import usefulapp.models or simply, since I am inside this very app, I could use: import models Which one ...

Request Extended Permissions in Facebook, Django, Pyfacebook

I'm developing an IFrame application in Facebook (using pyfacebook and Django) and could not understand the official documentation. Can someone give me a pointer on how to request extended permissions (like read_stream, publish_stream and offline_access)? I experimented with FB Connect but I'm not even sure it's the right way to go for ...

Django: using variables as array indices?

I am trying to create a template that will put items in a table. Controller: items = Item.all().order('name').fetch(10) template_values = {'items': items, 'headers': ['Name', 'Price', 'Quantity']} render('Views/table.html', self, template_values) Template: <table> <tr> {% for header in headers...

Django: How to Use upload_to=function with ModelForm

The goal is to dynamically update upload_to such that user uploaded files are stored in a directory location that depends on the user. There are several examples of this online, but none using ModelForm. See the code snippets for the two problems, one is that I am getting an empty string for the instance.user value, and when I try and ...

manage.py syncbd not syncing django.contrib apps

This is probably a setting error somewhere. I have a django app that works fine on my desktop with the developer server and sqlite3. I upload it to my server and syncdb and it only syncs my custom apps to my database, not the django.contrib apps. My apache config: ServerRoot "/home/myusername/webapps/accounting/apache2" LoadModule ...

Rebuilding website from Django 0.96 to Django 1.2

I've got a website done in Django 0.96 (done in 2007), and now we are thinking about rebuilding it (not just migrating) for Django 1.2 . Can anyone point me to the new (and worth the while) widgets, plugins and other stuff for Django 1.2 (released in april 2010). I've heard of "South" and of a widget for debugging (can't remember the ...

Apps not showing in Django admin site

I have a Django project with about 10 apps in it. But the admin interface only shows Auth and Site models which are part of Django distribution. Yes, the admin interface is up and working but none of my self-written apps shows there. INSTALLED_APPS INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.sites', 'django.co...

Django Admin: Detect if a subset of an object fields has changed and which of them

I need to detect when some of the fields of certain model have changed in the admin, to later send notifications depending on which fields changed and previous/current values of those fields. I tried using a ModelForm and overriding the save() method, but the form's self.cleaned_data and seld.instance already have the new values of the ...

about the post_save signal and created argument

the docs says: post_save django.db.models.signals.post_save created A boolean; True if a -new- record was create. and I have this: from django.db.models.signals import post_save def handle_new_user(sender, instance, created, **kwargs): print "--------> save() "+str(created) post_save.connect(handle_new_user, sender=User) when ...

Existing forms:In Django

I have an pre-built HTML form and I need to reuse it with Django form class (django.forms), So how do I incorporate my HTML form with Django form class. for example HTML: <li id="foli11" class=""> <label class="desc" id="title11" for="Field11"> Username <span id="req_0" class="req">*</span> </label> <div class="col"> <input id=...

Django many-to-many relationship to self with extra data, how do I select from a certain direction?

I have some hierarchical data where each Set can have many members and can belong to more than one Set(group) Here are the models: class Set(models.Model): ... groups = models.ManyToManyField('self', through='Membership', symmetrical=False) members = models.ManyToManyField('self', through='Membership', symmetrical=False) c...

Django with custom authentication backends, is Csrf middleware really required ?

Hello, Under Django 1.1.1, I am using several authentication backends such as social-registration for facebook connect and django-emailauth for email based authentication instead of user names. I am curious if the Csrf middleware is an essential security measure as it seems like it sometimes generates problems, especially with facebook ...

Filtering manager for django model, customized by user

Hi there! I have a model, smth like this: class Action(models.Model): def can_be_applied(self, user): #whatever return True and I want to override its default Manager. But I don't know how to pass the current user variable to the manager, so I have to do smth like this: [act for act in Action.objects.all() if a...