django

django model save error message

hi, i like to output an error message if this date allready exist. has someone an idea? class Bet(models.Model): name = models.CharField(max_length=30, verbose_name='Name') date = models.DateTimeField(verbose_name='Datum') def __unicode__(self): return self.name def save(self): newDate = self.date try: Bet.objec...

tag url template django doesn't work

HI guys, I trying to implement the url template tag into my project. I have a button that allows the user to save the data he is seeing. So the url of this button is this: (2)url(r'^nameviews/download/$', 'my.path.is.this.to.download' name="load"), template: <a href="{% url load %}">Download</a> the url of the page that shows the ...

How can I render a custom nested checkbox tree view in Django-admin?

I have a bugs model which is mapped to categories. Categories can own other categories. class Bug( models.Model ): categories = models.ManyToManyField('Category') name = models.CharField( max_length=100 ) slug = models.SlugField(unique=True) summary = models.TextField() summary_markdown = models.TextField(editable=Fa...

prepopulate an admin field from logged-in User

How do I prepopulate an Admin field from logged-in User info? I have model.py: from django.db import models class News(models.Model): title = models.CharField(max_length=65) body = models.TextField() author = models.CharField(max_length=55) and I have admin.py: from django.contrib import admin from django.contr...

Django: Login from page outside django

Maybe it's a stupid question, but I'm trying to login to my django app using a form that is outside django. My guess is that I could send a POST request to /login, but that would fail because of the csrf token. Maybe I'm missing some kind of theoretical background, but I would like to know what's the correct way to achieve this. Backgr...

MacOS + apache + mod_wsgi + django: what's a correct folder layout and permissions for web apps?

Hello. I'm testing django right now on Max OS X Snow Leopard Server. I have compiled mog_wsgi for build-in apache/python and enabled it in apache via LoadModule wsgi_module. I have also installed django via standard python setup.py install command. After that, i have created a test django application by named webtest in ~/Documents and ...

django template "file name too long"

I'm very new to Python and Django so maybe someone can point me in the right direction. I have the following url.py line url(r'^$', direct_to_template, {'template':'index.html', 'extra_context':{'featured_actors': lambda: User.objects .annotate(avatars_nb=Co...

Custom field's to_python not working? - Django

Hi folks, I'm trying to implement an encrypted char field. I'm using pydes for encryption This is what I have: from pyDes import triple_des, PAD_PKCS5 from binascii import unhexlify as unhex from binascii import hexlify as dohex class BaseEncryptedField(models.CharField): def __init__(self, *args, **kwargs): self.td =...

Python set and the "in" keyword usage issue

I'm trying to work with a set of django models in an external script. I'm querying the database at a preset interval to get the items that meet the query. When my external script is processing them, it takes a while and I may get the same results in the query if the processing hasn't updated the model yet. I figured I could use a set ...

django admin - add extra tickboxes for use with action dropdown

I want to use the django admin app to connect two records (as a parent and child). Using the admin actions guide here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ I have wrote a function which almost does this by utilises the actions dropdown (on the list view). What I have is the user ticks two records and then se...

Checking for duplicates

Hello everyone, I have a small problem. I am trying to check to see if status's value already exists and make sure I do not create another instance of it, but I am having some trouble. Ex. If the project status was once "Quote" I do not want to be able make the status "Quote" again. Right now, I check to make sure if the user select...

Using send_mail in Django: Cannot display data in invoice from functions

Hello, another Django send_mail question. Seems like I have problems displaying data in an email that separate form from function. Seems like this is a variable problem. Edit: I manage to make the client name show up! Now how can to the same thing with invoice. Say that I wanted to display the date, invoice_no, work_orders & contract_i...

django adding a ManyToMany field/table to existing schema, related_name error

I have an existing project with models (Users and Books). I would like to add a ManyToMany(M2M) field to the existing model Books, but the syncbb command does not do this. Details: Books already has a FK field that maps to User, and I want to add a new M2M field (readers) that also maps to User. As you know, Django's syncdb only cares...

Create a Django Admin Action to Duplicate a Record

I want to create a Django Admin Action that allows me to create a duplicate of a record. Heres the use case. Admin clicks the checkbox next to a record in an app that they want to duplicate. Admin selects "Duplicate" from the admin action drop down menu. Admin clicks go. Django admin creates a duplicate record with a new id. Page is re...

Deleting inline-code from html

Hi, I'm using the inline-app from Django-Basic-Apps for inserting images in Blogposts. But in some templates I don't want the images to appear. It's not enough to just not render them, I don't even want the inline-code to be in the html. Is there a way to delete the inline-code with a filter? I tried to use the "|cut" filter, but its jus...

Django - what is considered a "Big" model?

I like to normalize things the most I can in a database. This isn't obviously the best thing for performance, but it helps with flexibility, reporting, etc. I've found it hard to justify in a recent case though which has caused me to build a model that has 25 fields in it. Is this "too big"? Or, is that quite normal. Of course the obviou...

Filtering based on comparisons in django

I have a django model with a field Reminder_End_Date = models.DateField(). I have to filter all records of the model which have reminder date greater than todays date. However when I try to use the following statement, it does not work: now=datetime.date.today() reminderlist=Reminder.objects.filter(Reminder_End_Date>now ) Can anyone ...

Django nginx and append slashes problem

I am trying to use nginx as a simple load balancer for django per Jacob Kaplan-Moss' example: http://github.com/jacobian/django-deployment-workshop http://python.mirocommunity.org/video/1689/pycon-2010-django-deployment-w If I stop nginx and have apache listen on port 80 everything works fine. If I have apache listening to nginx my ur...

Django tags error. Invalid block tag: 'endfor'.

What is the problem? It says me that Invalid block tag: 'endfor'. {%else%} <ol id="sortable" name="plst{{first_list.pk}}"> {% for item in playlist %} <li id="item{{item.pk}}" media="{{item.media.pk}}" class="holderPlace" title="{{item.media.name}}"><span> {{item.media.name|custom_slice:30}} </span> {%ifequal item.media.w...

Django i18n internationalization and memcached

I'm trying to set up memcached on a django project on which I'm using the i18n internationalization system. Sadly, it looks that memcached is not caching different versions of the same page according to the language. In facts, when I switch language, it gets the previous cached page, without caring about the language switch. I'm using...