Aw: Re: Problem with relationships in models

2011-07-21 Thread Schmidtchen Schleicher
You were right! I resetted the app and now it works

+1

THX

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dfsjUI6oH7IJ.
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.



Re: Problem with relationships in models

2011-07-21 Thread Malcolm Box
A guess, but are you sure syncdb created the tables? Ie have you checked
using mysql, or manage.py dbshell that the tables are really there?

Syncdb only creates tables for a model the first time it is run - after that
it won't track updates. So if you ran it, then added the relationship, then
ran again you'd get the error your seeing.

If you have no data, just blow away the tables and start again. If you have
data, now is a good time to find out about South (http://south.aeracode.org)

Malcolm


On 21 July 2011 15:34, Schmidtchen Schleicher wrote:

> Something went wrong with posting the model, it should be:
>
>
> # -*- coding: utf-8 -*-
> from django.db import models
> from django.contrib.auth.models import User
> import datetime
>
> class Kalender(models.Model):
> name = models.CharField("Kalendername", max_length=100)
> description = models.TextField("Beschreibung")
>
> class Meta:
> verbose_name_plural = "Kalender"
>
> class Termin(models.Model):
> in_calendar = models.ForeignKey(Kalender)
> name = models.CharField("Terminname", max_length=100)
> date = models.DateTimeField("Datum und Uhrzeit")
> description = models.TextField("Beschreibung")
>
> def is_today(self):
> return self.date.date() == datetime.date.today()
>
> is_today.short_description = "Termin findet heute statt?"
>
> participants = models.ManyToManyField(User)
>
> class Meta:
> verbose_name_plural = "Termine"
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/IiaS26VAlVAJ.
>
> 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.
>



-- 
Malcolm Box
malcolm@gmail.com

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



Aw: Problem with relationships in models

2011-07-21 Thread Schmidtchen Schleicher
Something went wrong with posting the model, it should be:

# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
import datetime

class Kalender(models.Model):
name = models.CharField("Kalendername", max_length=100)
description = models.TextField("Beschreibung")

class Meta:
verbose_name_plural = "Kalender"

class Termin(models.Model):
in_calendar = models.ForeignKey(Kalender)
name = models.CharField("Terminname", max_length=100)
date = models.DateTimeField("Datum und Uhrzeit")
description = models.TextField("Beschreibung")

def is_today(self):
return self.date.date() == datetime.date.today()

is_today.short_description = "Termin findet heute statt?"

participants = models.ManyToManyField(User)

class Meta:
verbose_name_plural = "Termine"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IiaS26VAlVAJ.
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.



Problem with relationships in models

2011-07-21 Thread Oliver Schmidt
I'm trying to write my first django app, so maybe my problem is stupid. 
But I have problems in using relationships in my models.

My models.py looks like this:

   # -*- coding: utf-8 -*-
   from django.db import models
   from django.contrib.auth.models import User
   import datetime

   class Kalender(models.Model):
name = models.CharField("Kalendername", max_length=100)
description = models.TextField("Beschreibung")

class Meta:
verbose_name_plural = "Kalender"

   class Termin(models.Model):
in_calendar = models.ForeignKey(Kalender)
name = models.CharField("Terminname", max_length=100)
date = models.DateTimeField("Datum und Uhrzeit")
description = models.TextField("Beschreibung")

def is_today(self):
return self.date.date() == datetime.date.today()

is_today.short_description = "Termin findet heute statt?"

participants = models.ManyToManyField(User)

class Meta:
verbose_name_plural = "Termine"



Syncdb creates the tables without errors.
Next I configured the admin to include both classes:

   from kalender.models import *
   from django.contrib import admin

   admin.site.register(Kalender)
   admin.site.register(Termin)


The admin-interface for the class Kalender works fine, but Termin 
produces errors:



 OperationalError at /admin/kalender/termin/

(1054, "Unknown column 'kalender_termin.in_calendar_id' in 'field list'")

Traceback:

Environment:


Request Method: GET
Request URL:http://127.0.0.1:8000/admin/kalender/termin/

Django Version: 1.3
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'chor.poll',
 'chor.kalender',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in 
get_response
  111. response = callback(request, *callback_args, 
**callback_kwargs)
File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" 
in wrapper
  307. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in 
_wrapped_view
  93. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/views/decorators/cache.py" 
in _wrapped_view_func
  79. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in 
inner
  197. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in 
_wrapper
  28. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in 
_wrapped_view
  93. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in 
bound_func
  24. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" 
in changelist_view
  1159. 'selection_note': _('0 of %(cnt)s selected') % {'cnt': 
len(cl.result_list)},
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in 
__len__
  82. self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in 
iterator
  273. for row in compiler.results_iter():
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" 
in results_iter
  680. for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" 
in execute_sql
  735. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py" in 
execute
  34. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" 
in execute
  86. return self.cursor.execute(query, args)
File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py" in execute
  174. self.errorhandler(self, exc, value)
File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py" in 
defaulterrorhandler
  36. raise errorclass, errorvalue

Exception Type: OperationalError at /admin/kalender/termin/
Exception Value: (1054, "Unknown column 'kalender_termin.in_calendar_id' in 'field 
list'")



_*So what the hell am I doing wrong?
*_/Thanks for help/

--
You received