#web-development
2 messages Ā· Page 168 of 1
Few days ago I saw results of bitrix developers.... those..... individuals went into production without https.
Fantastic lack of skills.
this is a date returned by the django api 2021-06-13T0312Z
how do i format it in DD MM YYYY in Javascript?
Anyone down to help a newb with some HTML?
What do you need?
Right
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body { overflow: hidden; }
.vanta {
width: 100%;
height: 100vh;
}
</style>
</head>
<body>
<div class="vanta"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.clouds.min.js"></script>
<script>
VANTA.CLOUDS({
el: ".vanta",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
backgroundColor: 0xcd4949,
skyColor: 0x404059,
cloudShadowColor: 0x4e2066,
sunColor: 0x3a7793
})
</script>
<h1 style="color:black">Hi!</h1>
</body>
</html>```
So I'm making this page
And I want the h1 to be on top of my vanta background
But it's not for some reason
yoo
So @calm plume you came up with anything or...?
Then make it the first line
Html elemebts go in the order you put them in
I can't see that in your screenshot thing
What happens if you remove height: 100vh;
So the h1 worked
Yeah, no
Wdym
I want the h1 to be on the clouds
Listening
I spent too much time trying this, didn't work out
But sure I can retry
You see, it isn't really an image
It's an OpenGL render
wait what
?
nothing leave it
Figured it out. I needed to edit the Vanta.JS div as so: https://be-a-girl.today/indianscam/2OgufzzE
does anybody know how to make text go under a picture?
i want it to look like this
but it ends up like this
here's the html code ```html
<h3 style="margin-left:10%"> text </h3>
<div class="aboutdesc" style="margin-left:10%; float:left;">
text
</div>
<img class="aboutimg" style="margin-right:10%; float:right;" src="{{ url_for('static', filename='images/boardgamebotlogo.jpeg') }}"/>
<br />
<h3 style="float:right; margin-right:10%;"> Join a tournament! </h3>
<div class="aboutdesc" style="margin-right:10%; float:right;">
text
</div>
<div>
<img class="aboutimg" style="margin-left:10%; float:left;" src="{{ url_for('static', filename='images/boardgamebotlogo.jpeg') }}"/>
</div>
I am quite new to styling, and I barely know anything in css
but I think flexboxes will work in this situation
suggesting this awesome free game to get a hang of them
https://mastery.games/flexboxzombies/
i will look into it, thanks!
It was me
My DRF is not showing any of my fields ? First time using DRF help would be really appreciated
would this do as advertised?
# grabs the names of all the files in the documentation directory
# makes a new flask route to display that page
docsfolder = "/docs/"
documentation_directory = os.getcwd() + docsfolder
scanfiles = lambda directory,extension: [f for f in os.listdir(directory) if f.endswith(extension)]
for each in scanfiles(documentation_directory,".html"):
@app.route("/docs/" + each.replace(".html",""))
def displaydocpage():
render_template(each)
hello i am facing some problems in cloning the proj
I want to like the serverless framework.
but I've never encountered a project using it without some weird bug because of constant updates.
In a flask 404 error handler, how can I see the page that was not found? Eg.
@app.errorhandler(404)
def err_404(err):
return "Page somepage not found!"
I have a container that dynamically displays different content. The container's maximum height is basically the viewport height. The container also has a vertical scrollbar, if needed.
I want the container's height to always be the height of the tallest content, even if something shorter is current being displayed. This should still respect the container's max height and display a scrollbar as necessary.
I made progress by using display: grid on the container and visibility: hidden on hidden content. This overlaps the content and sets the container height as desired. However, the scrollbar is longer than necessary for some content, since its sized to accommodate for the tallest element, even if it's not currently visible. I want the scrollbar to only be as long as necessary for the content currently displayed.
I thought about disabling overflow by default and using JS to conditionally enable overflow if the currently displayed content needs it (comparing clientHeight and scrollHeight). However, I'd need a way to re-evaluate that if the height changes (e.g. window is resized). I guess I'd use a MutationObserver, but that just starts to get annoying and complicated.
Anyone have ideas for how to accomplish this?
Bro can you share your code. Maybe on codepen or something
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
In practice, there's a way to toggle visibility of the different content, but for the sake of example, just manually add/remove the hide class
@proper hinge can you summarize your issue
Has anyone attempted to use Weebly for a Front End, and develop with Python on the Backend for more DevOps type work? If how can I get a dang API Key
Guys i need help with something
1- background-image set to the body
2- i have a layer on top of it that covers the whole background image
The question is: how do i create another layer on top of those Lets say a 100 * 100 box
and that box can show me the background image through the other layer
Read the first two paragraphs.
The jsfiddle is an example of my attempt to fix it with the grid and visibility technique I described in the latter half.
@proper hinge just remove the height or set a min-height
But removing the height should work
Removing what height?
This? height: calc(100% - 5rem);? That's absolutely necessary, removing it just makes things worse.
What would the min-height be set to? It'd have to be the height of the tallest container. Furthermore, it would have to be clamped at 100%, otherwise it would override the max-height and go off screen. That would all have to be calculated in JS, which again, leads to complications when the window gets resized.
How do we make sure in django the user can't purchase when the stock is at 0?
you could authenticate in the view
or in the template using javascript
i would do it in the view though, because the view can't be taken control of by the user
Thank you for the info!
sorry didn't work
you can try using css grid or flexbox to create a grid system where you can place items in
Learn the most important concepts of CSS Flexbox Layout in 100 seconds.
#css #webdev #100SecondsOfCode
Upgrade to Fireship PRO at https://fireship.io/pro
Use code lORhwXd2 for 25% off your first payment.
My VS Code Theme
- Atom One Dark
- vscode-icons
- Fira Code Font
Learn the basics of CSS Grid in 100 seconds. Grid š±ā” is a powerful tool that can build layouts in the context of columns and rows. It's not easy to learn, but can dramatically simplify CSS positioning code for responsive designs.
Stay tuned for a full grid project next week! https://fireship.io/tags/css/
Grid Docs: https://developer.mozilla....
I'm not sure if this is the right channel but I was hoping I could at least be pointed in the right direction here. I'm using Django, and upon successful user registration I'd like to create a table based on my model for each user so that I can keep all information unique to that user.
So my question is this: What is the simplest way to achieve this or a good up to date guide to follow that can help me accomplish that task?
anyone good with XPath?
hey I was trying to find info on how to do this but I can't. I'm not that good and would know if you can give me an example or look at my code. Just let me know if you need my repository. If anything an example on how I could make it where if my product stock is 0 make sure they can't pay or continue even if it's already in the cart. For ex: We deleted this product from your cart due to it being out of stock or something like that. If you can't help its all good don't worry about it!
Does anyone else find Django documentation to be sort of scattered and hard to find what you're looking for?
Especially when starting off
Any interested please contact me via DM
no luck on upwork?
!rule 9
It is more about flood of job scammers
!tempban 287003991747985413 1w Take the time to decide whether you want to participate in the community and respect our rules.
:incoming_envelope: :ok_hand: applied ban to @torpid beacon until 2021-07-03 03:22 (6 days and 23 hours).
Well, you are not the only one who struggle with it.
I manage so far, but keeping in case of emergency a set of books about django 3.1+
From beginner to advanced level. I could send you their names if interested
Not python specific, anyone have experience hosting Wordpress. Looking to migrate off a bitnami multi site without spending a small fortune on tools to move sites.
I currently have Django 3 By Example only
I'd love to hear some alternatives
Hopefully books using Django rest framework instead of just Django
xD
William S. Vincent
he wrote books
Django for Beginners
Django for APIs (about DRF)
Django for Professionals
I did not read them though yet, so I can't say my review about them
Django Crash Course from Daniel Roy Greenfeld is also quite famous
besides that I found Web Development with Django from Pakckt by Ben Shaw (it has at least one chapter about DRF)
and that's it
those are three authors were picked by me, because they wrote about Django 3+ version
all the rest were for older version or for some other reason rejected
I am using python framework to send back json responses
If I am using many workers and threads will memcache even work as needed as there many threads so that means different clients for memcache are being used as well?
can the data being stored in cache be accessed or will it only work if the same worker or thread handles my request? quote confused here as to how it'll work
I did not use it yet, just going to start it
but would not be obviously memchache storage shared for all workers?
At least you know... when different workers connect to same postgresql, they have the same database too.
Nothing stops them having shared memory in external database (which memcache is)
memcache is essentially sort of the same database, except I think it is NoSQL one perhaps, as well main difference with it being completely in RAM instead of hard drive
in theory nothing stops you from caching multiple application instances to the same cache database (except different response time)
yeah but you see, we make a client thing for the memcache
so considering that each worker or thread uses a new instance of the code
will it also not be like it'll use that client object for the memecache?
or is there only one single memcache?
it should be. as long as you use the same hashed_keys to access your data
if I get it right, it stores in hash_key: data(+expiration time) style
yes that's right
well thank you darkwind, I'll give it a try an see today!
nothing is better than making experiment to confirm it š
yep definitely
some check with postman for an obvious situation could be done
postman?
for times when using unit tests is not enough
postman offers nice GUI to make requests to your APIs with comfort
graphical interface to make requests basicaly
oh I see
available as desktop application in windows and linux
the obvious test to check the theory would be...
launching your app two times at two different ports
with are attached to same memcache
the thing cached in the first one, should be able to be get in the second one
It's very new, so stuff is being added/existing being replaced or improved at a fast pace
Hi guys, what it means
db = SQLALCHEMY(), they say it is for initializing, but what that means? and why we need it?
has anyone ever deployed a deep learning model(face detection model to be specific) in Django app here?
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms at Timeout.<anonymous> (E:\web site part 2\server\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:197:23) at listOnTimeout (internal/timers.js:555:17) at processTimers (internal/timers.js:498:7)
Ask on data-science-and-ai
It's not a data-science problem actually, what I am looking for is a way to implement a way to use camera stream from client side and send it somehow to backend for inference and then work on its result like that, I will still post this question there as well in hope
i am making a project with django, im trying to add a login with google, email confirmation,password resetting and im gonna use the allauth package, i already have a Users app where it registers,logins and more. should i delete that app or is there a way to integrate it with the allauth package
https://hastebin.com/judocojevo.xml So I have this lil' website here, and the background should be fullscreen.
Instead, I get this: https://be-a-girl.today/indianscam/HBFMbqZ5
It depends I suppose, if you only want google login or if you also want to allow regular username/password style login/registration
i want a regular register and login system and i also want to add google auth
allauth package is only for social app authentication
for normal login/register you need have a django app
yeah you can just keep your app and add the allauth stuff on top I believe
it's been a while since I integrated it but it's reasonably straightforward I think
Did you use background-image in CSS to set it?
can plz sm1 help me in downloading pyaudio
plz
need some help coz its not downloading
how does one store dicts with pymemcache?
I'm getting started with django ... Does someone have any reference material/ course recommendations?
Also if anyone could explain the use of url dispatcher files?
ok so first: you have complete access to the user who sent the request when you pass in the request parameter to your view function. You can check if the user is logged in to their account (bc you probably should have an account to trade stock) by the property request.user.is_authenticated. from there, you can lookup the stock the user wanted to buy and check its price. If it is 0, then send back a database message
Database Messages allow us to flash a message up on the screen when our web form is processed successfully, or let the user know if there was an error with the form submission.
Django comes with a built in Messages system that we can use, and that's what we'll learn how to use in this video.
We'll also tweak our form validation system to...
I'm looking for a team to participate in the odin project web dev game jam
anyone?
dm me if you're interested
Ok so i have many urls the number may vary in db and i get data from db with javascript, now i need to create n number of <img> tags according to the number of links in the db, How can i do it?
(ping me if you reply)
Needs help with celery....
I wanted to post image processing from views to celery, but it shows me a JSON-related problem
"Object of type ImageForm is not JSON serializable"
Here the code from models.py
class Image...
i was using django...but suddenly the app which i have hosted on heroku is not saving the profile pics users upload in the databse
it won't, you'll have to setup AWS S3 Bucket
ooooh...yea i had not done that
but it worked for a few hours
then it stopped
@obtuse trouthey..is there no way to skip the adding card detail process?
fix it instead of skipping it
any django pros here? i need to load specific css on specific templates but the templates doesnt seem to load the static file it is supposed to. i think i can explain it better if i showed you lmao. @me if you can help me out
have you configured static files?
hi yea i got it to work already lmao shout out to @brave stag for helping me out. the problem was in my STATICFILES_DIRS, had ../ on my path
Hello everyone!
I use flask as my web framework. I learned that i can use python in html like {{% if session["user"] == 'admin' %}}
Can i do the same in css file? If yes, how?
.bg-image {
background-image: url("{{ session['avatarPng'] }}}");
filter: blur(8px);
-webkit-filter: blur(8px);
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
``` ^^ this didn't work
Hey @proper hinge , I have done some changes to your code. I am not exactly sure what output you wanted. But this is the output I thought you needed. Let me know if this is correct or not.
Or you can tell me what you wanted and I can help you write clean code for that one. This one is still bit messy.
Anyone want to join my team for a game jam?(Web development)
No, you can't do that
ok, but, how can i solve my problem then?
happens to the best of us lol. glad you figured it out š
Why am I getting this error? ImportError: Module 'emailbot_dashboard' does not contain a 'IPC_server' class.
import statement: py from .IPC_server import get_guilds,guild_channels, create_channel_subs, create_bot_subscription, get_subscription, get_excluded_channels, get_guild_channel_list
traceback: Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run autoreload.raise_last_exception() File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception raise _exception[1] File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 375, in execute autoreload.check_errors(django.setup)() File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Users\Carl\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\config.py", line 221, in create raise ImportError(msg) ImportError: Module 'emailbot_dashboard' does not contain a 'IPC_server' class.
guys hello
What does Python/Django uses instead of UserCreationForm?
it seems like it is not supported anymore
thanks for help
Thanks, I really appreciate you looking into this. I pretty much had to shelve it and prioritise other things because I couldn't figure this out. Unfortunately, your results aren't what I wanted. Let me try to explain it differently.
There's a container. The container has 2 pages. Only 1 page can be displayed at a time. Each page has dynamically generated content, so their dimensions are not fixed/static.
The container's height should adjust to fit the pages. However, the container has a fixed maximum height of 500px. If the page cannot fit within 500px, then a scrollbar has to appear.
The container's height should be the height of the tallest page it contains, even if the tallest page isn't displayed.
Example cases:
Case 1:
Page 1 is 200px tall.
Page 2 is 400px tall.
The container's height should be 400px when either page is displayed.
Case 2:
Page 1 is 200px tall.
Page 2 is 700px.
The container's height should be its maximum of 500px when either page is displayed.
Page 1 should be 500px without a scrollbar, since 200px fits within 500px.
Page 2 should be 500px with a scrollbar, since 700px doesn't fit within 500px.
I'd use JS to extract the height of the two pages:
// Extract heights of two pages
const page1Height = document.getElementById('page-1').clientHeight
const page2Height = document.getElementById('page-2').clientHeight
// Get the height of the largest page
const largestHeight = Math.max(page1Height, page2Height)
// Set container to the height of largest page (or 500)
let containerHeight;
if (largestHeight) > 500 {
containerHeight = 500
}
else {
containerHeight = largestHeight
}
Then apply containerHeight to your container's height.
also make sure your container has display: scroll
Hello everyone!
I have an fixed navbar on the top, when i have something to flash it does this:
How can i fix it
btw i use flask
db:
image: postgres
volumes:
- ./data/db:/var/lib/postgresql/data
Do you know where local postgreSQL databases are stored? So my docker container can access it.
if you have any idea, ping
for django-admin commands, does the command actually have to be named Command? Or can it be named anything?
anyone here know how to make a username checker ?
check this for an example postgres + python docker-compose file: https://github.com/gurkult/gurkbot/blob/main/docker-compose.yaml
@peak bronze gotcha... but I'm not sure about the volume for the postgres container
as in... where is my database stored on my local machine? I tried one path (something like /var/etc/postgres/12/main) but it's not accessible
I think it's /var/lib/postgresql/data but I'm not sure
@calm plume I'll try that out. Thanks
I am using windows 10 and visual studio code and flask. I need to create the database but don't know how. In vsc I need to type
from flaskblog import db
from flaskblog.models import User
db.create_all()
But when I type from flaskblog import db I get
Can someone help?
I want to add django-wiki to my own project and soon add django-tagulous to the wiki
https://django-wiki.readthedocs.io/en/latest/installation.html
I've read the docs and other sources and I gather I need to create an app in my project and override the django-wiki pages.
But the docs don't explictly list what to override (views, urls).
I splunked the module's code, but I don't recognize the patterns.
What's the first step?
I've followed the installation instructions on a new Django project and was able to create a wiki. How do I integrate their project with my own? It's confusing because WIKI is practically a whole django project by itself. You only need settings.py
I'm able to print the posts by themselves, but when I try to access the posts through the user, this happens
I've experimented with using JS for this before and basically it was the same as what you showed. The two main problems I ran into:
- Can't get the height of an element that is not displayed.
- Have to re-calculate the container's height when the window's height changes (in practice, the container's maximum height is relative to the window size rather than a fixed value). MutationObservers exist, and they probably work for this, but I'd rather avoid it if possible.
I tried using visibility: hidden to always display the elements, as my fiddle shows. That works for getting the height, but that introduces the problem of the scrollbar being too long for some pages. I understand why that happens, but not how to avoid it using that approach.
Alternatively, I tried temporarily displaying them all to get the height and then hiding them again, but that looked bad cause a user could see it happening. It's even worse since I have to account for window resizes.
@rare oar @summer dirge I use Tornado daily at work, so I have some field experience that is very fresh in my mind. Also I think this is a better question for #web-development than #internals-and-peps, so I am responding here.
Tornado has kept up-to-date with type annotations and first-class asyncio support, so it's not entirely antiquated. But the "old"ness is clearly visible in the APIs: reliance on untype-able kwargs and opaque "settings" dicts, and a highly imperative self.set_foo() style of APIs.
It's also fairly "minimal" in that it doesn't have lots of middlewares or plugins (e.g. you have to write your own CORS headers), so you might end up reinventing a wheel or two.
However it does come with a decently featureful HTTP client/server setup for testing, which is really really useful. It also has good logging, built-in support for XSRF cookies, and built-in support for both OpenID and OAuth.
I can't say it's a bad choice for new personal projects if you happen to like the design, or if you specifically want something that's generally minimal and highly modular. It might also be good for new projects at large organizations that are willing to build and maintain their own internal tooling around it, and want something that's "battle-tested".
However I mostly can't recommend it for a small or medium-size groups, where you don't really have the extra time to build/test/maintain a lot of "helper" code, or maybe you don't have a well-defined design processes, which could lead to a chaotic codebase.
All that said, there's probably no reason not to use FastAPI.
i made a custom user model with abstractbasemodel but the āobjectsā and āpermissionsā table were not present, how do i enable those
i feel like if you want minimal a microframework like flask or fastapi is just the better choice
is it worth building an e-commerce site from scratch or use something like shopify? I've researched about it before but I noticed that most developers would rather stick to shopify then dealing with it from scratch. (I would be the only one developing it.)

FYI this did not work, I get this error: Traceback (most recent call last): File "C:\Users\Carl\AppData\Roaming\Python\Python39\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\Carl\AppData\Roaming\Python\Python39\site-packages\django\core\handlers\base.py", line 188, in _get_response self.check_response(response, callback) File "C:\Users\Carl\AppData\Roaming\Python\Python39\site-packages\django\core\handlers\base.py", line 314, in check_response raise ValueError( ValueError: The view emailbot_dashboard.views.exclude didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view. [27/Jun/2021 00:05:23] "GET /exclude HTTP/1.1" 500 64307 sys:1: RuntimeWarning: coroutine 'exclude' was never awaited This is my return statement: py return await render(request,"Excluded.html", {"chosen_guild": guild[0], "form":excluded_channel_form})
from django.shortcuts import render
from django.contrib.auth.forms import UserCreationForm
def register(request):
form=UserCreationForm()
return render(request,'users/register.html')```why is this django.contrib.auth.forms used is it for that automatic form ? + should we create html form or django form which one is better
hey could anyone help with flask here i need to get something working?
Just share the issue you are facing!
Is there a good way to change values in a database after a certain timestamp?
I need it to be persistent and survive server reboots
Right now Iām doing polling on the database for the timestamps that expired
But Iām asking if thereās a better way to do that?
Itās mainly to expire people who havenāt paid their subscriptions
For my web app
hello , to make the above piece in a form , i am using the following code of html
<span><h4>Politcal Persuassion</h4></span>
<select>
<option>Left wing</option>
<option>Right wing</option>
<option>Conservative</option>
<option>Nazi</option>
</select>
<label for="politics">Education level completed:</label>
<select>
<option>University</option>
<option>College</option>
<option>High school</option>
<option>None</option>
</select>
This is the output which i am getting
how to fix , this
Whatās broken about that?
why the span tag is making a new line
Either throw it into a parent container of a div that uses flex alignment
sir , i am new to it
Or set itās style to display inline-block
please tell , something which is easy for a beginner to understand
i only want to write the correct html , no css
You canāt change that
Without css
The default would be to break it into a new line
Youāll need to use css to fix it
you mean to say that this can not be made without css
Yeah itās clear that screenshot has css
Yes
You can barely do anything in terms of html without css
forget the css, just tell me html
as alignment, styling, and color are all done with css
What youāre doing is correct
If youāre only asking about the html
I donāt see whatās wrong with your code
can you tell when a heading is appropriate and when a label , means what exactly a label does
Thatās up to how you design things
can you compare both the screenshots , one of my code , and another which i am copying
there is difference
The second screenshot clearly has css in it
If youāre gonna refuse to do any css, you canāt change it
Infact it even has a font on it
Which is also css
even i cannot bring , Political Persuassion , in front of first dropdown list
You canāt
Youāll need css for that
Html is just plain elements
How you align and style them
Is css
Youāll need to set the element in css to display: inline
So it doesnāt break into a new line
u see it ,
<label for="Politcal Persuassion">Political Persuassion:</label>
<select>
<option>Left wing</option>
<option>Right wing</option>
<option>Conservative</option>
<option>Nazi</option>
</select>
<label for="politics">Education level completed:</label>
<select>
<option>University</option>
<option>College</option>
<option>High school</option>
<option>None</option>
</select>
Not the best way to do it, youāre using more or less hacks
Ig that works
Whatās your goal?
Compared to that second screenshot tho, youāre missing a box and the font
goal , is to ask you why , we can not do this by using a span and a heading tag
You can
Html isnāt designed to be used by itself
You can do it with heading and spans using css
The fundamental issue here is youāre avoiding an important component
ok , let me see
You could change the span tag to display inline with css, or set a class on that span tag to make it display inline
And your job would be done
noone replied ;-;
you aren't even using that form
Idk what this module do
Is it imp to use it
if you are learning django then sure you should know what it is
(context django) i want to deploy on heroku and i have this in models.py
from django.db import models
from django.contrib.auth.models import User, Group
User._meta.get_field('email')._unique = True
if not Group.objects.filter(name='admin').exists():
Group.objects.create(name='admin')
if not Group.objects.filter(name='teacher').exists():
Group.objects.create(name='teacher')
if not Group.objects.filter(name='student').exists():
Group.objects.create(name='student')
since the tables aren't created this raises errors, i can comment them out run migrations and and then uncomment them back and again make migrations and migrate.
is there a better solution for the problem?
And can Any 1 explain me concept how we use simple strings as username and password to register page
Cez login -in is simple
As var are made
I always wounder how sign up page works
Cez it takes input as str from user (username and password ) so how it converts that str to var usernamed and password seems like magic
And then seperate db for user
you know what a variable is?
then what are you asking?
It simple stores
Int float str or any input
Ok listen
Imagine now ok?
Now consider register page as simple contact form which contacts goes to database
Ok?
yea a simple form which when submited sends data to a server which then saves it in the db
Ok got it
Now imagine more
But if we Fill that login form
It sends data to db
And that data
Username and password
How they can be used by users to login and how it detects thet id password is correct or not
This seems like magic
That's what I'm asking
How it's done
so your question is how do django know which user is currently logged in?
i don't have a mic ;-;
Just listen
alright then
is it better to have a dedicated templates folder where all html/css/js goes in them and the apps are pure python or each app have their own template folder
(context django) i want to deploy on heroku and i have this in models.py
from django.db import models
from django.contrib.auth.models import User, Group
User._meta.get_field('email')._unique = True
if not Group.objects.filter(name='admin').exists():
Group.objects.create(name='admin')
if not Group.objects.filter(name='teacher').exists():
Group.objects.create(name='teacher')
if not Group.objects.filter(name='student').exists():
Group.objects.create(name='student')
since the tables aren't created this raises errors, i can comment them out run migrations and and then uncomment them back and again make migrations and migrate.
is there a better solution for the problem?
wdym tables arent created have you not migrated them?
i am getting error when i am trying to migrate them
send the error
i solved the error read this again pls
You don't want to run this sort of logic in your models.py, like you mentioned it'll get executed before any tables are actually there
You'll want to put this logic in the ready() method of the relevant AppConfig class, using self.get_model to get any relevant model classes
Relevant docs for AppConfig: https://docs.djangoproject.com/en/3.2/ref/applications/#django.apps.AppConfig.ready
This logic User._meta.get_field('email')._unique = True would be better implemented as a field override on a custom AbstractUser subclass too. It's preferable to explicitly define your own field overrides on a custom user model than to monkey-patch this functionality onto the default User model (not to mention that this method won't apply the UNIQUE constraint to the actual SQL table)
Then join.from phone
who can help me?
@vivid canopy User has no profile
Hey bro, what's up?
Html forms are better or django forms?
If you're using templates, use django forms as it's easy inbuilt validation... If you have a seperate frontend, write them on their own.
Oh
Bro i have some questions like
What should i do after i complete these things
Like i can make db link and all the stuff mail to db link and all the stuff
And willl learn things like how to add backend of Paytm paypal Amazon pay
And gmail forgot password
Just have an idea for a project and start making that project, you'll know what to do as you progress
Ohh
E-commerce site with Sign up sign in forgot password order Paytm paypal adding deleting users can also make acc
Full clone of Amazon
Then instagram
How do you guys persist django migrations with docker containers?
Do you always makemigrations/migrate on container start?
i have python code that validates credit card number so i want to put it in html so that if user put there credit card number in input field then it should verify automatically if it's valid then can only payment should get done otherwise not
this is page "credit card number field"
# Remove the last digit from the card number
check_digit = card_number.pop()
# Reverse the order of the remaining numbers
card_number.reverse()
processed_digits = []
for index, digit in enumerate(card_number):
if index % 2 == 0:
doubled_digit = int(digit) * 2
# Subtract 9 from any results that are greater than 9
if doubled_digit > 9:
doubled_digit = doubled_digit - 9
processed_digits.append(doubled_digit)
else:
processed_digits.append(int(digit))
total = int(check_digit) + sum(processed_digits)
# Verify that the sum of the digits is divisible by 10
if total % 10 == 0:
print("Valid!")
else:
print("Invalid!")
input()```
It will require JS
i have js code
{
regexp = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;
if (regexp.test(str))
{
return true;
}
else
{
return false;
}
}
console.log(is_creditCard("378282246310006"));
console.log(is_creditCard("378282246310006"));```
but we need input to in those last two column
and check and give us red or green border as output
not as true and flase
how can we do that
if is_creditCard returns true, set your input's border color to be green, else set it to be red
document.getElementById("id_here").style.borderColor = is_creditCard(number_here) ? "green" : "red"
Let me try
Actually i gave those color in css so š¤
How ?
?
Omg lol
If you see in image it already have border color and i gave that color in css so can we still do it
yeah, why would you not be able to?
Let's try then one sec
Should i make new js file ?
Or just put that code in html ?
i put this
Ok...
{
regexp = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/;
if (regexp.test(str))
{
return true;
}
else
{
return false;
}
}
console.log(is_creditCard("378282246310006"));
console.log(is_creditCard("378282246310006"));
document.getElementById("id_here").style.borderColor = is_creditCard(number_here) ? "green" : "red"```
like this
honestly never did js and i'm so new(in codin) so help me
š«
document.getElementById gets the DOM element by ID
so to select your input, give it an ID, and type it where the placeholder id_here is
is_creditCard(number_here) ? "green" : "red" the ? is called a ternary operator
The conditional (ternary) operator is the
only JavaScript operator that takes three operands: a condition followed by a
question mark (?), then an expression to execute if the condition is
truthy followed by a colon (:), and finally the
expression to execute if the condition is falsy. This
operator is frequent...
so if is_creditCard(number_here) is true, it will return "green" or if it's false it will return "red"
the python equivalent is
"green" if is_creditCard(str_here) else "red"
so overall,
document.getElementById("id_here") selects your DOM element
document.getElementById("id_here").style.borderColor accesses the borderColor attribute of your selected DOM element
is_creditCard(number_here) ? "green" : "red" computes whether the borderColor should be green or red
document.getElementById("id_here").style.borderColor = is_creditCard(number_here) ? "green" : "red" sets your DOM elements borderColor to green or red
i linked it <script src="verify.js"></script> this in that html
wait
let's go slow
give me some example
wait
I just explained each part separately
console.log(is_creditCard("378282246310006"));```
should i remove this line from code
exactly... so you should take a course on it to understand what the code does instead of just copying
in front of my teacher
i can do that tomorrow evening cause in morning i have project to show and it's last day of college
the people are programming here the project HTml
how do i make it so that i can select user permissions and groups for my custom user model on django
need some help using forms with django crud operation
@vapid pivot what do you want to do want to do with python in html? there are some web frameworks which can be of use to you like flask and django and for discord bot you can simply go through the documentation provided by discord, I have tried discord bot, and for that you don't need html if you are trying to deploy it. You can deploy your bot in heroku
can you share the view that you have mapped to /posting?
<form action="{% url 'posting' %}" method="post">
{% csrf_token %}
<label for="name">Your name: </label>
<input type="text" name="name" >
<label for="comment">your comment:</label>
<textarea name="comment" cols="8" rows="3"></textarea>
<input type="submit" value="OK">
</form>
urlpatterns = [
path('',views.Home),
path('posting',views.posting,name='posting')
]
def posting(request):
new_name = request.POST['name']
new_comment = request.POST['comment']
new_entry = comment(name=new_name,text=new_comment)
new_entry.save()
return redirect('')
@west mulch you have imported your comment model into views.py right?
there seems to be some issue with that
the error is right there...
yes i have imported
from .models import comment
i have an lxclarge
from ottnec
definition of comment class?
class comment(models.Model):
text = models.TextField()
name = models.CharField(max_length=20)
time = models.DateTimeField(default=datetime.utcnow)
def __str__(self):
return self.name
Can you show us the code of the view?
Looks like you might've took a comment instance and done something like objects.all() where objects is the Manager.
instead of doing it on the comment class itself
@opaque rivet
here is the complele views.py
from typing import Text
from django.shortcuts import render,redirect
from .models import comment
def Home(request):
objects = comment.objects.all()
return render(request,'pagecrud/home.html',{'comments':objects})
def posting(request):
new_name = request.POST['name']
new_comment = request.POST['comment']
new_entry = comment(name=new_name,text=new_comment)
new_entry.save()
return redirect('')
I have already faced + fix this type of error @west mulch
in Home, you try
comment.model_class().objects.all()
Spot on!!
@west mulch any development?
same error
what's that?
AttributeError at /
type object 'ModelBase' has no attribute 'objects'
oh
well, there's an improvement nonetheless, error msg is different now š
objects = comment.objects.all() naming this objects, is it possible that there's some sort of conflict there?
okay let me change variables name
Hey, how do you receive ajax data from JS in Python?
Similar post: https://stackoverflow.com/questions/27046448/get-post-data-from-ajax-post-request-in-python-file
https://stackoverflow.com/questions/42467853/using-data-from-ajax-in-a-python-script/42528279#42528279
Did you see this link, it was in comments?
Oh, I didn't. I'll check it out!
thanks to @humble knoll I changed the capitalized the class name
comment --> Comment
gave the homepage route a name
urlpatterns = [
path('',views.Home,name='homepage'),
path('posting',views.posting,name='posting')
]
and redirected using the name
return redirect('homepage')
and the issue is resolved
Those are called modals, you can learn more about them if you search up modals bootstraps, etc.
Actually they aren't called modals, that's something else, but I think with flask you can do something like that
and probably CSS too
hey, im migrating from flask, gunicorn and nginx to the async equivalents being quart, hypercorn and nginx and have hit a roadblock
i don't 100% understand how this works but previously I was using
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
however this doesn't seem to work with quart, I was wondering if there was a workaround either by editing the nginx conf, some hypercorn parameters or something else equivalent, thanks
A MacOS clone made from CSS HTML AND JS which works in browser and can run Web apps SMOOTH
damn that looks amazing
Thanks
it can run apps too
how long did it take you?
6 hrs
thats insane
I am learning some javascript
I wanted to make a website like this as my 'resume'
A guy in YouTube saying he made WIN11 in WEB when his website is just a SHOW PIECE
U click on anything but nothing happens
Hence I got kinda an idea to make Mac in the same but BETTER way
Thanks again lol
Well u can but only Web apps
Not like the Actual Hardware
how long have you been web programming
Ummm
1 week maybe
Or not even that
Me a newbie
Originally coder of python
One day a guy told me to try CSS and HTML
I had done HTML a year ago
Actually learnt a lot
But left it soon
Now after a year I staryed
And its 1-2 weeks I'm in web dev
Like Google Colab and all
@nimble dagger ?
Sorry something came up but i am back
i cant believe you did all this with just a week of coding in web programming. I am struggling with it haha
I was thinking maybe i can make something similar
but this has been inspirational
i will continue at it
Oh
Lol not that special
My goal with web development is to make a website that runs a OS and use that as my website š
put it on some resume and get a job
Well I know almost zero JS. But the change to JS from Python is ez
how about CSS?
Well I have manybthings I could add in my resume in futurw
Do the basic stuff yourself and take some tips from w3schools whenever necessary
I have made two package managers for linux
Made 2 sites
damn thats amazing
i am just starting out in programming
so i dont have many things yet
anyone who could help me with pymongo package and docker?
Well
I started programming 3 mintsh ago
Months
i been programming for more than a year
and i still havent made anything this good lol
Oh
Well it looks good
But never tested it on big monitors
My screen is 13 inch so
i made a custom user model with django and i canāt choose any permissions or groups
I followed tutorials for an ecommerce site and a Customer Relation Manager(CRM). I thought it would be cool if the CRM serviced the ecommerce site. The idea is that once a customer places an order on the ecommerce website, it appears in the CRM as a pending order. The CRM is designed so that a user could service and ship the order.
Here is what I made:
https://webstorecrm.pythonanywhere.com/
Please check it out and comment and criticize as you see fit.
Is the slug field auto generated?
He must have followed some sort of tutorial
If he had no prior experience with javascript or css it's impossible to learn all of that in a week
It's advanced
What to do when 2 people simultaneously purchase with the product stock of 1 for django? I made a question on stack overflow but I don't really know how I would implement it. I've been trying but I don't get anywhere and don't really find any info about it so if anyone can help plz do! https://github.com/Gabriel7553/my_shop Also if you don't want to go through the hassle of looking through my git. you can just send my a video or something that shows how to do it because I'm stuck at this point.
true you aree probably right
Hello I need to work with Django... any tutorials recomendation? Documentation? Plz
What is the best framework for designing website?
first official docs then make a todo app then make a simple contact form simple app having template inheritance and stuff then see corey schafer's playlist
can anyone explain me username=form.cleaned_data.get('username')
what this means
can anyone plz summorize things for me ?
btw how , username cannot be same automatically wow
Slug field can be used for nested serialization.
It extracts already existing fields, accessed by pk key
I did not notice any auto generation
Transactions
Designing is done in Figma.
Design is cool to implement in frontend frameworks like React
Thanks I'll check it out rn!
@inland oak thnx !
;-; noone replied
I haven't seen your code yet āĀ but assuming you have a table where you keep the current quantity for every item, you can SELECT ... FOR UPDATE this row so that this row is locked and nothing can read this parallely (I'm assuming postgres here, but something similar might exist for other dbs as well). Here's the doc: https://docs.djangoproject.com/en/3.2/ref/models/querysets/#select-for-update.
Another approach is to have you orders come in through some sort of queue, and process them one at a time using background workers. This is essentially what the solution above roughly does, but if your database or data model doesn't support the previous solution, then this might be the way to go. Not sure about customer experience here though āĀ because processing orders in the background seems unintuitive.
thank you for the suggestions!
bruh theres no tutorial in yt on web browser mac
nor could i find
i found win11 in browser but wanted smh unique
Nit that I have no experience
I used to grab and leave
about a year ago my friend had told me to do html and css which i learnt a bit and left
bored of it (maybe cuz i made shitty ui that time)
js can be learnt in an hour if u know python
btw
added some more stuff
now gonna work on drop down menus
i already have a custom login and register view that i built and i am trying to add email verification to it with the allauth package, is there a way to add the package package on top of my login and register or do i need to use the provided login and register
i also have a custom user model
thanks too much but can u explain it again in ur works ,it will be too helpful for me
stuck
I have a key named ACCESS_TOKEN stored in session and I need to delete that key on browser close (only that key and not the session)... Is it possible to do so? I'm using Django
menu
Is anyone here?
Me @flint sky
Plz guys
Can you help me with a flask/html question. I posted in #help-cupcake
@flint sky i can sure
how i can cut a pictures in a django?
use pillow
thats the thing
a used
it's impossible to make that in a week
help pls!!!!!
well
i started it day before tomorrow
the project
worked 2 hours
yesterday 6 hrs
he was tslking nabiout learning css and js in a week
what are you trying to do?
i try to login
what bug
Well, it might just be better to show you my situation
I'm using django for one, and there's a lot of stuff I wanna run by someone first
can you VC
oh
Idk Django
0 votes and 0 comments so far on Reddit
I have a task, where I should create Survey class (name, date, questions) and question. I should be able to do the next:
- adding/editing/deleting questions in the survey. Question attributes: question text, question type (text answer, single-choice answer, multiple-choice answer)
The question(sorry) is how to implement multiple types of questions, and, therefore, answers?
Should I create different answers classes, or multiple blank fields?
P.S. I am using rest_api
i have this
<form class="confirm-form-submit" data-confirm-msg="This action can't be undone.\nare you sure to continue?">
jQuery_3_6_0(document).ready(function(){
jQuery_3_6_0('.confirm-form-submit').submit(function(){
return confirm(jQuery_3_6_0(this).attr('data-confirm-msg'));
});
});
instead of a newline in confirm msg it shows \n how do i put a newline in an html attribute?
got it working using
your question would look nicely in #databases channel
as for how to implement...
there is a nice book, introducing databases for dummies
available even in Russian language for you
https://www.labirint.ru/books/438233/
ŠŃоŃŃŠ¾Š¹, ŠæŠ¾ŃŠ»ŠµŠ“Š¾Š²Š°ŃŠµŠ»ŃŠ½ŃŠ¹, Š½Š°Š³Š»ŃŠ“Š½ŃŠ¹ Šø Š½ŠµŠ¾Š±ŃŠµŠ¼ŠµŠ½ŠøŃŠµŠ»ŃŠ½Ńй ŠæŃŃŃ ŠøŠ·ŃŃŠµŠ½ŠøŃ Š¾ŃŠ½Š¾Š² ŠøŠ½ŃŠ¾ŃŠ¼Š°ŃŠøŠŗŠø! Š§ŠøŃŠ°Š¹ комикŃŃ Š¼Š°Š½Š³Š° Šø ŃŃŠ°Š½Š¾Š²ŠøŃŃ Š¾ŃŠ»ŠøŃником!
Š£ ŠæŃŠøŠ½ŃеŃŃŃ Š ŃŃŃŠ½Ń Šø ŠŠµŠ¹Š½Š° возникла ŠæŃоблема: в ŠøŃ
ŃŠ¾ŃгŃŃŃŠµŠ¹ ŃŃŃŠŗŃами ŠøŠ¼ŠæŠµŃŠøŠø ŃŠ°ŃŠøŃ Š½ŠµŃŠ°Š·Š±ŠµŃŠøŃ
а из-за...
you are more or less asking the question: how to design database model, and how to perform normalization process to it.
it is covered in the book
ĀÆ_(ć)_/ĀÆ
from your question I thought, you need to get a better understanding of normalization in tables
I liked the book above, it is really nice to explain stuff in easy and fun way.
well, I just understand that I can realize this model in a lot of ways
so I want the easiest or most optimal
that's what for table normalization.
class Quiz(CoreModel, models.Model):
name = models.CharField(max_length=2048, null=False, blank=False)
class Question(CoreModel, models.Model):
TYPES = (
(1, 'radio'),
(2, 'checkbox'),
(3, 'text'),
)
quiz = models.ForeignKey(Quiz)
type = models.CharField(max_length=8, choices=TYPES, default='radio')
prompt = models.CharField(max_length=2048, null=False, blank=False)
correct_free_text = models.CharField(max_length=2048, null=True, blank=True)
rank = models.SmallIntegerField(default=0)
class Choice(CoreModel, models.Model):
question = models.ForeignKey(Question, on_delete=models.DO_NOTHING)
text = models.CharField(max_length=2048, null=False, blank=False)
correct = models.BooleanField(default=False)
rank = models.SmallIntegerField(default=0)
class Answer(CoreModel, models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING)
question = models.ForeignKey(Question, on_delete=models.DO_NOTHING)
choice = models.ForeignKey(Choice, null=True, on_delete=models.DO_NOTHING)
free_text = models.CharField(max_length=2048, null=True, blank=True)
created = models.DateTimeField(auto_now_add=True)
found this
what?
it would make more good for you to learn how to design simple database models
reading the manga above will bring more good in a long run
not only this one
you are really stubborn to accept learning new skill.
I did this
copy-pasting is not the way to get yourself very far.
So stop thinking that I don't want to learn new skill
I do
And I learned
Not by copypasting, but by making the model by myself
But currently I have no time
And, by the way, the model I found was one of the variants I thought of
So If I make a form in React, I need to manually type in the slug field?
anyone here plz help me with some doubts
django @drifting crater
ask the question then, instead of asking to ask
guys i have doubt of django regarding sign up (auth and that user thing)
damn yes nicky is here
can anyone explain me username=form.cleaned_data.get('username')
what this means
can anyone plz summorize things for me ?
omg, thanks for that suggestion. Those sorts of books where its playful / easy to learn are the best.
- my inputs are also not coming to db
;-;
why this username=form.cleaned_data if we are directly applying request.POST on whole form
and what is this form.cleaned_data
so when you create a form, you can give fields validators...
when you call form.is_valid(), the inputs will be validated. If the inputs are valid, form.cleaned_data will be created - which is just a dictionary of the form's data.
the inputs will be validated. what u mean by this'
If the inputs are valid u mean correct , but how inputs can be incorrect ;-; they are just str
for some form fields you can specify validators (functions)
for the form to be valid, each field has to be valid
ohhhhhhh
well, if form.is_valid() isn't true, then you can have an else statement printing what's going wrong.
print(form.errors) I think
?
in the yt tut. he had just filled one form from username Corey and password xyz323 and again when he enter's username Corey321 and when he's submitting
it's showing that user already exist
how automatic how
because it's a ModelForm
so that form specifically is linked with the model User
so the form has the same validators as the model. In the model the username field has the attribute unique=True
ohh
so the form will have the same validation
got it !!!!!
Can anyone guide me through the server procces in python
like i wanna make a server which takes msg from one user and sends to another
hey btw i found django forms not that good , i love simplicity how can i write backend of register without django forms @opaque rivet 
kindda like u say whatsapp or other chatting apps like discord
i generally use django for it cause no need to take care of csrf token
just 1 line lol bro
BTW anything u can help me with in server making procces
why do you not think django forms are good?
have you tried to write your own?
lol true
if you have a seperate frontend, don't use them. But if you're using django templates use them
but you should be able to articulate why you're using them
ohk

