Say I have choices defined as follows:
choices = (('1','a'),
('2','b'),
('3','c'))
And a form that renders and inputs these values in a MultipleChoiceField,
class Form1(forms.Form):
field = forms.MultipleChoiceField(choices=choices)
What is the right way to store field in a model.
I can of course loop thr...
I have recently started experimenting with Django for some web applications in my spare time. While designing the data model for one, I came across the dilemma of using inheritance to define a user of the website or using a technique known as monkey patching with the User class already supplied by the framework.
I tried to add a field b...
Hi all:
It's weird to me that the import fails even when it's in the sys.path.
today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab).
But when I went to the dorm, and checked out the code and start to run, it failed weird...
Hi guys, good morning :), somebody know how use Openx (php app) with Django?, i need to use openx or similar soft for ads.
Thanks :)
...
Let's picture a django powered service that bills its customers monthly. The owner doesn't want his customers to share the account with people that did not pay. Of course, he understand that some may want to work collaboratively on an account, and don't want to restrain the use of shared accounts to the same IP address.
How would you le...
Hi folks!
In my model, I want to use the domain name (HOST) I'm using in my views.
In views that'd be doable, thanks to the "request" object. But how do I do
this models methods? Which don't use "HttpRequest" objects?
Now I'm setting a global value HOST in settings.py and using it, but that's
ugly.
Also, I don't really want to manag...
Django will email ADMINS upon 500 errors.
Reading app-engine-patch docs, it claims to enable mail support, but I can't tell if it does so enough to support 500 emailing.
I tried it and it doesn't seem to be working, but it is a silent failure with no log messages, so I might have misconfigured something.
Does anyone have experience wi...
I have a Django view which creates 500-5000 new database INSERTS in a loop. Problem is, it is really slow! I'm getting about 100 inserts per minute on Postgres 8.3. We used to use MySQL on lesser hardware (smaller EC2 instance) and never had these types of speed issues.
Details:
Postgres 8.3 on Ubuntu Server 9.04.
Server is a "large"...
Is there any interface that exists already to facilitate selecting objects with django's filter function? I'd like to have the power of the filter function in my app, but don't really feel like writing a clumsy facade to just pass things through to the filter function.
...
class LineItemInline(admin.TabularInline):
model = LineItem
extra = 10
class InvoiceAdmin(admin.ModelAdmin):
model = Invoice
inlines = (LineItemInline,)
and
class LineItem(models.Model):
invoice = models.ForeignKey(Invoice)
item_product_code = models.CharField(max_length=32)
item_description = models.CharF...
I'd like to know how can use Django's automatic form generation...
<form action="/contact/" method="POST">
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
To achieve the following output (note the custom field in the middle of the form and error class within the wrapping div).
<form action="/contact/" method="P...
I'm trying to add images to my models in my Django app.
models.py
class ImageMain(models.Model):
product = models.ForeignKey(Product)
photo = models.ImageField(upload_to='products')
In development mode, every time I try to upload the image via Django admin, I keep getting:
Upload a valid image. The file you uploaded was either n...
I have a view that takes data from my site and then makes it into a zip compressed csv file. Here is my working code sans zip:
def backup_to_csv(request):
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename=backup.csv'
writer = csv.writer(response, dialect='excel')
#code...
I am building a Django site framework which will power several independent sites, all using the same apps but with their own templates. I plan to accomplish this by using multiple settings-files and setting a unique SITE_ID for them, like suggested in the Django docs for the django.contrib.sites framework
However, I don't want a user f...
Hello,
I have written a django page that requires only super users to login. So I have added
foo_view = staff_member_required(foo_view)
but it doesn't cut, now I can control only allowing staff marked users to login but this doesn't cut. I have tried something like
def foo_view(request):
if not request.user.is_superuser:
...
Python 2.5.2, Apache 2.2, Django 1.0.2 final
My Django app tries to connect to a certain port. When that port is busy, I get the error 10048 "Address already in use" from apache. I know where the error is coming from. How do I catch this apache error?
More info:
error at /report/5/2009/08/01/
(10048, 'Address already in use')
Reques...
I'm trying to build a REST API on top of django running on Google AppEngine.
Is there a FW with similar offering to piston (or a piston fork?) that can run on AppEngine models rather than on django's models?
...
There are several questions about more or less same issue in stackoverflow, but none of them seems to cover the issues i can foresee. Since my django knowledege is limited i might be overreacting... so..
What i want to accomplish, with django, is to edit 2 models, List and ListItem in same view. List as common form and listitem as inlin...
I am in the process of migrating an application (Sage) from Twisted to Django.
Static documentation is currently served under /doc/static, while live (built on-the-fly) documentation are served under /doc/live.
Is it possible to use Twisted to serve /doc/static only, leaving Django to serve the rest of /doc/*?
...
Can I simulate form like behaviour when a user clicks on a simple link?
For example, can I have in views.py
def remove(request, entity_id):
#remove the object with entity_id here
And in the HTML
<a href="profile/remove/{{ obj.entity_id }}">
And in the urls.py
(r'^app/profile/remove/(?P<entity_id>\d+)', 'app.views.remove')
O...