Re: How to access model class for a ModelAdmin?

2011-10-18 Thread Matt Schinckel
If you are in an instance method of a ModelAdmin, you can use `self.model` to get the model associated with the ModelAdmin. Have a look in django.contrib.admin's source for what methods you can override, or hook into. -- You received this message because you are subscribed to the Google

How to access model class for a ModelAdmin?

2011-10-18 Thread Lee
This must be easy but I'm not finding it in the docs. I need to access the model class corresponding to the current ModelAdmin instance, so that I can iterate through its objects. I need to do this generically so that I can use the routine in all ModelAdmins. Thanks for any help. Lee -- You

Batch upload data using ModelAdmin

2011-08-03 Thread Vasu Nagalingam
/88d3b1f40e3b4a8b?lnk=gst=modeladmin+as+a+batch +function#88d3b1f40e3b4a8b). I am having trouble understanding the flow. What does "cleaned_data" do? Is it loading the entire file or just the first row? If latter, where is it iterating? I would appreciate if someone can shed some light on th

Re: insert an inline to a ModelAdmin at runtime

2011-07-15 Thread Marc Aymerich
On Fri, Jul 15, 2011 at 1:35 PM, Marc Aymerich <glicer...@gmail.com> wrote: > Hi, > I created a method that generates an InlineFormset at runtime and inserts > it to a given ModelAdmin. > > It works perfectly when I call my method directly on admin.py > #admin.py >

insert an inline to a ModelAdmin at runtime

2011-07-15 Thread Marc Aymerich
Hi, I created a method that generates an InlineFormset at runtime and inserts it to a given ModelAdmin. It works perfectly when I call my method directly on admin.py #admin.py admin.site.register(MyModel, MyModelAdmin) insert_generic_plugin_inlines(MyOtherModelAdmin) but it doesn't work when

Re: Generic ModelAdmin class

2011-07-06 Thread Andre Terra
And if you were planning on hard coding a mapping of your model classes, use get_model() instead. www.b-list.org/weblog/2007/nov/03/working-models/ Cheers, Andre Terra On 7/6/11, gontran <geoffroydecorb...@gmail.com> wrote: > >> Do you mean, "in a ModelAdmin subclass in

Re: Generic ModelAdmin class

2011-07-06 Thread gontran
> Do you mean, "in a ModelAdmin subclass instance, how do I get the > model class that instance is associated with?"? If so, self.model. Yes I do. Thank you Tom. -- You received this message because you are subscribed to the Google Groups "Django users" group. T

Re: Generic ModelAdmin class

2011-07-06 Thread Tom Evans
On Wed, Jul 6, 2011 at 3:22 PM, gontran <geoffroydecorb...@gmail.com> wrote: > Hello everyone, > > I have an abstract class that defines a base Model. > Given the fact that the extended models are quite identical, in order > to administrate these models, I use a gen

Generic ModelAdmin class

2011-07-06 Thread gontran
Hello everyone, I have an abstract class that defines a base Model. Given the fact that the extended models are quite identical, in order to administrate these models, I use a generic ModelAdmin class. To sum up: class BaseClass(models.model): ...some fields... class Meta

Re: ModelAdmin, custom field: default value?

2011-06-28 Thread momo2k
Thanks, working :) def __init__(self, *args, **kwargs): super(MealModelForm, self).__init__(*args, **kwargs) try: instance = kwargs['instance'] self.fields['price'].initial = instance.price() except (KeyError, AttributeError): pass

Re: ModelAdmin, custom field: default value?

2011-06-28 Thread Marc Aymerich
On Tue, Jun 28, 2011 at 10:27 AM, Marc Aymerich wrote: > On Mon, Jun 27, 2011 at 11:03 PM, momo2k wrote: >> Hello, >> >> Is there a way to set dynamic default values for custom fields in the >> admin? >> >> Description of the problem: >> >> #

Re: ModelAdmin, custom field: default value?

2011-06-28 Thread Marc Aymerich
On Mon, Jun 27, 2011 at 11:03 PM, momo2k wrote: > Hello, > > Is there a way to set dynamic default values for custom fields in the > admin? > > Description of the problem: > > # models.py > # there are two models > class Meal(models.Model): >    name = ... > >    def

