I have what looks to me to be a pretty simple setup of model, modelform and a view playing with the two. The only hitch is that the model has a user property that can't be POSTed to the form, rather it should be populated by request.user so I have this:
# models.py
class Update(models.Model):
user = models.ForeignKey(User, ...
I have many pk-value in a dictionary and I want to update the object with his new value.
to_update = [{'id':id1,'value':value1}, ... ]
Now i'm doing this:
for t in to_update:
Mymodel.objects.filter(pk=t['id']).update(myfield=t['value'])
I think thant i can do this in a better way, but i didn't find it.
Thank You
...
I am using the delete() function from django.contrib.comments.views.moderation module. The staff-member is allowed to delete ANY comment posts, which is completely fine. However, I would also like to give registered non-staff members the privilege to delete their OWN comment posts, and their OWN only. How can I accomplish this?
...
Django's for loop seems to be removing all of my <img> tag's self-closing...ness (/>). In the Template, I have this code:
{% for item in item_list %}
<li>
<a class="left" href="{{ item.url }}">{{ item.name }}</a>
<a class="right" href="{{ item.url }}">
<img src="{{ item.icon.url }}" alt="{{ item.name }} Logo." />
</a...
The Django changelist table is really cool - searchable, filterable, multi-select actions etc.
I'm building a custom backend for an app and I keep realizing: this is exactly what I need, I should re-use it.
Has anyone had any experience using the change list outside of Django's admin app?
What I've arrived at currently is something li...
picture_url = models.CharField(max_length=2000)
...
Hi there,
I have a simple python method that should be returned by Django/pyAMF but it's returning HTTP Status 500 instead (although I do pass through the method with no error and the Grupo object is created):
def newGrupo(request, igID):
return { 'grupo': Grupo.objects.create(ig = Ig.objects.get(pk=igID)),
'membros'...
We are using django and django-socialauth ,
and my view is facebook/login
what is the facebook login-button for django,
thanks
...
{'quotes': u'Live before you die.\n\n"Dream as if you\'ll live forever, live as if you\'ll die today"\n\n"Love one person, take care of them until you die. You know, raise kids. Have a good life. Be a good friend. Try to be completely who you are, figure out what you personally love and go after it with everything you\'ve got no matter h...
http://wiki.developers.facebook.com/index.php/Mobile
I use Django/Python as my mobile website.
Am I missing something?
...
Hi.
I have following structure with example data:
id season_id title
1 1 Intro
2 1 Second part
3 1 Third part
4 4 Other intro
5 4 Other second part
(don't ask why), where season_id is always point to id of first episode of season...
What i want, to get follo...
Hi, I been going through most of the django book at a local bookshop and everyone of them has a chapter or two about django admin and which barely touch the surface and mostly about skinning the app.
I wonder if there is any django books that focuses all aspects of django admin or goes much more deeper in detail about django admin app.
...
Hay, I'm using django 1.2 and i want to know how to count rows from a raw queryset(RawQuerySet).
The traditional .count() method doesn't work.
Heres my query
query = "SELECT *, ((ACOS(SIN(%s * PI() / 180) * SIN(lat * PI() / 180) + COS(%s * PI() / 180) * COS(lat * PI() / 180) * COS((%s - lon) * PI() / 180)) * 180 / PI()) * 60 * 1.1515)...
I want to modify the django-admin app to see how far it can go :) I have found some interesting projects (django grappelli) mostly focused on skinning, more interesing django-admin apps out there?
Looking for students project :) ideas are welcome too :)
...
Hay, serializers is not returning JSON object
make = Make.objects.filter(slug__exact=make)
models = Model.objects.filter(make=make).values('slug','name')
json_models = serializers.get_serializer("json")()
json_models.serialize(models)
return HttpResponse(json_models.getvalue())
I'm getting an error
'dict' object...
I have a website on a django, and in a set of pages I use the Paginator. With paginator, my last page sometimes does not render completely.
You can see the problem here.
Code:
view rank - http://code.google.com/p/myps3t/source/browse/views.py
template - http://code.google.com/p/myps3t/source/browse/www/Rank.html
Just refresh a couple...
Hi,
I am struggling with the CSRF token in a simple POST form in Django. The template generates the following CSRF output instead of outputting the value of the token:
<input type='hidden' name='csrfmiddlewaretoken' value='{'csrf_token':django.utils.functional.__proxy__ object at 0x1255690>}' />
I am using {% csrf_token %} in the ...
Hi,
I'd like to add js validation to my forms, and that validation should be done without requests to my server.
So, say, I open a page with form, make some errors and js code show me (without single request to the server) that, say, this field is required, this field is too short, this field should be a number etc.
The main idea - DR...
hey,
I'm fairly new to Django and have a basic question: I want to use an ORM that I can work with it for Django and other python projects, so the basic question is Django ORM agnostic and if so how can I use SQLAlchemy with it for example?
If it's not, then what do you suggest for the above problem (using ORM objects that works with ...
Is it safe to let users make their own Django templates with a set of pre-defined variables, and then render this template on the server? I would only pass a very limited set of parameters to render, all of which are strings. Templates would be something like:
hey, my name is {{name}}.
So, the question is, are there any django templat...