django-admin

Django preview, TypeError: 'str' object is not callable

I'm trying to make a Preview function. I'm reading this blog, Django Admin Preview, but now I have the following error and I don't know what it means. Traceback (most recent call last): File "/home/user/webapps/django/lib/python2.5/django/core/handlers/base.py", line 92, in get_response response = callback(request, *cal...

getting the user from a admin validation class

Hello, I am trying to control admin item entry where non-super user accounts can't save a ChannelStatus model input that has a date attribute which is older than 2 days. I need to get the user so that I can check if the request is a reqular or a super user but couldn't achieve this. I have already tried "request.user.is_superuser", "use...

Getting the history of an object

Hello I use django admin for my users to add their Model objects, as you know django is keeping the track of user actions such as the user who added an item. For an object, At a custom view outside the admin panel, I need to display the user name of the adder. How can I fetch/retrieve this data ? Cheers ...

allowing only super user login

Hello, I have written a django page that requires only super users to login. So I have added foo_view = staff_member_required(foo_view) but it doesn't cut, now I can control only allowing staff marked users to login but this doesn't cut. I have tried something like def foo_view(request): if not request.user.is_superuser: ...

Order Django admin change list column by output of __unicode()__ method

Here's part of my Django app's models.py: class Person(models.Model): birth_year = WideYear(null=True, blank=True) birth_year_uncertain = models.BooleanField() death_year = WideYear(null=True, blank=True) death_year_uncertain = models.BooleanField() flourit_year = WideYear(null=True, blank=True) flourit_year_unce...

Django, sorl-thumb dont work

Hi guys, i dont know what im doing wrong, but sorl-thumb just upload the image but dont make thumbs... model.py from sorl.thumbnail.fields import ImageWithThumbnailsField ,ThumbnailField imagen = ImageWithThumbnailsField(upload_to='images', thumbnail={'size': (75, 75)}, ...

How do I hide the field label for a HiddenInput widget in Django Admin?

I've got a bit of Django form code that looks like this: class GalleryAdminForm(forms.ModelForm): auto_id=False order = forms.CharField(widget=forms.HiddenInput()) And that makes the form field go away, but it leaves the label "Order" in the Django admin page. If I use: order = forms.CharField(widget=forms.HiddenInput(), labe...

Change list link to foreign key change page

When viewing the admin change list for a model, is it possible to make the columns that correspond to foreign keys links to their respective pages? A simple example is I have a Foo object which contains Bar as a foreign key. If I'm viewing the admin change list for Foo (and have it set to include Bar in the display_list columns), the m...

In the Django admin, how can I set up searching profiles by username?

Heyas I'd like to be able to search user profiles by username in the django admin. Essentially, in admin.py, I'd be doing something like: class UserProfileAdmin(admin.ModelAdmin): search_fields = ['username'] but this wont work since user is a foreign key in the my usual user profile set up. Is there a quick way to achieve this ...

Django: reverse list of many to many relationship?

Hi, I have two simple models in models.py: Service and Host. Host.services has a m2m relationship with Service. In other words, a host has several services and one service can reside on multiple hosts; a basic m2m. models.py class Service(models.Model): servicename = models.CharField(max_length=50) def __unicode__(self):...

Debugging Django Admin Template Resolution

Hi, Can someone point me to the code or a way that I can say print to screen which admin template is being used? It happens many a time when I am replacing a admin template for an model that I add the template and hit the page and bham... still the same template. Usually its a case issue or something like that... but it takes me a whi...

Help with Admin forms validation error

Hi Guys, I am quite new to Django, I'm having few problems with validation forms in Admin module, more specifically with raising exceptions in the ModelForm. I can validate and manipulate data in clean methods but cannot seem to raise any errors. Whenever I include any raise statement I get this error "'NoneType' object has no attribute...

Django Relationships

Hi I'm new at Django and have a few problems getting my mind around manytomany relatiosnhips and Manytoone (i.e Foreign key). My setup is this. I have class A, Class B, Class C Every Class B object must belong to a Class A object. They cannot belong to more than one Class A object. A more practical example could be if Class A is a Mus...

Select item in Django admin inline with radio buttons

Here's part of my models.py: class Person(models.Model): birth_year = WideYear(null=True, blank=True) birth_year_uncertain = models.BooleanField() death_year = WideYear(null=True, blank=True) death_year_uncertain = models.BooleanField() flourit_year = WideYear(null=True, blank=True) flourit_year_uncertain = model...

"startproject" option disappeared from django-admin.py

I apologize in advance for my noobness. I tried to create a new project with "django-admin.py startproject blah" and I got an error saying "startproject" is an unknown option for django-admin.py. This can't be normal. I then did "django-admin.py help" and viewed the possible arguments, and they were the same as the arguments for manage.p...

Django Admin Fieldsets

Hi Trying to undertstand Django Admin a bit better, but I find the django documentation a bit lacking sometimes (or perhaps my capacity to understand). I know you can use fieldsets to control the layout of certain admin pages. What I cant seem to grasp is what the fieldset names are. If i have the following class Clas Demo(model.Mode...

Django admin choice field dynamically populated by generic foreign key's model fields

Say I have the following simple models for some tagging application (this is simplified from the actual code): # Model of tag templates class TagTemplate(models.Model): name = models.CharField() content_type = models.ForeignKey(ContentType) class Tag(models.Model): template = models.ForeignKey(TagTemplate) object_id = m...

In Django Admin, I want to change how foreign keys are displayed in a Many-Many Relationship admin widget

I have a ManyToMany relationship: class Book: title = models.CharField(...) isbn = models.CharField(...) def unicode(self): return self.title def ISBN(self): return self.isbn class Author: name = models.CharField(...) books = models.ManyToManyField(Book...) In the admin interface for Author I get a multiple sel...

Alternate datasource for django model?

I'm trying to seamlessly integrate some legacy data into a django application. I would like to know if it's possible to use an alternate datasource for a django model. For example, can I contact a server to populate a list of a model? The server would not be SQL based at all. Instead it uses some proprietary tcp based protocol. Copying ...

overriding module caption names in django admin

By default, the admin models are grouped by the app, and the app name is in the caption (accounts, auth, etc.). How to override the name in the caption without writing the admin templates? ...