ModelAdmin, custom field: default value?

2011-06-27 Thread momo2k
Hello, Is there a way to set dynamic default values for custom fields in the admin? Description of the problem: # models.py # there are two models class Meal(models.Model): name = ... def check_new_price(self, price): # checks if the price is new and creates a new price if

Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-08 Thread Eiji Kobayashi
On Sun, May 8, 2011 at 12:00 AM, Oleg Lomaka wrote: > You have started from the beginning. Take a look at my very first reply in > this thread. Remove 'areacode' and 'number' fields from your MemberAdmin. > Let them be available from PhoneInline and AddressInline. You will

Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-08 Thread Oleg Lomaka
You have started from the beginning. Take a look at my very first reply in this thread. Remove 'areacode' and 'number' fields from your MemberAdmin. Let them be available from PhoneInline and AddressInline. You will be see them on the same admin page, just in other visual block where inline forms

Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-07 Thread Eiji Kobayashi
ess the fields from the Phone and Address > > model from > > the MemberAdmin model. I still cannot do this. Any other way? > > > Eiji > > > On May 7, 7:22 am, Oleg Lomaka <oleg.lom...@gmail.com> wrote: > > > Move fields from ModelAdmin to approp

Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-07 Thread Oleg Lomaka
this. Any other way? > > Eiji > > On May 7, 7:22 am, Oleg Lomaka <oleg.lom...@gmail.com> wrote: > > Move fields from ModelAdmin to appropriate InlineModelAdmin > > > > #admin.py > > from models import Member, Address, Phone > > > > class PhoneInli

Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-07 Thread Eiji Kobayashi
This doesn't do anything. I still get the same error. I'd like to be able to access the fields from the Phone and Address model from the MemberAdmin model. I still cannot do this. Any other way? Eiji On May 7, 7:22 am, Oleg Lomaka <oleg.lom...@gmail.com> wrote: > Move fields from M

Re: Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-07 Thread Oleg Lomaka
Move fields from ModelAdmin to appropriate InlineModelAdmin #admin.py from models import Member, Address, Phone class PhoneInline(admin.StackedInline): model = Phone can_delete = True extra = 0 fields = ('areacode', 'number') class AddressInline(admin.StackedInline): model

Using fields from multiple models (connected by foreign key) in the ModelAdmin

2011-05-07 Thread Eiji Kobayashi
Hi! I'm having trouble figuring out what to do. I have multiple models linked together using foreignkey, like the following: # models.py class Member(User): middle_name = models.CharField(max_length=20) class Phone(models.Model): owner = models.ForeignKey(Member) areacode =

Save M2M "Through" Fields on ModelAdmin or ModelForm Save

2011-05-03 Thread jough
Apparently Django's ModelAdmin/ModelForm doesn't allow you to use save_m2m() if there's an intermediate through table for a ManyToManyField. If I have a model such as: class MyModel(models.Model): created = models.DateTimeField() many = models.ManyToManyField("Related

Re: Convert a list to queryset and override the one in modelAdmin

2011-02-21 Thread Vinicius Massuchetto
2011/2/21 Vinicius Massuchetto : > 2011/2/21 Daniel Roseman : >> On Monday, February 21, 2011 5:47:42 PM UTC, Vinicius Massuchetto wrote: > >> You can't "convert" a list to queryset, as a queryset is - as the name >> implies - a database query.

Re: Convert a list to queryset and override the one in modelAdmin

2011-02-21 Thread Vinicius Massuchetto
2011/2/21 Daniel Roseman : > On Monday, February 21, 2011 5:47:42 PM UTC, Vinicius Massuchetto wrote: > You can't "convert" a list to queryset, as a queryset is - as the name > implies - a database query. I imagined that. =/ > What you could do is get all the IDs from the

Re: Convert a list to queryset and override the one in modelAdmin

2011-02-21 Thread Daniel Roseman
ange list. > > I'm currently declaring a queryset() method in modelAdmin, and > building this list there, but it fails to a "database error" admin > screen if I return the list. > > Is there something I can use to convert it? > > Thanks. > -- > Vini

Convert a list to queryset and override the one in modelAdmin

