Re: Adding default rows to Django admin inlines

2019-01-28 Thread Kevin Olbrich
Hi! Maybe I did not fully understand but it seems we indeed don't talk about the same. I already got M2M relation. If I access the "Jobs" admin-page, I have the option to add inline-options. On a new object, there are no lines but I can add new. I would like to add lines for the attributes from M

Adding default rows to Django admin inlines

2019-01-19 Thread Mohammad Etemaddar
If I get you right you need to add m2m objects with a default value. In this situation, you can create an intermediate model to build m2m. For example: JobActionRel: job = fk action = fk-to-actions (default=Action.objects.get...) And use it as through model: https://docs.djangoproject.com/en/2.1/t

Adding default rows to Django admin inlines

2019-01-18 Thread Kevin Olbrich
Hi! I have a question regarding inlines in the Django admin interface. Currently there are following models: Jobs - holds the Job-ID, an action (FK JobActions) and execution status JobActions - holds a list of possible actions (like "create a new customer") [Also has a ManyToMany against JobAttr

Display old instances as read only in admin inlines

2016-06-17 Thread Olivier Dalang
Dear List, I'm a bit stuck on a problem. I googled a lot, but didn't find an answer. I have a "Loan" model and a "Payment" model. In the admin, I display the payments for each loan in inlines. I want payements that are more than 3 days old to be displayed as readonly, as they are considered to be

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Felipe
Does not work, why? remember, we need get each form inline guided on the next line self.initial = [{'attribute': attribute} for attribute in obj.category. attributes.all()] # Important: This start each form with a different value, [{'attribute': 'Colors'}, {'attribute': 'Sizes'}, ..] if you

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Filipe Ximenes
Think I got it now. Can you see if this stackoverflow answer solves your problem: http://stackoverflow.com/questions/5329586/django-modelchoicefield-filtering-query-set-and-setting-default-value-as-an-obj On Wed, May 27, 2015 at 9:41 AM, Felipe wrote: > Hello, Filipe Ximenes, in fact it is not s

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Felipe
Hello, Filipe Ximenes, in fact it is not so difficult. To avoid using ajax, what I do is initialize each form inline with a default value. Few ATTRIBUTES has verified and initialize no possibility that the fronentd they can edit. All right up here, but the problem is that for each attribute req

Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Filipe Ximenes
>From what I could understand, you want to change the options of the "value options" field depending on the selected "attribute". Since the choosing of the "attribute" happens in the frontend and there's no page refresh, the backend does not know about it, and therefore cannot filter the "value opt

Re: How to pass a queryset for each different field Admin Inlines

2015-05-26 Thread Felipe
Someone can help me ?, he took days trying to fix this and nothing to get it, if I could just iterate a QuerySet each model choice of the form. The only thing achieved is that a queryset applies to all forms inline, but I need a different one for each inline. def formfield_for_foreignkey(sel

How to pass a queryset for each different field Admin Inlines

2015-05-26 Thread Felipe
Pretend to have in the Django admin, 4 forms inlines, Each with a pair of fields choices, "Attributes" and "Value Option". We have the first pair, which initialize the field one with a value, for example color and other field you must have a queryset the choices.

Re: Admin Inlines

2015-04-25 Thread Timothy W. Cook
For reference. My mistake is that I really have a ManyToMany relationship and I used this http://www.mc706.com/tip_trick_snippets/18/django-manytomany-inline-admin/ to solve the problem. Thanks to Ryan McDevitt. On Sat, Apr 25, 2015 at 3:11 PM, Timothy W. Cook wrote: > The usage of AdminInl

Admin Inlines

2015-04-25 Thread Timothy W. Cook
The usage of AdminInlines seems backwards to me. At least in the use case I have. I have two models: DvInterval: lower = models.CharField(max_length=110) upper = models.CharField(max_length=110) ... ReferenceRange: ​ ​ ​ ​ ... ​data_range = models.ForeignKey(DvInterval)

Re: template for "Pagination for admin inlines" snippet

2013-02-06 Thread Axel Rau
Am 05.02.2013 um 22:16 schrieb Conor Pollock: > I'm currently trying to figure this out as well... I can pass a page query > in the url and everything works as expected, but I can't figure out how to > render the pagination controls in my template file. > > Did you ever get this to work? No,

Re: template for "Pagination for admin inlines" snippet

2013-02-05 Thread Conor Pollock
I'm currently trying to figure this out as well... I can pass a page query in the url and everything works as expected, but I can't figure out how to render the pagination controls in my template file. Did you ever get this to work? On Monday, 8 October 2012 10:37:09 UTC-4, axel...@chaos1.de w

template for "Pagination for admin inlines" snippet

2012-10-08 Thread Axel Rau
Hi, anybody got a template working for this https://gist.github.com/559911 ? I have no idea how to fiddle it into the admin template system. Thanks, Axel --- PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius -- You received this message because you are subscribed to th

Re: Filter admin inlines

2012-02-05 Thread NENAD CIKIC
Thanks. So to summarize the solution to filter inlines in admin interface based on userprofile was: define the form on Y model as: class YForm(forms.ModelForm): request=None #NOTE THIS lang=forms.ModelChoiceField(queryset=lang.objects.all()) #first get all def __init__(self, data=N

Re: Filter admin inlines

2012-02-05 Thread Marc Aymerich
On Sun, Feb 5, 2012 at 1:43 PM, NENAD CIKIC wrote: > Hello, > I have three models > X > Lang > Y > where the purpose of Y is to provide X fields in other languages. > So I have Y as > Y > x foreignkey on X > lang ForeignKey on Lang > additionalfields... > > I have created the ModelAdmin for Lang.

Filter admin inlines

2012-02-05 Thread NENAD CIKIC
Hello, I have three models X Lang Y where the purpose of Y is to provide X fields in other languages. So I have Y as Y x foreignkey on X lang ForeignKey on Lang additionalfields... I have created the ModelAdmin for Lang. For X I have the ModelAdmin and added the inlines = [ YInline,

(Solved) Re: Admin inlines suddenly missing?

2011-08-15 Thread Nan
delFormSet throws a > > ValidationError: [u'ManagementForm data is missing or has been > > tampered with'] when we try to save the Ticket.) > > > Thanks for your suggestions! > > > On Aug 15, 11:29 am, Reinout van Rees wrote: > > > > On 15

Re: Admin inlines suddenly missing?

2011-08-15 Thread Nan
[u'ManagementForm data is missing or has been > tampered with'] when we try to save the Ticket.) > > Thanks for your suggestions! > > On Aug 15, 11:29 am, Reinout van Rees wrote: > > > > > > > > > On 15-08-11 16:18, Nan wrote: > > > >

Re: Admin inlines suddenly missing?

2011-08-15 Thread Nan
t output to the browser the ModelFormSet throws a ValidationError: [u'ManagementForm data is missing or has been tampered with'] when we try to save the Ticket.) Thanks for your suggestions! On Aug 15, 11:29 am, Reinout van Rees wrote: > On 15-08-11 16:18, Nan wrote: > >

