{% csrf_token %}

2017-09-26 Thread Alex Kleider
I'm using test driven development (going through Harry J.W. Percival's book) and have found that the following code fails because the template tag ( {% csrf_token %} ) is rendered by the home_page view function but not by the django.template.loader.render_to_string function (and so the assertEq

different behaviour of datetime.datetime object before vs after save

2015-09-23 Thread Alex Kleider
I'm baffled by the fact that the __str__ method of an instance fails before the instance is saved but works fine afterwards. The relevant snippet from my models.py file: class Journal(models.Model): date = models.DateTimeField(default=timezone.now) user = models.CharField(max_length=24)

Re: starting afresh

2015-09-22 Thread Alex Kleider
On 2015-09-22 19:04, James Schneider wrote: Did you delete the previously created migration files? . There should be a 'migrations' folder that was created inside of your app. You can whack the whole folder, it will be created next time you run 'makemigrations'. Indeed, it is the

Re: starting afresh

2015-09-22 Thread Alex Kleider
On 2015-09-22 18:12, James Schneider wrote: Did you delete the previously created migration files? Django won't ask those questions unless previous migration files exist. If you're starting with a fresh database, you probably should. -James Ah, ha! That must be it. Much appreciate the tip

Re: starting afresh

2015-09-22 Thread Alex Kleider
On 2015-09-22 17:29, Nikolas Stevenson-Molnar wrote: It's telling you that your default "date" value will be the same for every instance of "Journal" you create (essentially it'll be the time when the migration is created), when you probably intend it to be the time each Journal entry is created.

starting afresh

2015-09-22 Thread Alex Kleider
Although at the intermediate level with regard to Python, I'm just beginning with Django, running Ubuntu 14.4LTS in a venv established by $ virtualenv -p python3 venv I set up a journal app with a models.py file and then changed some of the fields. Now I can't seem to get rid of the following wa