i am working on saving on the same form two tables - having a m2m relation.
I don't succeed, my error persists with something like: Cannot set values on a ManyToManyField which specifies an intermediary model. Use Membership's Manager instead
where Membership is my 'through table'.
my code :
def save_classroom(request):
classroom_...
I have a legacy database with a table storing a many-to-many relationship, but without a single primary key column. Is there any way to convince Django to use it anyway?
Schematically:
Product 1<---->* Labeling *<---->1 Label
The Labeling table uses (product_id,label_id) as a compound primary key, and I don't see any way to inform Dj...
I want to call for a self function of a model class as such in upload_to:
class Foo(models.Model):
filestack = models.FileField(upload_to=self. gen_save_path)
def gen_save_path(self):
"""
gen_save_path: void -> String
Generates the path as a string for fileStack field.
"""
return "some ge...
I try to keep a somewhat consistent naming scheme on my HTML templates. I.e. index.html for main, delete.html for delete page and so forth. But the app_directories loader always seems to load the template from the app that's first alphabetically.
Is there any way to always check for a match in the calling app's templates directory first...
I'm sure there's an easy answer here and i'm just over-complicating things, but i am in the process of writing a Django module responsible for storing and tracking user usage statistics which can then be displayed to users on certain pages.
Simplest example of this might be tracking which products a user has purchased and looked at so t...
I use cherokee(1.0) as web server and django web framework(1.2.1).
When I update django files like views.py or static files, web server seems
not to update instantly. I guess it is about cache, so i set expiration "already expired on 1970", but the problem remains.
I also try to restart server in admin website, but still can't solve t...
I manually changed the contents of a record in the database.
The changes are not reflected in the app.
I'm going to reset it by using the shell to load the query and then resave it. Is there another, easier way?
...
I have a Python Unicode string. I want to make sure it only contains letters from the Roman alphabet (A through Z), as well as letters commonly found in European alphabets, such as ß, ü, ø, é, à, and î. It should not contain characters from other alphabets (Chinese, Japanese, Korean, Arabic, Cyrillic, Hebrew, etc.). What's the best way t...
Hey,
I had problems deploying a Django project - Review Board. I did what the document says and but got "Error 403" errors when I tried visiting the site. Maybe I should have posted this question on serverfault.com, but I think this may help people write/deploy Django application in general.
Here is the installation:
I installed Revie...
i have a privacy form, in wich i am selecting what application should be hidden when one accesses a user's profile.
The form contains several checkboxes,and the user checks what he wants to be hidden. What i want is, when a user accesses this form, the form to be an instance of the privacy form already saved, if it exists one.
I mean, if...
In a blog application (which I have mostly built following a tutorial), I would like to have a next and previous post link on the single page views of the posts. The blog app's urls.py file looks like this:
from django.conf.urls.defaults import *
from django.views.generic import list_detail
from sandy.blog.models import Post
urlpatte...
Hi,
I have constant problem with cookies on my Django site which is set up on a subdomain. It works for a couple of days, then message 'your browser doesn't accept cookies' appears on a login page. I need to restart my web server to make it work for a couple of next days and this cycle repeats.
This is really frustrating. I am not sure...
I'm writing entries for cross-browser bugs/workarounds. I would like the main view to present a hierarchial tree starting with the primary categories and descending into more specific categories:
css
layout
float
position
specificity
js
dom
html
object
embed
Let's say I want to file an entry and have...
Hi,
I have a django.contrib.contenttypes.generic.genericForeignKeyField as a member of my model,
however, it is not appearing when I instantiate the model and then try to get the fields out of the _meta of the object.
e.g:
class A(models.Model):
field2 = models.IntegerField(...)
field1 = generic.genericForeignKeyField()
a...
My django unit tests take a long time to run, so I'm looking for ways to speed that up. I'm considering installing an SSD, but I know that has its downsides too. Of course there are things I could do with my code, but I'm looking for a structural fix. Even running a single test is slow since the database needs to be rebuilt / south mi...
I have a BooleanField in a Django 1.2 form.
I'm setting for it default=True but it is still unchecked in the browser by default.
Googling for it shows that some people are using initial=True, but this breaks the code for me completely (unrecognized keyword "initial").
Any ideas?
...
hello,
I am uploading some .doc and .txt documents on my server, and i'd like to have two options:
-the user to be able to download the document
-the user to be able to read it online
i've read some code for the download function, but it doesn't seem to work.
my code:
def download_course(request, id):
course = Courses.objects.get(...
form = AddItemForm(request.POST, request.FILES)
if form.is_valid()
do_stuff
return render_to_response(blah.html, {'form':form})
Now form will have the error information along with the original values of the fields, but it does not retain a selected file
How do I keep the selected file if the form fails validation?
...
I have an unsorted list of objects that each have a end_date attribute.
The list just looks like [obj1, obj2, obj3, <...>] in no specific order.
I want to end up with a list that looks like this:
[["Saturday, May 5", [obj3, obj5]], ["Monday, May 7", [obj1, obj8, obj9]] ... etc ]
Basically just a list of lists, where the "key" is t...
Hi everyone,
In django I made a simple ajax handler that will validate a POST request and on success write to a database -- which will later be available to be seen publicly. Anonymous in this case is allowed.
Much like StackOverFlow will accept questions posted by logged in and non logged in user, we'd have similar acceptance.
How d...