Re: Admin inlines suddenly missing?

2011-08-15 Thread Reinout van Rees
On 15-08-11 16:18, Nan wrote: I'm having a problem with admin inlines on a particular model suddenly not showing up, even though they were working previously. Oddly, they're working just fine on the exact same code in staging (granted, on a somewhat different server setup) but not in

Admin inlines suddenly missing?

2011-08-15 Thread Nan
Hi folks -- I'm having a problem with admin inlines on a particular model suddenly not showing up, even though they were working previously. Oddly, they're working just fine on the exact same code in staging (granted, on a somewhat different server setup) but not in production. The on

Re: Readonly on subset of forms in Admin inlines

2011-05-12 Thread Vinicius Massuchetto
Hi! Did you find any solution for this? I'm trying to achieve a similar behavior for inlines, as posted in another recent thread. Thanks. -- Vinicius Massuchetto On Jan 23, 8:07 am, Peter Phillips wrote: > Thanks for the reply! > > I probably didn't explain the problem properly. I have been usin

Readonly fields for existing items on admin inlines

2011-05-11 Thread Vinicius Massuchetto
Hi! In a tabular inline, i want that the added items can't be changed or deleted. I'm ok with the `can_delete` option, but setting `readonly_fields` will also turn the form entry at the bottom to be readonly too. There's another problem with some more fields that I need to display in this form, li

