I am writing a Django app for use in a country where they use comma as decimal separator. I have a model that contains a django.db.models.DecimalField, and I use model forms. How can I make the resulting form field render using comma and accept comma back from the user?
Following the advice of jweyrich, I have upgraded my application ...
Hi folks,
These are my following settings:
MEDIA_ROOT = '/home/webapps/test_project/media/'
MEDIA_URL = 'http://192.168.0.2:8090/site_media/'
ADMIN_MEDIA_PREFIX = '/media/'
These are my model fields:
large = models.ImageField(blank=True, null=True, upload_to="images")
thumb = models.ImageField(blank=True, null=True, upload_to="image...
I added a slug field to my database and now need to go through and add those. I want to run a script that looks at the slug field in the database and if empty generates and saves. Here is what I thought was along the lines, but is not working.
from project.apps.tracks.models import *
def process_slug():
if not track.slug:
...
hello,
i want to set a main page or an index page for my app.
i tried adding MAIN_PAGE in settings.py and then creating a main_page view returning a main_page object, but it doesn't work
Also, i tries to add in the urls.py a declaration like
(r'^$', index),
where indexshould be the name of the index.html file on the root (but it obvio...
I have a page which displays a form that a logged-in user can use to edit their profile.
The first time the user loads the corresponding view, with a GET request, the form should display the values of the users existing profile record.
Because I'd like to have granular control over the markup used for the form fields, I'd like to retri...
I want django-registration (version 0.8) to use my custom form rather than the default one. However, I want to continue to use the default django-registration view. What should the rest of the line below look like to achieve this?
(r'^accounts/register'...),
I've tried this below but get a syntax error:
(r'^accounts/register/$',
...
What is a way to handle database unavailability and redirect queries from unavailable slave to another one in Django 1.2?
Btw, i found out, that it was discussed: http://code.djangoproject.com/wiki/MultipleDatabaseSupport#Requirements (see "Transparently handling database failure")
UPD> I use PostgreSQL backend (probably will use pg po...
Hi,
I want to have 2 separate admin sites inside a Django project.
By separate I mean - they should have separate users authentication, they should administer different models, and have different looks and URLs.
The reason I want to do it is the customer wants separate section to administer the CMS part of the page, and separate to ...
Hi,
Django does not respect the max_length attribute of TextField model field while validating a ModelForm.
So I define a LimitedTextField inherited from the models.TextField and added validation bits similar to models.CharField:
from django.core import validators
class LimitedTextField(models.TextField):
def __init__(self, *arg...
I have a form that I use to display several fields from a record to the user. However, the user should not be able to update all the fields that are displayed. How do I enforce this? It would nice if I could specify which fields to save when calling form.save, but I couldn't get this to work. Here's some of the code:
obj = get_object_or...
I'm trying to install djangobb and when running manage.py syncdb it returns with
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manage
ImportError: No module named django.core.management
I know that deep in my python installation there is django/core/managemen...
I'm trying to add ajax form submit to my webpage. Form will add user's email to newsletter. I've found this solution : http://www.tutorialswitch.com/web-development/quick-and-simple-ajax-forms-with-json-responses/ and now I'm trying to rewrite it for django.
So I have my form, included on main page :
<div id="form-newsletter-messa...
Hello, i have a ModelForm, in which i'm having a CharField, which is declared as unique in the Model.
But I have 2 problems:
1.If i fill in the form with a field having the same name i don't get an error message
2.I'd like this field not to contain white spaces
Is it possible to do that using a ModelForm?
Thanks a lot!
...
Essentially I want to sanitize some data a user submits in a form when I redisplay it if there is an error. This is easy to do if I am extracting the data from a form object. I can override the clean() method and manipulate the data. I can also set the .initial value for the first time it is displayed. However, I cannot find a way of...
I'm creating a set of SQL full database copy scripts using MySQL's INTO OUTFILE and LOAD DATA LOCAL INFILE.
Specifically:
SELECT {columns} FROM {table} INTO OUTFILE '{table}.csv'
LOAD DATA LOCAL INFILE '{table}.csv' REPLACE INTO {table} {columns}
Because of this, I don't need just the tables, I also need the columns for the tables. ...
I want to be able to have an actual list of objects returned when I query, instead of a ResultSet with Hit objects.
Example:
indexer.search(word).prefetch()
this would return a ResultSet object with matching hits, but I would like to have access to the objects themselves. Similar to what:
model.objects.filter(name__icontains=word)
...
I have a Django ModelForm but don't want the user to click on a reguar submit button.
Instead, I made my own submit button and will post the form data using Ajax/jQuery.
The data to post is a mix of the form data plus other information I gather on my UI.
But... how do i get the formatted POST data the html form was supposed to submit?
If...
I'm attempting to install the PIL library in an Virtual Enviroment that I have created.
Usually to install PIL I'd grab the install, however this won't allow me to choose my virtualenv only my root Python folder (C:/Python26).
I tried both pip install PIL and easy_install PIP but they didn't work. I've also tried downloading the TAR, e...
Here's my view:
def rsvp_list(request, id, template="rsvp/rsvp_list.html"):
rsvp = RSVP.objects.get(id=id)
return render_to_response(template, {
'attendees': rsvp.attendee_set.all().order_by('email__first_name'),
}, context_instance=RequestContext(request))
and here's my template:
{% for attendee in attendees %...
Can I perform in django such operation, that in one view I assign a value of return from other view, that renders its own form template and basing on it returns value ? (So in other words if on this form rendered by the other function user clicks ok, I return true, and if user clicks cancel I return false) Sample code :
Main function:
...