# in models.py
class Seed(models.Model):
    name = models.CharField(max_length=128)

    UPLOAD_ROOT = 'uploads'
    files = models.FileField(upload_to=UPLOAD_ROOT, blank=True,
null=True)
    source = models.CharField(max_length=256, blank=True, null=True)

    def __unicode__(self):
        return self.name

# in from.py
from django import forms
from models import Seed

class SeedForm(forms.ModelForm):
    class Meta:
        model = Seed

    def clean(self):
        # how to get Seed.objects.filter(name='asdf').source here ?
        return self.cleaned_data

I got it.

# in models.py
class Seed(models.Model):
    name = models.CharField(max_length=128)

    UPLOAD_ROOT = 'uploads'
    files = models.FileField(upload_to=UPLOAD_ROOT, blank=True,
null=True)
    source = models.CharField(max_length=256, blank=True, null=True)

    def __unicode__(self):
        return self.name

# in from.py
from django import forms
from models import Seed

class SeedForm(forms.ModelForm):
    class Meta:
        model = Seed

    def clean(self):
        # how to get Seed.objects.filter(name='asdf').source here ?
        source = self.instance.source
        return self.cleaned_data

http://groups.google.com/group/django-users/browse_thread/thread/7b42604519c3b27e/2e01f339cdf0c3cc?lnk=gst&q=get+model+value+in+form#2e01f339cdf0c3cc



On Jul 30, 10:06 pm, Shuge Lee <shuge....@gmail.com> wrote:
> http://dpaste.com/73301/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to