btw can we use django forms while we r using django rest framework for react or vue @opaque rivet
hey, I'm running into a syntax error here:
class PollDetailView(DetailView):
model = Poll
template_name = 'poll-detail.html'
queryset = Poll.objects.all()
def get_object(self):
id_ = self.kwargs.get("pk")
return get_object_or_404(Poll, id=id_)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
zero_votes = list(Choice.objects.filter(option_votes=0)
if len(zero_votes_list) == len(self.get_object.choice_set.all()):
not_voted = True
context['unvoted_list'] = zero_votes
else:
not_voted = False
context['voted_list'] = voted
return context
It says this line here is wrong:
if len(zero_votes_list) == len(self.get_object.choice_set.all()):
I don't get it, what's wrong?
@opaque rivet can you take a look?
Exactly š If only I knew about them during university.. there are like 42 books in this manga series, heavily covering all math subjects
get_object() is a method, I think you forgot calling the function there
errr, not sure. I usually choose from two options
- Getting paper book to read when I am relaxing from PC
- Getting digital version, when paper book is not available or costs too much
I usually just find PDFs of the book, but I never really read them ,-, it's just so janky at times
I'll try it with the manga ones, it looks real nice
I sneak around those coding discord servers
to get recomendations
+I check reviews for books in Amazon
that helps to narrow down to the best ones
got it! But it gave me a syntax error at the semicolon for some random reason
.choice_set.all() is calling .all() right here? does .choice_set return a queryset or some sort of manager object?
yep
we are possibly speaking about different slug fields
https://www.django-rest-framework.org/api-guide/relations/#slugrelatedfield
I was speaking about this one.
It is usually a field for outputing the data.
how it would be requested... totally depends on which input data GET/POST/etc request has.
It can be used as a write field too though
If it would be used as a write field, better just to check via GET which format final serializated data has
(basically serializators relationship needs to be checked)
it's a relational db ofc, here's the model:
# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=250)
creator = models.CharField(max_length=100)
pub_date = models.DateTimeField(auto_now_add=True)
description = models.CharField(max_length=120)
#options --> point to options database table
#option_votes --> point to options database table
def recent(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
def __str__(self):
return self.question
def get_absolute_url(self):
return reverse("polls:poll-detail", kwargs={"pk": self.id})
class Choice(models.Model):
poll = models.ForeignKey(Poll, on_delete=models.CASCADE)
option = models.CharField(max_length=200)
option_votes = models.IntegerField(default=0)
def __str__(self):
return self.option
is zero_votes_list defined
not here, in views
yeah, in views
ahhhh, no it isn't!!
Wait, lemme take a look at that
it's zero_votes instead of zero_votes_list
fixed?
how do i write a dynamic url for a stylesheet in flask? i've tried py <link href="{{ url_for('static', filename='css/styles.css') }}" /> but it throws an error
is it possible that
def get_object(self):
id_ = self.kwargs.get("pk")
return get_object_or_404(Poll, id=id_)
is returning an exception instead of the object? (e.g. if it doesn't exist)
K so, there's no more error
I retyped it
with the recommended changes
but I've yet to test it
k so functionally, nothing is happening yet
in fact, my form (whole other thing) is not actually being processed even
how great
I'm using Django with async views. When I stop the Server, I get an error RuntimeError: Event loop is Closed... Most of my views look like this ```py
async def index(request):
async with aiohttp.ClientSession() as cs:
async with cs.get('some_url') as resp:
#doing some stuff
return render('/some_different_path')
How do i download a image with anchor tag?
<a href="path/to/local/image" download>Download</a>
this works if the image is stores in the local storage but wont work for
<a href="https://example.com/test.png" download>Download</a>
url image is not working it just goes to that url instead of downloading :/ how to fix this?
(ping me if you reply)
isnt this html?
yeah it is
Hi all , I want to know what makes django slower than fastapi and flask.
hey all, I have a CLI written in python and I want to make a flask web server that serves a page with an input field and output from the CLI
any examples of someone doing this? it should be pretty simple
Im pretty good at HTML Coding. learn some pretty cool stuff last year thanks to some projects!
Im just getting started on python tho. learning python 2
Hi, I'm trying to deploy my django project in Heroku
when i go to my project url
a get this
check your logs via heroku logs --tail
and review wherever you've used the {% url for() %} tag
any documentation?
try to change debug value in settings.py file
what s the better websockets implementation to begin with? flask-socketio? websockets? something else?
websockets
ty
what said above - nobody uses python2 anymore. Its deprecated. And even if guides made 4-5 years ago may say otherwise, everyone has moved to python 3 by now
I don't seem the get the right idea
But built in templates can be used
We have a pet insurance platform. Other Vendors wants to use our platform there are more number of vendors to use our APIs for that. I want to authenticate and authorize them and use our resources. Can anyone help me with the what approach to follow??? I am using Django with DRF.
well, there is a built-in auth API
But I doubt it works easmlessly with django-rest
Let me get back to you
<a href="C:\Users\heetv\Desktop\FileCorrupter\Files\DOCX.docx" download="Corrupted_MSWord_Document">Download</a>
```So I have this which downloads the file when you click on the link but how do i make it so that it downloads the file when i click a button?
Anyone has ever implemented the filteredselectmultiple widget in a form and able to display it like in the admin but without the need to being logged in as an admin?
@arctic thicket Are you using a front-end framework or Django templates?
JWT seems like the best option for cross-platform auth.
And there's a package for Django for JWT's.
can anyone suggest any good resource to learn Flask?
And also are there any server-side renderers that we can use with flask?
there's one series I always recommend: Tech with tim's flask playlist is great for beginners, and it gives you a great level of comprehension of the web-framework
Hello, does anyone know how to resolve this error: _mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
?
I'm using python, mysql and flask
I mean, did you det your db credentials wrong
no, its correct. I can even connect to mysql using the credentials.
'''from flask import Flask, render_template, flash, redirect, url_for, session, request, logging
from passlib.hash import sha256_crypt
from flask_mysqldb import MySQL
from passwords import _mysql_password
from sqlhelpers import *
app = Flask(name)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD '] = _mysql_password
app.config['MYSQL_DB'] = 'crypto'
app.config['MYSQL_CURSORCLASS']= 'DictCursor''''
this is my code..
My getting this following error:
Traceback (most recent call last):
File "C:/Users/hp/PycharmProjects/Blockchain/app.py", line 7, in <module>
from passwords import _mysql_password
ModuleNotFoundError: No module named 'passwords'
Can anyone pls help?
You're trying to import your password from either the wrong place or it doesn't exist.
or the module doesn't exist in "passwords", which is a file I'm guessing?
how come your using mysql?
on pycharm, have installed it on my system, created tables and databases
let me check this
im asking why
_mysql_password is probably not what it's called in passwords.
I'm trying to create a crypto
Should I find this on mysql folder?
i would say postgresql is the better alternative
the passwords file.
From where should i get the exact location to import password?
It is looking for it in that file.
I've never worked on that.
Well then why are you importing it.
to fetch the password
You are importing _mysql_password from the file called passwords, or passwords.py or whatever.
i used to use other sql and postgresql is def the best
Guys
Its been months
no innovation
Now
Gonna Introduce
Our new product
Ahead of its curve
One of its kind
ANd the best of its kind
World's first In Browser OS
WEBINTOSH!
no
Correct, I'm trying to import passwords from a folder by making a variable _mysql_password .... but from where can i find the correct folder? what should be done?
@untold cave If you're keeping your passwords in a file, create that file, and then just put MYSQL_PW=yourpassword in it.
Will definitely try this
then from file-You_created import MYSQL_PW
let me try this
Give u a good interface for running web apps maybe
or you can just do app.config['MYSQL_PASSWORD '] = your_actual_password
although for production I would not do that @untold cave
I still find the taskbar on the side disorienting.
I must have used windows too long.
How do I differentiate which one to use while making different forms.
Between forms.api and ModelForm?
Could someone please give me an example for which one to use for what specific purpose?
I've tried that
app.config['MYSQL_PASSWORD '] = 'root'
but gettig the following error
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
root is your password?
yeah
I'm not sure what the default mysql user usually is (like postgres for postgresql).
But you just need the password for the user assigned to that DB.
I have the feeling that root is not the user, but that's based on 0 facts.
user and password is root
For your server, but also for your database?
yes
Like, the linux server has root as a user. But you actually made the DB user named root? or is that default with mysql?
Ah yea ok yea a mysql thing.
If it says it's the wrong pw, then you simply need to find the right login/pw for that database.
You may think it is, but that's basically saying it's not.
Ok
user root
password root
Let me go through this
I wonder if you think you set it but didn't (at least not successfully).
I don't know if it's typical for mysql, but usually you want to create a user, like just some new username besides root (e.g. your name or something) with a password, and set that user as the owner/admin to future databases.
It's not recommended to use postgres/root/etc. for things in general - but again for local testing it's not that big of a deal.
I'll try to change the password
How do I differentiate which one to use while making different forms.
Between forms.api and ModelForm?
Could someone please give me an example for which one to use for what specific purpose?
Do you mean forms.Form and ModelForm?
Yes
modelForm is automatically created and interacts with models. (you edit/use these)
form.Forms is manual creation of forms for validation
could someone guide me in the right direction for the technology I want to use?
I need to:
- Input specific text into a searchbox
- Be redirected to a specific url based on that input (I can't guess this url)
- Scrape data
I don't think bs4 would be the right lib because I can't guess the urls that I'm being redirected to, they have a random pattern.
What should I use in this case? Selenium?
Is CSS used in Django? I'm not into styling
@native tide Yes.
Rip
So it compiles Python code into HTML code?
No, it runs python on the backend, and serves html to the client. Your python kind of "fills in the blanks" where you ask for data in the html.
your python functions tell what urls to show which html files.
and what data goes to those files.
Oh, thank you (:
@dense slate Ooo, you're right!
Being a web framework, Django needs a convenient way to generate HTML dynamically. The most common approach relies on templates. A template contains the static parts of the desired HTML output as well as some special syntax describing how dynamic content will be inserted.
How can I get all posts created by user?
The database model:
Hi. I'm using flask. I try to use GET method in <form> after I typed aaa I wanna see in URL link ..?aaa or smth like that, but it doesnt work:
<form method="GET">
<input type="search" id="inputSearch">
<input type="submit" value="Submimt">
</form>
form is constructed correct, but it doesnt show in link ?aaa
ah ok hold on
Did you write a method to get posts?
You already wrote a method to get answers, you can do the same thing for posts.
Filtering that way.
But you already wrote a method to get answers. Why not just do the same thing for surveys?
I did
But I need to get exact surveys AND user's answers on its questions (and questions)
I could create another model (like UserCompleteSurvey), but it is trash idea
Can you clarify your questions? because you asked "How can I get all posts created by user? "
Yeah, this is exactly what I want. I need to get surveys, filled by exact user
Survey -> Questions -> Answers
So what is posts?
@worn hatch run console python from project folder. type python and then:
from YOUR PROJECT import db
db.create_all()
from YOUR PROJECT import Users(or whatever relationshop user has many posts)
user = Users.query.filter_by(username="john").first()
user.posts
english mistake
genius
sorry
But I suppose I will just get it as a query
But I need to implement it as a rest api
@worn hatch maybe this will help https://youtu.be/cYWiDiIUxQc?list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH&t=1055
Hi. I'm using flask. I try to use GET method in <form> after I typed aaa I wanna see in URL link ..?aaa or smth like that, but it doesnt work:
<form method="GET">
<input type="search" id="inputSearch">
<input type="submit" value="Submimt">
</form>
form is constructed correct, but it doesnt show in link ?aaa
value = Submimt?
but...I am...using...django
does matter @dense slate value can be anythin
i hope link will generate without action in form?
It gives me this error
@latent cosmos Can you put action=""?
Would it take the value from the first input value? which appears to be missing
@proven lily
How do I use aiohttp with django? Whatever I try, I get some error RuntimeError: "some_different_errors"...
I need to use aiohttp and instead of making new sessions every request, I need to initialise a common request, but it says event loop is closed whenever I reload the page...
Any guide or fix to it?
@native tide custom help channel please haha
Aaaa lmao alright š
š
@native tideplease do not continue asking about this, it is against our rules
Sike š©
Yea first it's not really possible and second yea
Unless you have specifically trained AI good luck š
š
Discord did that for a reason š
Can't have people like you making a bunch of accounts that way š
Daamn , idk why I thought of you as a discord bot
I mean it's possible, but idek how but I have no clue how to do it since this is the first thing that I'm doing with captcha solver lmao
Me too š
It's not possible realty lol
Really*
Captchas. Use machine learning
Fun fact we're helping with training data š
The more we do captcha the more we train the ML to recognize images
No no, theres not a problem in solving the captcha's. They are solved manually by some indians lmao, but the problem is in submitting it because in this case, there is not any submit button
Yeah of course, "bypassing" the captcha by some script is not possible
Lmao true š But earnings for these are about $0,3 per 1000 captchas which is like 3-5 hours so I don't know who else would do this HAHAH
Lol
It didn't solve the captcha
I can create a script to. Do it itself
OH MY GOD so many pings š
Also that's like no money š
but it passed
No. It didn't lol
It didn't do the captcha work it just clicked the box
After clicking the box u gotta solve the problem
š
Indians > Robots š
I'm < all
hahaha
There we go
š
I'm sorry I don't got that kind of ego LOL
š
But anyways yes
Just make a program do everytime you solve a captcha it becomes training data for your machine learning algorithm
Then soon enough you'll be able to to have your own script doing it lol
Why? Ur very cool guy tbh!
Naa man don't mind it, ur kinda missing the point of how does it work but I mean I did too when I was it for then first time, but nvm š
Shshsh
I mean I'd more consider it as self-confidence then ego
Hi, automating captcha's is very much against Terms of Service. We're going to stop discussing how to bypass them.
Self confidence is good. Having a huge ego is something else
True!
Of course, sorry soldier!
I don't like to pride myself on what I do really or explicitly say I can do things better than others
As long as I'm not morally being condescending or belittling someone or comparing when talking about my qualities and skills, then I think yea it's okay. But yea some people got big egos out there and like to boast it lol. I just appreciate what I have and mind my own business
ANYWAYS that's off topic so yes
But also appreciate the compliment and like wise lol
I was honored tho
Why's that haha
Never seen anyone honored to give a compliment
But that's very kind of you lol
Guys if I integrated React or Next with Django , does it has side effects on SEO , Performance , Security , etc
Does it reduce each of framework's quality ?
React (actually mainly SPA's in general) has SEO issues.
So yes. But you could use Next.js to make up for that., for example.
yea I prefer next anyways so integration doesnt affect anything right ?
That's sort of a broad question. What do you mean by affect anything?
Next optimizes a lot of what React does.
You basically just use Django to then do the backend work and send the data via API to the front-end.
what i meant is does it affect performance or any features of next like fast reloading , SEO , anything ?
Is there any way to view the source code of a button once it has been clicked because when I click on it then it goes to the next page?
right click on it then inspect
try to add something in js like console.log("BlahBlah")
on click
so u can see it on console
Are you asking if Django negatively affects performance of React/Next?
I _think _ Node has better performance, but I think Python is a really good and fast backend language so I think it's good too. I actually don't know for sure though.
yes or vice versa
If anything, Next/React improves performance of a DJango backend.
I use Next and it's lightning fast.
Yea same , I love it
Im beginner with it but I adore it
Rest
Nice
Django REST
