Re: ModelAdmin

2023-01-04 Thread Mike Dewhirst
ly going out of business. I think Whatsapp, Slack etc are all very appropriate places for private conversations. Not so much for a user mutual-support mailing list like this one.  Thanks for understanding Cheers Mike On 5/01/2023 3:31 pm, Satyajit Barik wrote: Yes. It does. ModelAdmin cla

Re: ModelAdmin

2023-01-04 Thread Satyajit Barik
Yes. It does. ModelAdmin classes can define list filters that appear in the right sidebar of the change list page of the admin. For more reference: https://docs.djangoproject.com/en/4.1/ref/contrib/admin/filters/ For this topic related join our WhatsApp group: https://bit.ly/3oJtfcf Regards

Re: ModelAdmin

2023-01-04 Thread Mike Dewhirst
On 5/01/2023 5:43 am, Mario St-Gelais wrote: Hello group, first post here. Quick question.  Can capabilities of ModelAdmin such as list_filter or search_fields be used outside of the admin interface? Have you looked at htmx? https://www.simplecto.com/htmx-and-the-list_editable-in-django

ModelAdmin

2023-01-04 Thread Mario St-Gelais
Hello group, first post here. Quick question. Can capabilities of ModelAdmin such as list_filter or search_fields be used outside of the admin interface? I want a view that would allow non logged users to search a site through checkboxes and some search fields possibly and obviously, the way

Curious about ModelAdmin internals.. how the hell does it work

2021-09-01 Thread Michal Plsek
Hello, I would like to know about this (although I hacked around it, but I am still curious): if I have model which contains ForeignKey attribute and I am using autocomplete_fields on it, where is the found FK of foreign object saved on ModelAdmin page? Numerical ID of foreign object

Re: How to hide/disable ModelAdmin

2021-03-05 Thread zvo...@seznam.cz
Dne čtvrtek 4. března 2021 v 21:22:41 UTC+1 uživatel zvo...@seznam.cz napsal: > I want use Django 2+ autocomplete_fields. > Adding them into (source) ModelAdmin will give lot of errors (see bellow). > So I must add a (target) ModelAdmin with search_fields=... > > After that e

How to hide/disable ModelAdmin

2021-03-04 Thread zvo...@seznam.cz
I want use Django 2+ autocomplete_fields. Adding them into (source) ModelAdmin will give lot of errors (see bellow). So I must add a (target) ModelAdmin with search_fields=... After that everything works. However I don't want to have such new ModelAdmin's visible/accessible. I have dat

Re: ModelAdmin Not work

2020-09-24 Thread John Rajesh
First correct email to email On 24 Sep 2020 00:33, "coolguy" wrote: > either use admin.site.register > OR > *@*admin.register(User) > > On Wednesday, September 23, 2020 at 11:01:43 AM UTC-4 kkwaq...@gmail.com > wrote: > >> *models.py* >> >> [image: 1.jpg] >> >> *admin.py* >> >> *[image: 2.jpg]* >

Re: ModelAdmin Not work

2020-09-23 Thread coolguy
either use admin.site.register OR *@*admin.register(User) On Wednesday, September 23, 2020 at 11:01:43 AM UTC-4 kkwaq...@gmail.com wrote: > *models.py* > > [image: 1.jpg] > > *admin.py* > > *[image: 2.jpg]* > > *errors* > > > *[image: 3.jpg]* > > *Object is not callable* > > *Please any body sol

ModelAdmin Not work

2020-09-23 Thread kkwaq...@gmail.com
*models.py* [image: 1.jpg] *admin.py* *[image: 2.jpg]* *errors* *[image: 3.jpg]* *Object is not callable* *Please any body solutions * -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emai

ModelAdmin Media assets with django 1.8

2020-06-11 Thread Amirouche Boubekki
Using Django 1.8, I do not understand what is the behavior of `Media` [0] inside a `ModelAdmin` subclass. In particular, whether the default behavior of form's media is applied in `ModelAdmin` that is: `extend=True` [1] I am under the impression that the behavior is implement

