Hello, I need to add extra validation to my DateField in Admin to make sure the date given is in the future. I have no experience in such a thing, so here's what I've done.
1) I've created custom form field and added validation to it:
class PastDateField(forms.DateField):
def clean(self, value):
"""Validates if only date is in t...
The story so far:
Decided to go with Xapian as search backend because it has all search-engine features I was looking for, knows about Unicode, stemming, has few dependencies and requires no bloated app-server installation on top of it.
Tried Django and Haystack (plus xapian-haystack, the backend glue code to tie Haystack to Xapian) be...
I'm trying to figure out a way to serialize some Django model object to JSON format, something like:
j = Job.objects.get(pk=1)
##############################################
#a way to get the JSON for that j variable???
##############################################
I don't want want:
from django.core import serializers
serializers.s...
I have a need for some kind of information that is in essence static. There is not much of this information, but alot of objects will use that information.
Since there is not a lot of that information (few dictionaries and some lists), I thought that I have 2 options - create models for holding that information in the database or write ...
I currently have a site which uses a MySQL 4.x schema, the site uses PHP for the backend. I'm currently in Django-land and I like Postgres so far ( meaning I'm a noob to both ).
What would be the easiest way to go about importing the data in my tables ( the dump file for the entire DB is around ~200 MB ) into my new project? I currently...
I'm looking for some type of profiling utility I could use where I can compare between 2 different setups with some sort of consistency factor. Would appreciate if anyone could point me in the right direction.
...
{% for p in profiles %}
<div class="result">
{{ p.first_name }}
</div>
{% endfor %}
Suppose I have 1000 of these, in a huge list.
How would I make this code appear every 15 times?
<div class="menu">abc</div>
...
When I read this thread, I am confused by Vinko Vrsalovic's reply
At server start you'll get minspare
processes, which will keep growing
until maxspare (or maxchildren) if
more requests are coming.
Then, what will happen if the the value of maxspare and maxchildren are different? The server's processes will keep growing unti...
I'm trying this pattern:
(r'^jobs/(?P<job_id>\d+)/$', job_handler)
To work with jobs/ and jobs/{job_id}, but the above expression doesn't cover the first case(jobs/), it only work if I do something like:
(r'^jobs/$', job_handler),
(r'^jobs/(?P<job_id>\d+)/$', job_handler)
...
Hi,
I've been reading on the django docs about the comments framework and how to customize it (http://docs.djangoproject.com/en/1.1/ref/contrib/comments/custom/)
In that page, it shows how to add new fields to a form. But what I want to do is to remove unnecesary fields, like URL, email (amongst other minor mods.)
On that same doc page ...
class JobForm(forms.ModelForm):
class Meta:
model = models.Job
That was my form, now trying to save it will raise an exception, and trying to validate it just fails with no errors....
job = get_object_or_404(models.Job, pk=1)
form = forms.JobForm(instance = job)
try:
form.save()
except:
print sys.exc_info()
#=>(<t...
Does it exist? Basically I'm developing a Django app on my local machine, when I've finished adding my feature and get it working locally, I want to commit it, and then update the production server. Then I want to automatically restart apache. Is this possible? How?
...
I'm using this django app to implement PayPal IPN. I'm testing it using PayPal's IPN simulator, but it's telling me
IPN delivery failed. HTTP error code 500: Internal Server Error
So how can I debug this and see what's really going on? I've dug into code:
@require_POST
def ipn(request, item_check_callable=None):
"""
PayPal...
Hi all,
I have a Python / Django application which is supposed to call an external windows binary and get its output at some point. And it does so when tested via 'python manage.py shell'.
But when it is run from within the web browser, which is served by IIS, the external application is not executed.
Is IIS blocking something on the...
Hey, I've searched around to do this (particularly this Q: http://stackoverflow.com/questions/1854237/django-edit-form-based-on-add-form) but I just can't get it to work.
The problem I'm having is that the form always creates a new object, instead of modifying the existing one.
This is my code:
def new_task(request, task_id=None):
if...
I have an XMPP server (likely — python, twisted, wokkel), which I prefer not to restart even in the development version, and I have some python module “worker” (which is interface to particular django project), which gets jid and message text and returns some response (text or XML, either way).
The question is, what would be the best wa...
Hi, i have this function in a view that shows the xml in the browser, but what i want is to save the xml content in a file, to use in a Flash gallery.
def build_xml_menu(request):
rubros = Rubro.objects.all()
familias = Familia.objects.all()
context_data = {'rubros': rubros, 'familias': familias}
return render_to_res...
I'm trying to figure out if there's a way to do a somewhat-complex aggregation in Django using its ORM, or if I'm going to have to use extra() to stick in some raw SQL.
Here are my object models (stripped to show just the essentials):
class Submission(Models.model)
favorite_of = models.ManyToManyField(User, related_name="favorite_sub...
I currently have a news website setup in PHP/MYSQL that's a bit old and I'm in the process of migrating it to a new django site that uses Postgresql 8.4 and Psycopg2.
Django's admin models contain a auth_user table and I suspect this is the table I will need to insert all my user rows into.
Q#1: I should just rely on this already made ...
I find that it's pretty common most people hardcode the navigation into their templates, but I'm dealing with a pretty dynamic news site which might be better off if the primary nav was db driven.
So I was thinking of having a Navigation model where each row would be a link.
link_id INT primary key
link_name varchar(255)
url varchar(2...