Wednesday, June 29, 2011

Re: Comparing ManyToManyFields

Heh, whoops.

So I'm reading in all the information about a machine from a file that
is generated periodically on the machine (XML right now). I need to
compare all the data about that machine to what's currently in the
database, and create a new entry if anything has changed.

The models are really more complicated than I posted (obviously) but
the current idea is to key on the hostname, but to compare every
single little bit of data in the model to detect changes.

-josh

On Wed, Jun 29, 2011 at 09:40:24PM -0400, Andre Terra wrote:
> You'll first have to explain what you mean by 'reading from a file'
> and 'comparing'.
>
> Are we comparing against serialized model exports? Is the user
> importing data from a csv file? What column(s) is(are) you using as
> keys for matching db objects against the file?
>
> Give us a little more details and we'll try giving some suggestions in return =)
>
>
> Sincerely,
> André Terra
>
> On 6/28/11, Josh Lothian <lothian@ornl.gov> wrote:
> > So I'm working on my first Django application, and I've run into a
> > stumbling block. In simplest terms, I've got two objects:
> >
> > def Package(models.Model):
> > name=models.CharField(max_length=255)
> > version=models.CharField(max_length=128)
> >
> > def Machine(models.Model):
> > hostname=models.CharField(max_length=255)
> > installed_packages=models.ManyToManyField(Package)

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment