hash
stringlengths 64
64
| content
stringlengths 0
1.51M
|
---|---|
5090473026dcd47e8ae387754825e6c58903331de6b93898ef30d7ccb157c008 | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("migrations", "4_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
74ecaf38567ed73f901b398f8c81fb977ba4051fd2cb64d195cdae48c0b0a662 | from django.db import migrations
class Migration(migrations.Migration):
replaces = [
("migrations", "3_auto"),
("migrations", "4_auto"),
("migrations", "5_auto"),
]
dependencies = [("migrations", "2_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
413319169677e187c4a1127e63b5f9f9dd6142e5d4672470a010d5b47e70b30c | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("migrations", "6_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
4d75e29ea9d57d9a8567fbd5f18f394b2d7e5c43d0f4ea952ed3e3fcd9c3bad6 | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("migrations", "2_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
5c74ee548ed94360191fbd521ffe7f4a8c81be1adfb8e069a23019e520ae447b | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.DeleteModel("Tribble"),
migrations.RemoveField("Author", "silly_field"),
migrations.AddField("Author", "rating", models.IntegerField(default=0)),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
(
"author",
models.ForeignKey("migrations.Author", models.SET_NULL, null=True),
),
],
),
]
|
d0fbb65b9992c42171d7a54b8ec433b43b56e1bd0af55b13c26822559b304335 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("migrations", "0001_initial")]
operations = [
migrations.CreateModel(
"Something",
[
("id", models.AutoField(primary_key=True)),
],
)
]
|
ec5fe29f8301dd690a65ccd4d626a87028856f3367fdc41423f68b5c03bb44ee | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("migrations", "0001_initial")]
operations = [
migrations.DeleteModel("Tribble"),
migrations.RemoveField("Author", "silly_field"),
migrations.AddField("Author", "rating", models.IntegerField(default=0)),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
(
"author",
models.ForeignKey("migrations.Author", models.SET_NULL, null=True),
),
],
),
]
|
836fda63430ec3ba55d1ae36e1547f778ee1749226482a9ffcd8546d69d6c3bf | from django.db import migrations
class Migration(migrations.Migration):
initial = True
operations = []
|
b25931e053abf782d9c9f57e473d58b90d26a252d51110b1e58a978ca8e5377e | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("migrations", "0001_initial"),
]
operations = [
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
],
),
migrations.RunSQL(
["SELECT * FROM migrations_book"], ["SELECT * FROM migrations_salamander"]
),
]
|
71c2abe7674b5f49db20d77b0d4929f20eb861049d1b6ce92a80ac1a31350af1 | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("migrations", "0003_third"),
]
operations = [migrations.RunSQL("SELECT * FROM migrations_author WHERE id = 1")]
|
7cc4e3e52d27889b0a375ab1cbc831c7fdaba2fb0ca42b08a9fdc63ed7ac8620 | from django.db import migrations, models
def grow_tail(x, y):
"""Grow salamander tail."""
pass
def shrink_tail(x, y):
"""Shrink salamander tail."""
pass
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
"Salamander",
[
("id", models.AutoField(primary_key=True)),
("tail", models.IntegerField(default=0)),
("silly_field", models.BooleanField(default=False)),
],
),
migrations.RunPython(grow_tail, shrink_tail),
]
|
0b46a531609aa6b95307f4c05f23e5ccc39c75b3e61db3efed17fd414e89582e | from django.db import migrations
def grow_tail(x, y):
pass
def feed(x, y):
"""Feed salamander."""
pass
class Migration(migrations.Migration):
dependencies = [
("migrations", "0004_fourth"),
]
operations = [
migrations.RunPython(migrations.RunPython.noop),
migrations.RunPython(grow_tail),
migrations.RunPython(feed, migrations.RunPython.noop),
]
|
6b194ceda93f9fd0a56f6bd6c5bdf4c7fc9ba3355c0400738c07980e2af6fda7 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("migrations", "0002_second"),
]
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
],
),
migrations.RunSQL(
["SELECT * FROM migrations_author"], ["SELECT * FROM migrations_book"]
),
]
|
5315751e9fb276bdb341514de9a1550664eef101758b602370be768bd548eb0a | from django.db import migrations
def forwards(apps, schema_editor):
pass
class Migration(migrations.Migration):
dependencies = [
("migrations", "0001_initial"),
]
operations = [
migrations.RunPython(forwards, migrations.RunPython.noop),
]
|
4b16a276037a36e305dbd49a2c072c20a442be478f7ad5bfce81d83d43819ec8 | from django.db import migrations
def forwards(apps, schema_editor):
pass
class Migration(migrations.Migration):
dependencies = [
("migrations", "0002_second"),
]
replaces = [
("migrations", "0003_third"),
]
operations = [
migrations.AlterUniqueTogether(
name="somemodel",
unique_together={("id", "name")},
),
migrations.AlterUniqueTogether(
name="somemodel",
unique_together={("name",)},
),
migrations.RunPython(forwards, migrations.RunPython.noop),
]
|
d572fd9fda2ecdaba78b9c62818ff731fe7b1b22c92496755df9d08216f51da8 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
"SomeModel",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
],
),
]
|
d91ba0efee65b8ca3f7f9ca9f941852e4abfd4a7e86e7804c278067f739b7b6f | from django.db import migrations
def forwards(apps, schema_editor):
pass
class Migration(migrations.Migration):
dependencies = [
("migrations", "0002_second"),
]
operations = [
migrations.AlterUniqueTogether(
name="somemodel",
unique_together={("id", "name")},
),
migrations.AlterUniqueTogether(
name="somemodel",
unique_together={("name",)},
),
migrations.RunPython(forwards, migrations.RunPython.noop),
]
|
091536101993b93c646a3010c29569c89e49ef73fe43a18bb9294dcdae5dfb7c | from django.db import migrations, models
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
],
),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
(
"author",
models.ForeignKey("migrations.Author", models.SET_NULL, null=True),
),
],
),
]
|
ddc87df0dd6e9add2b34bb5acbec3d2fa4bf883faa9f2ac0861c47cdc99d8224 | from django.db import migrations, models
class Migration(migrations.Migration):
replaces = [
("migrations", "0001_initial"),
("migrations", "0002_second"),
]
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
("slug", models.SlugField(null=True)),
("age", models.IntegerField(default=0)),
("rating", models.IntegerField(default=0)),
],
),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
(
"author",
models.ForeignKey("migrations.Author", models.SET_NULL, null=True),
),
],
),
]
|
d28e8f9f8515875f9eb6f64f5c63d9c073f5e70ef2402ebd4b8a26b1dc1c0d93 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("migrations", "0001_initial"),
]
operations = [
migrations.AddField("Author", "rating", models.IntegerField(default=0)),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
(
"author",
models.ForeignKey("migrations.Author", models.SET_NULL, null=True),
),
],
),
]
|
7afa87000a4b1762a82ba21b2cd2f2bdbf6169c3156e45c0c3717dc81af158ea | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
("slug", models.SlugField(null=True)),
("age", models.IntegerField(default=0)),
("silly_field", models.BooleanField(default=False)),
],
),
migrations.CreateModel(
"Tribble",
[
("id", models.AutoField(primary_key=True)),
("fluffy", models.BooleanField(default=True)),
],
),
migrations.AlterUniqueTogether(
name="author",
unique_together={("name", "slug")},
),
]
|
33893a86950cbda535541a90202b92ac9e6cd52c5a1c11654e9ddfaea807e1d0 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="SillyModel",
fields=[
(
"id",
models.AutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
primary_key=True,
),
),
("silly_field", models.BooleanField(default=False)),
],
options={},
bases=(models.Model,),
),
]
|
c1fdc708af2d5be8af4e26a1b27fc3dfd93fcf71b9a6cd1b4edfebcd6fbfc8df | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("migrations", "0002_second"),
]
operations = [
migrations.CreateModel(
name="ModelWithCustomBase",
fields=[
(
"id",
models.AutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
primary_key=True,
),
),
],
options={},
bases=(models.Model,),
),
migrations.CreateModel(
name="UnmigratedModel",
fields=[
(
"id",
models.AutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
primary_key=True,
),
),
],
options={},
bases=(models.Model,),
),
migrations.DeleteModel(
name="Author",
),
migrations.DeleteModel(
name="Book",
),
]
|
5cad1b924f28d8e597daa6206e978320385755bb2d127f68ee6524d432ea5281 | from django.db import migrations, models
def raise_error(apps, schema_editor):
# Test atomic operation in non-atomic migration is wrapped in transaction
Editor = apps.get_model("migrations", "Editor")
Editor.objects.create(name="Test Editor")
raise RuntimeError("Abort migration")
class Migration(migrations.Migration):
atomic = False
operations = [
migrations.CreateModel(
"Editor",
[
("name", models.CharField(primary_key=True, max_length=255)),
],
),
migrations.RunPython(raise_error, reverse_code=raise_error, atomic=True),
]
|
f46799360bd051fcddfa1740b3ff9877fbfb734b19393823feebea5b1e1c8449 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("migrations", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="task",
name="projects",
field=models.ManyToManyField(to="Project"),
),
]
|
684cbf650dd847d6f09350de95ca2f51c60933a0ec933b738b02a4cdc7b7ce3d | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Project",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
],
),
migrations.CreateModel(
name="Task",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
],
),
migrations.AddField(
model_name="project",
name="tasks",
field=models.ManyToManyField(to="Task"),
),
]
|
1fedc71c8d14294f722760e3173e362f5f0a3930f4e27c9f80272971b8a58fa6 | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("migrations", "0001_initial")]
operations = []
|
829b20ff12a0f943026feec20549864658455bac9dae5fe2e7e687a43aaefed3 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
name="Entry",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=255)),
],
),
]
|
06b8b0e89201ab45c073eb3a1befbcdce36351bf74f836c313652bf7cbb711af | from django.db import models
class UnmigratedModel(models.Model):
"""
A model that is in a migration-less app (which this app is
if its migrations directory has not been repointed)
"""
pass
|
56edec0ddf88ab08a8394b774171e22786e6cc376737889a3f8440afa862567f | from django.db import models
class B1(models.Model):
pass
class B2(models.Model):
a1 = models.ForeignKey("lookuperror_a.A1", models.CASCADE)
class B3(models.Model):
pass
|
60a64569690c6ecfe9ba2f9de6266ea4b147c6203c8a560fe5907639f469aa3a | from django.db import models
class A1(models.Model):
pass
class A2(models.Model):
pass
class A3(models.Model):
b2 = models.ForeignKey("lookuperror_b.B2", models.CASCADE)
c2 = models.ForeignKey("lookuperror_c.C2", models.CASCADE)
class A4(models.Model):
pass
|
f83bfd3a69219d081e784c7d5d8ed4948042343f33afe344cf545f95b3d5b3c2 | from django.db import models
class C1(models.Model):
pass
class C2(models.Model):
a1 = models.ForeignKey("lookuperror_a.A1", models.CASCADE)
class C3(models.Model):
pass
|
86e0ec2bad01c0827383dcb31d9f5faf5ee11290e176b493a222322583810e82 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("author_app", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="Book",
fields=[
(
"id",
models.AutoField(
serialize=False, auto_created=True, primary_key=True
),
),
("title", models.CharField(max_length=50)),
("author", models.ForeignKey("author_app.Author", models.CASCADE)),
],
),
]
|
00cab7eac4d7cefd6ad838668c9174756df681abf5e0fa1f7fd272b205dd9509 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("author_app", "0001_initial"),
("book_app", "0001_initial"), # Forces the book table to alter the FK
]
operations = [
migrations.AlterField(
model_name="author",
name="id",
field=models.CharField(max_length=10, primary_key=True),
),
]
|
9bca08ca5d061379e93b0e5b411e20a16b7e32d41cd4a13abca1ab7988f0260b | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="Author",
fields=[
(
"id",
models.AutoField(
serialize=False, auto_created=True, primary_key=True
),
),
("name", models.CharField(max_length=50)),
],
),
]
|
02010c6da2cf05474f454614e3c6e467a3ce83a4dca382b1264f773574ded28e | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("unspecified_app_with_conflict", "0001_initial")]
operations = [
migrations.CreateModel(
"Something",
[
("id", models.AutoField(primary_key=True)),
],
)
]
|
137e88bf12c449050b8b25eb975138de790a7dcd1ab3df4496f0dad8f09502bc | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("unspecified_app_with_conflict", "0001_initial")]
operations = [
migrations.DeleteModel("Tribble"),
migrations.RemoveField("Author", "silly_field"),
migrations.AddField("Author", "rating", models.IntegerField(default=0)),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
],
),
]
|
59ceef0a0d5f832dd49e7308ecab662a0c3f2325cec3c5d728c59ab94eef7c57 | from django.db import migrations, models
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
"OtherAuthor",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
("slug", models.SlugField(null=True)),
("age", models.IntegerField(default=0)),
("silly_field", models.BooleanField(default=False)),
],
),
]
|
b7554abb77e8cf2a20fbca72bde4330ceab00a79b55fc59c3d128bcae631ed6a | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("conflicting_app_with_dependencies", "0001_initial"),
("migrated_app", "0001_initial"),
]
operations = [
migrations.DeleteModel("Tribble"),
migrations.RemoveField("Author", "silly_field"),
migrations.AddField("Author", "rating", models.IntegerField(default=0)),
migrations.CreateModel(
"Book",
[
("id", models.AutoField(primary_key=True)),
],
),
]
|
d4a24e7c13f9a28dc1a5545383f1c865f2f6e25ed2f2e769de620436f0968967 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("mutate_state_b", "0001_initial"),
]
operations = [
migrations.SeparateDatabaseAndState(
[],
[
migrations.CreateModel(
name="A",
fields=[
(
"id",
models.AutoField(
serialize=False,
verbose_name="ID",
auto_created=True,
primary_key=True,
),
),
],
),
],
)
]
|
ae79bf5059ea121896ff9e2879dbb9bd0c8d3a9c92238f4e664c9648213cef74 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_a", "0002_a2"),
("lookuperror_b", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="B2",
fields=[
(
"id",
models.AutoField(
primary_key=True,
verbose_name="ID",
auto_created=True,
serialize=False,
),
),
("a1", models.ForeignKey("lookuperror_a.A1", models.CASCADE)),
],
),
]
|
0b81b80967e829eaac09ee0e9317f190e19c34dfd800acf1c68a932ae4482132 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_b", "0002_b2"),
]
operations = [
migrations.CreateModel(
name="B3",
fields=[
(
"id",
models.AutoField(
verbose_name="ID",
serialize=False,
primary_key=True,
auto_created=True,
),
),
],
),
]
|
86755034baf1092c402258a4a0476e05554d1819843b83a9b11488d2f11b427e | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="B1",
fields=[
(
"id",
models.AutoField(
serialize=False,
auto_created=True,
primary_key=True,
verbose_name="ID",
),
),
],
),
]
|
354e38f910e8ef03414ab8e587dcbcba288c43679faccc400774e3e9a0255465 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_a", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="A2",
fields=[
(
"id",
models.AutoField(
verbose_name="ID",
primary_key=True,
serialize=False,
auto_created=True,
),
),
],
),
]
|
528d08a1545303774960ee6aac8a8cd9cf4e3fdc0300476a840f9baae7c6d25e | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_a", "0003_a3"),
]
operations = [
migrations.CreateModel(
name="A4",
fields=[
(
"id",
models.AutoField(
auto_created=True,
serialize=False,
verbose_name="ID",
primary_key=True,
),
),
],
),
]
|
509336c7f3355655ca0edee0f03088b0e713df2bfd95cb3f97f01b74b1fd3d35 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="A1",
fields=[
(
"id",
models.AutoField(
serialize=False,
verbose_name="ID",
auto_created=True,
primary_key=True,
),
),
],
),
]
|
344b53758a253b1d73a314c8fb19134ddcfeb6447197e06fb290f5a70216667b | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_c", "0002_c2"),
("lookuperror_b", "0002_b2"),
("lookuperror_a", "0002_a2"),
]
operations = [
migrations.CreateModel(
name="A3",
fields=[
(
"id",
models.AutoField(
serialize=False,
auto_created=True,
primary_key=True,
verbose_name="ID",
),
),
("b2", models.ForeignKey("lookuperror_b.B2", models.CASCADE)),
("c2", models.ForeignKey("lookuperror_c.C2", models.CASCADE)),
],
),
]
|
a45df7cca506eb161229a231b725fbb038c941ef1bb751fab449137638459b57 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("mutate_state_b", "0001_initial"),
]
operations = [
migrations.SeparateDatabaseAndState(
[],
[
migrations.AddField(
model_name="B",
name="added",
field=models.TextField(),
),
],
)
]
|
b916b28c7e73ca102d96b5249691995fb4d73a69f8966b3a85b346f0c312d2ad | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.SeparateDatabaseAndState(
[],
[
migrations.CreateModel(
name="B",
fields=[
(
"id",
models.AutoField(
serialize=False,
verbose_name="ID",
auto_created=True,
primary_key=True,
),
),
],
),
],
)
]
|
602d62b31fecb3473e9dfab4a681f27d93759114f5cee28975efa339da945114 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_a", "0002_a2"),
("lookuperror_c", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="C2",
fields=[
(
"id",
models.AutoField(
auto_created=True,
verbose_name="ID",
primary_key=True,
serialize=False,
),
),
("a1", models.ForeignKey("lookuperror_a.A1", models.CASCADE)),
],
),
]
|
6793e365bebe1596a5fe96a9b08b593d13f066ba920e4313ca53a74dabefbf45 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lookuperror_c", "0002_c2"),
]
operations = [
migrations.CreateModel(
name="C3",
fields=[
(
"id",
models.AutoField(
auto_created=True,
serialize=False,
verbose_name="ID",
primary_key=True,
),
),
],
),
]
|
d0190fe4c7ef653c4f82d61c4f1763bbfe3dfdf8e33ee49b5cfcf4f5f3c16151 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="C1",
fields=[
(
"id",
models.AutoField(
serialize=False,
verbose_name="ID",
auto_created=True,
primary_key=True,
),
),
],
),
]
|
43c7c34799e4c905901a45ed1ea5f5fa0185343de00d00841a408467e8b6afce | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("app1", "1_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
3001c79b3644731b42fd63c26542ff4eba85f9534eaa4cc22bc072c6a71210cf | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("app1", "3_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
369d205d443d374365f148b1b6733e2898925ca0cb5f9e192253a30dbf4bed1f | from django.db import migrations
class Migration(migrations.Migration):
replaces = [
("app1", "2_auto"),
("app1", "3_auto"),
]
dependencies = [("app1", "1_auto"), ("app2", "2_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
bcf1c5adb0af62face117b4c7076a89963bf2b505cd007b72dd4edf39ea162ef | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("app1", "2_auto"), ("app2", "2_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
c3974f518198f4bcc7bb5fc1c44979c5b84b685dc0b31a6e446e17c94a990044 | from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("app2", "1_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
c51449196e261349753dc1b47280a5e34ed663345fe06ae6e9cd260049ad0239 | from django.db import migrations
class Migration(migrations.Migration):
replaces = [
("app2", "1_auto"),
("app2", "2_auto"),
]
dependencies = [("app1", "1_auto")]
operations = [migrations.RunPython(migrations.RunPython.noop)]
|
f58a600c99116cdc553e34c1577b79f28bcdaef74828edb5c8d23dc47c556c38 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
name="fakeinitialmodel",
fields=[
("id", models.AutoField(primary_key=True)),
("field", models.CharField(max_length=20)),
(
"field_mixed_case",
models.CharField(max_length=20, db_column="FiEld_MiXeD_CaSe"),
),
(
"fake_initial_mode",
models.ManyToManyField(
"migrations.FakeInitialModel", db_table="m2m_MiXeD_CaSe"
),
),
],
options={
"db_table": "migrations_MiXeD_CaSe_MoDel",
},
),
]
|
4c09d9c6eb3c02c8b748916ede60ace6a4c1a5909e0c0834474a5b90ca19a6c8 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
"fakeinitialmodel",
[
("id", models.AutoField(primary_key=True)),
("field", models.CharField(max_length=20)),
],
options={
"db_table": "migrations_mIxEd_cAsE_mOdEl",
},
),
migrations.AddField(
model_name="fakeinitialmodel",
name="field_mixed_case",
field=models.CharField(max_length=20, db_column="fIeLd_mIxEd_cAsE"),
),
migrations.AddField(
model_name="fakeinitialmodel",
name="fake_initial_model",
field=models.ManyToManyField(
to="migrations.fakeinitialmodel", db_table="m2m_mIxEd_cAsE"
),
),
]
|
d44368cc7350f94f44139d14fe5d1dae8e2500cf836b8febbb4c74bd4779ce7e | from django.contrib.auth.models import User
from django.db import models
class Concrete(models.Model):
pass
class Proxy(Concrete):
class Meta:
proxy = True
permissions = (("display_proxys", "May display proxys information"),)
class UserProxy(User):
class Meta:
proxy = True
permissions = (("use_different_app_label", "May use a different app label"),)
|
3b7c2e3230e590c47b7e0d7e3ca59f5dc9797c20282e20f276df25689e090b7c | from .custom_permissions import CustomPermissionsUser
from .custom_user import CustomUser, CustomUserWithoutIsActiveField, ExtensionUser
from .invalid_models import CustomUserNonUniqueUsername
from .is_active import IsActiveTestUser1
from .minimal import MinimalUser
from .no_password import NoPasswordUser
from .proxy import Proxy, UserProxy
from .uuid_pk import UUIDUser
from .with_custom_email_field import CustomEmailField
from .with_foreign_key import CustomUserWithFK, Email
from .with_integer_username import IntegerUsernameUser
from .with_last_login_attr import UserWithDisabledLastLoginField
from .with_many_to_many import CustomUserWithM2M, CustomUserWithM2MThrough, Organization
__all__ = (
"CustomEmailField",
"CustomPermissionsUser",
"CustomUser",
"CustomUserNonUniqueUsername",
"CustomUserWithFK",
"CustomUserWithM2M",
"CustomUserWithM2MThrough",
"CustomUserWithoutIsActiveField",
"Email",
"ExtensionUser",
"IntegerUsernameUser",
"IsActiveTestUser1",
"MinimalUser",
"NoPasswordUser",
"Organization",
"Proxy",
"UUIDUser",
"UserProxy",
"UserWithDisabledLastLoginField",
)
|
74ddcd1edd52c433fb48aa6093ccfa64f7381b89d24a9fa2370e704d6f3e4eb6 | from django.contrib.auth.models import (
AbstractBaseUser,
AbstractUser,
BaseUserManager,
Group,
Permission,
PermissionsMixin,
UserManager,
)
from django.db import models
# The custom user uses email as the unique identifier, and requires
# that every user provide a date of birth. This lets us test
# changes in username datatype, and non-text required fields.
class CustomUserManager(BaseUserManager):
def create_user(self, email, date_of_birth, password=None, **fields):
"""
Creates and saves a User with the given email and password.
"""
if not email:
raise ValueError("Users must have an email address")
user = self.model(
email=self.normalize_email(email), date_of_birth=date_of_birth, **fields
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, password, date_of_birth, **fields):
u = self.create_user(
email, password=password, date_of_birth=date_of_birth, **fields
)
u.is_admin = True
u.save(using=self._db)
return u
class CustomUser(AbstractBaseUser):
email = models.EmailField(verbose_name="email address", max_length=255, unique=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
date_of_birth = models.DateField()
first_name = models.CharField(max_length=50)
custom_objects = CustomUserManager()
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["date_of_birth", "first_name"]
def __str__(self):
return self.email
# Maybe required?
def get_group_permissions(self, obj=None):
return set()
def get_all_permissions(self, obj=None):
return set()
def has_perm(self, perm, obj=None):
return True
def has_perms(self, perm_list, obj=None):
return True
def has_module_perms(self, app_label):
return True
# Admin required fields
@property
def is_staff(self):
return self.is_admin
class RemoveGroupsAndPermissions:
"""
A context manager to temporarily remove the groups and user_permissions M2M
fields from the AbstractUser class, so they don't clash with the
related_name sets.
"""
def __enter__(self):
self._old_au_local_m2m = AbstractUser._meta.local_many_to_many
self._old_pm_local_m2m = PermissionsMixin._meta.local_many_to_many
groups = models.ManyToManyField(Group, blank=True)
groups.contribute_to_class(PermissionsMixin, "groups")
user_permissions = models.ManyToManyField(Permission, blank=True)
user_permissions.contribute_to_class(PermissionsMixin, "user_permissions")
PermissionsMixin._meta.local_many_to_many = [groups, user_permissions]
AbstractUser._meta.local_many_to_many = [groups, user_permissions]
def __exit__(self, exc_type, exc_value, traceback):
AbstractUser._meta.local_many_to_many = self._old_au_local_m2m
PermissionsMixin._meta.local_many_to_many = self._old_pm_local_m2m
class CustomUserWithoutIsActiveField(AbstractBaseUser):
username = models.CharField(max_length=150, unique=True)
email = models.EmailField(unique=True)
objects = UserManager()
USERNAME_FIELD = "username"
# The extension user is a simple extension of the built-in user class,
# adding a required date_of_birth field. This allows us to check for
# any hard references to the name "User" in forms/handlers etc.
with RemoveGroupsAndPermissions():
class ExtensionUser(AbstractUser):
date_of_birth = models.DateField()
custom_objects = UserManager()
REQUIRED_FIELDS = AbstractUser.REQUIRED_FIELDS + ["date_of_birth"]
|
a2e724f85e3f37e9e436f93b513e0be59d778c6d4f7646cb3af48e84b30cd694 | """
The CustomPermissionsUser users email as the identifier, but uses the normal
Django permissions model. This allows us to check that the PermissionsMixin
includes everything that is needed to interact with the ModelBackend.
"""
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db import models
from .custom_user import CustomUserManager, RemoveGroupsAndPermissions
class CustomPermissionsUserManager(CustomUserManager):
def create_superuser(self, email, password, date_of_birth):
u = self.create_user(email, password=password, date_of_birth=date_of_birth)
u.is_superuser = True
u.save(using=self._db)
return u
with RemoveGroupsAndPermissions():
class CustomPermissionsUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
verbose_name="email address", max_length=255, unique=True
)
date_of_birth = models.DateField()
custom_objects = CustomPermissionsUserManager()
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["date_of_birth"]
def __str__(self):
return self.email
|
b6bb488bb61c07b563570f8c67ea3f8cc92977128632f477d04f72a66888ec11 | import uuid
from django.contrib.auth.models import AbstractUser
from django.db import models
from .custom_user import RemoveGroupsAndPermissions
with RemoveGroupsAndPermissions():
class UUIDUser(AbstractUser):
"""A user with a UUID as primary key"""
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
2a76e67477eb7c358798aa45a46487c4145e9642555350c7fe879a492b4fe0c0 | from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
from django.db import models
class IsActiveTestUser1(AbstractBaseUser):
"""
This test user class and derivatives test the default is_active behavior
"""
username = models.CharField(max_length=30, unique=True)
custom_objects = BaseUserManager()
USERNAME_FIELD = "username"
# the is_active attr is provided by AbstractBaseUser
|
502884036587c20eb326586f250a725e89d08db6994258f438f7a8a55b139463 | from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import BaseUserManager
from django.db import models
class CustomEmailFieldUserManager(BaseUserManager):
def create_user(self, username, password, email):
user = self.model(username=username)
user.set_password(password)
user.email_address = email
user.save(using=self._db)
return user
class CustomEmailField(AbstractBaseUser):
username = models.CharField(max_length=255)
password = models.CharField(max_length=255)
email_address = models.EmailField(null=True)
is_active = models.BooleanField(default=True)
EMAIL_FIELD = "email_address"
USERNAME_FIELD = "username"
objects = CustomEmailFieldUserManager()
|
0ca0cad0eaeadeae5761b23d70d5f31003b9f423f22af4411322fab5972c984d | from django.db import models
class MinimalUser(models.Model):
REQUIRED_FIELDS = ()
USERNAME_FIELD = "id"
|
cf94629fb920181487226d7d2264b1e34ed2c94f18b170e84a7c384d2b08940e | from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
from django.db import models
class Organization(models.Model):
name = models.CharField(max_length=255)
class CustomUserWithM2MManager(BaseUserManager):
def create_superuser(self, username, orgs, password):
user = self.model(username=username)
user.set_password(password)
user.save(using=self._db)
user.orgs.add(*orgs)
return user
class CustomUserWithM2M(AbstractBaseUser):
username = models.CharField(max_length=30, unique=True)
orgs = models.ManyToManyField(Organization)
custom_objects = CustomUserWithM2MManager()
USERNAME_FIELD = "username"
REQUIRED_FIELDS = ["orgs"]
class CustomUserWithM2MThrough(AbstractBaseUser):
username = models.CharField(max_length=30, unique=True)
orgs = models.ManyToManyField(Organization, through="Membership")
custom_objects = CustomUserWithM2MManager()
USERNAME_FIELD = "username"
REQUIRED_FIELDS = ["orgs"]
class Membership(models.Model):
user = models.ForeignKey(CustomUserWithM2MThrough, on_delete=models.CASCADE)
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
aeccf4871c96eff48641cc6e313000e4bf312920f28d6800f95c4ebd1937716a | from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, Group
from django.db import models
class Email(models.Model):
email = models.EmailField(verbose_name="email address", max_length=255, unique=True)
class CustomUserWithFKManager(BaseUserManager):
def create_superuser(self, username, email, group, password):
user = self.model(username_id=username, email_id=email, group_id=group)
user.set_password(password)
user.save(using=self._db)
return user
class CustomUserWithFK(AbstractBaseUser):
username = models.ForeignKey(Email, models.CASCADE, related_name="primary")
email = models.ForeignKey(
Email, models.CASCADE, to_field="email", related_name="secondary"
)
group = models.ForeignKey(Group, models.CASCADE)
custom_objects = CustomUserWithFKManager()
USERNAME_FIELD = "username"
REQUIRED_FIELDS = ["email", "group"]
|
3d081b8930035f36e773bcff992ece557f2d281fef00c7ce19386d071f3b8145 | from django.contrib.auth.models import AbstractBaseUser, UserManager
from django.db import models
class CustomUserNonUniqueUsername(AbstractBaseUser):
"""
A user with a non-unique username.
This model is not invalid if it is used with a custom authentication
backend which supports non-unique usernames.
"""
username = models.CharField(max_length=30)
email = models.EmailField(blank=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
USERNAME_FIELD = "username"
REQUIRED_FIELDS = ["email"]
objects = UserManager()
|
1f9bfe15820d979c3359a79b7f6cbdc57f5d61ffc9b4054fff2772c1ddffa7c7 | from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
from django.db import models
class IntegerUsernameUserManager(BaseUserManager):
def create_user(self, username, password):
user = self.model(username=username)
user.set_password(password)
user.save(using=self._db)
return user
def get_by_natural_key(self, username):
return self.get(username=username)
class IntegerUsernameUser(AbstractBaseUser):
username = models.IntegerField()
password = models.CharField(max_length=255)
USERNAME_FIELD = "username"
REQUIRED_FIELDS = ["username", "password"]
objects = IntegerUsernameUserManager()
|
6e1076c1bbc64d49fc64be75582af5c10d54f142d8089f13a12cb3dc01f7c63a | from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
from django.db import models
class UserManager(BaseUserManager):
def _create_user(self, username, **extra_fields):
user = self.model(username=username, **extra_fields)
user.save(using=self._db)
return user
def create_superuser(self, username=None, **extra_fields):
return self._create_user(username, **extra_fields)
class NoPasswordUser(AbstractBaseUser):
password = None
last_login = None
username = models.CharField(max_length=50, unique=True)
USERNAME_FIELD = "username"
objects = UserManager()
|
759c289b3472a3c6ccf424959e79f56cd582e3a982a8f80ef82423e54edd3e50 | # Import all the models from subpackages
from .article import Article
from .publication import Publication
__all__ = ["Article", "Publication"]
|
217c8467720ef86ebeee2a3a63582dec39d5f02516e6cd99243560069c2f9df4 | """
Doctest example from the official Python documentation.
https://docs.python.org/library/doctest.html
"""
def factorial(n):
"""Return the factorial of n, an exact integer >= 0.
>>> [factorial(n) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> factorial(30) # doctest: +ELLIPSIS
265252859812191058636308480000000...
>>> factorial(-1)
Traceback (most recent call last):
...
ValueError: n must be >= 0
Factorials of floats are OK, but the float must be an exact integer:
>>> factorial(30.1)
Traceback (most recent call last):
...
ValueError: n must be exact integer
>>> factorial(30.0) # doctest: +ELLIPSIS
265252859812191058636308480000000...
It must also not be ridiculously large:
>>> factorial(1e100)
Traceback (most recent call last):
...
OverflowError: n too large
"""
import math
if not n >= 0:
raise ValueError("n must be >= 0")
if math.floor(n) != n:
raise ValueError("n must be exact integer")
if n + 1 == n: # catch a value like 1e300
raise OverflowError("n too large")
result = 1
factor = 2
while factor <= n:
result *= factor
factor += 1
return result
|
6289bc4426adbc41282e6eb1a28f4aa442e36c5090ccea8fe313caf9dbcdf101 | import doctest
from unittest import TestCase
from django.test import SimpleTestCase
from django.test import TestCase as DjangoTestCase
from . import doctests
class TestVanillaUnittest(TestCase):
def test_sample(self):
self.assertEqual(1, 1)
class TestDjangoTestCase(DjangoTestCase):
def test_sample(self):
self.assertEqual(1, 1)
class TestZimpleTestCase(SimpleTestCase):
# Z is used to trick this test case to appear after Vanilla in default suite
def test_sample(self):
self.assertEqual(1, 1)
class EmptyTestCase(TestCase):
pass
def load_tests(loader, tests, ignore):
tests.addTests(doctest.DocTestSuite(doctests))
return tests
|
aba0a77f19ed122a75c15bbb0d920791ab7e5d78ea4abca1fb1c6bf9896c4e0c | from unittest import TestCase
class Test(TestCase):
def test_sample(self):
self.assertEqual(1, 1)
|
1d0fad8b0a8f32c760dd95b77934c87b3407f1cbbeaaf756fdd95df0d81692c9 | from unittest import TestCase
from django.test import SimpleTestCase
from django.test import TestCase as DjangoTestCase
class DjangoCase1(DjangoTestCase):
def test_1(self):
pass
def test_2(self):
pass
class DjangoCase2(DjangoTestCase):
def test_1(self):
pass
def test_2(self):
pass
class SimpleCase1(SimpleTestCase):
def test_1(self):
pass
def test_2(self):
pass
class SimpleCase2(SimpleTestCase):
def test_1(self):
pass
def test_2(self):
pass
class UnittestCase1(TestCase):
def test_1(self):
pass
def test_2(self):
pass
class UnittestCase2(TestCase):
def test_1(self):
pass
def test_2(self):
pass
def test_3_test(self):
pass
|
4d9ea8b40723347782d392736dc499f8d10c57f70437b4aa5930280bee73a73f | import sys
from unittest import TestCase
class WriteToStdoutStderrTestCase(TestCase):
def test_pass(self):
sys.stderr.write("Write to stderr.")
sys.stdout.write("Write to stdout.")
self.assertTrue(True)
def test_fail(self):
sys.stderr.write("Write to stderr.")
sys.stdout.write("Write to stdout.")
self.assertTrue(False)
|
688eb2b5f033003aee8a34a9bd0ea25f64a94a9a98bb7309f74cb06f5dfa8501 | from unittest import TestCase
from django.test import tag
@tag("slow")
class TaggedTestCase(TestCase):
@tag("fast")
def test_single_tag(self):
self.assertEqual(1, 1)
@tag("fast", "core")
def test_multiple_tags(self):
self.assertEqual(1, 1)
|
2a3cebf59a8a282905472882211fcd091ba9480c2794973b4ab6cddbdfd6bc97 | from unittest import TestCase
from django.test import tag
@tag("foo")
class FooBase(TestCase):
pass
class Foo(FooBase):
def test_no_new_tags(self):
pass
@tag("baz")
def test_new_func_tag(self):
pass
@tag("bar")
class FooBar(FooBase):
def test_new_class_tag_only(self):
pass
@tag("baz")
def test_new_class_and_func_tags(self):
pass
|
3282d772f7a9add92330aa15ea63efdc619a0fd110054299f3011d8858eda3fc | import unittest
class NoDatabaseTests(unittest.TestCase):
def test_nothing(self):
pass
class DefaultDatabaseTests(NoDatabaseTests):
databases = {"default"}
class DefaultDatabaseSerializedTests(NoDatabaseTests):
databases = {"default"}
serialized_rollback = True
class OtherDatabaseTests(NoDatabaseTests):
databases = {"other"}
class AllDatabasesTests(NoDatabaseTests):
databases = "__all__"
|
5b4a74313d9d7c1aa27dd2e31cd5473c20b792cef00d90848eb06d33bedfaade | from unittest import TestCase, expectedFailure
class FailureTestCase(TestCase):
def test_sample(self):
self.assertEqual(0, 1)
class ErrorTestCase(TestCase):
def test_sample(self):
raise Exception("test")
class ExpectedFailureTestCase(TestCase):
@expectedFailure
def test_sample(self):
self.assertEqual(0, 1)
class UnexpectedSuccessTestCase(TestCase):
@expectedFailure
def test_sample(self):
self.assertEqual(1, 1)
|
1cf446a01795ad4d5a40b459a1ea66f9a0e5cd04af684e96b2c04e22faf78042 | from unittest import TestCase
class Test(TestCase):
def test_sample(self):
pass
|
9d6cb9cee4e44305fc8caa40b63c929f5eeec1848cdad03bc38eaa8f45f98ea3 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="Book",
fields=[
(
"id",
models.AutoField(
verbose_name="ID",
primary_key=True,
serialize=False,
auto_created=True,
),
),
("title", models.CharField(max_length=100)),
],
options={},
bases=(models.Model,),
),
]
|
badc385ce7f3bc0c72452c9c201f8329cf6b081cff92c61489df54f5bff127f1 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
subparsers_1 = parser.add_subparsers(dest="subcommand_1")
parser_foo_1 = subparsers_1.add_parser("foo_1")
subparsers_2 = parser_foo_1.add_subparsers(dest="subcommand_2")
parser_foo_2 = subparsers_2.add_parser("foo_2")
parser_foo_2.add_argument("--bar", required=True)
def handle(self, *args, **options):
self.stdout.write(",".join(options))
|
5c119a2ca3b25f6cef5b0cb7eaf27fccb5851076745ca99b084f5da02891f0f4 | from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = "Dance around like a madman."
args = ""
requires_system_checks = "__all__"
def add_arguments(self, parser):
parser.add_argument("integer", nargs="?", type=int, default=0)
parser.add_argument("-s", "--style", default="Rock'n'Roll")
parser.add_argument("-x", "--example")
parser.add_argument("--opt-3", action="store_true", dest="option3")
def handle(self, *args, **options):
example = options["example"]
if example == "raise":
raise CommandError(returncode=3)
if options["verbosity"] > 0:
self.stdout.write("I don't feel like dancing %s." % options["style"])
self.stdout.write(",".join(options))
if options["integer"] > 0:
self.stdout.write(
"You passed %d as a positional argument." % options["integer"]
)
|
b54f89fab55a16379ff8554226da7b22b4eb70cce9be6f0566c6c3efb78340c6 | from django.core.management.base import BaseCommand
from django.urls import reverse
class Command(BaseCommand):
"""
This command returns a URL from a reverse() call.
"""
def handle(self, *args, **options):
return reverse("some_url")
|
c6c68491c6b39593d9865e9357534775696e98ba7ad61e1a7b5185145c92651f | from django.core.management.base import BaseCommand, no_translations
from django.utils import translation
class Command(BaseCommand):
@no_translations
def handle(self, *args, **options):
return translation.get_language()
|
932d9b5a99ab0269cea8bfadca3d5b2c9fb7593dccc0523934a54c273b181548 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Say hello."
args = ""
output_transaction = True
def handle(self, *args, **options):
return "Hello!"
|
71313cb59ee2e97cfa1e1fbc6ef954f94059c25ec2e7ea6b417e90bd5101341f | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("-n", "--need-me", required=True)
parser.add_argument("-t", "--need-me-too", required=True, dest="needme2")
def handle(self, *args, **options):
self.stdout.write(",".join(options))
|
4c7ce0444ca4d8490592de529e902ca389503eddf84e2d41ce28db4e07bcc0bc | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
subparsers = parser.add_subparsers()
parser_foo = subparsers.add_parser("foo")
parser_foo.add_argument("bar", type=int)
def handle(self, *args, **options):
self.stdout.write(",".join(options))
|
361571c4ca0081f1a9523de83efb9f4d750ce8be22d5f480c7f6548bc76ce6d8 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--for", dest="until", action="store")
group.add_argument("--until", action="store")
def handle(self, *args, **options):
for option, value in options.items():
if value is not None:
self.stdout.write("%s=%s" % (option, value))
|
0b94bc31fb5a72f794737fd7720a13541f8189b1ae6e4ab8989dbe71f62cbbdd | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
subparsers = parser.add_subparsers(dest="subcommand", required=True)
parser_foo = subparsers.add_parser("foo")
parser_foo.add_argument("--bar")
def handle(self, *args, **options):
self.stdout.write(",".join(options))
|
f11e89e93ae83ffd9abcdbe45f72db77906c4fe4777b1c616a4c265dba04411c | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def handle(self, **options):
self.stdout.write("Working...")
self.stdout.flush()
self.stdout.write("OK")
|
f977da1b923ca5eb5aa2c30e56156e82a4f5484f0ae2b9be349b911b58235949 | from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = "Useless command."
def add_arguments(self, parser):
parser.add_argument(
"args",
metavar="app_label",
nargs="*",
help="Specify the app label(s) to works on.",
)
parser.add_argument("--empty", action="store_true", help="Do nothing.")
def handle(self, *app_labels, **options):
app_labels = set(app_labels)
if options["empty"]:
self.stdout.write()
self.stdout.write("Dave, I can't do that.")
return
if not app_labels:
raise CommandError("I'm sorry Dave, I'm afraid I can't do that.")
# raise an error if some --parameter is flowing from options to args
for app_label in app_labels:
if app_label.startswith("--"):
raise CommandError("Sorry, Dave, I can't let you do that.")
self.stdout.write("Dave, my mind is going. I can feel it. I can feel it.")
|
5e0f475de123eea021caeb048266bfeec14e53ca8d4189f9a0093300ed9a67d6 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("--set")
def handle(self, **options):
self.stdout.write("Set %s" % options["set"])
|
531920d39b96ae5ff45b0733d6d7709e789e7266ad130192d7f086592588c55f | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
"--append_const",
action="append_const",
const=42,
required=True,
)
parser.add_argument("--const", action="store_const", const=31, required=True)
parser.add_argument("--count", action="count", required=True)
parser.add_argument("--flag_false", action="store_false", required=True)
parser.add_argument("--flag_true", action="store_true", required=True)
def handle(self, *args, **options):
for option, value in options.items():
if value is not None:
self.stdout.write("%s=%s" % (option, value))
|
37aaac345a3f6afbcfbd56fe664c2bff7583d871dfc79459166d0001ab73a36d | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--foo-id", type=int, nargs="?", default=None)
group.add_argument("--foo-name", type=str, nargs="?", default=None)
group.add_argument("--foo-list", type=int, nargs="+")
group.add_argument("--append_const", action="append_const", const=42)
group.add_argument("--const", action="store_const", const=31)
group.add_argument("--count", action="count")
group.add_argument("--flag_false", action="store_false")
group.add_argument("--flag_true", action="store_true")
def handle(self, *args, **options):
for option, value in options.items():
if value is not None:
self.stdout.write("%s=%s" % (option, value))
|
8dde60d830fbd8ba77e6c79f901d20aa93866b63cc8945722acdda24346a33d3 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("--foo-list", nargs="+", type=int, required=True)
def handle(self, *args, **options):
for option, value in options.items():
self.stdout.write("%s=%s" % (option, value))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.