Great, thank to both of you. I'm coming from a world of CakePHP. I did more Python programming back in the day, and am getting back into it, so I'm trying to get more familiar with Django.
Thanks for the suggestions, I'll see what I can make happen. ----- Original Message ----- From: sedl...@gmail.com To: "Django users" <django-users@googlegroups.com> Sent: Saturday, August 20, 2011 11:44:33 AM Subject: Re: Specific models without a database table Hi, you may use custom model manager (responsible for retrieving objects from DB) and custom save method (which would not call Model.save), together with managed=True. You may still face some issues, however I think this should be possible. Cheers, Filip On 20 srp, 12:51, Malcolm Box <malcolm....@gmail.com> wrote: > On 20 August 2011 02:33, Kristofer Pettijohn <kristo...@cybernetik.net>wrote: > > > Hello, > > > Is it possible to create specific models without a database table? > > Yes, it's possible. You want the "managed" attribute on the model - > seehttps://docs.djangoproject.com/en/1.3/ref/models/options/#managed > > This will prevent Django from creating or modifying the db table > > > Basically what I would like to do is create an email account management > > application that ties into my existing mail server and its API. I would > > like Django to have a Users model and keep track of users, a Domains model > > to keep track of the email domains for the user, but I don't want it to > > actually keep track of email addresses. Once the user is in the > > application, they will go into the "EmailAccount" model and I simply want > > the model to query my mail server via its SOAP API. So when they > > create/delete/edit email accounts, there will be form pages and simple > > validation done by Django, but the actual work will be done by connecting to > > the mail servers API and not a database. > > Is this possible? > > That is substantially harder, but could be possible. The main problem is > that the Django ORM will want to write SQL queries when there's a link to > the EmailAccount model. > > Your best bet is probably a proxy model that contains a reference to the > relevant API record (e.g. the email address identifier or whatever the API > uses), and then a custom save() method that writes the values out to the DB. > You can use the Django form logic etc without it needing to be backed by a > model. > > It will largely depend on how you want the EmailAccount to look - the closer > you want it to work to a standard ORM model, the more work you'll have to do > to trick things. If it's a simple field that isn't used for queries, then > you could look at creating a custom field type that knows how to read/write > the values to the API. > > All the above advice is worth exactly what you paid for it! > > Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.