2011-02-21 Thread Vinicius Massuchetto
Hi. I know that's not exactly the proper way of building a queryset, but I managed to build a list of objects of a model across operations and annotations, and I want to show that an admin change list. I'm currently declaring a queryset() method in modelAdmin, and building this list

Re: Custom ModelAdmin form for distinct logged users

2011-01-28 Thread Daniel Roseman
is is a method that you can override in your own ModelAdmin subclass - it's passed the request so you can check the value of request.user and return the appropriate form. See the code in django.contrib.admin.options. -- DR. -- You received this message because you are subscribed to the Google G

Re: Custom ModelAdmin form for distinct logged users

2011-01-28 Thread Moya, Mario
2011/1/28 hollando Hi hollando, You can use proxy models. Refer to > > http://stackoverflow.com/questions/2223375/multiplue-modeladmins-views-for-same-model-in-django-admin > I can't set permissions for proxy models, i think because the table auth_permissions doesn't have

Re: Custom ModelAdmin form for distinct logged users

2011-01-27 Thread hollando
You can use proxy models. Refer to http://stackoverflow.com/questions/2223375/multiplue-modeladmins-views-for-same-model-in-django-admin On 1月27日, 下午4时22分, Mario8k wrote: > Hello, > > How can I customize a form by the user who is logged in? > For example, if the user

Custom ModelAdmin form for distinct logged users

2011-01-27 Thread Mario8k
Hello, How can I customize a form by the user who is logged in? For example, if the user is_superuser(), i need to display the standard admin form, but if the user is another one, show only some fields and not all model fields. For this, I coud use ModelAdmin.fields (or exclude, or

How to access model_admin (ModelAdmin) in changeform-template?

2010-11-22 Thread Dekker
orm.model_admin (does not exists): UUUS! adminform.model_admin.actions (does not exists): UUUS! after What happend to model_admin? How do I get access to the model_admin within the changeform.html? I need access to the properties of the model_admin (ModelAdmin). -- You received this me

Registering a ModelAdmin, but with a different URL

2010-10-20 Thread Elie
Hey guys, This is my first post in here, and I'm also rather new to Django and a lot of things are still new to me. I'm also very confused going around the documentation, so I'd like to ask directly what should I do. Basically, what I want to do is very very simple really, but I can't exactly

Re: Strange error overriding changelist_view in ModelAdmin

2010-08-04 Thread Steve Holden
On 8/4/2010 5:43 AM, Erisa wrote: > Oops! I copied the old class with the "self" mistake left in. The > correct class is: > > class SettingsAdmin(admin.ModelAdmin): > def changelist_view(self, request, extra_context=None): > object_id = str(Settings.objects.all()[0].id) >

Re: Strange error overriding changelist_view in ModelAdmin

2010-08-04 Thread Erisa
Oops! I copied the old class with the "self" mistake left in. The correct class is: class SettingsAdmin(admin.ModelAdmin): def changelist_view(self, request, extra_context=None): object_id = str(Settings.objects.all()[0].id) return super(SettingsAdmin, self).change_view(self,

Re: Strange error overriding changelist_view in ModelAdmin

2010-08-03 Thread Erisa
I found the problem. The object_id needs to be a string! So the following works like a charm: from wolkdata.database.models import * from django.contrib import admin class SettingsAdmin(admin.ModelAdmin): def changelist_view(self, request, extra_context=None): object_id =

Re: Strange error overriding changelist_view in ModelAdmin

2010-08-03 Thread Erisa
I can't believe I missed the "self" problem, but when I fixed that I still received another strange error: Traceback: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ base.py" in get_response 100. response = callback(request, *callback_args,

Re: Strange error overriding changelist_view in ModelAdmin

2010-08-03 Thread natebeacham
Try not passing "self" to your super call. That parameter should be handled internally. ie: return super(SettingsAdmin, self).change_view(request, object_id, extra_context=None) On Aug 3, 8:26 pm, Erisa wrote: > I have a Settings model that contains settings for my

Strange error overriding changelist_view in ModelAdmin

2010-08-03 Thread Erisa
I have a Settings model that contains settings for my application. class Settings(models.Model): database_name = models.CharField(max_length=50) current_campaign = models.ForeignKey('Campaign') It only contains one object. I would like to be able to use the admin pages to edit it. Since

Re: ModelAdmin,get_form or Field._get_val_from_obj

2010-07-13 Thread Massimiliano della Rovere
> most cases. > > So I was in doubt whether to override the ModelAdmin,get_form or some > _get_val_from_obj for some fields from the ModelAdmin.form. > > Which one is more correct in your opinion? > -- You received this message because you are subscribed to the Google Groups &quo

Re: ModelAdmin,get_form or Field._get_val_from_obj

2010-07-13 Thread Massimiliano della Rovere
g >> the overhead necessary to select the correct string to be wasted in >> most cases. >> >> So I was in doubt whether to override the ModelAdmin,get_form or some >> _get_val_from_obj for some fields from the ModelAdmin.form. >> >> Which one is more correct in you

Re: ModelAdmin,get_form or Field._get_val_from_obj

2010-07-13 Thread Daniel Roseman
d thus avoiding > the overhead necessary to select the correct string to be wasted in > most cases. > > So I was in doubt whether to override the ModelAdmin,get_form or some > _get_val_from_obj for some fields from the ModelAdmin.form. > > Which one is more correct in you

ModelAdmin,get_form or Field._get_val_from_obj

2010-07-13 Thread Massimiliano della Rovere
o override the ModelAdmin,get_form or some _get_val_from_obj for some fields from the ModelAdmin.form. Which one is more correct in your opinion? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us

ModelAdmin with tabularinline Question

2010-07-04 Thread SilverFox
I am trying to write an application that credits a user's account when a bet is paid. I have an admin form with the bet and a TabularInline list of bet choices (the choices that can be bet on). To resolve a bet a ModelAdmin is used to set the status of the bet to True (paid) and the winner field

Re: Why is ModelAdmin to Model a 1-1 relationship?

2010-06-28 Thread euan.godd...@googlemail.com
d > > "deleted". When the delete() method is called, we set the deleted > > field to 1 and then save the model. We would like to create an admin > > site where we can manage the deleted and non deleted instances > > separately. > > > We could accomplish

Re: Why is ModelAdmin to Model a 1-1 relationship?

2010-06-26 Thread Lee Hinde
admin > site where we can manage the deleted and non deleted instances > separately. > > We could accomplish our goal by defining a queryset function for the > ModelAdmin that restricts the instances returned to deleted=0. > However, AFAIK this would eliminate the ability to undelet

Re: Why is ModelAdmin to Model a 1-1 relationship?

2010-06-26 Thread euan.godd...@googlemail.com
n manage the deleted and non deleted instances > separately. > > We could accomplish our goal by defining a queryset function for the > ModelAdmin that restricts the instances returned to deleted=0. > However, AFAIK this would eliminate the ability to undelete instances > via the a

Why is ModelAdmin to Model a 1-1 relationship?

2010-06-25 Thread patjenk
accomplish our goal by defining a queryset function for the ModelAdmin that restricts the instances returned to deleted=0. However, AFAIK this would eliminate the ability to undelete instances via the admin. Another option is to allow all instances to be shown and include delete as a value in the l

Django ModelAdmin doesn't seem to save m2m fields with save_model

2010-06-23 Thread Xavier Ordoquy
Hi, I have some trouble understanding how ModelAdmin do save models when those have many to many fields. Long story: I have for one of my application overridden ModelAdmin class and the save_model. Basicaly, the save_model is: def save_model(self, request, obj, form, change): super

ModelAdmin save_model method not saving many to many relationship value

2010-06-05 Thread Ryno in Stereo
I have a Page model that uses the sites framework and I've added a save_model method on its admin class to check if the template or sites collections are empty. If they are, I want to populate them with default values. Why not do this in the model declaration? - I can't seem to populate a

Localized fields in modelforms/modeladmin

2010-05-18 Thread Dejan Noveski
Hi everybody, Is there a way i can localize some of the form fields from the ModelForm class or ModelAdmin class? -- -- Dejan Noveski Web Developer dr.m...@gmail.com Twitter: http://twitter.com/dekomote | LinkedIn: http://mk.linkedin.com/in/dejannoveski -- You received this message because

ModelAdmin list_filter questions

2010-05-13 Thread manishgv
I am using the latest Django 1.2 release. Can someone please confirm if the ModelAdmin's list_filter supports these capabilities: 1) Multi-Value-Select: How to allow multiple values to be selected for the SAME filter field - i.e. I want to display all records with a "status" field of : "Active"

Re: Dynamic Model and ModelAdmin based on tables in db

2010-04-30 Thread akonsu
hello, may be this will be useful: http://code.djangoproject.com/wiki/DynamicModels On Apr 22, 5:53 am, Massimiliano della Rovere wrote: > An external process creates tables whose names follow the pattern > "collector_XYZ"; all the tables will have the very

Re: "dynamically" setting ModelAdmin properties?

2010-04-29 Thread Daniel Roseman
On Apr 29, 6:10 am, akonsu <ako...@gmail.com> wrote: > hello, > > in my custom admin class that inherits ModelAdmin i need to set > ModelAdmin.exclude, ModelAdmin.list_display, etc based on whether the > logged in user is a superuser or not. > > is this possib

"dynamically" setting ModelAdmin properties?

2010-04-28 Thread akonsu
hello, in my custom admin class that inherits ModelAdmin i need to set ModelAdmin.exclude, ModelAdmin.list_display, etc based on whether the logged in user is a superuser or not. is this possible? thanks konstantin -- You received this message because you are subscribed to the Google Groups

Dynamic Model and ModelAdmin based on tables in db

2010-04-22 Thread Massimiliano della Rovere
An external process creates tables whose names follow the pattern "collector_XYZ"; all the tables will have the very same structure. For each table I need to create a matching django.db.models.Model and django.admin.models.ModelAdmin, dynamically, because over time new tables will be created and

Re: ModelAdmin

2010-03-11 Thread Daniel Roseman
On Mar 11, 6:27 am, Praveen wrote: > On Mar 11, 3:03 am, Beres Botond wrote:> You cannot > directly register a form with admin, you should be > > registering models > > I know i can not directly register a form but i do not have any model >

Re: ModelAdmin

2010-03-11 Thread pjrhar...@gmail.com
On Mar 11, 6:27 am, Praveen wrote: > I know i can not directly register a form but i do not have any model > for Email. i just have plain form *forms.Form* > is there any other way to register Form with admin. > Thanks What would you expect it to do if you could?

Re: ModelAdmin

2010-03-10 Thread Praveen
I know i can not directly register a form but i do not have any model for Email. i just have plain form *forms.Form* is there any other way to register Form with admin. Thanks On Mar 11, 3:03 am, Beres Botond wrote: > You cannot directly register a form with admin, you should

Re: ModelAdmin

2010-03-10 Thread Praveen
On Mar 11, 3:03 am, Beres Botond wrote: > You cannot directly register a form with admin, you should be > registering models I know i can not directly register a form but i do not have any model for Email. i just have plain form *forms.Form* is there any other way to

Re: ModelAdmin

2010-03-10 Thread Beres Botond
You cannot directly register a form with admin, you should be registering models from myapps.forms import MyModelForm from myapps.models import MyModel class MyModelAdmin(admin.ModelAdmin): form = MyModelForm admin.site.register(MyModel, EmailAdmin) Also the form should be a ModelForm for

ModelAdmin

2010-03-10 Thread Praveen
Hi I have one form in forms.py class EmailForm(forms.Form): recipient = forms.CharField(max_length=14, min_length=12, widget=forms.TextInput(attrs=require)) message = forms.CharField(max_length=140, min_length=1, widget=forms.Textarea(attrs={'cols': 30, 'rows': 5})) and my site url is

ModelAdmin - related foreign keys

2010-02-09 Thread Ogi Vranesic
Hi I'm new in Django and want to explain my issue: For instance I have model A with foreign key to B and model B with foreign key to C. I would like to have add form of C with one B (extra = 1) and within B four A (extra = 4) With the following example in admin.py I can only achieve this

Re: Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-02-05 Thread mrts
Patch has been uploaded to http://code.djangoproject.com/ticket/12780 . After applying the patch you can override def formsets_are_valid(self, formsets, form, form_is_valid, instance, request): and do any complex validation you like. As it's rather arcane, I've provided an

Re: Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-02-04 Thread mrts
odels.BooleanField(default=False) > > >     language = models.ForeignKey(Language) > > > > class ClipDescription(models.Model): > > >     clip = models.ForeignKey(Clip) > > >     text = models.TextField() > > >     language = models.ForeignKey(Language) > >

Re: v1.2a change in ModelAdmin: save_model not called by add_view

2010-01-28 Thread Ian
Bug tracking system says it was fixed two weeks ago in trunk http://code.djangoproject.com/changeset/12206 - referenced by http://code.djangoproject.com/ticket/12696 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

v1.2a change in ModelAdmin: save_model not called by add_view

2010-01-28 Thread Ian
I have an hook in a v1.1.1 admin app that sets some default values when adding an object - it works by overriding ModelAdmin.save_model Well, I just tried it with v1.2a and it fails, it looks like the call to save_model that preceded the calls to save_formset was removed. Without save_model, is

view_form for class ModelAdmin

2010-01-21 Thread Massimiliano della Rovere
Has anybody ever implemented an extension to class ModelAdmin to add "view_form" function and templates? I'm in a situation where the logged user can list both draft and published files. With ModelAdmin.queryset i filter the files the user is allowed to list in "change_list" v

Re: Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-01-15 Thread Gabriel Reis
anguage) > > > > class ClipDescription(models.Model): > > clip = models.ForeignKey(Clip) > > text = models.TextField() > > language = models.ForeignKey(Language) > > > > I am editing via ModelAdmin. I defined a ClipModelAdmin class as ab

Re: Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-01-15 Thread Marco Rogers
age) > > class ClipDescription(models.Model): >     clip = models.ForeignKey(Clip) >     text = models.TextField() >     language = models.ForeignKey(Language) > > I am editing via ModelAdmin. I defined a ClipModelAdmin class as above > (simplified): > > class ClipA

Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-01-14 Thread Gabriel Reis
) class ClipDescription(models.Model): clip = models.ForeignKey(Clip) text = models.TextField() language = models.ForeignKey(Language) I am editing via ModelAdmin. I defined a ClipModelAdmin class as above (simplified): class ClipAdmin(admin.ModelAdmin): inlines

