django-admin

Relational Fields - Django

Hi, I am making a product app to add machines to a product list. Every product had a list of features, like motor type, motor output. Not all have the same features. Each feature has a value, like 2W, 1.5m etc, but this will only be put in once you add a product. So I wanna add all the possible features to my feature model. Then when I ...

Is it possible to create more than one admin interface in Django?

I asked a similar question here. I didn't get many useful answers. May be the question was confusing. So to make it simple, I have different databases used by different users. I want to create a separated admin interface for each of them so that the users will see and modify only the tables related to them. For various reasons multi-db o...

How to read/write input fields in Django-admin tabular inlines using ajax?

I am looking for ways to dynamically update the inline entries using ajax. i.e. as the user selects an item from the dropdown box, the associated input fields can be populated with data. The views.py part for ajax should be straightforward. But one problem for me is how to get the names of dropdown boxes in js, which can be added on the...

Saving a StackedInline foreign keyed model before primary model in Django Admin

I have four models with the relationships Model PagetTemplate(models.Model): pass Model TextKey(models.Model): page_template = models.ForeignKey(PageTemplate, related_name='text_keys') Model Page(models.Model): page_template = models.ForeignKey(Pagetemplate, related_name='pages') Model Text(models.Model): key = model...

django-admin.py on win7 asked programm for open

I have installed Django on Win7 and try >>> import django >>> django.VERSION (1, 2, 3, 'final', 0) it works. But when I call django-admin.py startproject myappname, Windows show me dialog with ask what program it should use to open this command. If I check python.exe then django-admin.py always show me help about django-admin.py ...

Add a custom button to a Django application's admin page

Hi, I have an application in Django with a routine which would be available only to the admin. I'm quite new to the python/django world, so maybe my question is trivial. What I want to do is add a button to perform the routine in this application's section of the admin app. I'm quite confused from there, am I suppose to make a template ...

Automatic author in Django admin

Hi, all. I'm working on the admin for my django site, and I've run into an obstacle. I've got an Entry model and a Related model. The Related model has two foreign key fields: one to the Entry model (entry) and one to django's User model (author). The Related model is considered a "sub-model" of the Entry model, and each user can only h...

Problem displaying related foreignkey data in Django Admin screen

To display foreignkey data in my admin list view, I created a callable: def next_date(self): EvDateObj = EventDate.objects.filter(event__id__exact=self.id) .exclude(event_date__lt=datetime.date.today()) .order_by('event_date')[:1] return EvDateObj This shows in the list view as: [<EventDate: 25 September 2010>...

Getting Django Admin Site Formatted Under Apache

My question is how can I get my Django admin site to be formatted (all pretty) under Apache the way it is under runserver? I can bring it up and log into it, but it is not all nicely formatted. There is nothing special about my urls.py file from django.conf.urls.defaults import * from django.contrib import admin from amr.views import h...

[SOLVED] DjangoUnicodeDecodeError and force_unicode

I've simple Django model of news entry: class NewsEntry(models.Model): pub_date = models.DateTimeField('date published') title = models.CharField(max_length = 200) summary = models.TextField() content = models.TextField() def __unicode__(self): return self.title Adding new news (in Admin page) with english text wo...

Calling function when model is called by django-admin

Hello! I have something like this in my model: class Artykul(models.Model): id = models.AutoField(max_length = 5, primary_key = True) tytul = models.CharField(max_length = 255) kategoria = models.ManyToManyField(Title, limit_choices_to = choices_limit) dodano = models.DateField(auto_now_add = True) autor = models.CharField(max_leng...

Inserting additional items into an inherited list in Django/Python

I'm using some subclasses in my Django app, and I'm continuing that logic through to my admin implementation. Currently, I have this admin defintion: class StellarObjectAdmin(admin.ModelAdmin): list_display = ('title','created_at','created_by','updated_at','updated_by) Now, I have a Planet class, that is a subclass of StellarObject...

Unable to login to admin site in localhost

I can't login to the admin site on localhost. I try with firefox, IE. I try using the 127.0.0.1:8000 address. Also, I set the SESSION_COOKIE_DOMAIN to localhost, localhost:8000 I change the host file to: 127.0.0.1 test.com and set: SESSION_COOKIE_DOMAIN = 'test.com' I can login in production (only after the SESSION_COOKIE...

custom html field in the django admin changelist_view

Hi Stackers' I'd like to some little customisation with the django admin -- particularly the changelist_view class FeatureAdmin(admin.ModelAdmin): list_display = ( 'content_object_change_url', 'content_object', 'content_type', 'active', 'ordering', 'is_published', ) list_edit...

Using Django-admin and a custom user-specific admin concurrently

I'm creating a Django powered website that will have numerous applications (Blog, Shop, Portfolio, etc.) that will be edited by 5 or so people, and I have so-far been designing everything with the Django admin in mind. I have come to realise that this is a very bad way of thinking -as really- the Django admin should really only be for ...

Django randomly order users in admin

I am trying to create a Django admin filter that will get random groups of users. At this point, I have two problems: Applying a custom filter to the User model, and Displaying a random set of users. On #1, I've tried using User.username.random_filter = True, but it comes back with an AttributeError saying that User has no attribute ...

Multiple versions of django admin page for the same model

In my django admin section, I'd like to show different versions of the admin page depending on what kind of user is currently logged in. I can think of a couple ways this might work, but haven't figured out how to do any of them. Perhaps I could put logic into the admin.ModelAdmin to look at the current user and change the 'exclude' fi...

Setting model level permissions in code for Django admin panel

Hi All, Is there a way to implement the permissions for models through the code? I have a large set of models and I want some of the models to be just viewable by the admin and not the ability to add them. Please suggest. ...

Django databrowse with custom queryset?

Django's databrowse is very different from the rest of django in that the docs literally don't exist. Has anyone tried to do more that databrowse.site.register on a model? Any code examples? In particular, I've got a model that has a ForeignKey to an auth.Group and I want databrowse to use this queryset instead of .all(): qs = Model.ob...

Do Django ManyToManyManagers cache their data?

Basic model breakdown: Movie and MovieGenre models. The Movie model has a field called genres, which is declared as: genres = models.ManyToManyField(MovieGenre, blank=True) Here is the issue: In [42]: frank = Movie.objects.get(id=122) In [43]: frank.genres.count() Out[43]: 2 In [44]: frank.genres.all() Out[44]: [<MovieGenre: Conc...