Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django html format radio select labels
Consider the following structure: models.py: class modela(models.Model): fielda = models.BooleanField(default=True, choices=((True, 'some <b>bold</b> text'), (False, 'zzz'))) forms.py: class forma(forms.ModelForm): class Meta: model = modela widgets = {'fielda': forms.RadioSelect} fields = '__all__' views.py: def a(request): form = forma() return render(request, 'a.html', {'form': form}) a.html: {{ form.fielda }} Django kindly escapes the tags for me as How do I render it as HTML tags like {{ form.fielda | safe }} doesn't work, either. -
extracting the csrf token from the get request /api/csrf_cookie
My api end point is essentially /api/csrf_cookie which works great (verified on postman), however, my understanding of CORS is very limited, and am confused, how to GET the token on react (FYI backend is locally hosted on Django and I followed this - https://fractalideas.com/blog/making-react-and-django-play-well-together-single-page-app-model/). I have tried multiple code snippets fro different sources, but they don't seem to work. Here is the code, as of now. const API_HOST = 'http://localhost:8000'; let _csrfToken = null; async function getCsrfToken() { if (_csrfToken === null) { const response = await fetch(`${API_HOST}/api/csrf_cookie`, { credentials: 'include', }); const data = await response.json(); _csrfToken = data.csrfToken; } return _csrfToken;} async function postRegister(email, password, cfmPassword, firstName, lastName, betaKey) { const csrfToken = await getCsrfToken(); const response = await fetch(`${API_HOST}/api/register/`, { method: 'POST', headers: { 'X-CSRFToken': csrfToken, 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ email: email, password: password, cfm_password: cfmPassword, first_name: firstName, last_name: lastName, beta_key: betaKey }) }); const data = await response.json(); return data.result; } -
Django How i store data such as token and user data
How i store data such as token and user data from api on django frontend website Store data in cache or cookies or local storage and how to store pls help me i'm a newbie -
Django: Cannot login to Django Admin
I tried to login to Django Admin. However I get this error: ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'auth_user'. (208) (SQLExecDirectW); [42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)") Before this, I have no problem login to Django Admin after migrated auth_user to MSSQL database. I could not figure out why is this happen and how to fix it? -
How to load events into fullcalendar.io from a json feed
Iam stuck with fullcalendar.io and the json feed to load the events in to the calendar. Json feed 1 with 1 event: this is working fine the events are fetched from the json feed in the url and loaded into the calendar. [{"id": 9, "title": "test event", "start": "2023-02-22T03:00:00Z", "end": "2023-02-22T01:03:00Z"}] And the relevant calendar code document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar') var calendar = new FullCalendar.Calendar(calendarEl, { events: { url : '{% url 'calendar_app:all_events' %}' }, --> working fine Json feed 2 with 1 event: this is not working, again the events are fetched from the json feed in the url, however the json has a different format { "result": [ { "id": 9, "title": "test", "start": "2023-02-21T04:30:00Z", "end": "2023-02-21T06:55:00Z" } ] } What do i have to do to be able to use the second json feed to load the events into the calendar. -
How to use the slug field in Django?
Can someone please explain how to use django slug field once and for all? :) I tried to follow some video tutorials, but they are half done every time, and every time i run into an error. -
Django virtual environment cannot be recognized by vscode, I tried to select interpreter. And the virtual environment works fine in my local terminal
I'm following the Django tutorial to build my Django project. When I'm running the virtual environment command \Scripts\activate.bat, the terminal information in VScode is cleared but I can't see my virtual environment name at the beginning of my path. But if I tried on my Windows terminal, I can see it works. I tried to select interpreter in VS code, but it still doesn't work. I looked through some threads, but none of them have the same situation with me. (Visual Studio Code does not detect Virtual Environments) Thanks -
Migration in Django causes bus-error in output
In my Django project I want to python manage.py migrate but I get a bus error, which I don't know I should detect. I'm new to python and Django and I just get errors when I try to install everything for the school project. I use sqlite3 for my database. So whenever I try python manage.py migrate or python manage.py makemigrations I get the following output: Operations to perform: Apply all migrations: admin, application, auth, contenttypes, oauth2_provider, sessions, sites, social_django Running migrations: Applying contenttypes.0002_remove_content_type_name...zsh: bus error python manage.py migrate And whenever I try to python manage.py runserver for testing purposes I get the following output: File "/Users/username/miniforge3/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 357, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such table: application_cronjob In my base.py file line 357 I have the following: def execute(self, query, params=None): if params is None: return Database.Cursor.execute(self, query) query = self.convert_query(query) return Database.Cursor.execute(self, query, params) Do anyone know how I can debug my bus-error? I have searched a lot in the internet but nothing really helped me as a beginner. Thanks! -
Django - How to filter a Many-to-Many-to-Many relantionship
I have 3 models (User is Django's built in user-model): class User(AbstractUser): pass class Listing(models.Model): name = models.CharField('Listing Name', max_length=64) description = models.TextField() owner = models.ForeignKey(User, related_name="listings", on_delete=models.CASCADE) active = models.BooleanField('Active', default=True) class Bid(models.Model): listing = models.ForeignKey(Listing, related_name="listing_bids", on_delete=models.CASCADE) bidder = models.ForeignKey(User, related_name="user_bids", on_delete=models.CASCADE) amount = models.DecimalField(max_digits=7, decimal_places=2) class Meta: unique_together = ('listing', 'bidder',) Basically a Listing can have multiple Bids from different Users Now I would like to get the Listing row and it's corresponding Bid row where Listing = x and User = y I am able to get a queryset returned when I do this: Listing.objects.get(pk=8).listing_bids.all() But now I'd like to filter that queryset further based on user=xx (or username = 'xx'). I should then only get one row back (that is if the Listing and User exist on the Bid table) or Noneshould be returned. It seems so simple to do but I can't figure it out - besides "looping" through all the rows myself. -
OperationalError at /admin/blog/comments/ no such column: blog_comments.post_id
I have a site and wanted to add comment to it. I wrote the model for comments and a FK to the posts model. There was a problem that I understood after migrating I tried deleting the migration files and then faking the migration but didn't help. when migrating I get this error: django.db.utils.OperationalError: table "blog_posts" already exists and when entering the admin panel and go to comment section I get this error: enter image description here I tried deleting the migration files and then faking the migration but didn't help. this is my models: class Posts(models.Model): product_name = models.CharField(max_length=50) cover=models.ImageField(upload_to='images/') price = models.DecimalField(max_digits=10, decimal_places=2) def __str__(self): return self.product_name class Comments(models.Model): post = models.ForeignKey(Posts, on_delete=models.CASCADE, related_name='comments',blank=True,null=True) name = models.CharField(max_length=80,default='neda') body = models.TextField(default="add here") def __str__(self): return self.post -
Inherited Classes Django - Id of manually created parent is not generated even after save, the pointer of child also not working
Problem explanation Hello I have been having some issues with saving a many to many field when trying to inherit from another class. I have overwritten the save function for my "CharacterBanner" class which extends my "Banner" class. I attempt to create and save a new Banner instance so that I can point the CharacterBanner to the newly created and saved instance. The main issue currently is that the id of the parent (Banner) is not being generated even though it is being saved so I cannot properly add a pointer to CharacterBanner. Other fields are being saved properly however. Additionally, even if I could get an id, I am unsure as to how I can assign the CharacterBanner pointer to the Banner that I create. That is why I have a wonky setup with both banner_ptr and banner_ptr_id in the database. When I migrate it certainly seems to expect banner_ptr_id. Code I have a "Banner" model that I want to contain the following fields CHARACTER = "Character" WEAPON = "Weapon" BANNER_TYPE = [(CHARACTER, "Character"), (WEAPON, "Weapon"),] class Banner(models.Model): name = models.CharField(max_length = 64) enddate = models.DateField() banner_type = models.CharField(max_length = 64,choices=BANNER_TYPE) I also have the "CharacterBanner" model that has … -
Cannot add or update a child row: a foreign key constraint fails. FOREIGN KEY CONSTRAINT
I am trying to migrate a new model to my database. It worked on my development server, but when pushed into development I get the following error. I require this model to enable user comments on my website. django.db.utils.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`mhprints_database`.`#sql-a7cd3_621`, CONSTRAINT `mhpapp_blogcomment_user_id_512d6a81_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))' I've researched many different posts online and none are fixing my issues. Hoping some one has some ideas? Thanks. -
How to make a Django UniqueConstraint that checks fields in a position-independant way?
I have a Django Model where I'd like to ensure that no duplicate Edge exists where the same pair of Nodes appear as node_a or node_b, in either order. class Edge(models.Model): project = models.ForeignKey(Project, related_name="edges", on_delete=models.CASCADE) node_a = models.ForeignKey(Node, related_name="+", on_delete=models.CASCADE) node_b = models.ForeignKey(Node, related_name="+", on_delete=models.CASCADE) class Meta: constraints = [ UniqueConstraint( fields=("project", "node_a", "node_b"), name="unique_edge" ), ] This catches if an Edge is made with the same (A, B), but not if the same Nodes are put in reverse (B, A). The validation function I'm trying to port to Constraints was: def validate_unique(self, *args: Any, **kwargs: Any) -> None: if self.project.edges.filter( Q(node_a=self.node_a_id, node_b=self.node_b_id) | Q(node_a=self.node_b_id, node_b=self.node_a_id) ).exists(): raise ValidationError( f"Edges must be unique within a project: {self.node_a_id}|{self.node_b_id}" ) This validation function validates that the Nodes are unique in both directions: (A, B) or (B, A). Is there a way to express this within a UniqueConstraint? -
Connection Refused to Django test server when run in github actions
I have a django project that is containerized in Docker. In a separate project, I am trying to use docker compose to load my django project as a service, and then use GitHub Actions to confirm that the django server is running. Every attempt to run curl to test whether the django server is running has failed, with no response. I tried running the curl command INSIDE the container, using docker exec, and it fails with "connection refused". If I docker compose build --no-cache, then docker compose up, and then curl -X GET localhost:8000/version/ locally, it works perfectly. It also works locally if I attempt to run curl from inside the container. It only fails in the github actions. My docker-compose.yml file reads as follows: services: blawx: build: https://github.com/Lexpedite/blawx.git#v1.3.40-alpha ports: - "8000:8000" expose: - 8000 volumes: - ./blawx/fixtures:/app/blawx/blawx/fixtures/nrcan-map My github actions file looks like this: jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build and run the Docker Images from docker-compose.yaml run: docker compose up -d - name: Show Running Containers run: docker ps - name: Check Blawx Heartbeat run: | docker exec -t nrcan-map-blawx-1 curl --retry 5 -X GET "localhost:8000/" - name: Shut Down Docker Containers run: … -
Django signals and channels
i am new with django and django channels i wanna create app and use signals when a user insert new row or order in the database table i send signal to Django channels My application have more than one company so i need filter users only users in the same company see the signal or the event of creating new row or new order of the same company All new order or row can filter by column company to send signal to users of the same company only , May like group every users of the same company Thank a lot -
How To Optimize Django ORM Many-to-Many Relationships?
I am trying to make a large scale REST API app, I came up with a-not-so-good models and maybe even worse serializers that makes 100 of queries per one request for one end point? My question is how to optimize this. this is the models code class MainModel(models.Model): text = models.CharField(max_length=150, unique=True) subclass = models.ManyToManyField(Subclass, related_name='Sclass') Premium = models.BooleanField(default=True) class Meta: indexes = [ models.Index(fields=['text',])] def __str__(self): return str(self.text) class AnotherModel1(models.Model): text = models.CharField(max_length=400, unique=True) mainModel = models.ManyToManyField(mainModel, related_name='mainModel1') def __str__(self): return str(self.text) class AnotherModel2(models.Model): text = models.CharField(max_length=300, unique=True) mainModel = models.ManyToManyField(mainModel, related_name='mainModel2') def __str__(self): return self.text class AnotherModel3(models.Model): text = models.CharField(max_length=300, unique=True) mainModel = models.ManyToManyField(mainModel, related_name='mainModel3') def __str__(self): return self.text class AnotherModel4(models.Model): text = models.CharField(max_length=300, unique=True) mainModel = models.ManyToManyField(mainModel, related_name='mainModel4') def __str__(self): return self.text class AnotherModel5(models.Model): text = models.CharField(max_length=300, unique=True) mainModel = models.ManyToManyField(mainModel, related_name='mainModel5') safety = models.CharField(max_length=20, default='Unknown') def __str__(self): return self.safety and so on for 12 models all linked to MainModel by many-to-many relationships. The request goes to MainModel and I use modelviewset class the view is something like this class MainViewSet(viewsets.ModelViewSet): queryset = MainModel.objects.all() serializer_class = MainSerializer http_method_names = ['get', ] filter_backends = [OrderingFilter] ordering_fields = ['text', ] ordering = ['text'] throttle_scope = 'Main' and the serializer … -
Get data that isn't related with field in other model
I have User, Profile, NotMatches, Matches models. How can I get all the profiles without profiles that are in NotMatches and Matches class NotMatches(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="first_user") not_matched_user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="second_user") class Matches(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="match_first_user") matched_user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="match_second_user") class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), unique=True) first_name = models.CharField(max_length=150, blank=True) My usecase So if you are user and you see something that you like/don't like you dislike/like it. The object is saved to NotMatches/Matches and if you go to the endpoint again you will see all the objects without the one you you interacted with I have the code that saves data etc but I'm struggling with grasping how to query data -
GraphQl Django, how to cache at resolver if Type has custom fields added
scratching my head with this one for the past while but I'm sure I'm just missing something simple. I am using graphene-django and I am trying to also use redis cache. The issue I am having is as follows. I have a model AdDetails class AdDetails(models.Model): id = models.IntegerField(primary_key=True) dealer = models.ForeignKey('DealerLookup', models.DO_NOTHING, db_column='dealer') county = models.ForeignKey('CountyLookup', models.DO_NOTHING, db_column='county') vehicle_type = models.ForeignKey('VehicleTypeLookup', models.DO_NOTHING, db_column='vehicle_type') href = models.TextField() make = models.ForeignKey('MakeLookup', models.DO_NOTHING, db_column='make') model = models.ForeignKey('ModelLookup', models.DO_NOTHING, db_column='model') year = models.ForeignKey('YearLookup', models.DO_NOTHING, db_column='year') mileage_km = models.IntegerField(blank=True, null=True) fuel_type = models.ForeignKey('FuelTypeLookup', models.DO_NOTHING, db_column='fuel_type') transmission = models.ForeignKey('TransmissionLookup', models.DO_NOTHING, db_column='transmission', blank=True, null=True) engine_size = models.ForeignKey('EngineSizeLookup', models.DO_NOTHING, db_column='engine_size', blank=True, null=True) colour = models.ForeignKey('ColourLookup', models.DO_NOTHING, db_column='colour', blank=True, null=True) for_sale_date = models.DateField() sold_date = models.DateField(blank=True, null=True) class Meta: managed = False db_table = 'ad_details and in schema.py I have added a few fields to it. class AdDetailsType(DjangoObjectType): price = graphene.Float() previous_price = graphene.Float() price_movement = graphene.Float() def resolve_price(self, info): price_history = self.pricehistory_set.order_by('-date').first() if price_history: return price_history.price return None def resolve_previous_price(self, info): price_history = self.pricehistory_set.filter(price__gt=0).order_by('date').first() if price_history: return price_history.price return None def resolve_price_movement(self, info): price = self.pricehistory_set.order_by('-date').first() prev_price = self.pricehistory_set.filter(price__gt=0).order_by('date').first() if price is not None and prev_price is not None: return price.price - prev_price.price else: return None class … -
how to create hyperlink to specific sections of same page on Django template
I have a website with a blog, I need to have a section of titles that includes hyperlinks (#) to the relevant section on the same page. To this I'm using a template tag as below. myapp/templatetags/custom_filters.py from django import template from django.utils.text import slugify register = template.Library() @register.filter def h3_slug(text): """ Returns a sanitized string that can be used as a slug for an H3 tag. """ return slugify(text) and in my template: <!-- my_template.html --> {% load custom_filters %} <h2>Table of Contents</h2> <ol> {% for h3_text in post.contents %} <li><a href="{% url '#'|add:h3_text|h3_slug %}">{{ h3_text }}</a></li> {% endfor %} </ol> {% for h3_text in post.contents %} <h3 id="{{ h3_text| h3_slug }}">{{ h3_text }}</h3> <p>Content for section {{ h3_text }}</p> {% endfor %} Now the problem is that it is listing all post.contents as Table of Contents !! I don't know how to make it detect only some specific sections like H3 tags as the title and add hypetlink to them using #. -
How to set X-Frame-Options header for uploaded files to S3 Django-storages?
I use DigitalOcean Spaces as a storage for /media/ files in Django using django-storages. I need files to send X-Frame-Options:'ALLOWALL' when they are fetched from Spaces so they can be displayed in iframe. How can I do that? U use boto3 Doesn't work: AWS_HEADERS = { "X-Frame-Options": "ALLOWALL", } Returns error when uploading file: AWS_S3_OBJECT_PARAMETERS = { 'X-Frame-Options': 'ALLOWALL' } Error: Invalid extra_args key 'X-Frame-Options', must be one of: ACL, CacheControl, ChecksumAlgorithm, ContentDisposition, ContentEncoding, ContentLanguage, ContentType, ExpectedBucketOwner, Expires, GrantFullControl, GrantRead, GrantReadACP, GrantWriteACP, Metadata, ObjectLockLegalHoldStatus, ObjectLockMode, ObjectLockRetainUntilDate, RequestPayer, ServerSideEncryption, StorageClass, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, SSEKMSEncryptionContext, Tagging, WebsiteRedirectLocation -
SerDe problem with django rest framework and foreign key
Context: I have written a simple django rest framework app as BE and a react JS app as FE. The db is SQLite and it's gonna stay that way, since there are only 2 simple models and the number of users will be quite limited as well. For the sake of the example let's assume there is only one team currently with name="First" and id=1. Requirements: display in a table the list of players with team as a name, not its id. add players from form Code: models.py class Player(models.Model): first_name = models.Charfield(max_length=50) last_name = models.Charfield(max_length=50) team = models.ForeignKey(Team, on_delete=models.SET_NULL, blank=True, null=True) class Team(models.Model): name = models.Charfield(max_length=50) def __str__(self): return f"{self.name}" views.py class PlayersView(APIView): def post(self, request): serializer = PlayerSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) In order to meed 1st requirement I've implemented serializer like this: serializers.py class PlayerSerializer(serializers.ModelSerializer): team = serializers.CharField(source="team.name", read_only=True) class Meta: model = Player fields = "__all__" That worked fine, but I wasn't able to add the players to the database when processing the request from the FE. The body of that POST request is: body { "first_name": "John", "last_name": "Doe", "team": 1 } Looking on SO I found: Retrieving a … -
I can't send the image in my Django chat application
Hello everyone. This is my first time asking a question on StackOverFlow, so I may not explain properly... I am developing a Django chat website, where two users can send message with each other. I can send message without any problem, but I have issue with sending images. I simply can't receive any image. Here is my model.py: class ChatMessage(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) receiver = models.ForeignKey(User, on_delete=models.CASCADE, related_name="received_messages") message = models.TextField(null=True, blank=True) image = models.ImageField(null=True, blank=True, upload_to="message-images/") updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['-created'] Here is my views.py: @login_required(login_url='login') def chatUser(request, pk): sender = User.objects.get(pk=request.user.id) receiver = User.objects.get(pk=pk) form = ChatMessageForm() if request.method == 'POST': form = ChatMessageForm(request.POST, request.FILES) if form.is_valid(): message = form.save(commit=False) message.user = request.user message.receiver = receiver sender.profile.chatters.add(receiver) receiver.profile.chatters.add(sender) message.save() return JsonResponse({'success': 'Message sent successfully'}) context = { 'receiver': receiver, 'messages': messages, 'form': form, } return render(request, 'base/chat.html', context) Here is my forms.py: class ChatMessageForm(forms.ModelForm): class Meta: model = ChatMessage fields = ('message', 'image') labels = { "message": "", } Here is my template: <form method="POST" action="" enctype="multipart/form-data" > {% csrf_token %} <textarea type="text" name="message" placeholder="Send Message..." rows="2" autocomplete="off" class="form-control border-own-left border-own-right border-own-top" style="border-bottom: none; border-radius: 0%;" oninput="autoExpand(this)"></textarea> <div class="d-flex justify-content-between bg-white … -
Virtual environment and django is not created in my directory. Python 3.11
PS C:\Users\38099\Desktop\courses> pipenv install django==4.0.8 Creating a virtualenv for this project... Pipfile: C:\Users\38099\Pipfile Using C:/Users/38099/AppData/Local/Programs/Python/Python311/python.exe (3.11.1) to create virtualenv... [ ] Creating virtual environment...created virtual environment CPython3.11.1.final.0-64 in 501ms creator CPython3Windows(dest=C:\Users\38099.virtualenvs\38099-inBhiGOL, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\38099\AppData\Local\pypa\virtualenv) added seed packages: pip==23.0, setuptools==67.1.0, wheel==0.38.4 activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator Successfully created virtual environment! Virtualenv location: C:\Users\38099.virtualenvs\38099-inBhiGOL Installing django==4.0.8... Resolving django==4.0.8... Installing... Adding django to Pipfile's [packages] ... Installation Succeeded Installing dependencies from Pipfile.lock (664a36)... To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. I need to install virtual environment and django version in my directory "C:\Users\38099\Desktop\courses>". But every time the location of VE is " C:\Users\38099.virtualenvs\38099-inBhiGOL". pipenv in my powershell is installed. I also have folder '.venv' in my explorer, but it ignores it anyway, choosing different location -
Using Drawflow library create nodes but they are not visible
I'm trying to use the amazing Drawflow library (Javascript) from: https://github.com/jerosoler/Drawflow Here is my code: <head> {% load static %} <link rel="stylesheet" href="{% static 'drawflow/src/drawflow.css' %}"> <link rel="stylesheet" href="{% static 'css/theme.css' %}"> </head> <body> <div id="drawflow"></div> <script type='module'> // The minified version is build as an UMD module, so it cannot be imported // It should be rebuild eventually. // https://stackoverflow.com/questions/75514648/uncaught-syntaxerror-the-requested-module-does-not-provide-an-export-named-dra import Drawflow from "{% static 'drawflow/src/drawflow.js' %}"; import sheet from "{% static 'drawflow/src/drawflow.css' %}" assert { type: 'css'}; import { h, getCurrentInstance, render } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js' const Vue = { version: 3, h, render }; const container = document.getElementById("drawflow"); var editor = new Drawflow(container); //const internalInstance = getCurrentInstance() //editor.value = new Drawflow(container, Vue, internalInstance.appContext.app._context); editor.reroute = true; editor.editor_mode = 'edit'; editor.start(); editor.addModule('nameNewModule'); const nodeData = { id: 'node-1', name: 'My Node', module: 'nameNewModule', x: 500, y: 100, class: '', html: function() { return '<div>' + this.name + '</div>'; } , inputs: { input_1: { label: 'Input 1', }, }, outputs: { output_1: { label: 'Output 1', }, }, data: { command: 'Run command', }, }; editor.addNode(nodeData.module, Object.keys(nodeData.inputs).length, Object.keys(nodeData.outputs).length, nodeData.x, nodeData.y, nodeData.class, nodeData.data, nodeData.html()); </script> </body> However, when I run this (using a Django server), I don't get any error, … -
Django application page styling, flex, responsive
I'm building an app with Django. The functional side is quite tackled, but I want to style the pages and fell into a css nightmare. I'm more a database/python guy than a web designer and not very good in css/flex. I added some of my own css files to the base.html templates in admin and my app's and I get the colors/background I want but I seem to have broken the element layout. What is the proper way to override Django's default styling without breaking the layout? Also can you recommend some debugging tools? The integrated google DevTools helps but is a bit cumbersome. Have any good learning sites recommendations? I know about the W3 schools etc.. but I have trouble linking their info with what I see in django... From what I read, responsive design is the way to go if I want to have my site display on all sorts of devices, and "progressive enhancement" is a good thing, so I'd like to go in that direction. My development environment is linux Ubuntu. Many thanks