Re: How to get ModelAdmin given a Model

2010-01-12 Thread Marco Rogers
t;tomasz.zielin...@pyconsultant.eu> wrote: > > On 11 Sty, 16:23, Marco Rogers <marco.rog...@gmail.com> wrote: > > > > I'm reposting this from earlier to see if I have better luck. I need > > > to be able to get the ModelAdmin associated with a model at runtime.

Re: using relationship fields in ModelAdmin

2010-01-12 Thread Daniel Roseman
On Jan 12, 5:32 am, Mike Thon <mike.t...@gmail.com> wrote: > I have an object in my model that has a OneToOne relationship with an > object in another app.  I would like to customize the way my object is > displayed in the admin interface by subclassing ModelAdmin as shown in >

using relationship fields in ModelAdmin

2010-01-11 Thread Mike Thon
I have an object in my model that has a OneToOne relationship with an object in another app. I would like to customize the way my object is displayed in the admin interface by subclassing ModelAdmin as shown in the tutorial. I'm not sure how to reference fields across the OneToOne relationship

Re: How to get ModelAdmin given a Model

2010-01-11 Thread Matt Schinckel
On Jan 12, 4:11 am, Tomasz Zieliński <tomasz.zielin...@pyconsultant.eu> wrote: > On 11 Sty, 16:23, Marco Rogers <marco.rog...@gmail.com> wrote: > > > I'm reposting this from earlier to see if I have better luck. I need > > to be able to get the ModelAdmin asso

