#web-development
2 messages · Page 84 of 1
see the codes
the frontend is working properly
but when i am sending a msg , it doesn't coming on the screen
can you tell me more about your problem? @nova storm
I con't help you with a problem so big, but if you have a specific question i can answer
oke
while flag == False:
snooze = input('would you like to snooze for 10 min? ')
if snooze.lower() == 'yes':
snooze_time = datetime.datetime.now().minute
snooze_time = snooze_time + 1
if snooze_time == datetime.datetime.now().minute:
print(snooze_time)
break
elif snooze.lower() == 'no':
print(snooze_time)
break
elif snooze.lower() != 'no' and snooze.lower() != 'yes':
snooze = input('would you like to snooze for 10 min? ')```
Is hard to create something like this https://list.thedevelopers.tk/
with django? 😄
my bad
does any1 know how to serve static files from nginx?
my root is set /var/www/application1
must it be a subdirectory?
just learned it nvm guys and gals
Is hard to create something like this https://list.thedevelopers.tk/
with django? 😄
@static night no
do any of you have experience with flask? I am working on making a header for my website and I want to be able to click on it and it to take me to other pages (like and "about" page) but I can't figure out how to make buttons embedded links. Do any of you know anything about how to do that? This is the first thing I've done in flask
do any of you have experience with flask? I am working on making a header for my website and I want to be able to click on it and it to take me to other pages (like and "about" page) but I can't figure out how to make buttons embedded links. Do any of you know anything about how to do that? This is the first thing I've done in flask
@glacial tapir I was just gonna send a message about Flask too. I'm curious to know how your website turns out. I have a college project that I have to work on with classmates. We are noobs when it comes to web development.
yeah I've never done web development before so things are going pretty slow
There are two YT playlists that do tutorials on Flask. one is codemy.com and the other is by Corey Schafer
yeah I've never done web development before so things are going pretty slow
@glacial tapir I don't have experience with Flask, but I am pretty sure they must have an official documentation. Your specific problem is a common use case, so I'm sure it's mentioned in the Flask documentation.
https://flask.palletsprojects.com/en/1.1.x/ this is the documentation i will have to reference
I've been looking through flask documentation and haven't found anything yet
yup @ocean gull that's the official documentation
how are you deploying your website? sublime text? Cause I was thinking of using pythonanywhere.com
How would you deploy using sublime text? That is a text editor. > how are you deploying your website? sublime text? Cause I was thinking of using pythonanywhere.com
@ocean gull
right. I mean't where is he writing is code on?
do any of you have experience with flask? I am working on making a header for my website and I want to be able to click on it and it to take me to other pages (like and "about" page) but I can't figure out how to make buttons embedded links. Do any of you know anything about how to do that? This is the first thing I've done in flask
@glacial tapir Here you go.url_for('some-route')https://flask.palletsprojects.com/en/master/tutorial/templates/
^^^
Highly recommend watching corey's videos! https://www.youtube.com/playlist?list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH
thank you!
I will check it out aswell
For the header, you can watch the 2nd vid https://www.youtube.com/watch?v=QnDWIZuWYW0&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH&index=3&t=0s @glacial tapir
In this Python Flask Tutorial, we will be learning how to use templates. Templates allow us to reuse sections of code over multiple routes and are great for serving up dynamic HTML pages. Let's get started...
The code for this series can be found at:
https://github.com/CoreyM...
thank you
hey guys, can anyone explain me how can i use email to authenticate in django ? I created a class of users based on AbstractBaseUser
class Customer(AbstractBaseUser):
first_name = models.CharField(max_length=100)
middle_name = models.CharField(max_length=100, blank=True)
last_name = models.CharField(max_length=100)
email = models.EmailField(max_length=255, unique=True)
phone_number = models.CharField(max_length=20)
date_of_birth = models.DateField()
def __str__(self):
return f"{self.first_name} {self.last_name}, {self.email}"
how can i put the box in the middle?
@native tide easy
use flexbox
display flex: Justice-content: center
where do i put it?
<style>?
yeah
ok
css
wut
this?
no
wait
.classname{
display: flex;
justify-content: center;
}
?
sorry i annoy
nvm i got it
@native tide but how I can get discord username etc.?
@native tide but how I can get discord username etc.?
@static night well I use flask-discord (flask) which is easier for what I need to do
but with DJango im not sure
can someone help me fix this? it seems like card itself is moving on hover. I only added in border on hover.. and it still does the same thing without a border
Hello how can i make flask serve the backend of react?
here is my repository https://github.com/happyperson10/flaskreact.
if you want to help me ping me.
Hello how can i make flask serve the backend of react?
here is my repository https://github.com/happyperson10/flaskreact.
if you want to help me ping me.
@native tide You need to make a REST API or a GraphQL, allow django CORS and fetch the data to your react-app from your flask-app
In other words if you don't know anything about these you have a long road of things to learn
at first you should learn djangorestframework
django rest framework
flask
and then a JS framework of your choice for front end like axios
oh yea indeed
he's using flask
maybe this https://flask-restful.readthedocs.io/en/latest/ ?
but yes. For my django react app, I allow django to act as ORM and it acts as my api. My React app then receives this data and displays it
here is an example with my api https://vagabondnovel.us/api/
and here is the site that is using the api https://vagabondnovel.us/home/chapters/1
this is how it should be structured. The front end is React and axios
Hey NativeLinux maybe you can help me with something
ok thanks guys
do you know how to implement an AbstractBaseUser in django ?
I would like to add more fields to user model
yeah, what do you need help with?
and login with email
I've done dis
first_name = models.CharField(max_length=100)
middle_name = models.CharField(max_length=100, blank=True)
last_name = models.CharField(max_length=100)
email = models.EmailField(max_length=255, unique=True)
date_of_birth = models.DateField()
def __str__(self):
return f"{self.first_name} {self.last_name}, {self.email}"
but i don't know how to setup the login via email
you can also use AbstractUser instead if you would like all the built in stuff, such as admin, staff, name, email, etc
Yes but i've seen that it's not good for my case, like adding more fields and stuffs
i don't remember exactly why i worked on it yesterday
but AbstractBaseUser was the one that would fit my needs
AbstractBaseUser also has the authenticate and basic things i would need no ?
i'm trying to build an e-commerce website that's why the class is called Customer
yeah, abstractbaseuser has auth as well.
I recently implemented an AbstractBaseUser in the code jam, we used the default django.contrib.auth.views.LoginView to manage our logins though
yes.
you may need to create a totally custom login form/view that will accept an email and check that the password is correct, then authenticate
I will make the front with react and graphql
I am also using graphql 😄
xd
this is the exact code, but we are using AbstractUser
def resolve_login(_, info, data):
request = info.context["request"]
user = authenticate(username=data["username"], password=data["password"])
if user is None:
return {
"status": False,
"error": "Invalid username or password",
"user": None,
}
# User is valid
login(request, user)
auth_token = generate_user_auth_token(user)
return {
"status": True,
"token": auth_token.token,
}
i find it more appealing i learned the basics of rest framework and then i learned also about graphql and decided i would learn and implement this instead
from django.contrib.auth import authenticate
thank you 🙂
graphql is way better imo haha
interesting
yea clearly xd
50 endpoints and useless data when you fetch is really meh
it's also more friendly to learn tbh
I hope this helps, I imagine you can replace username with email and it will authenticate?
yes that's what i was thinking about 🙂
I found REST easier to learn, but I have been using rest apis for some time, I had never used graphql before working on this project
yeah, haha
like you know what your endpoint is and which data it's gonna provide
i'm not very experienced tbh but your example definitely give me some clues so i'll do more researches on this, thank you NativeLinuxUser 🙂
np, I hope this helps
yea it does thanks 🙂
Could someone that has used git before help me in #🤡help-banana real quick?
yo idk if this is the right channel but if anyone has experience with regex can you tell me why this
print(re.search("correct_response\">Brazil</em>", "correct_response">Brazil</em>"))
is coming up with None as the result? I'm just trying to find a string using the exact string as the regex (escaping 2 times)
Can someone suggest a source to learn django like video tutorials?
Corey Shafer has a nice series
Hello how can i make flask serve the backend of react?
if you want to help me ping me.
@native tide I would recommendariadnetbh. More modern than REST. It also has flask support. https://ariadnegraphql.org/docs/flask-integration
With apollo client on the front-end side.
Corey Shafer has a nice series
@dapper tusk thanks mahn
thanks
Anyone with experience implementing Marketing API/Conversions API using Facebook Business SDK for PY?
Hi guys
I'd like to pass in a Jinja2 expression into a WTForms input placeholder.
WTForms input:
{{ form.email(class="formfield", disabled=True) }}```
I want it to have a placeholder="{{email}}". I can't find how to do this. Does anybody know what to do here?
I've found a workaround by just replacing it with a div that has the exact same look as a formfield, but still, I'd love to know how to do this.
@native tide you wanna a placeholder name ="Email"?
Hey all I have this query in Flask to retrieve data from my database using the id key. @app.route('/api/store/<id>', methods=['GET']) def get_store(id): store = Store.query.get(id) return store_schema.jsonify(store) How can I query it with another parameter instead of id such as a unique string
I have 3 columns: id, name, date.
@native tide I want the placeholder to be a jinja2 variable {{email}} which I pass from the flask route
I want to query it using name which is unique
@cold socket You can do Store.query.filter_by(name=name) etc
@native tide Now that I think about it. Does name have to be a primary key?
primary key only can be true
oh id name?
no, your ID should be the primary key.
say you had a user in your database with ID 1, and name 'Jeff'
You can do database.query.filter_by(name='Jeff') and you'll get his object
id shoule be primary key
it's required
then you can manipulate the object to get the info you need
Ah okay that makes sense. Thank you so much!
Hi guys, I keep trying to use Flask-Migrate for DB changes, but everytime I'm getting this error. I've fully deleted the migrations folder and this is the error:
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [root] Error: Can't locate revision identified by '28d844d650b0'
the sequence of cmd commands:
flask db init
flask db migrate -m "Initial migration."
flask db upgrade
Has anyone had the same issue?
Hello all. Today I stumbled upon this https://github.com/robinhood/faust and was wondering if someone could maybe explain a real world example maybe of how this is useful? I read it multiple times and tried to find projects that use this with flask or sanic (which is what I'm using) but failed to do so.
How would this be added to sanic (I use sanic to build a REST API for an note taking app that I'm making) and how would it benefit me?
How does a person make tests for web aplications like flask?
Or web stuff in general?
Hey @noble star, That's a pretty broad question. Can you narrow it down at all?
Most web frameworks offer support for testing as part of the framework.
Flask seems to use pytest as a base https://flask.palletsprojects.com/en/1.1.x/testing/
For example, in Flask you have access to a test client as an attribute of your flask app. app.test_client() gives you this object. You can use it sort of like a web browser to make get/post/put/delete requests
Postman can also be used to test responses from an api
yep.
Tests that send a request to some endpoint in your web application are a great place to start.
You can test that the expected urls exist, and that the right kinds of HTTP methods are available (and unavailable)
Yis. And expect whatever status code and the output for the response as well. And also see the response time
You can test logging in and out, and whether a user has to be authenticated to access a particular endpoint too
If you want to go beyond that, most web applications have lots of classes and functions in them as well. And in most cases those can and should be unit tested.
Cool Thanks @valid orbit that is what I needed
Hi guys, I have the following environment variables set on .env / .flaskenv meant to use it when I run my web app on localhost
TESTING=True
FLASK_ENV=development
But, I'd like to set
TESTING=False
FLASK_ENV=production
Whenever I commit and deploy changes through git push heroku deploy:master. Meaning that if it's not running local, it would change those variables.
Having to manually change those variables everytime I commit leaves room for an additional human vulnerability (which is me forgetting to change those, which would enable a blueprint with test routes that I wouldn't like to be deployed nor allow those endpoints to be scraped and displayed on SERPs)
you can use environment variables and set them on your heroku server Accordingly. You can also use pre/post commit git hooks. I suggest you try the first one.
@versed python I do commit and deploy my .envand .flaskenv files to Heroku and load them using dotenv.load_dotenv when I initialize my app using config.py. That's exactly the issue here, I want to force those changes in case I forget to change these environment variables when I'm testing stuff locally.
P.S: Will read about git hooks, never heard of that.
You shouldn’t have to commit the .env files to Heroku
I think you should use environment variables instead of .env files. That way you can have different values for different environments. then you can do something like SECRET_KEY = os.environ.get('SECRET_KEY').
If you go on the app’s settings in Heroku, there are environment variables you can easily set. It will work the same way with load dotenv
You shouldn’t have to commit the .env files to Heroku
@agile ermine yep,.envfiles are supposed to be developer specific. Infact if you look into the default.gitignorefile that github provides, you will see.envwould be included there.
So locally, keep the .env file. But don’t push it to github. You can just adjust the environment variables on Heroku and it will work the same way
Exactly! Especially if you make your repo public too
I think you should use environment variables instead of
.envfiles. That way you can have different values for different environments. then you can do something likeSECRET_KEY = os.environ.get('SECRET_KEY').
@versed python Yes, I think I have this going on here on myconfig.pyfile
^ agree
If you go on the app’s settings in Heroku, there are environment variables you can easily set. It will work the same way with load dotenv
@agile ermine Will try
If you go on the app’s settings in Heroku, there are environment variables you can easily set. It will work the same way with load dotenv
@agile ermine yep this is the correct way
I am sure that I have added .envand .flaskenv to gitignore, but I've stopped to deploying my app to github and I'm commiting changes directly to heroku, not sure if Heroku looks for a different .gitignore file now that you have mentioned it.
Oh, shoot, seems like I have not added .envand .flaskenv files to .gitignore, I'm just checking it right now. I may have deleted it last time I have deployed it to github
Heroku works using the basics of git, so it follows all rules of standard git. So yeah, it looks for .gitignore too.
Yes, I'm sure now that I'm commiting those files after seeing the variables
Seems like I have to create a whole lot of variables there
Yes, you would just set those variables there but shouldn’t commit your .env file as that might contain sensitive data
Indeed, all my integration keys, tokens, etc. are stored there
Thank you guys @agile ermine @versed python @worn rapids , I think I've everything sorted out now. Tomorrow I will deploy to test if everything is working properly
👍 happy to help!
i didn't do anything haha, but excited for u!
def fetchAllProductStock(self, productID):
return self.query.filter_by(productID=productID).all()
inside this table is a row called item, how can I do something like:
def fetchAllProductStock(self, productID):
return self.query.filter_by(productID=productID).all().productName
I want to first all items productNames inside this query
This will work:
def fetchAllProductStock(self, productID):
query self.query.filter_by(productID=productID).all()
names = []
for item in query:
names.append(item.productName)
return names
But it seems long. Surely there must be a way to do it in one line with sqlalchemy ?
def fetchAllProductStock(self, productID): return self.query.filter_by(productID=productID).all()inside this table is a row called item, how can I do something like:
def fetchAllProductStock(self, productID): return self.query.filter_by(productID=productID).all().productNameI want to first all items productNames inside this query
@past cipher[item.productName for item in self.query.filter_by(productID=productID).all()]
incidentally, in Python you should use snake_case instead of camelCase
yeah I always forgot to use snake case, a couple of people have mentioned this to me, when i'm quickly writing code I mix them up and end up eventually fix it
will try your above code now
works great @vestal hound , thanks!
np
works great @vestal hound , thanks!
@past cipher actually I think you might want to remove the.all()
it should stll work
yep you're right, no need for all()
yep you're right, no need for all()
@past cipher there's a difference
.all() turns it into a list
so there's an extra list created (less efficient)
seems to turn it into a list regardless
no
.all() makes a list, then the list comprehension makes another list from it
whereas the Query object is an iterator (doesn't produce values until necessary)
so only one list is ever created
(the result)
I created a project name “SHOP” and my first app is “PRODUCTS”,
My files go:
*Shop
-products
-shop
-venv
Is that right? I’m using VSC
“Products” is my first app.
what
k
Should pages, be it’s own App in Django?
Or is just adding them to a templates folder good enough?
different parts of your website should be different apps. For example, you'll probably want to separate user handling into a separate app called accounts and blog posts into a separate app called posts. So to answer your questionsl, no, each page will generally not be its own app.
Hello! i'm interested to learn django, and crossed these two tutorials
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django
and
https://docs.djangoproject.com/en/3.1/intro/tutorial01/
Which one is better to take?
The second one. Actaully both are good but its generally more preferable to learn a framework from its offiial docs @west jay
So yeah go with the second one
thanks!
hey guys - completely new to django (fairly new to python).... anyone able to help with getting a chart to display when i runserver? it shows when i run locally pasting the path into chrome
ive found a few different things on google but couldnt resolve (using window.onload =function ete, also found about some google security issue, but couldnt figure that bit out)
what kind of a chart do you want? @wraith prawn
line / bar charts
from what ive just read its to do with having the location hardcoded ? im watchign some vids now to try understand it a bit more
Do you know how to use some kind of graphing library (eg Matplotlib or Plotly)?
I would recomment something client-side like Chart.js and passing the data as JSON.
I had a lot of success with plotly too, especially if you want to make the graphs using python
Not familiar with Plotly, but matplotlib's API is... special lol
Great project, but hard to configure.
yep
@lethal orbit so I tried using chart.js, I have a separate JS file that has my charts in it with the data. should that instead be passed directly into the HTML ? (ill also look this up, not after someone doing all the work for me ! )
Mostly depends on your project structure. I usually use Quasar/Vue.js as a client, and have a Django REST or GraphQL API.
wait you use vuejs?
Oh god. How do you get it to run? I am having so many issues... Can you tell me where you learned how to integrate django and Vue together?
Easiest/best way I find is docker-compose, nginx, one node image for Vue, one python image for Django, and ariadne for GraphQL (back-end) and apollo-client on the front-end.
Isin't Vuejs supposed to be the front-end?
I already use docker-compose to run a python container, a nodejs and a third one for postgresql @lethal orbit
Yup, its front-end.
if you want, we are working on an open-source project using Docker-compose, Django, Quasar, Vue, Postgres... you can always join, and look at the code.
Here, I made the repo public: https://gitlab.com/djangocities/djangocities
So you can see the code without joining.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up Why exactly did you use two different docker-compose files here?
But yeah I will try it out, thanks @lethal orbit
NP. If you want to join us in working on it, feel free (though we're kind of busy with pyweek this month) to DM or ping me.
We have a fair bit of experience and you can definitely learn something.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml upWhy exactly did you use two different docker-compose files here?
@versed python Maybe not the best / most DRY approach, but I usually split those up into different environments that have different needs.
This one only has a dev stage for now, but it's a nice way to then set up a staging environment, and a production one, etc.
well, I will be looking into the progress every now and then. I am too inexperienced to contribute though.
So uh, I got a pretty weird email and I don't know how to best respond to it
I sell collectible trading cards online, and a customer randomly registered a whole bunch of shady sounding URLs related to the product and wants to "help" us by redirecting them all to my store until he figures out what he wants to do with it.
Is this something I can prevent? This guy sounds like a massive headache based on the rest of the email and I don't know enough about SEO etc to even begin to guess if this is even an issue for me.
Is there a simple way to show a modal in combination with a specific route?
-> show posts list
/post
-> show modal (on top of the posts list)
/post/:id
What do you mean by block them?
Is that a thing I can do? If a random person wants to do a 301 redirect from some random site they purchased to mine, is that something I can block? Or are you referring to just blocking their email so that I don't get more of these messages
@native tide
Block their email
If you think something is suspicious enough that you had to ask other people, i think its safe to assume its too suspicious. If you get an email from a stranger giving you a good deal, whose email has a link, avoid them.
Unfortunately, I don't think this is a scam. I sell trading cards for a popular card game and this is a regular customer.
and customers -constantly- decide they want to start a youtube channel, do a podcast and pull similar things like this all the time
hmmph
That being said, I've never had a customer just decide they want to buy a bunch of urls and 301 them to my website
how long have you been doing this?
It costs them money and as far as I understand, it does nothing.
I don't know, 16 years? I couldn't even tell you when I started
okay then if this is the first time you got such a request in more or less 15 years
This is really straying off course of the question I was intending to ask
If we can just abstract away my situation for a moment
What prevents me from registering www."somethingreallyoffensive".com and redirecting it to apple.com or something
and if that even matters if some random stranger does this
I don't think theres much that prevents you from redirecting a person from www.offensiveword.com to apple.com
Don't quote me on this, but I think django can detect which host is requesting its website (hence the ALLOWED_HOSTS setting in settings.py). Maybe you can use that to redirect users?
@high herald
Yes, it is a request header, Host
I think i am majorly incorrect though
Nah, you're right actually
Ah, that's helpful. Thank you
I created question and answer website using django I stuck on How I can associate each question or answer to a given comment in django models together with votes.
Link it here so that someone can help you
Ah, that's helpful. Thank you
@high herald even if I am, i dont see how that's gonna help your particular use case?
Perhaps I misunderstood what you were trying to communicate with me. It at least gives me a reasonable thread to start my own research
I was under the impression that there would be an option somewhere so that I could prevent a redirect, somewhat analogous to sites that disable hotlinking. But given your follow up, I guess this is not the case.
How can i implement vote, comment section reletes to a question and answer in django models?
How can i implement vote, comment section reletes to a question and answer in django models?
@prisma jackal Add a vote model with aUniqueConstrainton user, question, with a foreign key to question
and a Comment model with a foreign key.
What is uniqueConstraint @lethal orbit
I feel like you're a beginner. Have you completed any django tutorials? @prisma jackal
Google django UniqueConstraint 🙂
Probably quicker than waiting for me to be not busy; sorry.
some good guides for unit testing and migrations in flask?
Flask SQLAlchemy;
If I set a relationship between a 'User' class and a 'Review' class, can I access the Review class through the User class?
@lethal orbit I don't see very friendly article to me here.
@lethal orbit I don't see very friendly article to me here.
@prisma jackal https://docs.djangoproject.com/en/3.1/ref/models/options/#django.db.models.Options.constraints
https://docs.djangoproject.com/en/3.1/ref/models/constraints/#uniqueconstraint
user.profileam
[<ProfileDB 1>]
user.profileam.name
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'InstrumentedList' object has no attribute 'name'```
'user' is a DB row of 'User'. It has a relationship to another DB through the variable 'profileam'.
By doing user.profileam, it shows a row in the other DB. But it's a list, and I can't access any data in the other DB such as name.
Am I understanding this right? How could I fix it?
You just need to add a UniqueConstraint in class Meta
Function Definition in Python by Sadrach Pierre, Ph.D. in TData Science [spam url removed]
@native tide what does this have to do with web dev?
Why just spam nonsense no one asked about?
@lethal orbit yes! Thank u, I got nice article. Thnk u so much
@native tide what does this have to do with web dev?
@lethal orbit
I accidentally sent it here😅
@lethal orbit I left it here for someone to possibly take advantage of in data science & web dev
@lethal orbit I left it here for someone to possibly take advantage of in data science & web dev
@native tide so, spam. Got it.
Congrats, you're the first person on my block list 🙂
Thank you 😂
Is it possible to make async requests with requests library? And if not what is the best library for them
Is it possible to make async requests with requests library? And if not what is the best library for them
Haven't used it, but have heard good things abouthttpx: https://www.python-httpx.org/
There's also aiohttp: https://docs.aiohttp.org/en/stable/
I need to get in on that async train.
Could anyone help me understand, how does this work?
@lethal orbit yeah I am currently making an API and I gotta make multiple requests somewhere to return a result and without async it is taking too long to be acceptable. Will try httpx, just gotta wrap my head around this as well https://docs.authlib.org/en/latest/client/httpx.html
An OAuth 1.0 and OAuth 2.0 Client implementation for a next generation HTTP client for Python, including support for OpenID Connect and service account, powered by Authlib.
Could anyone help me understand, how does this work?
@limber laurel poorly xD
It creates a WebSocket with a string concatenation.
Could do that with template literals which look better (and is usually more efficient, at least in python, not so sure about JS). Edit: apparently it is faster in some engines, but not all.
const chatSocket = new WebSocket(`ws://${window.location.host}/ws/chat/${roomName}/`);
btw if you guys are trying to use logic like ==True in jinja2 templates the logic must be lowercase, e.g. true
Hello, I get the is error message whenever i ran makemigrations in Django error: django.db.utils.ProgrammingError: relation "ModelB" does not exist
@lethal orbit Alroght thank you
Why in Javascript we should avoid declaring Number & String & Boolean with the word new?
In Django website static files like css, images and sounds works on my localhost but they are not working on my aws windows server?
In Django website static files like css, images and sounds works on my localhost but they are not working on my aws windows server?
@fast basin do you runpython manage.py collectstaticand serve them properly? Django only serves static files ifDEBUGisTrue
It's not meant to be used in production.
Can someone explain to me the advantage of using websocket? I have this Javascript which works fine:
function runStripePayment(productID, stock){
document.getElementById('product-popup-' + productID).style.display = 'block';
if(stock === '0'){
return false;
}
var response = fetch('/create/' + productID + '/secret').then(function(response) {
return response.json();
}).then(function(responseJson) {
var clientSecret = responseJson.client_secret;
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(ev) {
ev.preventDefault();
stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
},
}).then(function(result) {
if (result.error) {
console.log(result.error.message);
document.getElementById('stripe-error').style.display = 'block';
document.getElementById('stripe-specific-error').innerHTML = result.error.message;
} else {
if (result.paymentIntent.status === 'succeeded') {
document.getElementById('s-token').value = clientSecret;
document.getElementById('user-delivery-email').value = document.getElementById('delivery-email').value;
document.getElementById('form-productID').value = productID;
document.getElementById('purchase-check').submit();
}
}
});
});
});
}
However, I was told I should really be using websockets, as this JS code could be manipulated by a malicious user. I just don't understand how a web socket would work
considering the websocket would should the full paymentIntent data
hi does anyone here know js?
<script type="text/javascript"
src="code.js"></script>```
can someone help me with what this code means
its a script tag linking to code.js file
so basically what happens if u type it in smthn like vsc? @past cipher
vsc ?
yea
what is that
i know, i don't understand your question
what happens when u run that script
it will import code.js file in your html document
ohhhh
so if u have a file name code.js
you can import it to ur html file using that code?
@past cipher
yes
lol you're not the first to say that
lmao
I literally just googled "avatar"
✌️
so.... what's the best way to store a LIST inside django model? Is it even possible to have a list in sqlite database in one cell?
how big is the list
4 elements inside, each element is a datetime
shit sounds complcicated 😛 I will try to google thi phrase thanks a lot
nah pretty easy once you understand it
20 min youtube video and you'll probs understand
anyone good with heroku apps? I am having db trouble xd
This SQL Server tutorial explores inter-table relationships, including how to work with one-to-many and many-to-many relationships. Watch more at http://www.lynda.com/SQL-Server-2008-tutorials/essential-training/71929-2.html?utm_medium=viral&utm_source=youtube&utm_campaign=vid...
@maiden kraken
not sure if its best option for your needs, but always useful to know when dealing with db
anyone good with heroku apps? I am having db trouble xd
@hallow jacinth yeah?
@past cipher thanks a lot man, really appreciated your help and spending time to help beginners!
lets go to #help-falafel
guys I need a help in js. What does const { data, id } = payload mean? I mean what does that syntax do?
lets go to #help-falafel
@hallow jacinth sure
@versed python it means that payload is an object with keys data, id (and maybe more), and those 2 keys get set to variables of the same name
SO it is extracting it basically?
Yeah, pretty much
is this vanilla js or is it something like idk es6? @dapper tusk
So that is normal javascript? const { data, id } = payload
I've seen people struggling to understand what is vanilla JS. To make the long definition short, Vanilla JS = normal javascript
yeah
Yep
since i have never seen it in my own js basics courses anywhere
You can do it in a browser console
Actually, the name was given to it simply to prove that Javascript is a powerful language even without any plugins
oh yeah, ik it works. I just wasn't sure how
doesn't Vanilla mean default? @vague ibex
Since ES6, JS is actually useable without external libraries, though they still help
^
so for example there is a module called axios. Is that a plugin? or vanilla?
Since ES6, JS is actually useable without external libraries, though they still help
@dapper tusk JS is actually believed to be pretty powerful. The name "Vanilla" is just used to make it look cool xD
so for example there is a module called
axios. Is that a plugin? or vanilla?
@versed python There's a difference between module and plugins
What is "Vanilla JavaScript"? ... "VanillaJS is a name to refer to using plain JavaScript without any additional libraries like jQuery. People use it as a joke to remind other developers that many things can be done nowadays without the need for additional JavaScript libraries."
^ for clearing ur doubt regarding vanilla js
its a source from google
that makes sense
Vanilla is a common term for things with no extensions
vanilla ice cream kek
Vanilla is a common term for things with extensions
@dapper tusk this confused me again
check this one.
Vanilla js is batteries included or not?
You'll understnad
Oops, no extensions, typod
lol lakmatiol
I am terrible at not skipping words when on a phone, sorry
just use text to speech duhh
That would wake the dog up
(actually please don't it's horrible)
yeah I did pretty much.
but I still dk why you said plugins and extensions are different
o,o
i dint say that
A plugin is, like its name says, a piece of software that you can plug into an application to provide new functionality. Plugins usually implement well defined API's and are reactive (that is, they provide services that the main application can use).
This is what stackoverflow says
oh
You can refer to the link I sent earlier
https://stackoverflow.com/questions/8519021/what-is-the-difference-between-module-plugin-and-component-in-java#:~:text=A module a quite generic,application to provide new functionality.
@vague ibex this one
This gives a clear explanation in smooth words
and this "component" referred to here. Is that different from Vuejs components?
be it java or javascript, plugins and modules are terms in general
and this "component" referred to here. Is that different from Vuejs components?
@versed python What do you mean by Vuejs components?
A component is any piece of software designed to be reusable.
Oh it is a js framework
so, component is just like a software
lol
yea, ik its a framework
A framework may/may not be a software
A component is any piece of software designed to be reusable.
@vague ibex Yeah thats what Vuejs decribe componenets in the docs too
so django and vuejs are frameworks right?
yep
how does one get so much knowledge from though?
Whenever I have a doubt of my own, I just try my best to get a solution from it
how long have you been doing this stuff?
how does one get so much knowledge from though?
@versed python Its like what u acquire
Well, I'm 14 (turning 15 this year)
how long have you been doing this stuff?
@versed python I've started programming casually at 11
that's cool, I am 18
I'm more inclined towards web development
what I meant was, how long have you been dabbling in web development and stuff?
so its like 14-11 , that gives 3
and what languages do you know other than python and js?
does one need to know anymore for web development?
other than HTML CSS
Its like you know JS today, and a new cool language comes up tmrw
you need to keep pace with the tech
if u dont, you get beaten in the race by other web devs
It actually depends on the work ur gonna do
Learning more is always better
But you need to learn the things carefully and clearly
there is a wide range of frameworks
what exactly do you mean by learning more? Learn more languages? Frameworks?
- langugaes
both languages and frameworkjs
frameworks*
and tips and tricks, you know
whooo I have a lot to learn lol
It is better to have a good grasp on the cool techs
suppose your client tells u to make an E-commerce site, you can have an idea of what to use and what to not
I can make a simple website out of html, css and js for e commerce purposy
purpose*
But if i want it to be a legendary website(Exaggerating ) , then i would prefer django, react and such things
but its probably easier to do with Vuejs or something?
There r plenty of technologies in the market
anything can be done to make an e commerce website
your sense/idea is what it requires
I heard react is much more difficult than Vue. Thats why i got started with vue
if u have already learnt the techs, it will be easy to make a plan
IgnisDa, do you know js or python?
alright anyways thanks for helping me out. Much appreciated! I gtg now
if u have already learnt the techs, it will be easy to make a plan
@vague ibex both
ah thanks! cya! o/
i mean ik both py and js
happy coding! 😄
thanks and same to you
Good day! I want to learn how to write tests. So can anyone suggest good tutorial or something like it how to write tests for django apps? Except official docs
you mean like a quiz app?
i think he want a tutorial to make unit test for his app
i want one too but i am using flask
In my case it's django blog app
Hi. First of all, very sorry for the probably stupid question. I am very new to coding python.
I have created a machine learning model using python which uses a simple text input string to generate some output.
I am running this using Colab, but also locally.
I now want to deploy this project to a website using a simple HTML field and a submit button. Once the user enters some text, i want to pass this string to my external python (.py) file
Normally I do this with python using e.g. "python input.py --input "Some string".
I've been looking a little at FLASK, but i don't seem to find any good pointers on how to work with separate python files, rather than passing around arguments inline.
Any help would be appreciated, where I should start looking. Again, I am a total noob when it comes to this
@regal furnace There is a book about test driven development in django by Harry Percival
I won't tell you if it is any good tho, that topic is unknown to me
@weary dragon I want to learn how to use Django simple test case as example
Hi. First of all, very sorry for the probably stupid question. I am very new to coding python.
I have created a machine learning model using python which uses a simple text input string to generate some output.
I am running this using Colab, but also locally.
I now want to deploy this project to a website using a simple HTML field and a submit button. Once the user enters some text, i want to pass this string to my external python (.py) file
Normally I do this with python using e.g. "python input.py --input "Some string".
I've been looking a little at FLASK, but i don't seem to find any good pointers on how to work with separate python files, rather than passing around arguments inline.
Any help would be appreciated, where I should start looking. Again, I am a total noob when it comes to this
@native tide When a Button is clicked, you can call a function using command option. Assign the command option with the function name you would like to call when the button is clicked.
Thank you @maiden kraken👍 I'll try to find this book, maybe it will be useful for me!
@vague ibex and i can pass what ever string is in the input field to a python file?
Thank you @maiden kraken👍 I'll try to find this book, maybe it will be useful for me!
@regal furnace If you don't like books, I'd prefer youtube videos lol
@vague ibex and i can pass what ever string is in the input field to a python file?
@native tide Most probably, yeah
hehe "most probably"
anyone with a web app hosted on heroku using flask and postgress db think they could help real quick :o
Thanks a lot. I will sure have a look at it. I have managed to create the web page itself
cool! I hope you can manage to do it! Happy Coding!
i will sure try
good luck!
Can I also receive an output from that file to show on the webpage btw?
so it is kept as a variable
session
i basically want to use my python file as an API of sorts
input > output
yea i got you
so you wanna take the input, apply a function on it and display an output?
yes indeed. Even make a file available for download
which is generated by the script
yea sounds nice
so lets say i input "cat" into an input field, and the function will return an image of a cat
although it is more fun than that 🙂
wow thats cool\
lol no
actually it will take a text as input, then generate a text to speech sound file
using a custom voice
that all works already
but the web deployment is tricky for me
btw lemme show u something rlly cool and interesting
presenting DOM manipulation using python!
oh man, its like greek to me
Its rlly easy to use and cool
ok, i will have to try to figure it out
No meter for me@vague ibex. I'll be glad for any good advice!
nice
If you want to do web deployment, knowing things regarding DOM proves to be rlly useful
i can imagine
:]
im a ux designer, so havent had to do this before 🙂
thanks again
if im using flask and i have a csv file i wanted to display
should i keep it as a csv file or convert it to SQL
I’m tutorials with Django.... no one barely talks about “initiated” a class. That’s what’s been wrong with my DB of objects to show
I think startng with csv is okay. You can always switch to sql db later
hello umm
how to add form in detailview currently i am displaying the Post model in detailview and what i want is to add a comment feature on the detailview using Comment model now i don't know how to add the comment form on detailview
can anyone help me please 😅
Django DetailView? @lapis spear
@versed python yes yes sir
From what I understand from your question, you're trying to get two different forms (since you arr dealing with two different models) into the same view. Now DetailView is a generic view and is meant to deal with only a single form and single model. You'll probably want to rethink your view and convert it to function based. Otherwise you'll have to do a bunch of subclassing and inheritance and modifications to get what you need.
do u need to know html to learn js?
no
and its talking about i mean before it was talking about <body> and <head>
what would you even learn in html? It's just a few angular brackets
so whats the use of that?
what would you even learn in html? It's just a few angular brackets
@versed python im not gonna lmao
You probably do want to know basic html before js
well its going smoothley for me
yeah thats right though
Most tutorials teach js in that context
its pretty easy for me ngl js
Guys isn't there any way to upload a Django website to an Apache server without mod_wsgi? Cause some hosts don't have command line interface
@versed python what im trying to do is using post model to display and comment model for form is it possible in detailview?
ight imma code peace
straightforward answer is no. you will have to do a lot of modifications which will probably not be worth all the time.
Oh well
@lapis spear
@versed python oh yes yes thank you sir
So basically it's possible
use a function based view it will be much easier
So basically it's possible
@glass sandal it is but i dont see why anyone would want to go through all that trouble
I did it once just for the sake of learning it was useless in an actual project
Oh I see ... And like could I get an overview of what you need to do?
@versed python sir when should i use cbv and method views? im at lost
hello umm
how to add form in detailview currently i am displaying the Post model in detailview and what i want is to add a comment feature on the detailview using Comment model now i don't know how to add the comment form on detailview
can anyone help me please 😅
@lapis spear they need help with this
<script type ="text/javascript"
src ="Code.js"></ script >
so what this code is doing so if u have two files and one is a html and ur coding in the html and one is called code.js so if u write this script in the html file all of the code from code.js is basically in that script combining with the html code
is this write?
bascailly bringing a .js file inside a .html file?
why do you call me sir @Hello? please don't. As a general rule i use cbvs since most views are generics. when i need to do something special, i have to switch over to function based ones or write a difficult class based one. depends on the use case.
yep
kk
marizuana idk if my discord is lagging but do u have a discord pfp? @sharp grotto
or not
idk if im lagging
I don't
xD
@versed python oh nice nice thank you mate 😅 👍
glad to help @lapis spear
document.write("Hello World"); //do u have to add the ; in it? ```
everytime u run a js code after the ()'s do u have to add a ;
@native tide its not required but recommended
ok thx
most IDEs will add one by default when they format your code
okay
yeah np
ngl js is easier than python in my opinion
i quit python cause its too hard ):
and js is perfect
but imma learn py after i finish learning js
it's the other way round for me. I find js hard.

