Comments (4)
yes, you will get it. Please reference import_data function where it imports data for two tables.
What you need to do is to write a custom constructor for choice, where you find the question and assign it to Choice.question.
from django-excel.
What if I need to save data to a table using 2 Foreign keys from different tables??
This is my model:
class SkuScore(models.Model):
sku = models.ForeignKey(Sku)
month = models.SmallIntegerField()
year = models.SmallIntegerField()
customer = models.ForeignKey(Customer)
There are two fields from different tables: Sku & Customer.
Is this code right?
def other_keys(row):
s = Sku.objects.filter(sku=row[0])[0]
row[0] = s
c = Customer.objects.filter(customer=row[2])[0]
row[1] = c
return row
I'm a bit confused about the row[x]
from django-excel.
The position x is indicated by your mapping dict.
from django-excel.
Thank you chfw!
from django-excel.
Related Issues (20)
- Save to model.FileField a generated xls
- How dow I format individual fields from a queryset in a make_response_from_querysets HOT 1
- How do I ignore a row or column when import data use save_to_database? HOT 2
- Incorrect message on file not found HOT 2
- Doc in Chinese HOT 1
- Unable save table after making changes in the model.py file HOT 1
- Question: How to overwrite the default encoding HOT 3
- Exception Type: IntegrityError Exception Value: UNIQUE constraint failed: myapp_question.slug HOT 2
- Not able to upload large excel or CSV file with the size 10Mb
- Urgent Help: Trying to Import data from two sheets(xlsx) into two different models(Foreign Key Related) - Not able to lead the Data HOT 5
- build failed with django 3.1.1 HOT 8
- jump column HOT 3
- Unable to support XLS and XLSX uploads in Python 3.9 HOT 3
- start test got wrong HOT 2
- Can't get XLSX support working HOT 4
- Import related models without static foreign keys HOT 4
- How to create an import for whole document without defining 'choice' and 'question'?
- Realy? Object of type UUID is not JSON serializable HOT 2
- Django 4.0 forward compatibility Error HOT 1
- <ul class="errorlist"><li>This field is required.</li></ul>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-excel.