Re: How to get ModelAdmin given a Model

2010-01-11 Thread Tomasz Zieliński
On 11 Sty, 16:23, Marco Rogers <marco.rog...@gmail.com> wrote: > I'm reposting this from earlier to see if I have better luck. I need > to be able to get the ModelAdmin associated with a model at runtime. > Similar to how django.db.models.get_model allows you to ret

How to get ModelAdmin given a Model

2010-01-11 Thread Marco Rogers
I'm reposting this from earlier to see if I have better luck. I need to be able to get the ModelAdmin associated with a model at runtime. Similar to how django.db.models.get_model allows you to retrieve a model. admin_class = get_admin(Model) Is this possible? The original post has more

How can I retrieve the ModelAdmin given the model class or an instance?

2010-01-06 Thread Marco Rogers
I'm retrieving a model using django.db.models.get_model. The view is receiving a post from a form generated by the ModelAdmin. How can I get a hold of that ModelAdmin instance so can then get a hold of the ModelForm? This will allow me to process the post (validation, related objects, etc

Re: new readonly_fields in modeladmin

2009-12-31 Thread Tim Miller
Alex_Gaynor wrote: > I've actually gone ahead and filed it, and uploaded a patch: > http://code.djangoproject.com/ticket/12477 > Thanks Alex. Your post on writing django tests has been helpful as well. -- You received this message because you are subscribed to the Google Groups "Django users"

