django

Why does django page cms get_absolute_url return an empty string?

I am having issues with get_absolute_url in my django templates when using django page cms. It returns an empty string and does not link to my required page. I have the following Models, URLs templates and views Models class Body(models.Model): ... url = models.SlugField(unique=True, help_text='---') urls (r'^news/', include('news...

unixODBC issue on a Django site on Linux that goes away on refresh.

I have a question about Django, unixODBC, FreeTDS, Apache2, mod_wsgi, that is somewhat similar to this question asked before on SO. I have a Django website built to run on the latest Django, that is, 1.2.3. It uses managed models for the most part, in that, save for the session information, nothing is written to the DB by Django, only r...

In Django, how can I make a field read only the first time a form is loaded?

I have model form and I need to have one of the fields be read only until after it's saved. I haven't figured out a good way to do this, and below is what I have in my admin.py. class RequestForm(forms.ModelForm): trac = forms.URLField(min_length=400, required=False) impacted_users = forms.ModelMultipleChoiceField(queryset=Grou...

Intermittent 403s due to CSRF failure (Django 1.2.3)

Hi folks. I've got a slightly crazy/infuriating bug with a site and CSRF. We're running Django 1.2.3, Python 2.6 on Ubuntu with Apache2 + mod_wsgi and have been getting end users reporting 403 CRSF verification failures and 403s as a result. All our forms have a csrf_token and - as far as I am aware - things work fine in local dev and...

How to filter objects of an object_list of a generic view in Django.

So I have a view that does a queryset and returns a simple list: def cdr(request): queryset = CdrView.objects.all() return object_list(request, queryset = queryset, template_name = "reports/cdrview_list.html", paginate_by = 200, page = request.GET.g...

Form doesn't accept additional parameters

I was trying to pass an additional parameter to my form, which is anObject to ForeignKey relation. But dunno why form returns __init__() got an unexpected keyword argument 'parent' when I'm pretty sure that it is possible to send additional parameters to form's __init__ (ie here : http://stackoverflow.com/questions/3182262/simple-form-no...

Query field across multiple django models

I want to create a "What's New" section that lists all of the database changes in the last day. I've added an "updated" field to my models: class Film(models.Model): . . . updated = models.DateTimeField(auto_now=True) class Actor(models.Model): . . . updated = models.DateTimeField(auto_now=True) Now I want to...

Decimal to JSON

To keep it short & sweet: I'm pulling a sum from a DB which is a decimal value. I'm trying to use that value in a JSON result json.dumps( { 'sum': amount } ) #where amount is my Decimal Django can't serialize the Decimal. I can convert it to a string, but I'd like a numeric type within the js If I try and convert it to a float I en...

Results being duplicated after 2nd request

I am playing around with django and python and have hit a bit of a roadblock here. I query my model and return the objects and then perform some simple operations on the results and return them to the view. After the 2nd request the childs for the forum category are duplicated and I have no idea why this happens. ForumBuilder class whic...

form doesn't allow editing

I have a following form: class PlayForwardPageForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(PlayForwardPageForm, self).__init__(*args, **kwargs) class Meta: model = PlayForwardPage exclude = ( 'id',) def save(self, *args, **kwargs): post = super(PlayForwardPa...

When running Celery with Django's manage.py command, it returns a strange error

When I run the following command, it produces the following error: % python manage.py celeryd -l INFO ~/Workspace/django-projects/project/src Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(...

Setting up django for the first time

I'm used to setting up a server for nginx with php and mysql. I understand that just fine. But I'm extremely confused at where to even start with django. I know nothing about python by the way. I'm running ubuntu 10.04 Python is already installed (not sure what version though. I read I need less than 3 or something) So firstly, how do...

Multiple Django apps hitting same backing DB - Issues?

heya, I have a standard Django application we're using to manage a database of articles from various publications. Anyhow, we're currently having issues getting permission to get the server infrastructure in place to deploy this. One option tossed was that we could make the Django app a desktop application, accessing a remote DB insta...

Django Model - choices versus foreign key?

Hi, I understand that in Django, the ORM doesn't support the ENUM type in MySQL or PostgreSQL, as this was originally a MySQL extension, and not portable across other DB types. So the two options are to use a "choices" argument to your model, or using a foreign key reference. What are the pros and cons of these approaches? For somethi...

Is there a way i can display the drop down tab in django admin generator with tree hierarchy

My Model:: class Category(model.Models): parent = model.ForeignKey('self', blank = True, null = True, related_name = 'children') name =.......... desc = ............ This does work but the admin generator does not show a hierarchical tree menu after insertion of data. Is there any way i can configure admin.py to show a hiera...

GWT set variable values with Django templates.

I am using a tree control in my GWT application. The tree has different items based on the user logged in. One way to populate the tree would be to query the server from my GWT code to get a list of tree items. But since the items will always be shown would it not be better to include information regarding them in the page itself? I am l...

Django response query

What would be the correct statements for the below two.I want to send the base variable to my template which keeps varying but there will be an error if i send {'form': form,'msg' : msg} in the second statement return render_to_response('chatlist/newchat.html', context_instance=RequestContext(request,{'form': form,'msg' : msg}),extra_co...

jquery template tags conflict with Django template!

Today I'm trying to play with jquery-tmpl {{if}} & {{else}} statements. <script id="mission-dialog" type="text/x-jquery-tmpl"> <h3>${name}</h3> <p>${description}</p> <ul> {{each(i,cond) conditions.data}} <li> <img src="${cond.image}"/> <h4>${cond.name}</h4> <p class="status...

Django url image extraction like facebook

Does anybody know if there is a pluggable app that you can use to achieve url like image extraction for Django? ...

Django - How do I redirect ie6?

Hi. I want to send a user to a page on my site that prompts him to upgrade to a more recent browser if they are using ie6 or lower. How can this be achieved in Django? ...