Re: Readonly on subset of forms in Admin inlines

2011-01-23 Thread Peter Phillips
Thanks for the reply! I probably didn't explain the problem properly. I have been using the ModelAdmin.readonly_fields option, however it hasn't been doing quite what I need for inline formsets. In the case of my inline form, when I set some of the fields to readonly, they end up read only for all

Re: Readonly on subset of forms in Admin inlines

2011-01-20 Thread Thomas
Am 20.01.2011 um 03:27 schrieb Peter Phillips: > Hello, > > Is there a straightforward way to set fields to read only for a subset > of the forms in an inline formset in the Admin? I'd like to set some > fields to read only on my inline form for rows that were not created > by the user. However,

Readonly on subset of forms in Admin inlines

2011-01-19 Thread Peter Phillips
Hello, Is there a straightforward way to set fields to read only for a subset of the forms in an inline formset in the Admin? I'd like to set some fields to read only on my inline form for rows that were not created by the user. However, when I set the fields to read only, it of course affects all

uuid as primary key on admin inlines results with MultiValueDictKeyError. Please advise

2010-11-22 Thread Iclaimthisname
Hi, I am coming to the conclusion that it is not possible, but I wanted to ask one last time before I give up. Is it possible to use a uuid primary key on a model used as an admin inline? I've tried every uuid field I could find and attempted to get my own to work as well, but no matter what I t

Admin Inlines only show up after a browser refresh

2010-11-09 Thread vjimw
We have an odd situation where, for one of our model forms, the inlines do not regularly show up on the form page, but if you refresh the browser window, they will appear with the correct data. Has anyone else run into this before? I am not really sure how to debug it since it is not consistent. H

Re: Filtering Admin Inlines

2010-11-01 Thread derek
Its not clear if you want to filter the choices before the form is displayed, or dynamically in the browser? On Oct 26, 7:29 pm, Lllama wrote: > Hello all, > > I've got an admin site that includes some inlines. These in turn > contain a ChoiceField. I'd like to filter the choices based on an > at

Filtering Admin Inlines

2010-10-26 Thread Lllama
Hello all, I've got an admin site that includes some inlines. These in turn contain a ChoiceField. I'd like to filter the choices based on an attribute of the parent model. Does anyone know if this is possible and, if so, what hook I need to use? I feel like I should be able to use formfield_for_

Customize behavior of admin inlines

2010-10-22 Thread Bojan Mihelac
I would like to customize behavior of admin inlines interface so when the editor edit a parent model he is offered with all possible variations of child objects. Here is simplified use case: class Shirt(models.Model): name = models.CharField(max_length=80) class

Re: Validating or modifying admin inlines against main form

2010-09-28 Thread derek
On Sep 28, 12:16 pm, graeme wrote: > I need to do one of the following in the admin using Django 1.2: > > 1. Validate a value in a form against which objects have been added > using an inline form. > 2. Add or delete related objects depending on the value in the main > model from. > > The first wo

Validating or modifying admin inlines against main form

2010-09-28 Thread graeme
I need to do one of the following in the admin using Django 1.2: 1. Validate a value in a form against which objects have been added using an inline form. 2. Add or delete related objects depending on the value in the main model from. The first would be preferable as the user would be able to dec

Admin Inlines, unique_together, and updates?

