mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Fixed #22563: Added migration to admin, fixed a few more loader issues.
This commit is contained in:
		
							
								
								
									
										36
									
								
								django/contrib/admin/migrations/0001_initial.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								django/contrib/admin/migrations/0001_initial.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | from __future__ import unicode_literals | ||||||
|  |  | ||||||
|  | from django.db import models, migrations | ||||||
|  | from django.conf import settings | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  |  | ||||||
|  |     dependencies = [ | ||||||
|  |         migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||||||
|  |         ('contenttypes', '__latest__'), | ||||||
|  |     ] | ||||||
|  |  | ||||||
|  |     operations = [ | ||||||
|  |         migrations.CreateModel( | ||||||
|  |             name='LogEntry', | ||||||
|  |             fields=[ | ||||||
|  |                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||||||
|  |                 ('action_time', models.DateTimeField(auto_now=True, verbose_name='action time')), | ||||||
|  |                 ('object_id', models.TextField(null=True, verbose_name='object id', blank=True)), | ||||||
|  |                 ('object_repr', models.CharField(max_length=200, verbose_name='object repr')), | ||||||
|  |                 ('action_flag', models.PositiveSmallIntegerField(verbose_name='action flag')), | ||||||
|  |                 ('change_message', models.TextField(verbose_name='change message', blank=True)), | ||||||
|  |                 ('content_type', models.ForeignKey(to_field='id', blank=True, to='contenttypes.ContentType', null=True)), | ||||||
|  |                 ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, to_field='id')), | ||||||
|  |             ], | ||||||
|  |             options={ | ||||||
|  |                 'ordering': ('-action_time',), | ||||||
|  |                 'db_table': 'django_admin_log', | ||||||
|  |                 'verbose_name': 'log entry', | ||||||
|  |                 'verbose_name_plural': 'log entries', | ||||||
|  |             }, | ||||||
|  |             bases=(models.Model,), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										0
									
								
								django/contrib/admin/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								django/contrib/admin/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -205,7 +205,7 @@ class MigrationAutodetector(object): | |||||||
|                         elif dep[0] != app_label: |                         elif dep[0] != app_label: | ||||||
|                             # External app dependency. See if it's not yet |                             # External app dependency. See if it's not yet | ||||||
|                             # satisfied. |                             # satisfied. | ||||||
|                             for other_operation in self.generated_operations[dep[0]]: |                             for other_operation in self.generated_operations.get(dep[0], []): | ||||||
|                                 if self.check_dependency(other_operation, dep): |                                 if self.check_dependency(other_operation, dep): | ||||||
|                                     deps_satisfied = False |                                     deps_satisfied = False | ||||||
|                                     break |                                     break | ||||||
|   | |||||||
| @@ -135,7 +135,7 @@ class MigrationLoader(object): | |||||||
|             return self.disk_migrations[results[0]] |             return self.disk_migrations[results[0]] | ||||||
|  |  | ||||||
|     def check_key(self, key, current_app): |     def check_key(self, key, current_app): | ||||||
|         if key[1] != "__first__" or key in self.graph: |         if (key[1] != "__first__" and key[1] != "__latest__") or key in self.graph: | ||||||
|             return key |             return key | ||||||
|         # Special-case __first__, which means "the first migration" for |         # Special-case __first__, which means "the first migration" for | ||||||
|         # migrated apps, and is ignored for unmigrated apps. It allows |         # migrated apps, and is ignored for unmigrated apps. It allows | ||||||
| @@ -151,7 +151,10 @@ class MigrationLoader(object): | |||||||
|             return |             return | ||||||
|         if key[0] in self.migrated_apps: |         if key[0] in self.migrated_apps: | ||||||
|             try: |             try: | ||||||
|                 return list(self.graph.root_nodes(key[0]))[0] |                 if key[1] == "__first__": | ||||||
|  |                     return list(self.graph.root_nodes(key[0]))[0] | ||||||
|  |                 else: | ||||||
|  |                     return list(self.graph.root_nodes(key[0]))[-1] | ||||||
|             except IndexError: |             except IndexError: | ||||||
|                 raise ValueError("Dependency on app with no migrations: %s" % key[0]) |                 raise ValueError("Dependency on app with no migrations: %s" % key[0]) | ||||||
|         raise ValueError("Dependency on unknown app: %s" % key[0]) |         raise ValueError("Dependency on unknown app: %s" % key[0]) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user