Hi, 
the errors disappear when the models.py file is changed by adding _id to 
the fields defined for the tables where the errors are exist.

As an example for one table I changed


class AuthUserUserPermissions(
models.Model):
    user = models.ForeignKey(AuthUser)
    permission = models.ForeignKey(AuthPermission)

    class Meta:
        db_table = 'auth_user_user_permissions'
        unique_together = ['user_id', 'permission_id']

to 

class AuthUserUserPermissions(models.Model):
    user_id = models.ForeignKey(AuthUser)
    permission_id = models.ForeignKey(AuthPermission)

    class Meta:
        db_table = 'auth_user_user_permissions'
        unique_together = ['user_id', 'permission_id']

For some reason when the code for the django tables is generated it does 
not use the correct field names.

Only the other errors left.

Christoph

On Wednesday, October 21, 2015 at 1:11:40 PM UTC+2, Christoph Knapp wrote:
>
> Hi, 
> I have the same problem. 
>
> The models.py file was created by 
>
> python manage.py inspectdb > models.py
>
> I just copied it over into my app and modified it. My output is 
>
> readDatabase.AuthGroupPermissions: (models.E012) 'unique_together' refers 
> to the non-existent field 'group_id'.
> readDatabase.AuthGroupPermissions: (models.E012) 'unique_together' refers 
> to the non-existent field 'permission_id'.
> readDatabase.AuthPermission: (models.E012) 'unique_together' refers to the 
> non-existent field 'content_type_id'.
> readDatabase.AuthUserGroups: (models.E012) 'unique_together' refers to the 
> non-existent field 'group_id'.
> readDatabase.AuthUserGroups: (models.E012) 'unique_together' refers to the 
> non-existent field 'user_id'.
> readDatabase.AuthUserUserPermissions: (models.E012) 'unique_together' 
> refers to the non-existent field 'permission_id'.
> readDatabase.AuthUserUserPermissions: (models.E012) 'unique_together' 
> refers to the non-existent field 'user_id'.
> readDatabase.Messwerte: (models.E004) 'id' can only be used as a field 
> name if the field also sets 'primary_key=True'.
> readDatabase.Modifikationen: (models.E004) 'id' can only be used as a 
> field name if the field also sets 'primary_key=True'.
> readDatabase.ProteinSequences: (models.E004) 'id' can only be used as a 
> field name if the field also sets 'primary_key=True'.
>
> The last three messages are from tables which were in the original db. All 
> other messages come from tables created by django. I'm using postgresql and 
> confirmed that all tables were created in my database. Below is the output 
> of postgres \dt command to show all tables in the database. This happens 
> when I migrate (python manage.py migrate) the changes.
>
>  variantendatenbank=# \dt
>                       Liste der Relationen
>  Schema |            Name            |   Typ   |   Eigentümer    
> --------+----------------------------+---------+-----------------
>  public | auth_group                 | Tabelle | christoph_knapp
>  public | auth_group_permissions     | Tabelle | christoph_knapp
>  public | auth_permission            | Tabelle | christoph_knapp
>  public | auth_user                  | Tabelle | christoph_knapp
>  public | auth_user_groups           | Tabelle | christoph_knapp
>  public | auth_user_user_permissions | Tabelle | christoph_knapp
>  public | b_ids                      | Tabelle | christoph_knapp
>  public | bedingungen                | Tabelle | christoph_knapp
>  public | django_admin_log           | Tabelle | christoph_knapp
>  public | django_content_type        | Tabelle | christoph_knapp
>  public | django_migrations          | Tabelle | christoph_knapp
>  public | django_session             | Tabelle | christoph_knapp
>  public | messwerte                  | Tabelle | christoph_knapp
>  public | modifikationen             | Tabelle | christoph_knapp
>  public | protein_information        | Tabelle | christoph_knapp
>  public | protein_sequences          | Tabelle | christoph_knapp
>  public | substrate                  | Tabelle | christoph_knapp
> (17 Zeilen)
>
> If anyone could help with the errors from the django tables (maybe also 
> with the problems on my tables)?
>
> I only started yesterday to use django, so let me know if you need 
> anything else.
>
> Christoph
>  
> On Monday, September 14, 2015 at 7:51:58 PM UTC+2, Dmitry Homenok wrote:
>>
>> Hey John,
>>
>> Agree with James. makemigrations command doesn't create models.py file - 
>> it's on your plate. But after creating models.py file and filling it with 
>> your models - you have to create migration file with makemigrations command 
>> and run migrate one to create all required tables, fk, etc.
>>
>> - Dmitry
>>
>> On Friday, September 11, 2015 at 10:42:03 PM UTC+3, John Emmatty wrote:
>>>
>>> I ran makemigrations against my legacy, MySQL database and it created 
>>> models.py file for me, I copied the file to my applications package 
>>> directory and ran makemigrations again after adding a table to extend the 
>>> default users table. Now makemigrations is throwing following errors . I 
>>> created a fresh django project which had no reference to older versions.
>>>
>>> SystemCheckError: System check identified some issues:
>>>
>>>     ERRORS:
>>>     djangogettrix.AuthGroupPermissions: (models.E012) 'unique_together' 
>>> refers to the non-existent field 'group_id'.
>>>     djangogettrix.AuthGroupPermissions: (models.E012) 'unique_together' 
>>> refers to the non-existent field 'permission_id'.
>>>     djangogettrix.AuthPermission: (models.E012) 'unique_together' refers 
>>> to the non-existent field 'content_type_id'.
>>>     djangogettrix.AuthUserGroups: (models.E012) 'unique_together' refers 
>>> to the non-existent field 'group_id'.
>>>     djangogettrix.AuthUserGroups: (models.E012) 'unique_together' refers 
>>> to the non-existent field 'user_id'.
>>>     djangogettrix.AuthUserUserPermissions: (models.E012) 
>>> 'unique_together' refers to the non-existent field 'permission_id'.
>>>     djangogettrix.AuthUserUserPermissions: (models.E012) 
>>> 'unique_together' refers to the non-existent field 'user_id'.
>>>     djangogettrix.RolesUsers: (models.E012) 'unique_together' refers to 
>>> the non-existent field 'role_id'.
>>>     djangogettrix.RolesUsers: (models.E012) 'unique_together' refers to 
>>> the non-existent field 'user_id'.
>>>
>>> Kindly help me by throwing some light on this.
>>>
>>

-- 
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/79a3e181-3ebe-4346-ad57-54a13d71b237%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to