2010-06-08 Thread ringemup
Say I have a pair of classes roughly like so: class Parent(models.Model): name = models.CharField(maxlength=50) class Child(models.Model): parent = models.ForeignKey(Parent) name = models.CharField(maxlength=50) order = models.IntegerField() class Meta: unique_togethe

Re: Help with admin inlines

2009-08-30 Thread Frank Wiles
On Fri, Aug 28, 2009 at 3:12 AM, Léon Dignòn wrote: > > Hi, > > I tried to stack two models in the admin interface. Any ideas why I > get this error? > > issubclass() arg 1 must be a class > File "C:\Django\myproject\myapp\admin.py" in >  22. admin.site.register(Manufacturer, ManufacturerAdmin)

Admin inlines onetoone related object not saved

2009-08-28 Thread Jean Stebens
Hi there, I have the following models: class A(models.Model): id = models.AutoField(primary_key=True) class B(models.Model): mya = models.OneToOneField(A, primary_key=True) text = models.TextField(default='Init') In admin interface, I have used an inline to include B when changing/

Help with admin inlines

2009-08-28 Thread Léon Dignòn
Hi, I tried to stack two models in the admin interface. Any ideas why I get this error? issubclass() arg 1 must be a class File "C:\Django\myproject\myapp\admin.py" in 22. admin.site.register(Manufacturer, ManufacturerAdmin) admin.py class Aer

over-riding queryset for admin inlines

2009-08-13 Thread smcoll
i'm having trouble getting some instances to show up as inlines in the admin. Since i'm managing multiple sites from one domain, many of those instances won't show up because the condition in their default manager ("is it on this site?") fails. i'd like my admin to use `objects` for everything,

Re: Django + user profile admin inlines = breakage

2009-07-02 Thread hagan
Ah, got this working It helps to put admin stuff in the admin.py file. I was doing to much in the models.py file and after spending a moment to separate admin/model/forms everything started to work magically... Possibly because I added "admin.autodiscover()" --~--~-~--~~--

Django + user profile admin inlines = breakage

2009-07-01 Thread hagan
I'm using python 2.6.2, django 1.1-beta-1 with mod_wsgi 2.5 So this very well could be a beta bug... I'm having a strange problem, which I've tracked down to my UserProfile model... well, the admin interface. Basically I'm trying to do something like this (Simplified from working model)

Re: admin inlines saving empty objects

2009-05-07 Thread modelmike
I, also, am receiving inexplicable "Please correct the errors below" messages within templates with inlines that contain fields with 'blank=True' and / or 'null=True'. The messages appear about every third or fourth save attempt that involves empty strings. But I'm unsure. The bug is difficult

admin inlines saving empty objects

2009-05-06 Thread nbv4
I have an admin page set up where I have two inlines for this one model I have. Both inlines have extra=3 so theres three instances per inline. One of the inlines behaves badly by saving all three objects, even if two of them are completely empty. The other inline behaves nicely by only saving the

Re: Admin Inlines astray

2009-04-11 Thread Andy Wilson
fixed after trying all sorts of approaches I finally got it to work by chmod'ing o+r to the files under the django/contrib/admin directory. Most of them already had read permissions but I could see that a few didn't. a On Sat, 2009-04-11 at 19:58 +0100, Andy Wilson wrote: > ps. I used the 'song

Re: Admin Inlines astray

2009-04-11 Thread Andy Wilson
ps. I used the 'song' and 'recording' models as an example, in fact I have several apps that use inlines, and on the one installation they are missing in every case. No errors are thrown and I can see nothing relevant in the logs. On Sat, 2009-04-11 at 19:50 +0100, Andy Wilson wrote: > has anyon

Admin Inlines astray

2009-04-11 Thread Andy Wilson
has anyone any idea why the inlines might go missing? I have a model 'song' and a model 'recording'. I've created a recordingInline class, and in the modelAdmin I set: inlines = [recordingInline] this all works fine on my Ubuntu installation running python 2.5.2 and django 1.0.2, but on another

Re: Admin inlines and foreign keys

