[mezzanine-users] Field Injection Will Not Migrate

2015-11-19 Thread R.J. Jackson
Hello, so I have worked with Django for over a year now, and wanted to give 
Mezzanine a try but I have not gotten far with it.  I'm just doing some 
Field Injections and when I run a migrate command I get an error.


*settings.py*

EXTRA_MODEL_FIELDS = (
(   "mezzanine.blog.models.BlogPost.featured_post",
"BooleanField",
("Featured Post",),
{"blank": False, "null": False, "default": False},
),
)


Operations to perform:
  Synchronize unmigrated apps: customize, boot, filebrowser_safe, sitemaps, 
staticfiles, grappelli_safe
  Apply all migrations: core, redirects, django_comments, sessions, admin, 
twitter, galleries, sites, auth, blog, generic, contenttypes, conf, forms, 
pages
Synchronizing apps without migrations:
  Creating tables...
Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying blog.0007_auto_20151119_0048...Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_from_command_line(sys.argv)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 354, in execute_from_command_line
utility.execute()
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 394, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 445, in execute
output = self.handle(*args, **options)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
 
line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, 
fake_initial=fake_initial)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 148, in apply_migration
state = migration.apply(state, schema_editor)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/migrations/migration.py",
 
line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py",
 
line 62, in database_forwards
field,
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py",
 
line 179, in add_field
self._remake_table(model, create_fields=[field])
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py",
 
line 77, in _remake_table
self.effective_default(field)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py",
 
line 211, in effective_default
default = field.get_db_prep_save(default, self.connection)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
 
line 710, in get_db_prep_save
prepared=False)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
 
line 1482, in get_db_prep_value
value = self.get_prep_value(value)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
 
line 1461, in get_prep_value
value = super(DateTimeField, self).get_prep_value(value)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
 
line 1317, in get_prep_value
return self.to_python(value)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
 
line 1420, in to_python
parsed = parse_datetime(value)
  File 
"/home/project/newenv/local/lib/python2.7/site-packages/django/utils/dateparse.py",
 
line 93, in parse_datetime
match = datetime_re.match(value)
TypeError: expected string or buffer


I have tried removing the code in the settings.py and running 
makemigration/migrate command but I continue to get the same error.  I have 
tried starting a new mezzanine project and still I get the same error.  I 
have been stuck on this for the past day.  Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Field Injection Will Not Migrate

2015-11-19 Thread Eduardo Rivas
It looks like you have a migration file inside Mezzanine's source code. 
If you see the name of the migration that raises the exception, it's 
blog.0007_auto_20151119 (meaning it was created on November 19, 2015, by 
your injected field I presume). Remove that file and the associated .pyc 
file and Mezzanine should go back to normal.


Now, regarding field injection in Mezzanine 4, it's not as simple as it 
was in the Mezzanine 3 days. There are essentially two ways of doing it: 
One is explained by the official docs 
, 
and the other is a method developed by Josh Cartmell 
 (look for the 
field injection section in that article). I use the first one, as it is 
less brittle and somewhat supported by Django itself. It is not as 
elegant though, and will require you to manually maintain the migration 
history of all models with injected fields and any model that inherits 
from them.


Both methods have the same goal: to make sure that the migrations for 
your injected fields exist in your project, not in Mezzanine's source. 
Doing otherwise is a nightmare for collaborating with other devs and 
deploying.


--
You received this message because you are subscribed to the Google Groups "Mezzanine 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Field Injection Will Not Migrate

2015-11-19 Thread Sam Kingston
I just wanted to add there is a third way of doing this, and that is creating a 
model in your own app and adding a OneToOne field to the Blog model. I now use 
that method exclusively instead of EXTRA_MODEL_FIELDS and it is much cleaner 
and easier to maintain. 

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Field Injection Will Not Migrate

2015-11-20 Thread R.J. Jackson
Yes you were dead on, I just deleted the migrations and it worked fine.

On Thursday, November 19, 2015 at 4:37:15 PM UTC-5, Eduardo Rivas wrote:
>
> It looks like you have a migration file inside Mezzanine's source code. If 
> you see the name of the migration that raises the exception, it's 
> blog.0007_auto_20151119 (meaning it was created on November 19, 2015, by 
> your injected field I presume). Remove that file and the associated .pyc 
> file and Mezzanine should go back to normal.
>
> Now, regarding field injection in Mezzanine 4, it's not as simple as it 
> was in the Mezzanine 3 days. There are essentially two ways of doing it: 
> One is explained by the official docs 
> ,
>  
> and the other is a method developed by Josh Cartmell 
>  (look for the 
> field injection section in that article). I use the first one, as it is 
> less brittle and somewhat supported by Django itself. It is not as elegant 
> though, and will require you to manually maintain the migration history of 
> all models with injected fields and any model that inherits from them.
>
> Both methods have the same goal: to make sure that the migrations for your 
> injected fields exist in your project, not in Mezzanine's source. Doing 
> otherwise is a nightmare for collaborating with other devs and deploying.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Field Injection Will Not Migrate

2015-11-20 Thread R.J. Jackson
Thanks! Ill keep this in mind next time.  i managed to get the Field 
Injection to work.

On Thursday, November 19, 2015 at 8:23:24 PM UTC-5, Sam Kingston wrote:
>
> I just wanted to add there is a third way of doing this, and that is 
> creating a model in your own app and adding a OneToOne field to the Blog 
> model. I now use that method exclusively instead of EXTRA_MODEL_FIELDS and 
> it is much cleaner and easier to maintain. 

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.