How to deal with multiple foreign keys in child tables

2012-04-10 Thread Carlos Quiros
Hi,

I am new to DJango.

I have a database with three tables:

-CRP
   - SubComponents of a CRP
 - Objectives of a SubComponent of a CRP.

For this tables I created the following models:

-Model
Code
class period(models.Model):
period_code =
models.IntegerField(primary_key=True,verbose_name='Period code')
period_desc = models.CharField(max_length=45,verbose_name='Period
description')
period_current = models.IntegerField(verbose_name='Current period')
def __unicode__(self):
return self.period_desc
class Meta:
db_table = 'period'

class crp(models.Model):
crp_code =
models.CharField(max_length=3,primary_key=True,verbose_name='CRP
code')
crp_desc = models.CharField(max_length=45,verbose_name='CRP
description')
def __unicode__(self):
return self.crp_desc
class Meta:
db_table = 'crp'

class subcomponent(models.Model):
crp_code =
models.ForeignKey(crp,db_column='crp_code',related_name='subcomponent_crp_code',to_field='crp_code',primary_key=True,verbose_name='CRP
code')
subc_code =
models.CharField(max_length=3,primary_key=True,verbose_name='SubComponent
Code')
subc_desc = models.CharField(max_length=45,verbose_name='SubComponent
Description')
def __unicode__(self):
return self.subc_desc
class Meta:
db_table = 'subcomponent'


class objective(models.Model):
crp_code =
models.ForeignKey(subcomponent,db_column='crp_code',related_name='objective_crp_code',to_field='crp_code',primary_key=True,verbose_name='CRP
code')
subc_code =
models.ForeignKey(subcomponent,db_column='subc_code',related_name='objective_subc_code',to_field='subc_code',primary_key=True,verbose_name='SubComponent
Code')
obj_year =
models.ForeignKey(period,db_column='obj_year',related_name='objective_obj_year',to_field='period_code',primary_key=True,verbose_name='Objective
year')
obj_code =
models.CharField(max_length=7,primary_key=True,verbose_name='Objective
code')
obj_desc = models.CharField(max_length=45,verbose_name='Objective
description')
def __unicode__(self):
return self.obj_desc
class Meta:
db_table = 'objective'
-End model
code--

All works fine for the "subcomponent" model (reference to CRP); in the
administration of "subcomponent" the user can pull down a CRP and add
a subcomponent to it.

However, the model "objective" reference the model "subcomponent". In
the administration of "objective" I would like the user to pull down
and select a CRP, then filter the subcomponents of that CRP also in a
pull down list. How can I do this?

Many thanks,

Carlos.

-- 
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.



Django manage.py returns ValueError: zero length field name in format

2014-01-05 Thread Carlos Quiros
Hi,

I am trying to run a Django application in Python 2.6.6 Django==1.5.5 . But 
when I try to run

*python manage.py*

I get:

*Traceback (most recent call last):
  File "manage.py", line 12, in 
print('Your environment 
is:"{}"'.format(os.environ['DJANGO_SETTINGS_MODULE']))
ValueError: zero length field name in** format*

Any idea what is wrong? I am also running the same application in another 
server but with Python 2.7.5 and it works ok.

Note: DJANGO_SETTINGS_MODULE is an environmental variable in both systems

Thanks,

Carlos



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc3c63a0-ff11-47cd-866f-069683af3ee6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Broken links even after change the site information

2014-01-06 Thread Carlos Quiros
Hello.

I have a Django application running in my server 
http://data.ilri.org/formhub

However the links of the application are broken for example 
*http://data.ilri.org/accounts/register/* instead of 
*http://data.ilri.org/formhub/accounts/register/ 
*

I been looking on the internet and also configured the site framework with:

python manage.py shell
>>> from django.contrib.sites.models import Site
>>> one = Site.objects.all()[0]
>>> one.domain = 'http://data.ilri.org/formhub/'
>>> one.name = 'Formhub'
>>> one.save()
>>> quit()
(formhub-env)[cquiros@rmg formhub]$ python manage.py dumpdata sites
Your environment is:"formhub.preset.default_settings"
[{"pk": 1, "model": "sites.site", "fields": {"domain": 
"http://data.ilri.org/formhub/";, "name": "Formhub"}}](formhubnv)

But still the links are broken.

What else do I need to do?

Any help is much appreciated.

Carlos.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c3d05252-7253-409d-ab03-5f9296bdc24c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.