Questions tagged [django-fixtures]

A fixture is a collection of data that Django knows how to import into a database, can be written as XML, YAML, or JSON documents. They can be used to provide initial data for models.

187 questions
1
vote
1 answer

How to make my test fixtures loaded only while testing in Django?

I have a Django project with production fixtures and testing fixtures. How to make testing fixtures loaded only while running tests?
Sashko Lykhenko
  • 1,554
  • 4
  • 20
  • 36
1
vote
0 answers

how to use variables in django fixtures YAML file

I am using django fixture, i want to use variable in Yaml file ,Here is an example. - model: taskmanagement.mailsettings pk: 1 fields: username: asdfgh password: %x I want to encrypt the password. and here i want to use x as a…
vipin
  • 670
  • 2
  • 9
  • 25
1
vote
0 answers

Can I process Django fixture data before it is written to the database?

Let us say you have a simple model with a mandatory foreign key: class Pupil(models.Model): name = models.CharField(max_length=40) teacher = models.ForeignKey(Teacher) I want to load Pupil instances from a fixture file but add a default…
Kit Fisto
  • 4,385
  • 5
  • 26
  • 43
1
vote
1 answer

Installed 0 object(s) from 0 fixture(s) not reading FIXTURE_DIRS correctly

Here are my settings FIXTURE_DIRS = ( os.path.join(BASE_DIR, "fixtures",) ) $ python manage.py diffsettings | grep fixtures FIXTURE_DIRS = '/home/user/project/src/fixtures' What is strange when I run syncdb I get the following. It…
nelaaro
  • 3,006
  • 5
  • 38
  • 56
1
vote
0 answers

django: factory boy in south datamigrations?

In the past we used south datamigrations to update the data in tables. For fixtures we want to use factory boy in the future. Inside a south datamigration I have only the orm, and must not import the real models. Is it possible to use factory boy…
guettli
  • 25,042
  • 81
  • 346
  • 663
1
vote
3 answers

Cannot load fixtures when testing Django

I hope not to make a fool of myself by re-asking this question, but I just can't figure out why my fixtures are not loaded when running test. I am using python 2.7.5 and Django 1.5.3. I can load my fixtures with python manage.py testserver…
Phil
  • 879
  • 2
  • 10
  • 23
1
vote
0 answers

Error loading django fixtures

I have two sets of fixtures, Person.json and Movies.json. The Person fixture basically have this format: { "pk": 1, "model": "data.Person", "fields": { "full": "Anna-Varney", "num": "I", "short": "Anna-Varney" } …
dl8
  • 1,270
  • 1
  • 14
  • 34
1
vote
3 answers

Couldn't load fixtures with South in Django project

I've Django project which is using South application to handle schema and data migration. In one of my applications I have migration (number 0004) which is responsible for loading data fixtures from json file: class Migration(DataMigration): …
Gie
  • 1,907
  • 2
  • 24
  • 49
1
vote
4 answers

How to instantiate class by package_name.module_name.class_name "path"

I want to implement something a bit similar to django fixture system where in fixture you set model property which indicates a model class of fixture. It looks something like this my_app.models.my_model My question is what is the standard way to…
yakxxx
  • 2,841
  • 2
  • 21
  • 22
1
vote
1 answer

Django Admin: Why are some fields showing up empty?

I have a Django blog with a "Post" model like so: class Post(models.Model): title = models.CharField(max_length=1000) author = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') text =…
GChorn
  • 1,267
  • 1
  • 19
  • 36
0
votes
2 answers

Fixtures in raw Python?

Is there a way to have fixtures in raw Python to, for example, create initial data from external files? I have fixtures in JSON presently, and it might actually be more effective to migrate them to a kind of CSV file and have Python parse these and…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
0
votes
1 answer

Django, applications with fixtures

I am writing Django app, it is an admin interface based on jQuery Grid Plugin. Now i want to make demo of this app and to allow experiments with different data, and of course just to test it. Do you guys know any django applications with predefined…
FoRever_Zambia
  • 1,179
  • 9
  • 13
0
votes
1 answer

Django testing: How to get a database with ONLY fixture data and no IntegrityErrors (by diagnosing the source of errors)?

I'm trying to run tests with fixture data, and getting the infamous IntegrityError: column user_id is not unique error. Now, looking at my fixtures, I can see that the ids of my User models in my fixture are unique between each other. I infer that…
Marcin
  • 48,559
  • 18
  • 128
  • 201
0
votes
2 answers

syncdb not adding fixtures in 3rd party project

I've written a pretty simple Django application called django-locality which takes the headache out of working with countries and territories. It provides a lot of initial data for countries and territories. I just the 0.1 release up to PyPI, and…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
0
votes
1 answer

While testing routes of my django prodject, i got Type error: expected sting or bites like object. How i can fix this error?

The page of the published news on my blog, is available to any user. I use pytest to check if the page is accessible to an anonymous user. Url is formed by using the id of the news, which I pass in the address parameters (as a tuple). In the result…