Creating a custom view in Django admin,

29 views
Skip to first unread message

Dexter

unread,
May 26, 2010, 1:02:04 PM5/26/10
to django...@googlegroups.com
Hi,

I am building a newsletter system, but I'm wondering how to incorporate it into the django admin.
Just recently I started discovering the capabilities of the admin interface, and finding out how things are supposed to be working.
I want to make an interface which follows the django "zen".

My situation is as follows, I have to models which need to be incorporated into the newsletter,
An agenda, with events, and a messaging system to display announcements.
My newsletter model has two manytomanyfields pointing to the event and the message models.

What I really want to do, is at creation of a new newsletter, the user selects the events and messages that should be displayed in the newsletter.
Then, when the user saves the newsletter, a custom view is displayed (The newsletter is not yet saved). In which the user can select the order in which the objects (messages and events) should be displayed.(ie via drag and drop)

The next step is confirmation, so the user sees the entire newsletter, entirely formatted.

Is this the best way to do this kind of thing?, or should it be approached differently?

Another thing:
At the event model, it is unnecessary to display all the events in the admin. How can I make sure only the events coming (ie date__gte=datetime.now()) are displayed in the admin?

 Thanks in advance for your help.

Greetings, Dexter

chr

unread,
May 27, 2010, 2:54:00 PM5/27/10
to Django users
On May 26, 7:02 pm, Dexter <a.essel...@gmail.com> wrote:
> Another thing:
>
> At the event model, it is unnecessary to display all the events in the
> admin. How can I make sure only the events coming (ie
> date__gte=datetime.now()) are displayed in the admin?

i think a proxy model[1] might work where you set the default manager
to only filter for all objects greater than now(). then, instead of
(or in addition to) the actual event model you register the proxymodel
with the admin.

[1] http://docs.djangoproject.com/en/dev/topics/db/models/#proxy-model-managers

Dexter

unread,
May 28, 2010, 11:12:05 AM5/28/10
to django...@googlegroups.com
Thank you chr,

I've never experimented with managers, but it's quite useful.
I guess a custom manager is also the only way to have a foreignkey to a user in a specific group. 

But although I'm a bit further, I still don't know the answer to my million-dollar question.

Is it possible to have an intermediary step before actually saving the object. In which I have a custom view?
What I actually want is a multiple step saving process.

Is that possible without ugly hacks?

Thanks in advance.

Grtz, Dexter


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Reply all
Reply to author
Forward
0 new messages