English 中文(简体)
Django 1.3 - Admin - “更多入境”
原标题:Django 1.3 - Admin - "Add Entry" button - copy the fields from previous model instance

由于某种原因,找不到如何做到这一点。

在阿杜米特网页上点击“Add_model Access”纽顿时,我希望大多数领域都以用户在以前的模型中采用的相同价值填充,这些数值是制造和节省的。 (我不关心哪一个用户,仅是最后一个(最忙的)用户拯救了模型的事例。)

使用案例:用户将按批量方式,例如10个非常相似的物品,形成这种模式的事例,因此,如果大多数发明者每次打上“Add条目”的 but子,就会非常有用。 如果出于某种原因,他们每天可能这样做3-4次,每批货物在田里的数值与原批数大不相同,但批量中的每一例都相同。 因此,我的想法预示着最近挽救的价值观。

Contrived Example:


class person:<br>
    name= CharField       =>   (obvious)<br>
    interests= CharField  =>   Example (fly, skate, swim)<br>
    age_range= CharField  =>   Example (old, middle, young)<br>


batch 1 = people who fly and are old

Jim Smith, Fly, Old
Sara Smith, Fly, Old
Larry Jones, Fly, Old


batch 2 = skaters

Sam Samuelson, Skate, Young
Alfred Bob, Skate, Old
Jon Jon, Skate, Old

每一批货物都非常相似,但批量可能差别很大。 因此,我要猜测,我需要一份以前保存的模式的复印件,有新的红利(这里没有处理过的问题,但还有外岛)。 我如何在“进入”纽特/地点加上这个词?

最佳回答

作为第二种选择,你还可以使用https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as”rel=“nofollow”>。 这完全是你所回顾的,但这将使用户能够进入先前的条目,将一些领域 ,然后将这作为新的目标加以节省,而后者将产生同样的效果。

问题回答

您可以为您的<代码>ModelAdmin设定一个惯例>>。 提供(如果是的话,这将意味着你重新编辑现有物体,而不是制造新的物体),如果不是,则询问最新物体,然后把<代码>初步<>编号/代码>与你从中提取的数值联系起来。





相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...