Re: new readonly_fields in modeladmin

2009-12-31 Thread Alex_Gaynor
On Dec 31, 3:06 pm, Alex_Gaynor <alex.gay...@gmail.com> wrote: > On Dec 31, 12:46 pm, Tim Miller <t...@lashni.net> wrote: > > > I just want to confirm this isn't my own idiocy or intended behaviour > > before I file a bug. > > > I've got the follow

Re: new readonly_fields in modeladmin

2009-12-31 Thread Alex_Gaynor
On Dec 31, 12:46 pm, Tim Miller <t...@lashni.net> wrote: > I just want to confirm this isn't my own idiocy or intended behaviour > before I file a bug. > > I've got the following line defined in my modeladmin entry... > > readonly_fields = ('date_created', 'date_mo

new readonly_fields in modeladmin

2009-12-31 Thread Tim Miller
I just want to confirm this isn't my own idiocy or intended behaviour before I file a bug. I've got the following line defined in my modeladmin entry... readonly_fields = ('date_created', 'date_modified', 'date_published') They get displayed in the admin as 'Date created', 'Date modified

in modeladmin - show a field to edit only if superuser

2009-10-13 Thread Sergio A.
I'd like to show for editing the 'owner' field only to superuser; I'm using django 1.0: class ProductAdmin(admin.ModelAdmin): form = ProductForm fieldsets = [ ('Product Identification', {'fields': ['owner', 'code', ...), ('Product Description', {'fields':

Re: Limiting queryset on ModelAdmin based on date field

2009-09-24 Thread Alvaro Mouriño
On Thu, Sep 24, 2009 at 2:52 AM, Brian McKeever wrote: > > I'm not too familiar with customizing the admin, but you want to use > the range field lookup. > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#range Thanks McKeever, but that's actually the problem: I

Re: Limiting queryset on ModelAdmin based on date field

2009-09-24 Thread Alvaro Mouriño
On Thu, Sep 24, 2009 at 6:19 AM, Daniel Roseman wrote: > > On Sep 24, 6:07 am, Alvaro Mouriño wrote: >> Hi list. >> >> I'm developing a news application that handles articles, about 10 new >> articles each day. The site administrator every

Re: Limiting queryset on ModelAdmin based on date field

2009-09-24 Thread Daniel Roseman
On Sep 24, 6:07 am, Alvaro Mouriño wrote: > Hi list. > > I'm developing a news application that handles articles, about 10 new > articles each day. The site administrator every morning selects from a > drop-down-list the ones that hit the front page. As time goes by

Re: Limiting queryset on ModelAdmin based on date field

2009-09-23 Thread Brian McKeever
I'm not too familiar with customizing the admin, but you want to use the range field lookup. http://docs.djangoproject.com/en/dev/ref/models/querysets/#range On Sep 23, 11:07 pm, Alvaro Mouriño wrote: > Hi list. > > I'm developing a news application that handles

Limiting queryset on ModelAdmin based on date field

2009-09-23 Thread Alvaro Mouriño
Hi list. I'm developing a news application that handles articles, about 10 new articles each day. The site administrator every morning selects from a drop-down-list the ones that hit the front page. As time goes by this list grows bigger and bigger, and what's worst, old articles doesn't even

Re: My ModelAdmin customizations don't work

2009-08-09 Thread Chao Xu
= > > from entity.models import * > > from django.contrib import admin > > > class UniversityAdmin(admin.ModelAdmin): > >    list_display = ('name', 'abbreviation') > >    search_fields = ['name'] > > > admin.site.register(University) > > Your problem is

Re: My ModelAdmin customizations don't work

2009-08-08 Thread Alex Gaynor
eviation') >    search_fields = ['name'] > > admin.site.register(University) > > > > Your problem is you registered your Model with the admin without telling it about your custom ModelAdmin class, so it used the default one. The last line should be. admin.site.register(University, Univ

My ModelAdmin customizations don't work

2009-08-08 Thread Chao Xu
I want't to add search in admin site and followed the instructions of official guide of The Django admin site. But nothing on admin site changed, nor errors appeared after I changed my code. following is my code, please help me. Thank you in advance! entity.models.py code ===

change_view to change ModelAdmin

2009-08-03 Thread akhen
Hi I'm using change_view(self, request, object_id, extra_context=None) override on a ModelAdmin object, to display field differently based on the object entries, and change the fieldset order. def change_view(self, request, object_id, extra_context=None): post = Post.objects.get(id

Re: Trying to reference a foreignKey in a modelAdmin class

2009-07-28 Thread irishsteve
Karen, Luke, thank-you both for replying. Luke, there isn't an error message as such, it's just that the Entry model disappears from the admin. If I try to go directly to an entry page URL I get a 404. As soon as I go back to using list_filter = ('competition', 'division') it's ok. I've tried

Re: Trying to reference a foreignKey in a modelAdmin class

2009-07-27 Thread Karen Tracey
On Mon, Jul 27, 2009 at 6:01 PM, irishsteve wrote: > > Hi > > I'm new to Django, so thanks in advance for taking the time to help > me! I can't work out how to reference a foreignKey in the list_filter > method. > > Here are the two relevant objects from my model: > > [snip]

Re: Trying to reference a foreignKey in a modelAdmin class

2009-07-27 Thread Luke Seelenbinder
s.TextField("Update", null=True, blank=True) > > class Meta: > verbose_name_plural = "entries" > unique_together = ['member','competition'] > > def __unicode__(self): > return self.member.get_formatted_name() >

Trying to reference a foreignKey in a modelAdmin class

2009-07-27 Thread irishsteve
quot; unique_together = ['member','competition'] def __unicode__(self): return self.member.get_formatted_name() Then I have a few modelAdmin classes, here is the problematic one: class EntryAdmin(admin.ModelAdmin): fieldsets = [ ("Event entrant details"

custom field in ModelAdmin

2009-06-22 Thread Andrés Otárola
a look up to get the corresponding "id" and save the relationship. Well, that's my idea. It's a indirect relationship in the form model. how can I achieve that using ModelAdmin ?, is there another alternative way? (is not a solution for me use "bar_code" as primary_

a DRY ModelAdmin?

2009-06-08 Thread byron
. I know that I can create a custom ModelForm for the add/change views for Study, but i was curious why this limited queryset does not propagate throughout the entire admin since it has been set at the admin-wide level (ModelAdmin)? --~--~-~--~~~---~--~~ You received

Auto populate ModelAdmin

2009-05-12 Thread Matias Surdi
I've noticed that on the admin interface, if a model has for example a "name" attribute, if I access to the add form with an url like this: http://localhost:8000/admin/mymodel/add?name=something The name field is prepopulated with the parameter value. Is this behaviour documented somewhere?

Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Daniel Roseman
On Mar 22, 4:15 pm, Roy wrote: > That would require the extra files be hosted on my media url though. I > want to be able to link js externally so I can use stuff like YUI, > etc. without having to host it. Not at all - if you pass in an absolute path, it is left alone. See:

Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Brian Neal
On Mar 22, 11:15 am, Roy wrote: > That would require the extra files be hosted on my media url though. I > want to be able to link js externally so I can use stuff like YUI, > etc. without having to host it. No, not if you use a fully qualified string like

Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Roy
n't want to touch the model code though. > > > The particular scenario is I want to change the flatpage edit screen > > in the admin to use a rich-text editor (NicEdit) instead of the plain > > memo box. > > > Thanks! > > http://

<    1   2   3   >