Hay,
i have an app which essentially a conversation system (much like reddits)
Where a post can have multiple replies, and a reply and have multiplies, and a reply to a reply can have multiple replies (etc)
I've made the model like this
class Discussion(models.Model):
message = models.TextField()
replies = models.ManyToManyFi...
According to this section in the Django docs I should use {% blocktrans %} for cases where I need to translate pluralizations. However, with an example like the following, isn't there something more convenient I can do?
{% blocktrans count video.views.count as views %}
The video has been viewed <span>{{ views }}</span> time
{% plural %}...
I am trying to build a web site in both English and Bulgarian using the Django framework. My idea is the user should click on a button, the page will reload and the language will be changed. This is how I am trying to do it:
In my html I hava a the button tag <button id='btn' onclick="changeLanguage();" type="button"> ... </button>
An ...
I'm having a problem with a test app I'm writing to verify some Django functionality. The test app is a small "grade book" application that is currently using Alex Gaynor's readonly field functionality http://lazypython.blogspot.com/2008/12/building-read-only-field-in-django.html
There are 2 problems which may be related. First, when ...
Hello,
I have tabs that calls via javascript urls of django to complete the "container"
But i am getting 301, any idea why this is happening?
Server misconfiguration?
urls.py
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^list/', 'carsproj.cars.views.list'),
)
view
def list(request):
if request.i...
i have an application, and in my urls.py i have something like that:
urlpatterns = patterns('',
url(r'^profile_view/(?P<id>\d+)/$',
profile_view,
name='profile_view'),)
meaning that the profile_view function has id as a parameter.
Now, i want to call that functio...
Specifically, I'm trying to use a string to arbitrairly filter the ORM. I've tried exec and eval solutions, but I'm running into walls. The code below doesn't work, but it's the best way I know how to explain where I'm trying to go
from gblocks.models import Image
f = 'image__endswith="jpg"' # Would be scripted in another area, but pa...
I've got a view like the following:
from django.views.decorators.http import condition
def stream():
for i in range(0, 40):
yield " " * 1024
yield "%d" % i
time.sleep(1)
@condition(etag_func=None):
def view(request):
return HttpResponse(stream(), mimetype='text/html')
However, it definitely doesn't se...
I'm writing a test "grade book" application. The models.py file is shown below.
class Student(models.Model):
name = models.CharField(max_length=50)
parent = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Grade(models.Model):
studentId = models.ForeignKey(Student)
finalGrade =...
Is there a simple way to discard/remove the last result in a queryset without affecting the db?
I am trying to paginate results in Django, but don't know the total number of objects for a given query.
I was planning on using next/previous or older/newer links, so I only need to know if this is the first and/or last page.
First is easy...
In Django admin site, when listing all the objects for a given model, I know we can customize which columns get displayed for a ModelA via list_display
Say that ModelA has a one-to-many relationship with ModelB. I would like to add another column on the listing page for ModelA, where each entry is a URL pointing to all objects of ModelB...
I am have a list of "Entries"
I want to get the first entry in the list's "title".
In the template I tried writing
{{ Entries|first.title }}
But it results in an error.
Is there a way to achieve this without writing a loop or doing it in the view?
...
Using the django admin, I would like to be able to specify which models a user sees when he logs in. For a stretch goal, for each model types a user can see, I would like to specify a filter to limit which instances of the model the user can see.
Could someone please provide a pointer for how to go about achieving this?
...
I just moved a django project to a deployment server from my dev server, and I'm having some issues deploying it. My apache config is as follows:
<Location "/">
Order allow,deny
Allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE proj...
I tried extending RegistrationFormUniqueEmail
class CustomRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
first_name = forms.CharField(label=_('First name'), max_length=30,required=True)
last_name = forms.CharField(label=_('Last name'), max_length=30, required=True)
def save(self, profile_callback=None):
ne...
I have a django app that is mostly done, and the URLs work perfectly when I run it with the manage.py runserver command. However, I've recently tried to get it running via lighttpd, and many links have stopped working.
For example: http://mysite.com/races/32 should work, but instead throws this error message.
Page not found (404)
Reque...
I am using Django's comment framework which utilizes generic foreign keys.
Question: How do I sort a given model's queryset by their comment count using the generic foreign key lookup?
Reading the django docs on the subject it says one needs to calculate them not using the aggregation API:
Django's database aggregation API doesn'...
Heyy there,
i have for example a view function like this:
def profile_view(request, id):
u = UserProfile.objects.get(pk=id)
return render_to_response('profile/publicProfile.html', {
'object_list': u,
},
context_instance=RequestContext(request))
and the url:
url(r'^profile_view/(?P\d+)/$',
...
Hi,
I'm working with django-piston to attempt to create an API that supports oAuth.
I started out using the tutorial at:
http://blog.carduner.net/2010/01/26/django-piston-and-oauth/
I added a consumer to piston's admin interface with key and secret both set to "abcd" for test purposes.
The urls are successfully wired-up and the oAut...
Hi all,
I guess this is a PATH/PYTHONPATH error, but my attempts failed so far to make django working.
System is Ubuntu 10.04, 64bit:
mx:~/webapps$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS"
Python version: 2.6.5:
@mx:~/webapps$ python -V
Python 2.6.5
...