Overriding change_list_results template per ModelAdmin

2019-10-17 Thread Luka Jančin
I have a model which is registered to two different admin sites with two ModelAdmins. I would like to override the template for change_list_results for each ModelAdmin independently. Currently it's not possible the same way you can do it for add_form_template, change_form_template et

Re: How to override the ModelAdmin "change" form ?

2019-03-01 Thread Mike Dewhirst
Hi, I'm currently struggling with a custom ModelAdmin. Karim I haven't tried to fully understand your use case. However, this is what I think your process could be if you do not wish to ajax it ... 1. Override the model save() method to call a model meth

Re: How to override the ModelAdmin "change" form ?

2019-03-01 Thread karim . atiki
2019 9:46 pm, karim...@gmail.com wrote: > > Hi, > > I'm currently struggling with a custom ModelAdmin. > > > Karim > > I haven't tried to fully understand your use case. However, this is what I > think your process could be if you do not wish to ajax it

Re: How to override the ModelAdmin "change" form ?

2019-03-01 Thread karim . atiki
vendredi 1 mars 2019 00:06:40 UTC+1, Mike Dewhirst a écrit : > > On 28/02/2019 9:46 pm, karim...@gmail.com wrote: > > Hi, > > I'm currently struggling with a custom ModelAdmin. > > > Karim > > I haven't tried to fully understand your use case. However, this is w

Re: How to override the ModelAdmin "change" form ?

2019-02-28 Thread Mike Dewhirst
On 28/02/2019 9:46 pm, karim.at...@gmail.com wrote: Hi, I'm currently struggling with a custom ModelAdmin. Karim I haven't tried to fully understand your use case. However, this is what I

Re: How to override the ModelAdmin "change" form ?

2019-02-28 Thread Nelson Varela
You maybe want a model admin view where you can send the user to and collect the data you want to comare and show warnings -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an

How to override the ModelAdmin "change" form ?

2019-02-28 Thread karim . atiki
Hi, I'm currently struggling with a custom ModelAdmin. Considering the following model: # Bloc fonctionnel class Assembly(Item): product = models.ForeignKey(to='ProductFamily', on_delete=models.CASCADE , null=True, verbose_name=_('Famille Produit')) functions

Re: Django ModelAdmin ignores has_delete_permission

2018-05-19 Thread Daniel Germano Travieso
Hello! Ordinary staff users on the main django admin module are just standard django users that can access the admin site. Setting the has_add_permission, has_change_permission and has_delete_permission via the ModelAdmin should be done to customize the permissions for specific object

Django ModelAdmin ignores has_delete_permission

2018-05-18 Thread Vitaly Trifanov
I have simple project on Django 1.11.13, that uses ordinary Django's admin module. Staff user can not delete object while is permitted (has_delete_permission returns always true). models.py: class MyModel(models.Model): name = models.IntegerField("Value", blank=True, null=True) admin.py

Re: Add extra fields to a ModelAdmin form

2018-05-05 Thread Mark Phillips
James, I was finally able to add extra fields to a ModelForm dynamically! Check out the answer to this post - https://stackoverflow.com/questions/32335349/how-do-i-create-and-save-dynamic-fields-in-django-modeladmin It worked for me in django 2. I have not tried it in django 1.11. I hope this

Re: Admin site and ModelAdmin

2018-05-03 Thread Mike Dewhirst
On 4/05/2018 7:02 AM, jt.oldn...@gmail.com wrote: Thanks for the response Mike. I generally don't like it when a design has to change to fit a framework, I agree. My design is almost entirely in the models. I want an API to be able to work without Django forms. however, in this case I decid

Re: Admin site and ModelAdmin

