1👍
You can define a foreign key to non-materialized django model which stores the info you require.
To do so, in the new model to which foreign key (or a OnetoOne Key) is defined, just place
class _meta:
managed = False
4👍
I’m not sure exactly what you’re trying to do. But remember that Django models are just Python objects – and Python objects are completely dynamic. So it is perfectly valid to do obj.uuid = whatever
even if there is no uuid
field defined on the model.
0👍
I don’t know of such a temporary field. It would be nice 🙂
But my suggestion is this: In the view that receives the JSON and makes it into objects, you check the attributes. You create an object, with only the “real” attributes (not foreign keys or M2M). You can assign arbitrary attributes to them (instance.arbitrary_attribute = something) but you won’t get the nice lookup mechanism (Model.objects.filter(…)). After you created all the objects, you loop over the objects again, and for each FK you look up the object that has the link’s UUID, and link to it (using the instance.id).
- [Django]-Django-allauth – Send email verification using Gmail account
- [Django]-How to redo makemigrations after getting an error?
- [Django]-Twitter Bootstrap 2 drop down menu is not work
- [Django]-Free CDN to store my images and css files for django on heroku
- [Django]-Use context processor only for specific application
0👍
You can try creating plain python attributes, they are not saved to db. Like:
class Link(models.Model):
sourceuuid = None
- [Django]-Django Administration: Delete record from custom user model
- [Django]-Django Rest Framework regroup queryset by a category
- [Django]-Django form not visible
- [Django]-I keep getting the following error "local variable 'total_results' referenced before assignment"
- [Django]-Django page not rendering in Facebook iframe
0👍
Why not just use UIDS as primary keys ?
set primary_key to True
class Node(models.Model):
uuid = models.CharField(max_length=32, primary_key=True)
[...]
class Link(models.Model):
uuid = models.CharField(max_length=32, primary_key=True)
- [Django]-Click in a dropdown option and show an specific field in Django
- [Django]-Python & Django on a Mac: Illegal hardware instruction
- [Django]-Maximum recursion depth exceeded, save method, Django
- [Django]-PlaceholderAdmin throws <lambda>() takes exactly 1 argument (2 given)
- [Django]-Django collectstatic on S3 uploads unchanged files everytime on Heroku