views:

51

answers:

1

I have an app name sync which has a form created from a model that saves itself. I want to create another app called activity that retrieves the data from the sync models and other future apps. How can I do that in the activity views app?

This is my sync models.py

from django.db import models
from django.contrib.auth.models import User
from django.forms import ModelForm

FS_CHOICES = (
    ('/path1/', 'P1'),
    ('/path2/', 'P2'),
    ('/path3/', 'P3'),
)

OPTIONS = (
    ('-n', 'TRY'),
)


class SyncJob(models.Model):
  date = models.DateTimeField()
  user = models.ForeignKey(User, unique=False)
  source = models.CharField(max_length=3, choices=FS_CHOICES)
  destination = models.CharField(max_length=3, choices=FS_CHOICES)
  options = models.CharField(max_length=10, choices=OPTIONS)

class SyncJobForm(ModelForm):
  class Meta:
    model = SyncJob
    fields = ['source', 'destination', 'options'] 

Ok, in activity views.py I have this:

from toolbox.sync.models import SyncJob
from django.shortcuts import render_to_response

def Activity()
   sync_job = SyncJob.objects.get(id=03)

   return render_to_response('base.html', {'sync_job': sync_job})

UPDATE: When I try to view the page it displays the error: 'function' object is not iterable

+2  A: 

Just import it like any other python class.

So in your activity app you'd do something like this:

from sync.models import SyncJob
sync_job = SyncJob.objects.get(id=99)
sdolan
Thanks! I have edited my views.py as shown in the original question, but when loading the page it doesn't show anything. I must be doing something wrong here.
xzased