2018-05-03 Thread jt . oldnews
Thanks for the response Mike. I generally don't like it when a design has to change to fit a framework, however, in this case I decided to try your solution. I ran into a couple of problems though :-( 1) The fields that I'm looking up were required fields. Validation failed and error messages

Re: Admin site and ModelAdmin

2018-05-02 Thread Mike Dewhirst
:-(. Forgive me if I screw up the lingo. I've got a ModelAdmin page for registrants of a conference which has fields for Employee ID, Name, email etc. The registrant does not have to be an employee, but if they are I could lookup their name, email etc. from an external source (already have

Re: Admin site and ModelAdmin

2018-05-02 Thread Mike Dewhirst
On 3/05/2018 7:00 AM, jt.oldn...@gmail.com wrote: I'm new to Django and web development in general (C++ background) and I've got amazingly far very quickly, but there's one thing I've been struggling with for a couple days now :-(. Forgive me if I screw up the lingo. I

Admin site and ModelAdmin

2018-05-02 Thread jt . oldnews
I'm new to Django and web development in general (C++ background) and I've got amazingly far very quickly, but there's one thing I've been struggling with for a couple days now :-(. Forgive me if I screw up the lingo. I've got a ModelAdmin page for registrants of a co

Re: Add extra fields to a ModelAdmin form

2018-05-02 Thread 'James Foley' via Django users
am running django 1.11. > > Thanks! > > Mark > > On Mon, Apr 30, 2018 at 1:41 AM, 'James Foley' via Django users < > django...@googlegroups.com > wrote: > >> So, I have a ModelAdmin that I need to add extra fields to. These fields >> do not exist

Re: Add extra fields to a ModelAdmin form

2018-05-02 Thread Mark Phillips
> So, I have a ModelAdmin that I need to add extra fields to. These fields > do not exist on the model, but will be dynamically added to a custom > ModelForm through the __init__ method, and logic inside clean will handle > the returned data on save. > > I can't seem to find any sol

Add extra fields to a ModelAdmin form

2018-04-30 Thread 'James Foley' via Django users
So, I have a ModelAdmin that I need to add extra fields to. These fields do not exist on the model, but will be dynamically added to a custom ModelForm through the __init__ method, and logic inside clean will handle the returned data on save. I can't seem to find any solid information re

Re: How to get ModelAdmin given a Model

2018-01-04 Thread Edouard C.
UTC, Matt Schinckel wrote: > > On Jan 12, 4:11 am, Tomasz Zieliński > wrote: > > On 11 Sty, 16:23, Marco Rogers 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 m

Re: ModelAdmin Media JS file order issue in Django 2.0

2017-12-10 Thread Andréas Kühne
Checking through the documents I found the following reference: https://docs.djangoproject.com/en/2.0/topics/forms/media/#order-of-assets Changed in Django 2.0: In older versions, the assets of Media objects are concatenated rather than merged in a way that tries to preserve the relative orderin

Re: ModelAdmin Media JS file order issue in Django 2.0

2017-12-10 Thread Marc R
because they are specific to only a few models, particularly the loading scripts, and options, etc. this worked great in Django 1.11 On Sunday, 10 December 2017 09:36:56 UTC-5, Etienne Robillard wrote: > > Why don't you simply put the javascripts into your base template without > using Python ?

Re: ModelAdmin Media JS file order issue in Django 2.0

2017-12-10 Thread Etienne Robillard
Why don't you simply put the javascripts into your base template without using Python ? Etienne Le 2017-12-10 à 09:30, Marc R a écrit : I have this in my model: class Media:         js = ( *'/static/plugins/codemirror/lib/codemirror.js',* '/static/plugins/codemirror/mode/htmlmixed/htmlmixed.

ModelAdmin Media JS file order issue in Django 2.0

2017-12-10 Thread Marc R
I have this in my model: class Media: js = ( * '/static/plugins/codemirror/lib/codemirror.js',* '/static/plugins/codemirror/mode/htmlmixed/htmlmixed.js', '/static/plugins/codemirror/addon/fold/foldcode.js', '/static/plugins/codemirror/addon/fo

How to combine change_list_template in ModelAdmin mixin

2017-06-29 Thread ecas
I would like to create a mixin to extend the ModelAdmin class that adds a description text to the view, overriding the default change_list_template. [admin_extra.py] class DescriptionAdminMixin(object) change_list_template = "description_change_list.html" ... def changelist

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-17 Thread James Schneider
On Sep 16, 2016 1:46 AM, "Andrea D'Amore" wrote: > > On 16 September 2016 at 00:53, wrote: > > I have a ModelAdmin subclass (code at: <https://dpaste.de/0LAt>) > > Gives a 404: > > The requested URL /0LAt was not found on this server. > &g

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-16 Thread thauk
Apologies, I updated it. class MyModelAdmin(ModelAdmin): model = MyModel form = MyForm def get_form(self, request, obj=None, **kwargs): form_class = super(MyModelAdmin, self).get_form(request, obj=obj, **kwargs) some_parameter_for_one_thing

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-16 Thread Andrea D'Amore
On 16 September 2016 at 00:53, wrote: > I have a ModelAdmin subclass (code at: <https://dpaste.de/0LAt>) Gives a 404: The requested URL /0LAt was not found on this server. I'm missing the rationale of using an external paste service while you're already using a tex

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-15 Thread thauk
e. If you look through the >> Trac tickets you might find something related. However, your subclass where >> you store "self.instance" on ModelAdmin is a no no due to thread safety. >> See >> http://stackoverflow.com/questions/3388111/modeladmin-thread-safety-cac

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-15 Thread thauk
> tickets you might find something related. However, your subclass where you > store "self.instance" on ModelAdmin is a no no due to thread safety. See > http://stackoverflow.com/questions/3388111/modeladmin-thread-safety-caching-issues > > for an explanation. > &g

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-15 Thread thauk
27;m all ears! T On Thursday, September 15, 2016 at 5:34:50 PM UTC-7, Tim Graham wrote: > > I think these ideas have been floated before. If you look through the Trac > tickets you might find something related. However, your subclass where you > store "self.instance" on Mod

Re: ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-15 Thread Tim Graham
I think these ideas have been floated before. If you look through the Trac tickets you might find something related. However, your subclass where you store "self.instance" on ModelAdmin is a no no due to thread safety. See http://stackoverflow.com/questions/3388111/modeladmin-thr

ModelAdmin missing a couple of key features, or am I doing this wrong?

2016-09-15 Thread thauk
I have a ModelAdmin subclass (code at: <https://dpaste.de/0LAt>) and I need to do a couple of things, but the functionality seems to be missing: 1. I need to access the model instance to perform some initialization, but there's no instance member set. There are a few questions on Sta

Re: Dynamic ModelAdmin Field

2016-07-22 Thread Bernat Bonet
El jueves, 14 de julio de 2016, 17:29:38 (UTC+2), Bernat Bonet escribió: > > I need to add dynamic fields to ModelAdmin that are not part of the Model. > > Models: > > product: cod, des > product_categories: cat, val > > I want to add val1, val2 in ProductAdmin > &g

Re: Dynamic ModelAdmin Field

2016-07-15 Thread Derek
you want to do) On Thursday, 14 July 2016 17:29:38 UTC+2, Bernat Bonet wrote: > > I need to add dynamic fields to ModelAdmin that are not part of the Model. > > Models: > > product: cod, des > product_categories: cat, val > > I want to add val1, val2 in ProductAdmin > &g

ModelAdmin dynamic fields

2016-07-14 Thread Bernat Bonet
I need to add dynamic fields to ModelAdmin fieldset that are not part of Model. This field is to show or hide certain fields. How can I do this? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this grou

Dynamic ModelAdmin Field

2016-07-14 Thread Bernat Bonet
I need to add dynamic fields to ModelAdmin that are not part of the Model. Models: product: cod, des product_categories: cat, val I want to add val1, val2 in ProductAdmin Thanks -- You received this message because you are subscribed to the Google Groups "Django users"

please help me !django admin search bar add placeholder variable and how to call it in modelAdmin! HELP!

2016-01-17 Thread superzhang16
I want to add placeholder to search bar .First,I override the template change_list.html and find the search bar ,I know add attribute placeholder ,and I defined a variable placeholder={{'''search_tip'}} to placeholder, as my app has three searchbar in different modelAdmin, I

django admin search bar add placeholder variable and how to call it in modelAdmin

2016-01-15 Thread superzhang16
I want to add placeholder to search bar .First,I override the template change_list.html and find the search bar ,I know add attribute placeholder ,and I defined a variable placeholder={{'''search_tip'}}to placeholder, as my app has three searchbar in different modelAdmin, I

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
Hi Malcolm, > With the patch to check an instance rather than a class, perhaps I should extend the checks to check the result of get_readonly_fields() rather than just obj.readonly_fields. What do you think? I think the checks should be run statically against ModelAdmin instances, that

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Malcolm Box
Hi Simon, On Thursday, 10 September 2015 16:57:51 UTC+1, Simon Charette wrote: > > Hi Malcolm, > > > The system check checks that all the values returned from > get_readonly_fields exist as class attributes on the ModelAdmin (or are > callable/fields on model, neither of wh

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
Hi Malcolm, > The system check checks that all the values returned from get_readonly_fields exist as class attributes on the ModelAdmin (or are callable/fields on model, neither of which helps here). With them being created via __getattr__, they don't. There might be something else

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Malcolm Box
t_readonly_fields exist as class attributes on the ModelAdmin (or are > callable/fields on model, neither of which helps here). With them being > created via __getattr__, they don't. > > I'm coming to the conclusion that the right behaviour is to run the system > check ag

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Malcolm Box
Hi Simon, I've tried that, and it still fails the same system check. The system check checks that all the values returned from get_readonly_fields exist as class attributes on the ModelAdmin (or are callable/fields on model, neither of which helps here). With them being created via __geta

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-09 Thread Simon Charette
rder of fields to be maintained somehow. > I therefore suspect that the check is actually borked, and it should be checking hasattr(instance, field_name) rather than hasattr(cls, field_name) The thing is checks are run against ModelAdmin classes and not the instances bound to the site they wer

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-09 Thread Malcolm Box
#x27;, 'image_thumbnail'] def image_thumbnail(self, obj): return "" % obj.image.url That's fine, but if there's lots of image fields (with a variety of names) spread over several ModelAdmin classes, then you end up with a lot of duplicated code. The normal solution

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Simon Charette
i 8 septembre 2015 13:31:47 UTC-4, Malcolm Box a écrit : > > Hi, > > I'm trying to add a dynamic method to a ModelAdmin so that I can have > automatically generated thumbnail fields for any image by simply adding > '_thumbnail' to the field definitions - which

Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Malcolm Box
Hi, I'm trying to add a dynamic method to a ModelAdmin so that I can have automatically generated thumbnail fields for any image by simply adding '_thumbnail' to the field definitions - which saves a lot of code when there's a load of admin classes with image fields that ne

Django Admin - get formset class reference from modeladmin

2015-07-16 Thread Edward Chan
Dear All, In a ModelAdmin object, how to reference the formset class of the inline? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-user

is it safe to use ModelAdmin variables like this

2015-07-03 Thread Zaher Sarieddine
Is it safe to set a modeladmin variable and use it like this; it is set in the changelist_view based on the url search criteria and is used to limit the choices of a foreign key when adding new item class MyModelAdmin(reversion.VersionAdmin): ... selected_period = None def

Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-22 Thread Carsten Fuchs
djangoproject.com/en/dev/ref/signals/#django.db.models.signals.pre_save Many thanks for your reply! While I seem to understand signals generally, I followed Collin's suggestion, because the ModelAdmin class already has so many readily available customization callbacks, so that this even

Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-22 Thread Carsten Fuchs
Hi Collin, Am 20.12.2014 um 00:18 schrieb Collin Anderson: save_model() happens first, then save_related() which calls save_formset() on each formset. It might end up being easier to save the parent model _again_, instead of doing something before it's saved. Thank you very much for your repl

Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-20 Thread Alex Haylock
On 18/12/14 17:19, Carsten Fuchs wrote: > I would like to find out if anything has changed in the parent > model or the related (inline) models, and depending on the result, > update one of the parent model's fields before it is saved. > > Can you please tell me how can this be achieved? Take a

Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-19 Thread Collin Anderson
https://docs.djangoproject.com/en/dev/ref/forms/fields/#has-changed Collin On Thursday, December 18, 2014 12:20:34 PM UTC-5, Carsten Fuchs wrote: > > Hi fellow Django developers, > > using a model with several related models, for the Django Admin I have a > ModelAdmin that uses several Inli

ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-18 Thread Carsten Fuchs
Hi fellow Django developers, using a model with several related models, for the Django Admin I have a ModelAdmin that uses several InlineModelAdmin objects, very much as in the example at <https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#inlinemodeladmin-objects>. All work

Re: Modifying a ModelAdmin instance at runtime

2014-11-17 Thread Collin Anderson
h registered ModelAdmin once at > registration time.[1] The default AdminSite itself is a module global. > Thus, any long-running, multi-threaded Django application server (e.g. a > threaded uWSGI process) might be relying on a given ModelAdmin instance to > serve multiple requests concurr

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Peter Sagerson
> Your analysis is entirely correct, as far as I can tell. Setting > attributes on `self` in a per-request method of a `ModelAdmin` is not > concurrency-safe, and it should not be recommended or demonstrated in > the docs. If you'd be willing to file a bug (or, better, a

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Carl Meyer
Hi Peter, On 11/12/2014 10:59 PM, Peter Sagerson wrote: > I agree that setting self.exclude will set the instance attribute, > thus hiding the class attribute of the same name. However, it appears > that a given AdminSite instantiates each registered ModelAdmin once > at registration

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Peter Sagerson
I agree that setting self.exclude will set the instance attribute, thus hiding the class attribute of the same name. However, it appears that a given AdminSite instantiates each registered ModelAdmin once at registration time.[1] The default AdminSite itself is a module global. Thus, any long

Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Collin Anderson
On Tuesday, November 11, 2014 3:24:48 PM UTC-5, Peter Sagerson wrote: > > The documentation of ModelAdmin.get_form()[1] demonstrates modifying > self.exclude in order to modify the add/change form on a per-request basis. > However, looking at django.contrib.admin, it seems clear tha

Modifying a ModelAdmin instance at runtime

2014-11-11 Thread Peter Sagerson
The documentation of ModelAdmin.get_form()[1] demonstrates modifying self.exclude in order to modify the add/change form on a per-request basis. However, looking at django.contrib.admin, it seems clear that ModelAdmin is instantiated when it's installed, not for every request. It also do

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-11-02 Thread Mario Gudelj
Thanks Collin. That's the path I've had to take. On 03/11/2014 11:55 am, "Collin Anderson" wrote: > Hi Mario, > > If you are able to edit the model replacing the IntegerField with this > should do what you want: > user = models.ForeignKey(CRMUser, null=True, blank=True, > on_delete=DO_NOTHING) >

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-11-02 Thread Collin Anderson
Hi Mario, If you are able to edit the model replacing the IntegerField with this should do what you want: user = models.ForeignKey(CRMUser, null=True, blank=True, on_delete=DO_NOTHING) Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. T

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-29 Thread Mario Gudelj
Here's the models code, DR: class CRMUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField( verbose_name='Email Address', max_length=255, unique=True, ) first_name = models.CharField("First Name", max_length=50, blank=True) last_name = models.C

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-29 Thread Mario Gudelj
I did not produce the original model so I wouldn't know. My thinking is that the order model had to be independent of the user model so that the deletion of the user doesn't cascade down to orders. It's a mezzanine site and that's how it handles fk from orders to users. On 29/10/2014 9:27 pm, "Dani

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-29 Thread Daniel Roseman
On Wednesday, 29 October 2014 03:57:36 UTC, somecallitblues wrote: > > Hi list, > > I have a table of orders where one of the columns is a IntegerField > containing the id of a user who created the order. > > Since it's not a FK field django admin can't display these orders inline > inside the u

Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-28 Thread Mario Gudelj
Hi list, I have a table of orders where one of the columns is a IntegerField containing the id of a user who created the order. Since it's not a FK field django admin can't display these orders inline inside the user details page. I would normally use something like: class OrderInline(admin.Tab

Re: FieldError with ManyToMany relationship in ModelAdmin list_display item when server is not in DEBUG mode

2014-03-10 Thread Andrew Niccolo Pangilinan
Hi, Have you had any solutions to this yet? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, sen

Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Timothy W. Cook
In the ModelAdmin I use a get_form() to test for conditions on the object. Specifically, if this item has been published then make it read_only. You should be able to test for users as well. I had to add the try/except in order to add new objects because obj.published doesn't exist on

Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Bill Freeman
It's easy, if you don't insist on making it part of the admin, to do this with a custom view. It can pay attention to whatever permissions you like. On Wed, Oct 9, 2013 at 10:06 AM, Victor wrote: > Yes, I know but unfortunately if in Admin Site you say that a user cannot > Add, Delete, and Mod

Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Victor
Yes, I know but unfortunately if in Admin Site you say that a user cannot Add, Delete, and Modify a model if that user is connected he/she doesn't see the model itself in the list but only those models for which it has some kind of permission. I instead would like to make the model visible but n

Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Rafael E. Ferrero
In Admin Site, you can manage users permissions for Add, Delete, Modify of every model on your site. 2013/10/9 Vittorio > For the sake of simplicity let's suppose I have > > models.py > > class Book(models.Model): > title = models.CharField(max_length=100) > authors = models.ManyToManyF

admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Vittorio
For the sake of simplicity let's suppose I have models.py class Book(models.Model): title = models.CharField(max_length=100) authors = models.ManyToManyField(Author) publisher = models.ForeignKey(Publisher) Under admin I would like that some username (say "vic" and "lucky") can edit

FieldError with ManyToMany relationship in ModelAdmin list_display item when server is not in DEBUG mode

2013-03-14 Thread Eric Bass
I can not for the life of me figure out why my list_display works when the django server is in DEBUG=True but not when it is in DEBUG=False. I am using Django 1.4.3 (mod_wsgi 3.4/Python 2.7) Here is the partial stack trace... File "/home/difuzi0n/webapps/wedding/lib/python2.7/django/db/m

Re: a way to display a model formset in a ModelAdmin ?

2012-10-25 Thread Nicolas Emiliani
elForm? >> >> The thing is that I have a Verification model with its ModelAdmin, and >> then I have >> an ImageModel that has no ForeignKey to the Verification model (and I >> intend to keep >> it that way) so I can not inline it into the VerificationAdmin and I >

Re: a way to display a model formset in a ModelAdmin ?

2012-10-25 Thread Stephen Anto
orm? > > The thing is that I have a Verification model with its ModelAdmin, and > then I have > an ImageModel that has no ForeignKey to the Verification model (and I > intend to keep > it that way) so I can not inline it into the VerificationAdmin and I would > like

a way to display a model formset in a ModelAdmin ?

2012-10-24 Thread Nicolas Emiliani
Hi, As the subject states, is there a way to display a model formset in a ModelForm? The thing is that I have a Verification model with its ModelAdmin, and then I have an ImageModel that has no ForeignKey to the Verification model (and I intend to keep it that way) so I can not inline it into

Calculated attributes of ModelAdmin classes

2012-10-19 Thread Daniele Procida
I have a ModelAdmin class. Sometimes, I want it to include a certain field in the fieldsets, and sometimes I don't (whether it does or not would be the result of a calculation on the instance that is being edited in the admin). How can I make the fieldsets attribute a calculated

Re: dynamic fildsets on ModelAdmin

2012-08-05 Thread Nicolas Emiliani
rom, but > > when I try to > > add this fields into the fieldset attribute and load the page it fails > > saying. > > Sorry to say this, but you have to go back to the drawing board. You > cannot add random fields to fieldset. They *have* to be models.Field > cla

Re: dynamic fildsets on ModelAdmin

2012-08-05 Thread Melvyn Sopacua
nd load the page it fails > saying. Sorry to say this, but you have to go back to the drawing board. You cannot add random fields to fieldset. They *have* to be models.Field classes of the model attached the ModelAdmin so that the values get cleaned properly. If you want extra fields for the form,

dynamic fildsets on ModelAdmin

2012-08-05 Thread Nicolas Emiliani
Hi, I've been struggling with dynamic forms and until now I'm loosing the battle :S The thing is that I have a HomeAdmin(ModelAdmin) that uses the form HomeAdminForm(ModelForm) The HomeAdminForm redefines the __init__ method to add a bunch a of hidden input fields like this : class Hom

Adding Checkbox in ModelAdmin

2012-07-10 Thread JZint
Hello, i have a little question which i could'nt answer myself reading the documentation. i'm trying to modify the modelAdmin of my "Picture"-model this is what i'm trying to do: class PictureAdmin(admin.ModelAdmin): def save_model(self, request, obj, fo

How to render a modeladmin dynamically?

2012-06-22 Thread Thomas Weholt
In a view, I need to get a modeladmin for a model provided dynamically, change some of the attributes of the modeladmin ( add an aggregated field to the queryset, order the queryset by that field and add a column for that new field in the list_display of the modeladmin ) and render the request

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
Hi Alireza, Yes, that did the trick! Thank you, Paulo On Thursday, June 14, 2012 2:26:46 PM UTC+1, Alireza Savand wrote: > > > > On Thursday, June 14, 2012 3:04:54 PM UTC+4, Paulo Almeida wrote: >> >> Hi, >> >> I would like to access the request.user in

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Alireza Savand
And if it's just for logged-in user, you can do like https://gist.github.com/2930287 at the ModelAdmin -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/m

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Alireza Savand
On Thursday, June 14, 2012 3:04:54 PM UTC+4, Paulo Almeida wrote: > > Hi, > > I would like to access the request.user in a ModelAdmin function, so I can > filter the results of a query based on the logged in user. I have these > models: > > class Speaker(m

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
ogled around and saw solutions for similar >> > problems involving overrides of save_model, queryset or >> > formfield_for_manytomany, but I couldn't adapt them to list_display, >> > because I'm creating a function in the ModelAdmin, where I only know >>

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
k because request isn't available in > the > > is_endorsed function. I googled around and saw solutions for similar > > problems involving overrides of save_model, queryset or > > formfield_for_manytomany, but I couldn't adapt them to list_display, > > beca

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Melvyn Sopacua
he > is_endorsed function. I googled around and saw solutions for similar > problems involving overrides of save_model, queryset or > formfield_for_manytomany, but I couldn't adapt them to list_display, > because I'm creating a function in the ModelAdmin, where I only kno

Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
Hi, I would like to access the request.user in a ModelAdmin function, so I can filter the results of a query based on the logged in user. I have these models: class Speaker(models.Model): name = models.CharField(max_length=50) endorsements = models.ManyToManyField(User

  1   2   3   >