2008-09-15 Thread Donn
On Monday, 15 September 2008 19:00:39 Steve Holden wrote: > So, as Karen already said, there really doesn't seem to be any need for > a "pluginsEnabled" module. The foreign key implements a one-to-many > relationship between Website and Plugin: many Plugins can have the same > Website, each Websit

Re: Admin inlines and foreign keys

2008-09-15 Thread Steve Holden
Donn wrote: > Okay, I am totally confused. > I had a working system before, but trying to relate my models is hurting my > head. If anyone has a minute here's my scheme: > > == means has many > -- means has one > > Client == Website -- pluginsEnabled == Plugin > > 1. I create many Plugin entri

Re: Admin inlines and foreign keys

2008-09-15 Thread Donn
Karen, I suspect I have been using foreign keys where I should be using one to many or somesuch. I will retreat and rethink my layout. Thanks, \d --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group

Re: Admin inlines and foreign keys

2008-09-14 Thread Karen Tracey
On Sun, Sep 14, 2008 at 4:26 PM, Donn <[EMAIL PROTECTED]> wrote: > > > That should happen automatically - you shouldn't see the foreign key > > to the parent model. Can you post your model and admin code on > > dpaste.com so we can work out what's wrong? > Thanks, I'm sure it's something dumb I'm

Re: Admin inlines and foreign keys

2008-09-14 Thread Ali Deniz EREN
So closed problem with me. My model's parent is itself. I mean, I want it like that. class Content(models.Model): subtitle = models.CharField(blank=True, max_length=300, help_text='Something is coming.') title = models.CharField(max_length=300, unique=True, help_text='Something is coming.'

Re: Admin inlines and foreign keys

2008-09-14 Thread Donn
> That should happen automatically - you shouldn't see the foreign key > to the parent model. Can you post your model and admin code on > dpaste.com so we can work out what's wrong? Thanks, I'm sure it's something dumb I'm doing. Here: http://dpaste.com/78053/ \d --~--~-~--~~

Re: Admin inlines and foreign keys

2008-09-14 Thread Daniel Roseman
On Sep 14, 9:05 am, Donn <[EMAIL PROTECTED]> wrote: > Hi, > I have been looking, but can't find. > > I have a Client model with a Website inline (related by FK). it's open in a > change screen in the admin. > The inline below has a field that refers to the parent Client. > That field is a drop-dow

Admin inlines and foreign keys

2008-09-14 Thread Donn
Hi, I have been looking, but can't find. I have a Client model with a Website inline (related by FK). it's open in a change screen in the admin. The inline below has a field that refers to the parent Client. That field is a drop-down showing many Clients. Is there any way to tell the inline to

Re: newforms-admin inlines question

2008-02-11 Thread Aaron Fay
Hey guys, Thanks for the replies.  Part of the issue I was having is I had the extras keyword in the wrong subclass (I had it in the options class for my model, instead of the inline class).  It appears the functionality is working as it should be for now... Cheers, Aaron Brian Rosner wrot

Re: newforms-admin inlines question

2008-02-11 Thread Brian Rosner
> I am using newforms admin and have a custom UserProfile model set in my > inlines for my User, is there a way to limit the UserProfile to 1 for > the User? Right now it's trying to offer 4 profiles for the user, and > 'extras=1' doesn't seem to affect how many are displayed (I don't want > extr

Re: newforms-admin inlines question

2008-02-11 Thread shabda
I dunno if this is the answer you are looking for, but if you want to enforce that there is only one user set unique = True for the user in the UserProfile class. class UserProfile(models.Model): user = models.ForeignKey(User, unique = True) On Feb 11, 10:42 am, Aaron Fay <[EMAIL PROTECTED]> w

newforms-admin inlines question

2008-02-10 Thread Aaron Fay
Hi List, I am using newforms admin and have a custom UserProfile model set in my inlines for my User, is there a way to limit the UserProfile to 1 for the User? Right now it's trying to offer 4 profiles for the user, and 'extras=1' doesn't seem to affect how many are displayed (I don't want