#web-development
2 messages Β· Page 197 of 1
I understand, but that is not what is meant by dynamic or static
Oooh idk actually like I still have no idea how my site is gonna look
Probably just 1 page
Do you have a site
And how much is it going to cost
Well based on what you've told me, I think you could get a site up quicker than 6 months if you apply yourself
Nice
I don't have a site that is publicly available right now
Ohh wdym with publicy
Hosting plans are pretty cheap, but cheap can be relative
The site I am working on is in dev state, so I just run it localy
Ohh cause if it's like 20 dollars a month I need to find a way to make money online
Nicee tell me when it's public so I can visit it
taKE A look at their pricing, this isn't a direct recommendation, but an example of what the cost may look like
HostGator is a leading provider of secure and affordable web hosting. Discover why thousands of customers trust us to handle their website hosting needs.
guess it would help if I posted the link
yes, with a catch, note the * asterisk
But can it get than like unlimited visitors
the next year the price will increase
Ohh damn
Than I really need to find a way how to make money online haha
So I can run a website
it is hard to define unlimited, if you have a 1 page site, not really creating much server load because you are not doing anything on the backend, you will probably be fine
Nice
bear in mind you are probably also underestimating how long it will take to buyild a following
But it can handle like 50k visitors right cause idk how it works but I readed that some sites can only handle a limited visitors
Yeah true
Ig
So now I only need to see how I can make that money online to run that site
i mean a basic site that is only html, css and a few png's isn't going to create much server load.
What does server load mean like how many memory or bruh idk what I am talking about π
how much memory and cpu you are consuming from the shared resources
all cheap hosting plans are on shared servers, so you split resources with your neighbors
Ooh nice so I had it almost right with memory
Nice
yah
i have a hosting plan, it was cheaper to get the plan than just register the domain. However since shared hosting packages almost never support python in any meaningful way, I will probably have to pay for a VPS at some point
Should I do freelancing work to get that 3 dollar a month
Ohh
You can, definitely.
I can try it tho
Okay that seems nice tho cause next year I am going to follow ict on school
And I am going to work with arduino than
You can run a decent amount on a $5/mo VPS with some linux skills.
@native tide good point, @gusty reef you should familarize yourself with Linux
What is linux
Handful of commands and understanding docs gets you a long way.
Ohh nice i only need to see how am I going to get that 5 dollar a month XD
It runs the majority of the web
I take it you probably don't have a job? student, etc
would your parents spot you?
Idk maybe
where I live $5 is nothing, but I know that isn't true everywhere
What should I do if they don't should I do freelancing or something than
How about this, @gusty reef . You make something worth putting on the web, and I'll pay you the $60 for your first year on a $5/mo server.
freelancing as a noob is a bit dangerous,
I am from the Netherlands
Ohh XD
@gusty reef heh, not too familiar with the Netherlands economy
Ohh sorry i really can't take ppls money I want to earn my own money by working hard
Ohh it's just decent I think
my advice, before worrying about hosting, or how you are gonna pay for it; build your site locally, make sure you actually enjoy creating websites
That's my point. You will be working hard...to make something that's worth putting on the web. If you have a real project, that's ready to use and will run on some kind of hosting, I'd be happy to help out an up and coming developer with some hosting costs.
Okay yeah I can try that first
Yeah but
Idk it feels weird to take ppls money
@echo iron is right though, you have a whole lot in front of you before you're even ready for that.
Yeah true
I can update you guys if you guys want it
Cause I still need to learn everything about coding
And stuff like that
So it's going to take time XD
sure hang out, don't be a stranger
Absolutely. And I'm sure you'll have questions along the way and if you go with Python, this will be a good resource.
Okay thx
I'll install everything I need tomorrow on my laptop
What is the best way to learn coding
Depends on you...really. Books and or videos help, but nothing beats trying it out.
Okay so I just need to try things
@gusty reef That being said, the site as you are describing it is less coding and more about layout
And do as much as i can everyday
HTML and CSS are not programming languages
Yeah true
Ohh what are they than
Like layout languages if that exists
Idk
html is a mark up language, and css is a styling language for lack of a better term
Nice
a lot of ppl start where you are tho
How old are you guys if I can ask you don't need to answer if you want
Nice
then they realize they need a programming language, because they want more functionality from their site.
I'm in my 40's trying to make a career change
Ohh like phyton
Ohh that's cool
hence why i am learning python, and yes exactly
I am 16
Yes haha
Okay thx
π
Ohh that's good tho cause I already have a glasses π€£
When I am in my 40s i am probably blind lmao
nah, I wear glasses too, since I was a kid
Nice
r u using windows 10?
Yes
Cause I am on my school laptop
It has a ryzen 5 5600u and 16gb ram
So idk if that's good for coding
search the M$ store for Ubuntu, it is a command line version of linux for windows, will let you familiarize yourself with linux
Okay is Linux like a whole software like windows
Yiss
Cause I think I can't change from windows to Linux cause of school
Or I would have to buy a new laptop
Or pc
it will let you run the Linux command line interface within Windows!
Okay thx
yup
But I think I have to sleep now XD cause it's almost 2 am and I need to wake up at 6:30 for school so thx for all the help I'll start tomorrow after school with all this but I am going to sleep now
Bye
Thx
guys does some one has a really nice DJANGO course like those from zero to hero
with projects included pls
cs50w by harvard, tech with tim youtube, coding entrepreneurs on youtube, there are alot more which you can pick from
Anyone know how to use the tmp storage on Heroku using Flask?
how do i overwrite webpush_serviceworker.js in django-webpush?
I literally followed 6 before completing my site
how do i show push notification only when tab is not visible?
document is not available in service worker
so i can't do document.hidden
hey guys, does anyone have an idea why I'm getting this error in react js
Error: Invalid hook call.
what does your nav.html look like?
why do people use linux?
@quasi willow are you asking in terms of development on linux
or just general every day use?
linux is more lightweight meaning less bloated, quicker and more reliable than windows
hence most of the servers on the web that make up the "internet" are running on linux
what do you mean lightweight
windows in particular has so many trackers in its code as well as useless features that just eat up you RAM that it noticeably affects your performance
for example in games you would see an actual drastic change in FPS
if you ran some of "debloating" cleaner programs
that get rid of all the tracking and optional features
that run in the background
in linux thats not an issue most of the time
@quasi willow also security
compared to windows linux basically doesnt have any viruses
customisation as well, you get way more control of your linux machine that you do of your windows or MacOS machine
whats in nav.html
I am web developer, I develop application which run at Linux servers.
Using Linux for development helps me to learn the target where my apps will run
Plus all web developing tools have only Linux support by default. Windows and MacOs are supported at the remaining level with half arse amount of efforts.
Every stuff is just easier to install at Linux. CLI faster than GUI
Plus it is nice to have a bit of privacy. Windows is surely one big bloated spyware
If I would choose being desktop Dev, perhaps I would have remained at Windows
I keep having windows at dual boot purely for games btw. I am not π· perverted enough for alternatives.
but if we put web dev aside, what about other things like AI or mobile dev
can i share my free hosted dynamic website, on 000webhost, to anybody else ?
AI is python, and python works everywhere. Although I think companies wish for web dev + ML, so it goes again to linux
and android dev?
Mobile device I am not sure
It depends on where Android development thing works better
Technically Android is Linux, but I heard people were finding windows better to contact their droids
Not sure for sure, I did not do mob dev
If u develop for macos and iOS. Obviously u need macos ;b
Plus... Partial support for mob Dev is extended to technically web frontend solutions. React native, Vue native, and few other things.
But kotlin should be more powerful by magnitude
I did not do mob Dev, that is just what I gathered as rumours ;)
π
Because windows is preinstalled everywhere when u buy computer.
U got used to it
It takes different habits to get used to linux
Windows is technically stupid user oriented first
Linux is technically oriented to developers first
then does that mean that you can install linux on your windows computer?
Linux desktop experience can a bit suck. More advanced skill is preferred
Sure
In different ways
Virtual machine
Dual boot on separated logical volume
And etc
and can i install window back again?
Sure, but there are some complications
Let me tell u them
Linux works fine without license keys
And in 99% cases u don't need to install any additional drivers
If u install Linux as dual boot, u keep windows and can return safely back at any moment
But
If u will replace windows fully with Linux.
Reinstalling windows back requires from you
Having license key
Installing right windows for driver compatibility and downloading them
Usually windows key is written into your hardware.
Perhaps only specific windows version release will work on your pc
idk how to made web by py
Can someone help me with my Django code?
so dual boot is recommended?
Yeah. Virtual machine as lightweight easiest choice to try (but VMS are laggy)
Dual boot for full diving is recommended
I usually just install to separate hard drives (dual boot at physical level)
I just know how to create game by python
Linux is not requiring a lot of space. 50 GBS will be more twice more than enough
so with dual boot, i can simply just change whenever i want?
:
Better to backup everything before doing that though, just in case
As a first experience it is possible that u will crash boot, and since u use logical volumes
I use separate hard drives just because of that π
That is part of reinstalling any operational system
U just learn how to handle it
And keep less attachments at pc. Everything backing up to clouds (or at least to external drives)
It is just best practice with any OS
k
hmm the UI doesn't look that bad
yup. and once you learn linux... you understand that you can't go back.
linux gives you full power and control over its system
everything can be configured, you are the root, you are the admin
in windows... access is quite abstracted from you. u a just having semi user access, pseudo admin.
i used windows for 15 years, but after few months of diving into linux... it was already a point of no return for me)
i return to windows only for games, or in case of need to develop smth for windows.
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
getting json decoder error fetching records using nsetools
few hours back there was no such error
how to solve it?
i am fetching record using API
it is not mine
check the records
this is the line where i am getting the error
and when i am using it outside the project then also it is showing the same error ...
is that a problem with api coz in docs the same thing is working?
<!doctype html>
<html>
<head>
<title>Home page</title>
</head>
<body>
<h1>Home Page</h1>
<p>Hello</p>
</body>
</html>
I have an error with this
how can I fix this
Remove or fix the doctype tag
hey guys, does anyone have an idea why I'm getting this error in react js
Error: Invalid hook call.???
Your hook call is invalid. That's all we know because you haven't told us anything else. This is a Python server anyway so not sure if anyone can help you with react
well, isn't it in web development category?
Sure but there are other servers where you might have better luck
I did ask in a react server, but they are of no help..
Is web development worth doing for the future? π€
That's a good question. But with everything, it mostly depends on how good you will be/are.
That's how you will get the people to consider you as an option when trying to make a website. So you can't exactly tell if it will be, maybe it will, maybe not, but you should proceed to do what you are skilled in and love doing.
Ok, thanks a lot. Also another question, can Python be used in professional web dev?
Yes!
Ofc
Hello,
I need to help about Django models.
I have custom User model and email and phone_number fields. Users can signup with any of this fields and these fields are must be unique. When I use unique attributes for fields user must fill these. How can I use these fields unique and one of blank?
I believe adding null=True, blank=True to the field should do it. Null shouldn't count against uniqueness
how can i show push notification only when tab is not in focus?
You asked and they told you to supply them with more code to be more helpful for you. So you ignored that and came here.
And again offered basically nothing to get to the root of the problem.
funny in python you have one way to create an array while in javascript they have alot of ways to create an array << disaster language
gota love python
First of all, both have different uses. PHP is only for Web-Development. Python on the other hand, can do much more than that. So I do not know what you wan't to use them for. I would still go for Python because PHP is way to old. It's also not really the best because it can only function at the start of the program (before the website is actually on, I think). I would not consider learning PHP nowadays because you got way better options ahead of you. So yeah, Python.
Doesn't matter if you can do PHP, still gotta learn JS :/
I use PHP for a lot of network automated tasks. over the open internet. but most things I've wanted to accomplish in .py, I fall back on php for anyway. since it's familiar.
Well, at the end of the day, I can't tell you what to use and what not to use ;). If you prefer PHP and don't need Python, go for it.
Can you please explain your problem more precise?
the static file not change any thing
Codes do not work
I put it on the right track and I did
python manage.py collectstatic
@solar zephyr
Are you using Flask?
no
django
when i collect the static no files that i create imported
it says 0 copeid
and i have a css folder and its contans a style.css file
pls help
@native tide
u can help me ?
I have a question is it possible to run a api website in a apache2
Or does this have to be started separately from the website or how does this work exactly ?
hellllllllllllllllllllllllppppppppppppppp
@native tide check the spelling of STATICFILES_DIRS
yes you can do this. Typically the split between an API and the rest of the site is either done as just a path (eg /api/...) or at a subdomain of the site ie api.example.com both of these would be possible in apache
nothing no files or folders has been coped just the admin folder @lilac solar
how can i fix
i create the static folder in project
and i collect it
and no fiels has been collected
files*
Do you have the STATICFILES_FINDERS setting set to something?
add this to your settings.py and try running collectstatic again:
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]```
@native tide more broadly I would recommend using cookiecutter (https://github.com/cookiecutter/cookiecutter) with this template (https://github.com/cookiecutter/cookiecutter-django) to create a django starter project with everything you will need to let you focus on learning the basics of Django. It will save you a ton of time and lets you focus on learning rather than settings you don't know about yet
okay, but i want to learn all the thing to not fall in the way you know
sure, i get that but I literally went to that templated project to look at what settings you were missing, they are the kind of settings that you don't want to think about for every new project, they need to just be there when you start the project.
That template also has a lot of good practices that will benefit you when learning Django even if you don't use them straight away
Can u pls tell me which one
i want to do e.g. api.example.com but do i need to install something extra to activate the api and connect to the api.exmaple.com website or how do i do that exactly?
You ought to be able to configure an extra virtual host in apache that can go to either the same upstream server or a different thing entirely if you want. What are you running behind apache?
i just installed apache2 on my normal vps server and have the api page running so without the flask codes but if i just add the flask code for example the page does not work anymore
You will need to configure mod_wsgi to connect to your flask app. I default to nginx these days but a quick search for flask apache returns a few relevant results: https://flask.palletsprojects.com/en/2.0.x/deploying/mod_wsgi/ this would be a good starting point
Is ngnix better for an api?
both are good
any tutorials for how to world with django and React at same time? xd
How can I see if I already have mod_wsgi
From a stack overflow answer, may need some modification depending on what your VPS is running.
To check if it is installed:
$ dpkg -s libapache2-mod-wsgi
In case it is installed, you might check if it's loaded by Apache:
$ apache2ctl -t -D DUMP_MODULES
You added a new non nullable field to your model and the database doesn't know what to put there during the migration. You either need to allow it to be nullable or give it a default.
aha i fix it thx
i forgit ti
Hellooooo, using django to make a site and have the site made but getting it on wit uwsgi is not working. Tried running it but keep getting module not found errors where it says it can't find my project which is specified under module in the uwsgi file module=Mysite.wsgi:application. Done some research online but those solutions didn't fix my issue. Any advice?
I am using Flask and socketio, and I cant seem to get the socketio.emit and the socketio.on to communicate with each other, no errors at all. Heres the code for the both functions: ```py
@views.route('/join/', methods=['POST'])
def joinGame():
gameCode = request.form.get('pin')
name = request.form.get('name')
print("sent info")
socket.emit('join-game', {'pin': gameCode, 'name': name})
return render_template('test.html')
@socket.on('join-game')
def joingame(data):
print('made it this far')
gameFound = False
pin = data['pin']
name = data['name']
for i in games:
if games[i]['pin'] == pin:
gameFound = True
if gameFound == True:
print('Bruh')
join_room(pin)
else:
print('Didnt find anything')
redirect(url_for('views.join'))```
Hello
Sorry I am still a noob I just started today with learning
what libraries can I use to make this kind of file explorer tree for my note taking app in html css and javascript
https://www.jstree.com/ is probably a good place to start
Hey nano do you have a second?
<!DOCTYPE html>
<html lang="en">
<head>
{% block head %}
<link rel="stylesheet" href="style.css" />
<title>{% block title %}{% endblock %} - My Webpage</title>
{% endblock %}
</head>
<body>
<div id="content">{% block content %}{% endblock %}</div>
<div id="footer">
{% block footer %}
{% endblock %}
</div>
</body>
</html>
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def home():
return render_template("test1.html")
# @app.errorhandler(404)
# def page_not_found(e):
# return render_template('404.html'), 404
if __name__ == "__main__":
app.run()
{% extends "test1.html" %}
{% block title %}Index{% endblock %}
{% block head %}
{{ super() }}
<style type="text/css">
.important { color: #336699; }
</style>
{% endblock %}
{% block content %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage.
</p>
{% endblock %}
Having difficulty with jinja 2, not sure how to approach this as the page isn't loading the seperate files.
Assuming the 2nd file is "test1.html", it needs to extend "base.html", not itself.
That was the old problem but yes this is essentially it, the files weren't pointing to the proper places
I ended up getting a bunch of errors as a result of the files
my first django course was this person on youtube called telusko, it was some 3 hrs
How does anyone like JS
What's the most efficient way to query a postgres DB for a string that I am splitting in Django? For each word in the string, I want to return the objects whose name contains one or the other from the split array as part of its name (so partial words would also match).
@inland oak
first possible solution that comes to my mind:
pseudocode
SELECT your names from your table
WHERE word LIKE %name% in Array(word1, word2, word3)
second solution: Postgres probably should have bulk request feature
where you can request stuff with delay, when you already requested everything
if you want a django ORM way, you'll want to look at contains and icontains I believe
Third solution:
for stuff like that I think people apply Searching Engines to databases, like Elastic Search
and query stuff with them for more speed
I'm using the ORM, yea.
I have the icontains, but I'm getting stuck on how to do it for multiple words and then return the joined query.
I'm afraid I'm getting into some inefficient areas here though.
Django ORM has syntax for __in thing
icontains__in=["list", "of", "stuff"]
yeah, this in
Are you sure icontains can be combined with __in?
maybe not
you might have to do a big OR in the filter
.filter(Q(title__icontains="word1") | Q(title__icontains="word2"))
And if you have n words?
great question. π€
or if it's sometimes 1 or sometimes 2, or sometimes n
might have to construct a query in sql and then use the raw sql method
there might be a way strictly using the ORM, but I can't think of it at the moment
What's the use case, someone enters a bunch of words you want to find rows that contain those words?
Yea, user enters one or more words in search. DB returns all objects with any of the words in the object name, either partial matches or full.
I've really only seen it done with a single string. After that, we use elasticsearch
Ok, i'm not too familiar with that. I'll take a look.
Whole can of worms, but if that feature is important, might be something you want to use.
raw sql will be the easiest way to stay in postgres world
you can do this
q = Q()
for word in search.split():
q |= Q(field__icontains=word)
query = model.objects.filter(q)
not sure if that's good or not but I've definitely done it before
really? that's awesome
I was thinking that, but didn't think you could functionize it like that
yup!
TIL
Will try it, thanks!
in flask we use
if __name__ == '__main__':
app.run()
why we use this we can use if a = = a or something else
It's because __name__ is only __main__ if ran by the main script, otherwise it's the name of the script (like an imported module or something, which won't return __main__)
It's used to mark scripts as runnable, and they will execute the code inside it only if they were ran as the main script.
oh ok thank you
So i'm trying to make a website with a made-up map that shows if parking slots are available based on license plate detection using pi camera to provide images. I would just like to know whats the best tech to use to achieve this. Like i started using django for it and i'm a bit lost on whether i made the right choice or i'm taking the long way to achieve my goal.
If you're going to do the frontend with Python I would think Django is the way to go. Or maybe Flask if you're going to keep it very simple. Aside from those two, you would probably need a js framework
https://svelte.dev/tutorial/basics as an easiest js frontend framework
this will make me add a file ??
@native tide
@lilac solar
any one of u u are the best
so help pls
What is the right way of if condition for this case?
def validate(self, attrs):
"""
At least one of the phone or email information must be provided.
"""
if "phone_number" not in attrs or "email" not in attrs:
raise serializers.ValidationError(
{
"email": "Email or phone number is required.",
"phone_number": "Email or phone number is required.",
}
)
return attrs
Hi!
I'm looking for an asyncio package (I'm using Starlette) to provide a server push service (usable within a ServiceWorker)...
Any idea?
models.FileField?
@native tide That error is basically saying that "FieldFile" doesn't exist. So often this would happen because you didn't import it or you misspelled it.
Where could I get started with creating a dashboard for my bot? I've got a website running on Flask atm
so how to import it
i import the media for img
but now i want files
so pls help
@dense slate
Is this in your models.py? Did you try FileField? I've never used FieldFile, but I think that's used in views.
Didn't you have this same error before?
@native tide Sorry but I'll have to ask you to try to learn to ask some better questions and show an interest in learning how to figure these things out on your own. We aren't your personal debuggers but we will absolutely help you learn if you show some initiative to learn how to first debug these things on your own and then work out why you are stuck. For example, I have no idea what that error is referring to because you don't provide any of the traceback or any other relevant code, like your /post/add/ view. What have you tried to fix it?
Hey guys, i have a question. There is someone asking me for making a website. how much should i charge for the website? or how much is the correct amount?
@fast hare Whatever you feel your time is worth. Find out how complex it is and how much time it will take. Try your best to convert it into hours and think about what you would want per hour to make it worth it. There's no right answer, just what you feel is appropriate for your effort.
you still didn't show your stacktrace
Hey can I check if this is the right way of aligning tags in script?
How do I make in flask for example that if I enter 127.0.0.1:5000/ironman that it then returns for example an endpoint like e.g. 127.0.0.1:5000/data/ironman.png
you're adding a new field to your schema and don't have a default value set. Your database doesn't know how to add the new column.
You probably want something like a redirect. I believe flask has that.
they should make a channel for working with python and socket io for video streaming, voice chat etc xD
Hello I am back
Guys I have a question what is a free tool website that ppl often use
Cause I wanna make a website like that
I know but I do not know exactly how this works
I want it to pick an endpoint when I type 127.0.0.1:5000/ironman I want to make a gif api so to speak
I think it has something to do with my initialization of socketio, but I dont know
Sorry if i could code I would help you but I can't sadly I am learning it tho
thats fine, maybe someone else can help me π
Yes I am sure someone here can help you :)
Do you maybe know what for website I should try to make
um, idk
Cause I want to make something like a speed testing site, is that hard to make
Do you have any code yet attempting this?
I have a code but when I enter for example 127.0.0.1:5000/ironman nothing comes or it comes an error that it finds nothing or what
Can you share any code or error messages
Could I send you the code via dm so you can have a look at it right now I have no errors but if I simply 127.0.0.1:5000/ironman nothing happens then no endpoint comes up
Any reason you don't want to use a help room here?
@app.route('/ironman/<endpoint>', methods=['GET'])
def ironman(endpoint):
return f'http://localhost:5000/ironman/{endpoint}' + (str(random.choice(os.listdir(f"C:/Users/wn/Codes/Extras/ironman/{endpoint}"))))```
so its a image and file fild so i dont have a duf value
if i type https://172.0.01:5000/ironman should come something like https://172.0.01:5000/ironman/ironman.png
but nothing happens
Ah okay. I think you want something like this. You pass the term as endpoint and it goes and pulls a random image from the folder and returns it.
@app.route('/gif/<endpoint>', methods=['GET'])
def gif(endpoint):
image_path = str(random.choice(os.listdir(f"C:/Users/wn/Codes/Extras/{endpoint}")))
return f'http://localhost:5000/gif/{endpoint}/{image_path}'
Exactly
made it more general, try something like that and see if it gets you closer
current, you aren't allowing old records to be null
when I go to http://127.0.0.1:5000/ironman nothing happens it just says nothing found ?
did you try http://127.0.0.1:5000/gif/ironman ? Not sure which code you copied
i changed it back to ironman and the endpoint should be the gif not image_path ?
It's tough, you need to serve up the images somehow and they need to be accessible by the server. I need to get a few things done, but can help you in a bit.
so I'm testing everything on pycharm can it be because it does not work or how ?
shouldn't be. Have you gotten a simple url to work, just something that returns hello?
so type what in the field
localhost should be fine
need to supply a default or null=True
I'm out for a bit, catch you later
Is there a guide somewhere for using nodejs npm modules as ordinary JavaScript served from Flask /static/ ? Can I just comment out the require/import/export stuff in the .cjs files and call stuff from the global namespace?
I just have one module, I don't need to make a webpack bundle THANK GOODNESS
unfortunately it includes another .{,c}js file with requre() so I'm going to have to take the brain damage hit of trying to understand javascript, aren't I?
can someone help me? the error is: the User model save the user of the form but don't do the same thing with the Profile model
What's the error?
Your form doesn't do anything for the Profile. If you want the profile to be created with nulls on User creation you need to do that in the view or save() of the User Model
none, I just want you to create the user using the User model and the profile so that I can log into the page, but only create the User not the profile
Yea I was wondering why you were sharing the user form with the profile model.
I don't think I understand this.
Those two points seem to be opposite of each other.
Still have not managed xD
Did you get a simple URL working? try to get something like 127.0.0.1:5000/ironman to return "Hello, ironman" first.
that works
@app.route('/ironman')
def ironman():
return 'Hello Ironman'```
that's cheating, I mean something like this
@app.route('/hello/<name>')
def hello(name):
return f'Hello {name}'
It works
but it does not do what I want I can only send you something about dm so you understand what I want to have approximately please
Either I am explaining it wrong or I am lost
I hope you understand now approximately what I want to do either I do something wrong or I do not know it
in any case it does not come out what I want
someone please help thank you
django.db.utils.ProgrammingError: column Occupier_occupier.date_of_birth does not exist
LINE 1: ..."."is_staff", "Occupier_occupier"."is_superuser", "Occupier_...
email = models.EmailField(verbose_name='email',max_length=59, unique=True)
username = models.CharField(max_length=30,unique=True)
occupations = models.CharField(max_length=200,null=False) #amount of occupations user does
#cliques = models.ForeignKey(Clique,null=True,on_delete=models.CASCADE) #cliques user is in
date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True)
last_login = models.DateTimeField(verbose_name='last login', auto_now=True)
is_admin = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
date_of_birth = models.DateField(default=None)
password = models.CharField(max_length=255,unique=True)
objects = OccupierManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username','occupations','password']```
Did you migrate since you added date_of_birth?
You got it when you tried to migrate, or did you get a successful migrate?
May need null=True if you want to default=None on a DateField
thanks for replying will try now !
And Demi's question is good, did you get through the migration
or did it fail
looking to talk with someone about setting up my own file server as a music producer....
You need someone to do it or you have questions how to do it?
both lol
it failed i said i got the error
so far going to check out nginx to start ππΌ
Can you paste the stacktrace?
in _execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "date_of_birth" of relation "Occupier_occupier" does not exist
this was trying to add null=true to date of birth
i commented out my admin.register but i will uncomment now
It should be commented out, since that can throw the error until it has successfully migrated.
I mean the error means that date_of_birth isn't in your DB, so something is trying to read it before you migrated.
So you need to remove whatever that is and migrate, then put it back in.
I know admin.py sometimes catches me.
hmm ive been searching but cant find it
A good ol' fashion bug hunt! Yeehaw!
Is there anyway to disable the "auto-fetch" functionality of dropdowns in django admin? I use javascript to only populate the state dropdown with whats needed but django still populates the state dropdown with thousands of entries before the JS runs
look into raw_id_fields
if that doesn't work for you, you'll have to look into modifying the form field queryset
I have but those interfere with the javascript
You may need to look into overriding the form to set the queryset to either be smaller or even something like yourmodel.objects.none()
actually this may work for you
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
Hey guys! get_current_site(self.request) for me fetches example.com
How do I make it fetch the current url
Django
ToDo App
Thank You!!
Id say blog app with login system and file uploads
its not work help pls
just ask the question, can't make any promises
u know django ?
Okay so I completed this question (on replit) and then my teacher said that for the question im abt to send i just copy the code and make adjustments
The second image is the one i gotta finish^
Would i be able to share my replit coding link so u can see what i got so far
Java = car
Javascript = carpet
similar name, nothing to do with each other at all
I don't feel like thinking about Java right now, I hate that language
It doesn't seem hard. It's a loop
While balance isnt 2000, do compound interest formula
Yes but you're not even trying
Ya i am i sat 2 hours the whole period in class tryna figure this out
Im not one if those kids i swear
There's no figuring out. Learn the basic concepts of java
No I hate Java
But believe me you can solve it yourself
If you actually try and not just sit and think you can do it
Ya i think so too im just not thinking if the formulas or their not in my head
Try consulting teacher. They do help too
Which right
Oh and while bankbal != 2000
No nvm you don't get it. Put it back
And just change this while to this
Okay
Because you do it until it's 2000
Ya thats what I thought
Thanks man!
how to get this there am doing it in the static but in django i dont know how
If you're using django's templating language the html/css to do it would be roughly the same as in a static site. I'm not a designer and only write enough html/css to get by.
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card">
<a href="Untitled-1.html">
<img src="k.jpg" class="card-img-top zoom" alt="...">
</a>
<div class="card-body">
<h4 class="card-title"><center>RKYfaultx8</center></h4>
<p class="card-text">category : RP <br> </p>
</div>
</div>
</div>
<div class="col">
<div class="card">
<a>
<img src="j.jpg" class="card-img-top zoom" alt="...">
</a>
<div class="card-body">
<h5 class="card-title"><center>RKYfaultx8</center></h5>
<p class="card-text">category : RP</p>
</div>
</div>
</div>
<div class="col">
<div class="card">
<a>
<img src="h.jpg" class="card-img-top zoom" alt="...">
</a>
<div class="card-body">
<h5 class="card-title"><center>RKYfaultx8</center></h5>
<p class="card-text">category : RP</p>
</div>
</div>
</div>
</div>
its a cars
card
boost rap
i take this part only
@native tide
with the style
hey man would u be able to help me with my homework
on while loops in java
begginer leve
am a python only and bigneer
ohh you dont know java?
see up
nah
augh okay
so is it showing up in the right side instead of below or not at all?
images and aligning stuff really isn't what I'm good at, sorry
it show in the lift side and i want it to showes lie that
@native tide
Sorry, not sure.
okay
thx at all
Anybody using Fiver for side jobs? How is it?
can anyone help me make these tags look better
Yeah right now my title and fonts look bad in html page how can I make them better
Hi
I've a Chat application built on Django Channels
It has the capability to send images
I send my message data over channels
And create my Message model object during that. Now I've to upload images as well. Uploading images via a REST API and creating/updating a ImageField is what I've done before.
Now in this case, I create the message object when something is sent over the channel and uploading an image over a websocket isn't good as I've read. How do people send images and create the object upon image upload success?
so, you already upload image with REST API call, and using temporally formed link to render it back to person?
I think you are already doing fine, since in this scheme you can apply client side caching to image stored as static file, so you should be fine
perhaps you ve been reading about sending images with web sockets from server to user is bad
the only small issue with all of it... that users send images to servers, and they can be not images but smth else π€ β£οΈ
and if you store them as basically files in filesystem, with url link to object, that can be a bit not efficient too (if I remember right that what ImageField does), simple for sure though
people use things like Mongo DB to store files / images for example, as a way for better scaling
it makes sure to keep... stateful things out of your application/server. which is quite needful thing.
https://paste.pythondiscord.com/peqocibogo.xml anyone know how to convert an html table like this to a dictionary array\
Could someone please help me with this image, no matter what I do or what I google, I can't get this image to stretch to the edges of the page (100%) width:
.image-container-homepage {
margin-top: 55px;
width: 100%;
height: 345px;
position: relative;
background-image: url(images/home_encryption.png);
background-repeat: no-repeat;
background-size: cover;
}
<h1 class="text-center">Data Encryption</h1>
<br>
<div class="text-center">
<p>Encryption is about obfuscating data such that unauthorised observers, ideally, can't understand it. Encryption
historically has been vital in protecting wartime secrets and now is integral to the internet as we know it.</p>
<a class="btn btn-outline-primary" href="https://en.wikipedia.org/wiki/Encryption" target="_blank">Learn More</a>
</div>
<div class="image-container-homepage"></div>
<br>
Current result:
I think you can move the width above 100%. Try that π€·ββοΈ
Already did, just distorts the image and fires it off the right side of the screen only.
Which also makes the page scrollable
hey im new here, needed a help
I will help you if you solve my problem rather than burying it π
Probs, who knows
actually im uploading images and vdeos to aws s3 with django, in local they are uploading fast, but in production it take a hell out of time
i dont know wht to do
if i upload 700 t0 800 mb it takes like forever
Would I be correct that local is your machine and production is some datacenter far away?
Assuming I am, maybe your internet just sucks like mine
yeah and production is like when site is live
haha no man
internet is good
about ur problem
probably ur image not getting full width
coz fo some div issue
i suppose
Yeah probs, given it sits in a div with content:
<body>
<!-- Build Navbar > Content > Footer -->
<header class="site-header">
{% include 'navbar.html' %}
{% block header %}{% endblock %}
</header>
<div class="container content">
{% block content %}{% endblock %}
{% if not self.content() | trim %}
{% include "other/soon.html" %}
{% endif %}
</div>
{% include 'footer.html' %}
</body>
I wanted to avoid putting it in the header, pushed down.
i had a similar
issue one time
what i did was , i had extra div which was not closed
i removed it worked
Speaking of not closing things properly, my website had a 50% increase in buttons before: http://prntscr.com/1xku4dk
Guess I can check that all divs close correctly
No it was all good. I will just put this into the header instead.
To much work otherwise.
,
help? it was working before but idk now.
type pip install discord and pip update and python update 3.9.5
and it well work
i think
i guess im in wrong group
Django is a framework where u can build web apps
using python
It's a batteries-included Python web framework that has all sorts of things you can use to get a website up and running with python
Hello Everyone. Recently I developed a Python Package usage that can be used to setup a React application in a Django Project
Want to use React with Django without any hassles ?? Presenting to you django-webpack-dev-server, a command-line Python package that could help you to set up a react application in a Django project. This package uses webpack and webpack-dev-server to bundle your frontend code. It currently supports React in both the Javascript and Typescript programming languages.
A great thanks to Tim for his awesome tutorial for developing a Full Stack Web App with Django and React. Do check it out!
This project is open source and if you find any issues or have a new feature in mind, feel free to make a Pull Request. Your contributions are always welcome. I believe if this package also supports other frontend frameworks such as Angular and Vue, it would be even more helpful to the community.
Here are the links to the Project:
- Github: https://github.com/Jitensid/django-webpack-dev-server
- Pypi: https://pypi.org/project/django-webpack-dev-server/
- Youtube Demo: https://www.youtube.com/watch?v=6c-lPkKzI_E
LinkedIn: https://www.linkedin.com/in/jiten-sidhpura-40257817b/
Tech with Tim's Youtube Tutorial: https://www.youtube.com/watch?v=JD-age0BPVo&list=PLzMcBGfZo4-kCLWnGmK0jUBmGLaJxvi4j
Django Webpack Dev Server is a command line Django reusable app to setup configuration files for React. It uses webpack and webpack_dev_server to bundle your frontend code. - GitHub - Jitensid/djan...
Django Webpack Dev Server is a command line Django reusable app to setup configuration files for React. It uses webpack and webpack_dev_server to bundle your frontend code.
Github: https://github.com/Jitensid/django-webpack-dev-server
Pypi: https://pypi.org/project/django-webpack-dev-server/
LinkedIn: https://www.linkedin.com/in/jiten-sidhpura...
In this django and react tutorial we will be using python and javascript to create a full stack web app. The purpose of this series will be to learn how to use react and django together to develop a full stack web application. Specifically we will be creating a collaborative music playing app in which we will integrate our application with the t...
Hope this package helps Django developers !!
ya it well help many pep you are the best one continue in your ideas
Hi, no I'm uploading to S3 directly via a presigned URL
Which goes like GET PRESIGNED URL FROM MY BACKEND -> Upload Image -> Send image path to websocket
Thank you
Hey all
π
I have a list of "labels" on an object, a pretty straight forward thing, normally it's solved with a choice field. But I also have a request to make it dynamic. Is creating another model necessary to allow changing and adding "labels" or can it be done without making another model?
unresolved attribute "Column" in class "SQLAlchemy"
can someone tell me what i'm doing wrong? i followed the same thing in a tutorial and this happens
This is a question for #databases room
oh right sorry lol
Unless they say that ORM is not real databases thing and send back to here ;b
Just kidding. Or not. I already received opinions like that
do you guys know how to use beautifulsoup ?
Question about Python, servers, and security
I'm making a python framework that interacts with a webpage. The frame writes the HTML from one or more documents supplied by the user (it stitches them together into a single document). This means that there is some limited opportunity to pre-parse both the HTML and any Javascript it directly links to (though, not any it links to from other locations on the web)
Also, the browser that is launched is Cefpython, a python binding for Chromium β this means I have some control over the settings of the browser
My question is, is it safe to use the basic http.server with no security measures?
They say in the docs that there are no security checks and so its only safe to use http.server for a quick-and-nasty dev server. I need my frameworks server to be distributable
There's this manual: https://www.crummy.com/software/BeautifulSoup/bs4/doc/
Thanks
No problem!
I'm building an API route with Flask, and one or more integers for a certain value can be included in the JSON payload. In terms of what is generally considered clearer or better practice or just normal and expected, should I require input like a) "employee_id": "1" and "employee_id": "1,2" or should it be like b) "employee_id": [1] and "employee_id": [1, 2] or c) should I make it flexible and allow both?
quite good book
giving general info about everything related
not just beautiful soup
If anyone cares, an experienced dev told me to go with "b" so that's what I'll do. Guess that makes sense since the code will be simpler
Yep, and I'll concur. If you're giving out multiple items for a single value, you should use a list of them so it's easy to process
Depends on the intended use case. If a user is performing a query, and you deliver a list of results, then return a list. If the user is performing a query on a list of users, then accept a list. If it makes no sense to accept or return a list, for instance if an operation is intended to execute on exactly 1 employee all the time, then return a scalar.
Never return a list as a comma-separated string.
makes sense
how to set a range for loop and continue in a page 2 ??
like this
and this will work
??
if youre talking about pagination, there is, in django.
No, not only about numbering, but also how the loop works on this testicle
you have put " inside { and don't put 2
ok
okay so how can i loop this
this my for
loop
nice
you doing a veb
how to fix
i don't now soory
Use filter() instead of get()
so one more qw how can i make the user download a file from the data base
my models
I'm new to django any tips for debugging just spend a day trying to figure out that my linter was eating up an unused but needed import in my urls
If you want to store and serve from s3
https://stackabuse.com/uploading-files-to-aws-s3-with-python-and-django/
AWS S3 is a great, low-cost service for file storage. In this article, we'll be using Python and Django to upload files to AWS S3.
I really have that. What I would like to ask is how do I put the file link in the download button and the file is in the database, I can access the images, but the files I don't know how
@odd belfry
what if i just comment out date of birth ?
Sure, try it
tried it got this return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "date_of_birth" of relation "Occupier_occupier" does not exist
damn im losing my mind π€£
if it opens the file in new window, then anyone can just right click and download or sth
In order to create a download link, we need to create a Django view that would serve the files: # views.py import mimetypes ... def download_file(request): # fill these variables with real values fl_path = β/file/path' filename = βdownloaded_file_name.extensionβ fl = open(fl_path, 'rβ) mime_type, _ = mimetypes.
I have a putton i want to get the file url from the models to download the file
ill check this after eating
Hey guys! I want my image URL to be inside the style tag like this but this won't work in Django. How do I make it work?
<div class="view" style="background-image: url('{% static 'images/IMG-1284.jpg'%}'); background-repeat: no-repeat; background-size: cover;">
Okay in other news this is working but I'm getting a lot of semicolon expected errors on Visual Studio
Whenever I put the static inside the style tag like that
i want to deploy a flask website on apache2 but when i try to type the command pipenv install it says python: not found
But I have python installed on my server
do you have pipenv installed?
if you type which pipenv what do you get back?
/usr/bin/pipenv
and you're in your code directory with a pipenv file when you run pipenv install
i am trying to run this file on my /var/www/API
what do you mean ?
can you screen shot the command you're running and the output
i run the file with pipenv install
what does he want to remove please he should just install it besides i have python 3.9.5 what i please the problem this pipenv
can anyone help ? django.db.utils.ProgrammingError: column "date_of_birth" of relation "Occupier_occupier" does not exist
class Occupier(AbstractBaseUser):
email = models.EmailField(verbose_name='email',max_length=59, unique=True)
username = models.CharField(max_length=30,unique=True)
occupations = models.CharField(max_length=200,null=False) #amount of occupations user does
#cliques = models.ForeignKey(Clique,null=True,on_delete=models.CASCADE) #cliques user is in
date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True)
date_of_birth = models.DateField(default=None,null=False)
last_login = models.DateTimeField(verbose_name='last login', auto_now=True)
is_admin = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
password = models.CharField(max_length=255,unique=True)
objects = OccupierManager()
i try migrate and i get that error
what's your pipfile look like?
not the one that i want , i want to be like the photo
what's your OccupierManager look like?
you must be referencing the field somewhere in your code
does your server have 3.9 installed on it?
yes
class OccupierManager(BaseUserManager):
def create_user(self,email,username,date_of_birth,occupations,password=None):
if not email:
raise ValueError('Users must have email address')
if not username:
raise ValueError('Users must have username')
if not occupations:
raise ValueError('Occupiers must have occupation')
if not date_of_birth:
raise ValueError('Users must enter date_of_birth')
user = self.model(
email = self.normalize_email(email),
username =username,
occupations = occupations,
date_of_birth = date_of_birth
)
user.set_password(password)
user.save(using=self._db)
return user
just installed it now
can you type python3.9 and get a shell?
@native tide, hi can u help me
Python 3.9.5 (default, May 19 2021, 11:32:47)
Type "help", "copyright", "credits" or "license" for more information.
this could be your problem
user = self.model(
email = self.normalize_email(email),
username =username,
occupations = occupations,
date_of_birth = date_of_birth
)
?
That means I have python ?
yea, looks like python3.9 is there
but why does he not install anything
its not work why @native tide
How can it be that he says he can not find python
if you type pipenv shell do you get anything
file uploads are tricky and this doesn't feel like a question. I don't see an error message or explanation of what's happening
I do not understand why he wants to remove it
it gives me this and i give the button {{ post.file.url }} not a image url
you have poste in the snippet you posted, is that right?
it's trying to use 3.8 though, which is weird
uh and why
the deleting is normal, it deletes and recreates at times
oh I know why
And what do I do now
remove pipenv
still didnt work bro
how do i do that
sudo apt uninstall pipenv or something similar @edgy sable
no other references to it?
Have deleted it and now ?
pip3.9 install pipenv
bash: pip3.9: command not found
which python3.9
and now ?
honestly, not sure. file uploads suck. I don't have a good answer
what did that tell you
bash: pip3.9: command not found
which python3.9
I have already entered
you aren't listening
/usr/bin/python3.9
when i create a post the file comes here
cd /usr/bin/
ls pip
ls -tla python
ls: cannot access 'python': No such file or directory
I already have the feeling I have installed Python incorrectly
ls -tla /usr/bin/python3.9
bash: pipenv: command not found
how did you install python3.9
yea, you should have pip and such installed along with python3.9
you should be able to run through those steps again
and you want it somewhere else?
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
this on ubuntu vps? or debian?
ubuntu
might need to jump into unix channel for that
or try installing libc6-dev
do you have a lot on the VPS, could always start over
another channel here on the python server. need to resolve what's going on with that install before we can get pipenv working correctly
I need to wrap up some work, may be around later to help
Hello
yp want it in db how
you probably dont' want to store a file in a db at all
you want to store it in a bucket or on the server and have a path to it on your db
yp to make the user download it
@native tide
now u understand me
don't know what you mean...you should store a record of the file in your db, but the file itself lives in a filesystem or bucket
now you know what you should do, research how to do it
all that time researching and i dont fine only one ved about that thing
@native tide
Jo I look tomorrow what I can do I have python installed completely wrong
Have already tried and have just made everything worse because I have entered other path or whatever
show me err
There is no error I just installed it a thousand times and entered something different from each page no matter I look at it tomorrow
k
I'm trying to work with the "@keyframe move" to make an animation for the welcome class so that it appears to bounce onto the screen.
Absolute position plus before and after?
Using Django crispy forms to render a form to a page so a model instance can be edited. Whenever I use Layout() it breaks the submission for some reason
nevermind got it
can anyone help me in my fastapi project?
umm maybe i'm a very a basic user still have to figure out how to restrict my end point to user with api keys
It was @naive crater
ok sir thanks
@naive crater in the web that was made by latkescary it said that its made using python
can someone help with html?
I was just wondering, using asyncio, how many requests per second can u handle in python?
I could see that top frameworks like falcon max out at 80,000. Is it possible to go any further with any optimizations but same hardware?
Hey guys! I am using FastAPI for, well, building an API lol I have an endpoint that receives a couple of parameters, one of them is a list of strings. Anyone know how do I make sure the list is no longer than 5 strings and every string isn't longer than 20 letters?
Why does python convert my javascript object to type none when it receives it as json, I'm using flask
def notes_search(request):
if request.method == 'POST':
searched=request.POST.get('searched')
q1=Notes.objects.filter(title__contains=searched)
if len(searched)>55:
messages.info(request,'TEXT IS TOO LONG')
return render(request,'index/notes.html')
return render(request,'index/notes_search.html',{'q1':q1,'searched':searched})
return render(request,'index/notes.html')
``` how can i take it advanced the next lvl as im gonna deploy this n i dont want bugs
how can take a damn good search bar
Are you using flask?
hello guys
i have watched this video: https://www.youtube.com/watch?v=PFcnQbOfbUU&ab_channel=TheDumbfounds
In this django rest api authentication tutorial, you will learn how to use TokenAuthentication and SessionAuthentication and when each approach is appropriate.
7 Tips For Getting Better At Django:
https://mailchi.mp/dea592ab3f6d/tips-for-getting-better-at-django
Here you can find more information about REST API authentication:
http://www.djang...
its just basic token authentication through username and password
but how do i make sure that the user is authenticated on each page?
none of the django tutorials seem to provide any context to that
You could return a 400 error with if statements to check the list length. https://fastapi.tiangolo.com/tutorial/handling-errors/
FastAPI framework, high performance, easy to learn, fast to code, ready for production
hi i need help
I want the user to be able to download the file
The file is stored in the media folder inside the files folder
And I want the user to be able to download it
And each post has its own file
Please use a help channel instead of dumping streams of screenshots in here, thanks. #βο½how-to-get-help
idid and no one helped me
so
So... "Can so someone please help me in #help-whatever? I'm trying to make it so a user can download a file." No need to invade a discussion channel.
Yep! The backend of the website is written in python, using flask as the web framework.
Next level? You could probably try django haystack with elasticsearch. Elasticsearch is also easier to deploy, you'd need a dedicated search engine that's kept in sync with the db, with a scheduler like celery beat (search engines usually like to index data in bulk, although realtime indexing is also a possible solution for smaller apps)
That's what I'm doing- but with fastapi instead for my backend
How do i get the values from a POST request? i know it has something to do with flask.request
{{ request.values }}
can u help me
hellllllllllllllllllllllllpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pleaseeeeeeeeeeeeeeeee
When I run a file and call a print statement in that program that does NOT change the file? But if I run the same program on that file with return THAT will change the original file?
I'm playing around with parsing and using my messed up apple music folder to see If I can clean it up with some python code?
I'd love to hear your thoughts?
sorry incorrect channel