hi ..im trying to use django threaded comments however im stuck in how to correctly set values in this:
{% get_comment_form for [object] as [varname] with [parent_id] %}
{% get_comment_form for [app].[model] [object_id] as [varname] with [parent_id] %}
{% render_comment_form for [object] with [parent_id] %}
{% render_comment_form for [...
This is a question prompted by another question from me.
Django provides Abstract base classes functionality (which are not to same as ABC classes in Python?) so that one can make a Model (Django's models.Model) from which one can inherit, but without that Model having an actual table in the database. One triggers this behavior by setti...
Take a simple view like this:
def my_gallery(request):
images= ?
t = Template("<html><body>Here my images from XY {{ images }}.</body></html>")
html = t.render(Context({'images': ? }))
return HttpResponse(html)
How do I have to define the variable images/ What do I have to fill in the Context
so that Django displays m...
Hello everybody,
I am working on a loginMiddleware class for Django. This middleware class must send a user to the login page when it's not logedin. But there are a few exceptions.
Because i run the build-in django server i had to make a media url. But know is de problem that when the login page loads a javascript file, the javascript...
Hey Guys,
I'm having problems displaying nested blocks in a template.
eg.
{% for category in categories %}
//code to display category info
{% products = products.object.filter(category = category) %}
{% for product in products%}
//code to display product info
{% endfor %}
{% ...
Hi
I created a list in Python:
mylist=os.listdir("/User/Me/Folder")
now I have a list of files in a List.
What I would like to do is:
Take one file name after the other and add a URL to it:
/myurl/ + each item in mylist
And then I would like to write the result in a html template from Django.
So that it display all the images in...
I have this working code
f = SomeForm(request.POST)
When I tried to modify it into
f = SomeForm(request.POST, initial={'spam', 4})
it didnt work, the 'initial' wasnt selected ('spam' is a ModelChoiceField), but when I tried
f = SomeForm(initial={'spam', 4})
it worked (selected value was correct). Am I missing something here? If ...
This is the code I'm trying to embed:
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jJECepNeCJ0&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jJECepNeC...
Ok, now I know how to display images on ONE /myurl/ in Django as a list (YEAH!)
But how can I display ONE Image per url with a button to click to the next image etc.
So basically I would want to come to the first /urlstart/:
text and a next button.
brings user to e.g. /urlstart/1
There the first image of a List is displayed and belo...
Hello Everyone,
I've got a question about testing my Django applications in a built out Django project.
First, I've got the same project not built out and everything works fine. This project follows the standard Django project architecture apart from putting my tests in their own directory:
django_project/
manage.py
settings.py
...
I currently have the following javascript array:
var stuffs = ['a', 'b'];
I pass the above to the server code using jQuery's load:
var data = {
'stuffs': stuffs
};
$(".output").load("/my-server-code/", data, function() {
});
On the server side, if I print the content of request.POST(I'm currently using Django), I get:
'stuffs...
I am interested in learning Python and Django.
Are there any books that you would recommend especially to Java / JavaEE developers?
I already know Dive into Python (by Mark Pilgrim) and the Book of Django (although I think the latter expects readers to already know Python).
Cheers!
...
I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id).
These events would essentially contain an event type like "click" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including item...
I'm running a Django installation with geoDjango, and have created a model like this:
#models.py
from django.contrib.gis.db import models
class Route(models.Model):
name = models.CharField(max_length=100)
path = models.LineStringField(srid=4326)
objects = models.GeoManager()
def __unicode__(self):
return str(s...
Why does this code eat up memory? When I run it it slowly consumes more memory with every loop, and I have something like 300000 loops. I'm using Windows, and Python 2.6.
def LoadVotes(self):
old_votes=Votes.objects.all()
amount=old_votes.count()
print 'Amount of votes is: ' + str(amount)
c=0
for row in old_votes:
...
I know how to change or extend a model's views in the Django admin ( http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.add_view ) but I want to extend the admin index (dashboard) view.
Specifically, I want to keep it the same, but add some information to some of my models that will let me sort them ...
I get the following error:
sqlite3.OperationalError: table gallery_image has no column named filename
Here is my Model:
from django.db import models
class Image(models.Model):
filename= models.Field(max_length=40);
gallery = models.ForeignKey('Gallery')
def __unicode__(self):
return u'%s(%s)' % (self.filename,se...
Why does Django give me this exception
[(7, u'Acura'), (18, u'Alfa Romeo'), ...] is not JSON serializable
When I try
data = VehicleMake.objects.filter(model__start_year__gte=request.GET.get('year',0)).values_list('id','name')
return HttpResponse(simplejson.dumps(data, ensure_ascii=False), mimetype='application/json')
?
It's just ...
I have a Django view that receives POSTs which do not need to have the CSRF token. Therefore I used the @csrf_exempt decorator on the view. The problem is that sometimes I do not issue a response from the view (it's a Twitter bot, it receives an HTTP POST for every tweet and I do not want to respond to every tweet). When I don't issue a ...
Hi,
I need to know how to start a session by Ajax in Django. I'm doing exactly as described bellow, but it is not working! The request is sent correctly, but don't start any session. If a request directly without ajax it works! What is going on?
'# urls
r'^logout/$', 'autenticacao.views.logout_view'
'# view of login
def login_view...