Python is eaaaasier than JS
i think js is lmao
SO much easier
especially all that Promise and api stuff
JS is easy in the first glance
any language vs language debate is pretty much useless and never gonna be resolved. It's just a developers personal preferences
Well the more programming languages you know , the easier it gets to learn new ones
yea
laughs in C++
XD
<script>
var price = 55.55;
document.write(price);
</script>
is it optional to add <script> ?
you want difficult, get down on the C bois
Yesss
nope
C hard
u have to add <script>
But
<script>
var price = 55.55;
document.write(price);
</script>
is it alright if i just added:
Let's see what you do with brainfuck
var price = 55.55;
document.write(price);
is it the same?
Let's see what you do with brainfuck
@glass sandal lmao
@native tide Is that in your .js file or your .html?
C hard
@glass sandal The problem with it is you have to learn stuff like pointers ajd memory addresses as part of the basics. Thats what makes it hard.
@versed python I know C++ , but C is just barebones you know
C is nice for simple programs
Let's see what you do with brainfuck
@glass sandal i saw the Wikipedia page once. Needless to say, i didn't venture anymore lol
@native tide You don't need <script> in .js files
@versed python XDDDD Same
I know C++ too. But i have never really used it for anything major
just those small calculator programs they make at school
Yeah never used it for my real projects , just done some simple algorithm stuff + Some ncurses
python on the other hand is mmmmmmmmmmmm
@native tide \n
\n
<br>
even for js?
especially coming from C++, i picked up the syntax with a day and made my own hangman with another day
Yes
kk
For almost any language it's like that
@versed python omg my first lang was C++ and then Python , wow similarities
@native tide You need to document.write them
you Indian? @glass sandal
hmm
i was taught C++ at school, learnt py myself. wbu?
I'm not too much into religious stuff , tho I respect them
@versed python Learned all by myself
i learned myself too
im not like perfect in coding
like im still learning js and py
I'm just like 14 tho
I don't think anyone from our generation is really serious about religion
Good
im 18
lmao
yep
i like to code cause i wanna make a buisness
i can photoshop so i wanna make a buisness where i create ads
i can video edit too
you should start by learning how to spell business my man @native tide
No I loved coding in the first place , cause I LOVED inventing . And inventing needs money . Coding is like inventing from scratch . That's what I loved about it
business
lmao i thought it was that for my whole life
Don't get spell problems please lol
I love coding since people are annoying. mostly.
lmao
Lol?
i have a quest about hacking its a pretty weird quest but was wondering
nah you guys are fine. people are fine when you vibe with them
otherwise m.. mehh
is there a hacking lang ?
I like coding because it is really hard to make an irreversible mistake
goto
Though this is getting ot
@native tide Python is the best I could think of?
let's take this to #ot0-fear-of-python
Yes
like using js to make a coding lang
YEsss
@versed python yo😅 how can i reference in view the currently displayed data in my detailview?
like accessing the post title in detailview
i want to fill the user and post field by current user and displayed post in detail view in my comment model is this the right solution?
def form_valid(self, form):
form.instance.user = self.request.user
form.instance.post = self.request.post.id
form.save()
this is the comment model
class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', on_delete=models.CASCADE)
comment = models.TextField()
user = models.ForeignKey(User, on_delete=models.CASCADE)
@versed python
instance = form.save(commit=False)
instance.user = self.request.user
#... whatever else you want...
instance.save()
@lapis spear
@versed python i got an error it seems a field in comment is not filled after sent
NOT NULL constraint failed: blog_app_comment.post_id
well yeah you have to associate a post id to it.
form.instance.post = self.request.post.id
wait what
no
instance.post = form.cleaned_data.get('post') use this @lapis spear much easier
@versed python alright thank you 😅
@versed python oh i edited it sorry😅
@versed python yo this must be a silly question it seems like i don't understand much what im doing but i think its solving the problem does that count? can i proceed and just hope the as time goes i will understand it?
or should i take a rest and understand it?
yep that's how i do stuff. just follow blindly whatever the right way is, i end up getting it later
for example what the hell does this do?
def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = self.get_form()
if form.is_valid():
return self.form_valid(form)
else:
return self.form_invalid(form)
😅
@versed python oh i see nice nice i m hoping that the more i repeat those stuff i will understand it
yeah
for example what the hell does this do?
def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = self.get_form()
if form.is_valid():
return self.form_valid(form)
else:
return self.form_invalid(form)
😅
@lapis spear which part?
@versed python self.object = self.get_object() this one sir
the others i think i get it like getting form and checking if its valid or not
if you look into the source code of this particular CBV, you will find it implements a def get_object method.
@versed python self.object = self.get_object() this one sir
@lapis spear this particular line is just calling that method and associating it with the object attribute
if you have time, i highly recommend you checkout the django source code. You'll learn a lot, especially since it is well commented.
it's on http://github.com/django/django
@versed python alright thank you again mate 😅
yeah no issues
Yes
Should it be the exact same routing????
Then you include app's urls in project's urls
That is a good design in general, will help during extention of project I can say Same for the template, inside the app folder templates/app
Shouldn’t the pages “for the app” be only in the app urls? Then the main HTML pages is the actual project?
Yes
Has anyone here implemented PageView events using Facebook Business SDK?
@prisma jackal I only have one “views.py” file and that’s in the app, not the main project
can someone help me?
var x = 3;
switch (x) {
case 1:
document.write(x);
break;
case 2:
document.write(x+2);
break;
default:
document.write(x+5);
}```
can someone tell me what this code means pls
its kinda like an if statement?
fuck all without context
like whats it doing
if you mean the switch statement
its just doing what a block of if elifs would be doing
i dont get break default and swift
Switch is more fast than if statement
its another way to write conditional statements i guess
so how is the output 8?
its basically doing
if x = 1:
write x
elif x = 2:
write x + 2
else:
write x + 5
so since x = 3
the first two dong work
@frozen python project urls is for handling all urls from different apps. Each app should each own urls then urls from a given app is imported in project urla
its a way to write a bunch of elifs
default is basically the else
Prefer switch to if statement when they are both working equally.
Break prevents fallthrough
@young saddle so I need to update 2 files then? urls and views?
is that django?
@frosty lion yes
Yes
okay
Why????
I have one project that I only have one views.py and it’s in my app, not main project
u should have a templates folder for ur html
i think its called static
only apps should have views im quite sure
ur folder with settings and stuff doesnt have views?
@frosty lion no, that’s a picture of it. Why do I need to update 2 view files? Isn’t one good enough?
ur templates folder
seems kinda wrong
unless u changed how django will search for static files
I have a products folder with detail.html in it, then it’s the other files for the pages
“Shop” is my project, then “product” is a app. Is this setup right?
@frosty lion
products and shops seems to be at the right level
ur templates should be app sepecific
and should be inside the folder for ur app
@frosty lion but, that’s not how the default layout is? Should I have the exact same urls for the shop and products?
@frosty lion SHOP is the shop is the project (main) then products is a App
Break prevents fallthrough
@prisma jackal wdym?
Any experienced django user here?
If yes, I'm used some very complex UI made in HTML and CSS. Checked how Django forms work and it seems like it's a bit tricky to use already made forms in Django. Should I go with the trouble or just use Angular connected to DRF?
You can make your own forms you know and just send a Post request
No point using angular just for some forms
Do you have any guide that shows it? Never done Django beside drf
Litterally raw Html and css will work
Oh okay, and views will do the work?
Oh okay, and views will do the work?
Oh okay, and views will do the work?
Holy crap sorry
All you need on django's side is a check to see the request method and get the body if its a Post request
I Litterally never touch any of the form generators
Making your own forms are easy enough
Cool, mind if I add you to show if it's done right when i get my guy to do it?
Sure but I'm about to sleep so won't respond for a bit
All good champ, thanks
so what this code is doing its switching day with case two day 2 is = tuesday (case 2)
switch (expression) {
case n1:
statements
break;
case n2:
statements
break;
default:
statements
}
Wrong channel (wrong Discord?). And switch statements normally will fall through (execute) the cases starting from whichever it initially matches.
but this is help with js read channel info
so what this code is doing its switching day with case two day 2 is = tuesday (case 2) am i right about this?
but this is help with js
Sure. You also could've just searched that statement up and not pinged a user which clearly stated that he was about to sleep 40 minutes ago.
lmao i never read that tho
so my bad
Sure. You also could've just searched that statement up and not pinged a user which clearly stated that he was about to sleep 40 minutes ago.
@wicked tide alright my bad about that i never read that cause my pc battery died so sorry bout that
I have no damn clue what you're asking about, being honest. I cannot decipher what you're asking. Fix your english and example.
do u know js?
Sure. But switch statements aren't just Javascript.
well im learning that in solo learn
in javascript course in solo learn lmao
wait i read ur thing wrong @wicked tide
im talking about js
Technically the switch statement you provided could go straight into Java, is all I'm saying. It might go into C# too, and a couple other languages. Still, no idea what you're trying to ask.
Does anyone here have an idea as to why this element has a height of 0? It's a Skeleton component in Vue. It might have no content inside, but it refuses to expand the height.
I've tried height: 100%, font size, min-height (as shown) etc. The element above has a height of 24px, so that can't be the problem.
PermissionError: [Errno 13] Permission denied: '/flask_session' im getting this and its infuriating, I've been tring to fix it all day.
- www-data has access to flask_session
- python directory is correctly set
can someone tell me whats the diff with
document.write("Hello World") and console.log("Hello World!")
uh
they are very different
document.write writes html to the DOM
console.log prints text to the console
don't use document.write unless you have a good reason to
console.log is usually used for debugging
@native tide
why my validation is always getting false when I have Free tag ? https://dpaste.org/8pL4
ok so I have a django rest framework app thats getting fairly big and we've got a repeated problem where we want the serializers to have different fields for normal users, admins and creation, we've ended up with viewset abstractions to make it a little nicer, but it feels like this problem must have come up many times before to other people, is there a better way of doing this?
maybe you can override the get serializer method on the viewset and then add conditionals there, and return an appropriate serializer there? @spark rover
we already do that with some viewset base classes we defined, maybe its the only way, it just feels really hacky to have this many serializers
don't serializers have a get fields method?
they do https://www.django-rest-framework.org/api-guide/serializers/#dynamically-modifying-fields @spark rover
Django, API, REST, Serializers
I'll have a look at that, thanks
you're welcome
ok so I have a django rest framework app thats getting fairly big and we've got a repeated problem where we want the serializers to have different fields for normal users, admins and creation, we've ended up with viewset abstractions to make it a little nicer, but it feels like this problem must have come up many times before to other people, is there a better way of doing this?
@spark rover I too had this problem!
what I ended up doing was creating a subclass of Serializer which, when initialised, takes a keyword argument allowing you to specify what fields you want
(basically)
and in particular, for my usecase there was often nesting (usually only one level, but still)
so there was also the ability to specify whether I wanted to use a child serializer or just the normal PrimaryKeyRelatedSerializer
Guys can anyone tell me what is the equivalent of logging that we do in python but in Javascript?
i am not talking about console.log
i actually want the data/errors to persist
not unless you have a special use case and need to do that. Why complicate things when the easier one gets the job done? import this @glacial night
yep @glacial night
So, im making a blog and im working on the profile pic feature rn. I've ran into a problem where the specified picture will show up on the web site but not the default picture I have set to
what module do you use for using google's oauth2?
is it a good idea to do /products/id/reviews/ or just show all reviews as a object inside product instance?
@glacial night depends, really.
on what? amount of reviews? @vestal hound
@glacial night not really
more like your workflow
for example
how often will you need
just the product?
how does this align with your conventions
for your other endpoints?
etc.
honestly this is the kind of thing
you can try yourself
and after a while
figure out
I would say both approaches are viable
okay
if you're not in a rush
I'd suggest
you pick one
and try it
experimentation is how you learn
what do you mean
hey i am very new to web development. i just wanna know where to start.
what are the different coding format which sanitized the user inputs
how do you show code in discord?
@glacial night
change js to py for python code
same for html, css etc
hai anyone here
ask away
hello
hi i have a prob with an html templTE
what's the problem with it?
ok, idrk what that is
here ya go
<!DOCTYPE html>
<html>
<body>
<header>
<div class="container">
<h1 class="logo">danoxzilla's web app</h1>
<strong><nav>
<u1 class="menu">
<li><a href="{{url_for('home') }}">Home</a></li>
<li><a href="{{url_for('about') }}">About</a></li>
</ul>
</nav></strong>
</div>
</header>
<div class="container">
{%block content%}
{%end block%}
</div>
</body>
</html>
hello?
hello
heres ma code
ok
looks allright to me
just copy paste it into HTML file and open it
u hacker?
not that hard
just copy paste it into HTML file and open it
@proper trench i did dat man
ok, do you use VS code?
ur running off of a local server
not just a basic file
just open ur html file with crome
use that then
it says file not founf
