Hi,
say I've got:
class LogModel(models.Model):
message = models.CharField(max_length=512)
class Assignment(models.Model):
someperson = models.ForeignKey(SomeOtherModel)
def save(self, *args, **kwargs):
super(Assignment, self).save()
old_person = #?????
LogModel(message="%s is no longer assigned to ...
It would be easy with a custom list_display, but that would cause me to lose the sorting ability according to that column.
...
Hey,
I am writing simple site that requires users and profiles to be handled. The first initial thought is to use django's build in user handling, but then the user model is too narrow and does not contain fields that I need. The documentation mentions user profiles, but user profiles section has been removed from djangobook covering dj...
I only you can limit what a user can do via the user permissions in admin.. But is there a way to limit them in admin via what group you add them to?
I want to allow a certain group to do everything in that model if they belong to a certain group
thanks!
...
href="http://www.torontolife.com/daily/daily-dish/restauranto/2010/03/10/best-new-restaurants-2010-james-chatto-names-five-honourable-mentions/">Best new restaurants 2010: honourable mentions
does django have built in mechanism to format links above
i mean words joined with hypens
how can i achieve this ?
...
I've been trying to find a django wiki app, which has the following -
1.) WYSIWYG
2.) Attach files
3.) Revisions
I see moinmoin, but before going all in, wanted to see what you all have used.
...
Trying to add email notification to my app in the cleanest way possible. When certain fields of a model change, app should send a notification to a user. Here's my old solution:
from django.contrib.auth import User
class MyModel(models.Model):
user = models.ForeignKey(User)
field_a = models.CharField()
field_b = models.Ch...
I have a projects page where users can start up new projects. Each project has two forms.
The two forms are:
class ProjectForm(forms.Form):
Title = forms.CharField(max_length=100, widget=_hfill)
class SsdForm(forms.Form):
Status = forms.ModelChoiceField(queryset=P.ProjectStatus.objects.all())
With their respective models as follows:...
I have 50 different websites that use the same layout and code base, but mostly non-overlapping data (regional support sites, not link farm). Is there a way to have a single installation of the code and run all 50 at the same time?
When I have a bug to fix (or deploy new feature), I want to deploy ONE time + 1 restart and be done with ...
In mysql, you can insert multiple rows to a table in one query for n > 0:
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9), ..., (n-2, n-1, n);
Is there a way to achieve the above with Django queryset methods? Here's an example:
values = [(1, 2, 3), (4, 5, 6), ...]
for value in values:
SomeModel.objects.create(first=v...
I can't find the bug in this code. I've tried isolating the problem, but it works when I copy the relevant code into a separate file. The problem must be with the surrounding code, but I don't see how it's even relevant. Here's everything:
The problem is with the "Activate Your PROJECT Account" email. It sends me an email with something...
Hi folks,
I am a new Djangoer, and figuring out how to build custom widget, my problem is cannot get the MEDIA_URL in my widget's template, while the form use MySelectWidget able to get the MEDIA_URL itself.
#
#plus_sign.html
#
<a href="" class="" id="id_{{ field }}">
<img src="{{ MEDIA_URL }}images/plus_sign.gif" width="10" height...
Originally started here: http://stackoverflow.com/questions/2650181/django-in-query-as-a-string-result-invalid-literal-for-int-with-base-10
I have a number of apps within my site, currently working with a simple "Blog" app. I have developed a 'Favorite' app, easily enough, that leverages the ContentType framework in Django to allow me ...
How can I store some data on Google App Engine? I'm using Django.
...
i don't know what the remote_api will do
thanks
...
querysets from django can be combined with a pipe like so:
q1 = Articles.objects.filter(name="goats")
q2 = Articles.objects.filter(name='cows')
q1 = q1|q2.
Is there a way to do this for sphinxquerysets? So far, I'm striking out.
...
I was hunting around the Internet for a way to easily allow users to blank out imagefield/filefields they have set in the admin.
I found this: http://www.djangosnippets.org/snippets/894/.
What was really interesting to me here was the code posted in the comment by rfugger:
remove_the_file = forms.BooleanField(required=False)
def save...
I have a custom SQL call that is returning different results to the template than I get when I run the same query against the database directly, 1 row vs 2
Query - copied from Django Debug Toolbar:
SELECT ((Sum(new_recruit_interviews) / Sum(opportunities_offered)) * 100) as avg_recruit, ((Sum(inspections) / Sum(presentations)) * 100) ...
Where can i find good practice python problems with solutions?
I'm looking for detailed practice problems that are designed with a coding purpose in mind.
...
my form is
class MapForm(forms.ModelForm):
class Meta:
model = Map
fields = ('mapName', 'kmlStr')
and the view is :
map_form = MapForm(request.POST or None)
if map_form.is_valid():
map = map_form.save(commit=False)
map.mapName=map_form.mapName#is this code right ?
how to get the mapName 's value , us ...