I am trying to add a dynamic Meta attribute to all of my Django models using model inheritance, but I can't get it to work. I have a permission that I want to add to all my models like this:
class ModelA(models.Model):
class Meta:
permisssions =(('view_modela','Can view Model A'),)
class ModelB(models.Model):
class M...
Hi all,
I have a form like the following:
class MyForm(Form):
#personal data
firstname = CharField()
lastname = CharField()
#education data
university = CharField()
major = CharField()
#foobar data
foobar = ChoiceField()
Since some fields (like foobar) are populated from the database i can't use another method othe...
I've added a method 'highlight_link' to my model's admin.py class:
class RadioGridAdmin(admin.ModelAdmin):
list_display = ('start_time', highlight_link)
def highlight_link(self):
return ('some custom link')
admin.site.register(RadioGrid, RadioGridAdmin)
It returns a custom link for (I've left out highlight_link.short_...
Using Django, how do I generate the value of a field the first time it's accessed? Then storing the value on the field.
In my case it's an image, but it could be anything I suppose. What I need is a function that runs before the field is accessed or wrapping the access and upon checking for nullness I generate it, or something like that...
Summary
As I'm looking on stackoverflow and around the net, I find that there is a general lack of good documentation on best practices for caching a high performance site that uses sessions. It would be helpful if we can share some ideas around some basic building blocks particularly around caching. For the purpose of this discussion, ...
I have a Django installation at /home/masi/mySite.
How can you set that the files at the folder */home/masi/public_html/mySite* uses the Django installation?
...
Is there any way to set a foreign key in django to a field of another model?
For example, imagine I have a ValidationRule object. And I want the rule to define what field in another model is to be validated (as well as some other information, such as whether it can be null, a data-type, range, etc.)
Is there a way to store this field-...
Hello, I have gotten quite familiar with django's email sending abilities, but I havn't seen anything about it receiving and processing emails from users. Is this functionality available?
A few google searches have not turned up very promising results. Though I did find this: http://stackoverflow.com/questions/348392/receive-and-send-e...
Hi all.
This is probably a pretty n00b question, but i can't get it to work.
If i have following model:
from django.contrib.auth.models import User
class Entry(models.Model):
title = models.CharField()
users = models.ManyToManyField(User)
How would i get a list of all entry-titles of the currently logged in user?
Something like:
l...
I have a django application using mod_python, fairly typical configuration except that media files are being served by a (I know, not recommended) 'media' directory in the document root. I would like to test and maybe deploy with mod_wsgi but I cannot figure out how to create something simple to serve static files. mod_python allows th...
I'm working on a Django app for hosting media (specifically audio and images). I have image galleries and photos separate in my model, and have them linked with a ForeignKey (not sure if that's correct, but still learning). What I need is for the Album class's __unicode__ to return the album owner's username.
class Album(models.Model):
...
I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think ...
I'm doing some local development using Django and Satchmo. When I upload product images locally via the admin, the path to the image shows up as an absolute path, complete with drive letter, rather than the proper relative path.
Stranger still, Satchmo saves both the original image and the thumbnails it generates in both me /media/ dir...
How do I get the primary key after saving a ModelForm? After the form has been validated and saved, I would like to redirect the user to the contact_details view which requires the primary key of the contact.
def contact_create(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid(...
Guys,
I have the following code from some example i got from here, but its not working on my django application.
On my templete i have this function:
$(function(){
setAutoComplete("tags", "tagResults", "/taglookup/?query=");
});
and on my urls i have the following line
(r'^taglookup/$', 'twine.twineapp.views.tag_lookup'),...
I need to generate external links in admin interface grid column, but they shows as html code:
<a href="http://www.site.com/">site</a>
Admin interface translates my links as html-entities and they doesn't shows as right links.
Is it possible to show external links there, not html code?
I think list_display_links doesn't work...
I have a CheckboxSelectMultiple field, why can't I iterate over the single choices?
This doesn't work:
{%for choice in form.travels.choices%}
{{choice}}
{%endfor%}
Even specifying {{choice.0}} doesn't help, how could i do this?
Thanks
...
I know a site can have many apps but all the examples I see have the site called "mysite". I figured the site would be the name of your site, like StackOverflow for example.
Would you do that and then have apps like "authentication", "questions", and "search"? Or would you really just have a site called mysite with one app called Stack...
When I have a valid Django form, I can access the data with form.cleaned_data. But how do I get at the data a user entered when the form is not valid i.e., form.is_valid is false.
I'm trying to access forms within a form set, so form.data seems to just give me a mess.
...
I would like to do aggregate calculations based on month for a datetime field.
I am currently using the extra() function to format the date like:
...extra(select="strftime('column', '%m/%Y') as t").values('t').annotate(SUM(foo))
and it works great for sqlite3.
In sqlite3 I can use strftime(), but that doesn't work with MySQL.
In MyS...