#web-development

2 messages Ā· Page 168 of 1

inland oak
#

Bitrix is bad analog of Wordpress in a nutshell

#

Few days ago I saw results of bitrix developers.... those..... individuals went into production without https.

#

Fantastic lack of skills.

native tide
#

this is a date returned by the django api 2021-06-13T03![22](https://cdn.discordapp.com/emojis/734185971846742056.webp?size=128 "22")12Z

#

how do i format it in DD MM YYYY in Javascript?

gray thistle
#

Anyone down to help a newb with some HTML?

calm plume
gray thistle
#

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

calm plume
#

Uhhh

#

Where's the h1

gray thistle
#

wdym

#

last line of body

#

the site just looks like this

desert estuary
#

yoo

gray thistle
#

So @calm plume you came up with anything or...?

calm plume
#

Html elemebts go in the order you put them in

calm plume
#

Errr

#

Where even is the h1 in the image

gray thistle
#

wdym

#

its under the clouds

calm plume
#

I can't see that in your screenshot thing

gray thistle
#

thats the issue

#

i want it to be on top of the clouds

calm plume
#

What happens if you remove height: 100vh;

gray thistle
#

Good question

calm plume
#

So the h1 worked

gray thistle
#

Yeah, no

calm plume
#

Wdym

gray thistle
#

I want the h1 to be on the clouds

calm plume
#

Ohhhh

#

That'll be some css

gray thistle
#

Listening

calm plume
#

There's an example

gray thistle
#

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

calm plume
#

Oh, then I have no idea sorry

#

I haven't touched opengl

quiet ridge
gray thistle
#

?

quiet ridge
#

nothing leave it

violet dock
#

what is this?

#

this is my code

gray thistle
pliant pewter
#

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>
inland oak
pliant pewter
native tide
#

bro something is not going good in my pc

#

he got hacked ithink

maiden salmon
#

It was me

manic crane
#

My DRF is not showing any of my fields ? First time using DRF help would be really appreciated

sullen forge
#

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)
twin hamlet
#

hello i am facing some problems in cloning the proj

tepid lark
#

I want to like the serverless framework.

#

but I've never encountered a project using it without some weird bug because of constant updates.

weak anvil
#

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!"
proper hinge
#

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?

ripe dirge
proper hinge
#

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

proven lily
#

@proper hinge can you summarize your issue

proven lily
#

Or bottom: 0

distant flax
#

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

smoky oar
#

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
proper hinge
#

The jsfiddle is an example of my attempt to fix it with the grid and visibility technique I described in the latter half.

proven lily
#

@proper hinge just remove the height or set a min-height

#

But removing the height should work

proper hinge
#

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.

carmine wharf
#

How do we make sure in django the user can't purchase when the stock is at 0?

gritty cloud
#

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

carmine wharf
#

Thank you for the info!

pliant pewter
gritty cloud
quartz yacht
#

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?

native tide
#

anyone good with XPath?

carmine wharf
# gritty cloud you could authenticate in the view

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!

ocean notch
#

Does anyone else find Django documentation to be sort of scattered and hard to find what you're looking for?

#

Especially when starting off

torpid beacon
#

Any interested please contact me via DM

ocean notch
#

no luck on upwork?

lavish prismBOT
#

9. Do not offer or ask for paid work of any kind.

normal pebble
#

!rule 9

lavish prismBOT
#

9. Do not offer or ask for paid work of any kind.

torpid beacon
#

Oh sorry, didnt know people is so selfish. lol

#

go get some life

inland oak
#

It is more about flood of job scammers

normal pebble
#

!tempban 287003991747985413 1w Take the time to decide whether you want to participate in the community and respect our rules.

lavish prismBOT
#

:incoming_envelope: :ok_hand: applied ban to @torpid beacon until 2021-07-03 03:22 (6 days and 23 hours).

inland oak
rotund swallow
#

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.

ocean notch
#

I'd love to hear some alternatives

#

Hopefully books using Django rest framework instead of just Django

#

xD

inland oak
#

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

frosty glen
#

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

inland oak
#

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)

frosty glen
#

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?

inland oak
#

if I get it right, it stores in hash_key: data(+expiration time) style

frosty glen
#

well thank you darkwind, I'll give it a try an see today!

inland oak
frosty glen
#

yep definitely

inland oak
#

some check with postman for an obvious situation could be done

inland oak
# frosty glen 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

frosty glen
#

oh I see

inland oak
#

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

frail sage
#

It's very new, so stuff is being added/existing being replaced or improved at a fast pace

elder iron
#

Hi guys, what it means

#

db = SQLALCHEMY(), they say it is for initializing, but what that means? and why we need it?

humble knoll
#

has anyone ever deployed a deep learning model(face detection model to be specific) in Django app here?

restive bluff
#

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)

humble knoll
# frail sage 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

primal thorn
#

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

gray thistle
solar epoch
primal thorn
obtuse trout
#

allauth package is only for social app authentication

#

for normal login/register you need have a django app

solar epoch
#

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

calm plume
mellow prawn
#

can plz sm1 help me in downloading pyaudio

#

plz

#

need some help coz its not downloading

frosty glen
#

how does one store dicts with pymemcache?

hybrid cloak
#

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?

gritty cloud
# carmine wharf hey I was trying to find info on how to do this but I can't. I'm not that good a...

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

candid yew
#

I'm looking for a team to participate in the odin project web dev game jam

#

anyone?

#

dm me if you're interested

scenic galleon
#

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)

civic pewter
#

Needs help with celery....

viscid sparrow
#

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

obtuse trout
viscid sparrow
#

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?

obtuse trout
#

fix it instead of skipping it

arctic thunder
#

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

gritty cloud
arctic thunder
indigo junco
#

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
ripe dirge
# proper hinge Sure. https://jsfiddle.net/32Lmrydv/

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.

candid yew
#

Anyone want to join my team for a game jam?(Web development)

indigo junco
gritty cloud
stable hemlock
#

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.

royal radish
#

guys hello

What does Python/Django uses instead of UserCreationForm?
it seems like it is not supported anymore

#

thanks for help

proper hinge
# ripe dirge Hey <@!137073073168973824> , I have done some changes to your code. I am not exa...

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.

opaque rivet
# proper hinge Thanks, I really appreciate you looking into this. I pretty much had to shelve i...

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

indigo junco
#

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

opaque rivet
#
 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.

opaque rivet
#

for django-admin commands, does the command actually have to be named Command? Or can it be named anything?

native tide
#

anyone here know how to make a username checker ?

peak bronze
opaque rivet
#

@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

calm plume
#

I think it's /var/lib/postgresql/data but I'm not sure

opaque rivet
#

@calm plume I'll try that out. Thanks

astral pagoda
#

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?

languid raptor
#

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

stable coral
#

I'm able to print the posts by themselves, but when I try to access the posts through the user, this happens

proper hinge
# opaque rivet I'd use JS to extract the height of the two pages: ```ts // Extract heights of t...

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:

  1. Can't get the height of an element that is not displayed.
  2. 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.

surreal thicket
#

@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.

primal thorn
#

i made a custom user model with abstractbasemodel but the ā€œobjectsā€ and ā€œpermissionsā€ table were not present, how do i enable those

summer dirge
#

i feel like if you want minimal a microframework like flask or fastapi is just the better choice

carmine wharf
#

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.)

dusk portal
stable hemlock
#

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})

dusk portal
#
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
nimble axle
#

hey could anyone help with flask here i need to get something working?

dull tartan
#

Just share the issue you are facing!

native tide
#

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?

rain delta
native tide
#

It’s mainly to expire people who haven’t paid their subscriptions

#

For my web app

rain delta
#

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

native tide
#

What’s broken about that?

rain delta
#

why the span tag is making a new line

native tide
#

Either throw it into a parent container of a div that uses flex alignment

rain delta
#

sir , i am new to it

native tide
#

Or set it’s style to display inline-block

rain delta
#

please tell , something which is easy for a beginner to understand

#

i only want to write the correct html , no css

native tide
#

You can’t change that

#

Without css

#

The default would be to break it into a new line

rain delta
native tide
#

You’ll need to use css to fix it

rain delta
#

you mean to say that this can not be made without css

native tide
#

Yeah it’s clear that screenshot has css

#

Yes

#

You can barely do anything in terms of html without css

rain delta
#

forget the css, just tell me html

native tide
#

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

rain delta
#

can you tell when a heading is appropriate and when a label , means what exactly a label does

native tide
#

That’s up to how you design things

rain delta
#

there is difference

native tide
#

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

rain delta
#

even i cannot bring , Political Persuassion , in front of first dropdown list

native tide
#

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

rain delta
#

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>

native tide
#

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

rain delta
#

goal , is to ask you why , we can not do this by using a span and a heading tag

native tide
#

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

rain delta
#

ok , let me see

native tide
#

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

cerulean badge
dusk portal
#

Is it imp to use it

cerulean badge
#

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?

dusk portal
#

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

cerulean badge
dusk portal
#

Lmao

#

Yes

cerulean badge
#

then what are you asking?

dusk portal
#

It simple stores
Int float str or any input

dusk portal
#

Imagine now ok?

#

Now consider register page as simple contact form which contacts goes to database

#

Ok?

cerulean badge
#

yea a simple form which when submited sends data to a server which then saves it in the db

dusk portal
#

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

cerulean badge
#

so your question is how do django know which user is currently logged in?

dusk portal
#

Umm

#

Can u come voice chat @cerulean badge

cerulean badge
#

i don't have a mic ;-;

dusk portal
#

Just listen

cerulean badge
#

alright then

primal thorn
#

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

cerulean badge
#

(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?

primal thorn
cerulean badge
primal thorn
cerulean badge
mild bridge
#

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

#

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)

stark tartan
vivid canopy
#

who can help me?

opaque rivet
#

@vivid canopy User has no profile

dusk portal
opaque rivet
dusk portal
#

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

opaque rivet
#

Just have an idea for a project and start making that project, you'll know what to do as you progress

dusk portal
#

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

opaque rivet
#

How do you guys persist django migrations with docker containers?
Do you always makemigrations/migrate on container start?

topaz basin
#

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()```
topaz basin
#
{
 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

opaque rivet
#

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"
topaz basin
#

Let me try

topaz basin
#

How ?

opaque rivet
#

?

dusk portal
#

Omg lol

topaz basin
# topaz basin

If you see in image it already have border color and i gave that color in css so can we still do it

opaque rivet
topaz basin
#

Let's try then one sec

#

Should i make new js file ?

#

Or just put that code in html ?

opaque rivet
#

Ok...

topaz basin
#
{
 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

#

😫

opaque rivet
#

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

#

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

topaz basin
#

i linked it <script src="verify.js"></script> this in that html

#

wait

#

let's go slow

#

give me some example

#

wait

opaque rivet
#

I just explained each part separately

topaz basin
#

console.log(is_creditCard("378282246310006"));```
should i remove this line from code
opaque rivet
#

up to you

#

to me it seems you need to learn JS

topaz basin
#

i'm doin this first time so

#

i just need this project to work for 5 min

opaque rivet
#

exactly... so you should take a course on it to understand what the code does instead of just copying

topaz basin
#

in front of my teacher

topaz basin
native tide
#

the people are programming here the project HTml

dusk portal
#

Wow man

#

U guyz are too good

vapid pivot
#

someone knows how to use python in html?

#

like in general or for a discord bot

primal thorn
#

how do i make it so that i can select user permissions and groups for my custom user model on django

west mulch
#

need some help using forms with django crud operation

humble knoll
#

@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

humble knoll
west mulch
#
 <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('')
dusk portal
#

Whats the error

#

@west mulch

humble knoll
#

@west mulch you have imported your comment model into views.py right?

#

there seems to be some issue with that

opaque rivet
west mulch
#

yes i have imported

from .models import comment
vapid pivot
#

from ottnec

humble knoll
west mulch
#
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
opaque rivet
#

instead of doing it on the comment class itself

west mulch
#

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('') 
dusk portal
#

I have already faced + fix this type of error @west mulch

humble knoll
humble knoll
#

@west mulch any development?

west mulch
#

AttributeError at /

humble knoll
#

i see

#

try

comment.__class__.objects.all()
west mulch
#

same error

humble knoll
west mulch
#

AttributeError at /

type object 'ModelBase' has no attribute 'objects'

humble knoll
#

well, there's an improvement nonetheless, error msg is different now šŸ˜…

opaque rivet
#

objects = comment.objects.all() naming this objects, is it possible that there's some sort of conflict there?

west mulch
#

okay let me change variables name

dusty urchin
humble knoll
dusty urchin
#

Oh, I didn't. I'll check it out!

west mulch
#

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

wet dust
#

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

mint folio
#

Its a toast notification

#

There are js packages that can make it easy for you

fervent raft
#

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

mint folio
terse anchor
#

A MacOS clone made from CSS HTML AND JS which works in browser and can run Web apps SMOOTH

nimble dagger
#

damn that looks amazing

terse anchor
#

Thanks

nimble dagger
#

it can run apps too

terse anchor
#

Yes

#

Just made this out of interest

nimble dagger
#

how long did it take you?

terse anchor
#

6 hrs

nimble dagger
#

what you did all that in 6 hours

#

damn

terse anchor
#

Nah

#

I mean today I worked 6 hrs

#

Yesterday 2

nimble dagger
#

thats insane

#

I am learning some javascript

#

I wanted to make a website like this as my 'resume'

terse anchor
#

U click on anything but nothing happens

#

Hence I got kinda an idea to make Mac in the same but BETTER way

nimble dagger
#

yeah damn it looks like the real thing

#

can you can run apps on it

#

thats amazing

terse anchor
terse anchor
#

Not like the Actual Hardware

nimble dagger
#

how long have you been web programming

terse anchor
#

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

terse anchor
#

@nimble dagger ?

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

terse anchor
terse anchor
nimble dagger
#

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

terse anchor
nimble dagger
#

how about CSS?

terse anchor
terse anchor
terse anchor
#

Made 2 sites

nimble dagger
#

damn thats amazing

#

i am just starting out in programming

#

so i dont have many things yet

quasi relic
#

anyone who could help me with pymongo package and docker?

terse anchor
#

I started programming 3 mintsh ago

nimble dagger
#

what

#

how

terse anchor
#

Months

nimble dagger
#

i been programming for more than a year

#

and i still havent made anything this good lol

terse anchor
#

Oh

#

Well it looks good

#

But never tested it on big monitors

#

My screen is 13 inch so

primal thorn
#

i made a custom user model with django and i can’t choose any permissions or groups

scarlet swift
#

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.

native tide
#

Is the slug field auto generated?

candid yew
#

If he had no prior experience with javascript or css it's impossible to learn all of that in a week

#

It's advanced

carmine wharf
#

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.

GitHub

Contribute to Gabriel7553/my_shop development by creating an account on GitHub.

nimble dagger
jolly epoch
#

Hello I need to work with Django... any tutorials recomendation? Documentation? Plz

night sequoia
#

What is the best framework for designing website?

dusk portal
#

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

inland oak
inland oak
carmine wharf
jolly epoch
#

@inland oak thnx !

tacit finch
# carmine wharf What to do when 2 people simultaneously purchase with the product stock of 1 for...

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.

tacit finch
# carmine wharf What to do when 2 people simultaneously purchase with the product stock of 1 for...

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.

terse anchor
#

nor could i find

#

i found win11 in browser but wanted smh unique

terse anchor
#

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

primal thorn
#

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

dusk portal
# primal thorn

thanks too much but can u explain it again in ur works ,it will be too helpful for me

#

stuck

native tide
#

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

terse anchor
flint sky
#

Is anyone here?

dusk portal
#

Me @flint sky

dusk portal
flint sky
#

Can you help me with a flask/html question. I posted in #help-cupcake

dusk portal
#

@flint sky i can sure

vivid canopy
#

how i can cut a pictures in a django?

inland oak
candid yew
vivid canopy
#

a used

candid yew
#

it's impossible to make that in a week

vivid canopy
#

help pls!!!!!

terse anchor
#

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

west mulch
vivid canopy
#

i try to login

ivory bolt
#

hey

#

I have a bug and I cannot figure it out

#

can someone please help me out?

terse anchor
#

what bug

ivory bolt
#

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

worn hatch
#

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

cerulean badge
#

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 &#10;

inland oak
#

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

worn hatch
#

well I understand something in designing databases

#

example

inland oak
# worn hatch example

ĀÆ_(惄)_/ĀÆ
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.

worn hatch
#

well, I just understand that I can realize this model in a lot of ways

#

so I want the easiest or most optimal

inland oak
worn hatch
#

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

inland oak
worn hatch
#

what?

inland oak
#

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

worn hatch
#

yes, I know

#

but, lol, I made some of them already

worn hatch
inland oak
#

you are really stubborn to accept learning new skill.

worn hatch
#

I did this

inland oak
#

copy-pasting is not the way to get yourself very far.

worn hatch
#

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

native tide
dusk portal
#

anyone here plz help me with some doubts

drifting crater
#

doubts regarding what ?

#

flask or Django ?

dusk portal
#

django @drifting crater

opaque rivet
#

ask the question then, instead of asking to ask

dusk portal
#

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 ?

opaque rivet
# inland oak

omg, thanks for that suggestion. Those sorts of books where its playful / easy to learn are the best.

dusk portal
#
  • 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

opaque rivet
dusk portal
#

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

opaque rivet
#

for some form fields you can specify validators (functions)

#

for the form to be valid, each field has to be valid

dusk portal
#

ohhhhhhh

opaque rivet
#

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

dusk portal
#

in his automatic idk how in yt his tutorial , he cannot use same username

#

idk how

opaque rivet
#

?

dusk portal
#

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

opaque rivet
#

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

dusk portal
#

ohh

opaque rivet
#

so the form will have the same validation

spring cipher
#

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

dusk portal
#

hey btw i found django forms not that good , i love simplicity how can i write backend of register without django forms @opaque rivet tmg_cry_sad

spring cipher
#

kindda like u say whatsapp or other chatting apps like discord

spring cipher
spring cipher
#

BTW anything u can help me with in server making procces

opaque rivet
#

have you tried to write your own?

spring cipher
#

lol true

dusk portal
#

ok ill use

#

django forms

#

as u say

#
True```
opaque rivet
#

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

dusk portal
#

ohk

#

btw can we use django forms while we r using django rest framework for react or vue @opaque rivet

ivory bolt
#

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?

spring cipher
#

what doess the error

#

says try to put in the same

#

line

inland oak
opaque rivet
#

woah šŸ˜„

#

i'm contemplating getting a kindle, do you think it's worth?

spring cipher
#

yes

#

i have it

opaque rivet
inland oak
#

errr, not sure. I usually choose from two options

  1. Getting paper book to read when I am relaxing from PC
  2. Getting digital version, when paper book is not available or costs too much
opaque rivet
#

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

inland oak
#

to get recomendations

#

+I check reviews for books in Amazon

#

that helps to narrow down to the best ones

ivory bolt
opaque rivet
#

.choice_set.all() is calling .all() right here? does .choice_set return a queryset or some sort of manager object?

ivory bolt
#

yep

inland oak
# native tide So If I make a form in React, I need to manually type in the slug field?

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)

ivory bolt
#

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
ivory bolt
#

not here, in views

opaque rivet
#

yeah, in views

ivory bolt
#

ahhhh, no it isn't!!

#

Wait, lemme take a look at that

#

it's zero_votes instead of zero_votes_list

opaque rivet
ivory bolt
#

doing now

#

still giving me the syntax error

obtuse whale
#

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

opaque rivet
#

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)

ivory bolt
#

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

native tide
#

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')

scenic galleon
#

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)

inner glacier
#

isnt this html?

scenic galleon
proud lintel
#

Hi all , I want to know what makes django slower than fastapi and flask.

grave swan
#

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

inner glacier
#

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

west peak
#

Hi, I'm trying to deploy my django project in Heroku

#

when i go to my project url

#

a get this

ivory bolt
#

check your logs via heroku logs --tail

#

and review wherever you've used the {% url for() %} tag

west peak
#

i don't use this tag :C

#

I'm only put /routeName when i use an url

ivory bolt
#

well, I'd recommend you do for starters

#

it makes your site more dynamic

west peak
#

any documentation?

median flare
west peak
#

ohh

stark axle
#

what s the better websockets implementation to begin with? flask-socketio? websockets? something else?

opaque rivet
#

@inner glacier learn python 3

#

Not python 2

stark axle
#

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

arctic crow
#

I don't seem the get the right idea
But built in templates can be used

arctic thicket
#

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.

ivory bolt
#

well, there is a built-in auth API

#

But I doubt it works easmlessly with django-rest

#

Let me get back to you

steel pier
#
        <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?
ember adder
#

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?

dense slate
#

@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.

twilit elm
#

can anyone suggest any good resource to learn Flask?

#

And also are there any server-side renderers that we can use with flask?

ivory bolt
untold cave
#

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

ivory bolt
#

I mean, did you det your db credentials wrong

untold cave
#

no, its correct. I can even connect to mysql using the credentials.

untold cave
#

'''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?

dense slate
#

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?

untold cave
dense slate
#

_mysql_password is probably not what it's called in passwords.

untold cave
untold cave
lethal nova
dense slate
#

the passwords file.

untold cave
#

From where should i get the exact location to import password?

dense slate
#

It is looking for it in that file.

untold cave
dense slate
#

Well then why are you importing it.

untold cave
dense slate
#

You are importing _mysql_password from the file called passwords, or passwords.py or whatever.

lethal nova
terse anchor
lethal nova
#

no

dense slate
#

What would a browser OS even... do.

#

Like Chrome OS?

untold cave
dense slate
#

@untold cave If you're keeping your passwords in a file, create that file, and then just put MYSQL_PW=yourpassword in it.

untold cave
dense slate
#

then from file-You_created import MYSQL_PW

terse anchor
dense slate
#

or you can just do app.config['MYSQL_PASSWORD '] = your_actual_password

#

although for production I would not do that @untold cave

terse anchor
dense slate
#

I still find the taskbar on the side disorienting.

#

I must have used windows too long.

woven spoke
#

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?

untold cave
#

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)")

dense slate
#

root is your password?

untold cave
#

yeah

dense slate
#

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.

untold cave
#

user and password is root

dense slate
#

For your server, but also for your database?

untold cave
#

yes

dense slate
#

Like, the linux server has root as a user. But you actually made the DB user named root? or is that default with mysql?

untold cave
#

default mysql

#

db is crypto

dense slate
#

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.

untold cave
#

This is the firdt time im using mysql

#

okay will search for that

dense slate
#

You may think it is, but that's basically saying it's not.

untold cave
#

okay will check

#

Thanks a lot for the guidance

dense slate
#

Usually root has no password.

#

Unless you set it

untold cave
#

oh okay willcheck on that

#

i set that

dense slate
#

Ok

untold cave
#

user root
password root

untold cave
#

Let me go through this

dense slate
#

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.

untold cave
#

I'll try to change the password

woven spoke
#

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?

dense slate
#

Do you mean forms.Form and ModelForm?

woven spoke
#

Yes

dense slate
#

modelForm is automatically created and interacts with models. (you edit/use these)

#

form.Forms is manual creation of forms for validation

opaque rivet
#

could someone guide me in the right direction for the technology I want to use?

I need to:

  1. Input specific text into a searchbox
  2. Be redirected to a specific url based on that input (I can't guess this url)
  3. 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?

native tide
#

Is CSS used in Django? I'm not into styling

dense slate
#

@native tide Yes.

native tide
#

Rip

dense slate
#

I mean, it's used in HTML.

#

Django serves HTML templates.

native tide
#

So it compiles Python code into HTML code?

dense slate
#

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.

native tide
#

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.

worn hatch
#

How can I get all posts created by user?
The database model:

latent cosmos
#

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

worn hatch
#

My try:

dense slate
#

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.

worn hatch
#

Not posts, I mean survey

#

Well, I l just post all serializers and views code

dense slate
#

But you already wrote a method to get answers. Why not just do the same thing for surveys?

worn hatch
worn hatch
#

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

dense slate
#

Can you clarify your questions? because you asked "How can I get all posts created by user? "

worn hatch
#

Yeah, this is exactly what I want. I need to get surveys, filled by exact user

#

Survey -> Questions -> Answers

dense slate
#

So what is posts?

worn hatch
#

Forget about posts(

#

there was a mistake

latent cosmos
#

@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
worn hatch
#

english mistake

worn hatch
#

sorry

#

But I suppose I will just get it as a query

#

But I need to implement it as a rest api

latent cosmos
#

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

dense slate
#

value = Submimt?

latent cosmos
#

does matter @dense slate value can be anythin

#

i hope link will generate without action in form?

worn hatch
#

It gives me this error

dense slate
#

@latent cosmos Can you put action=""?

latent cosmos
#

doesnt work

#

I want that values in URL

#

if I type aaa I wanna see ?aaa in link

dense slate
#

Would it take the value from the first input value? which appears to be missing

native tide
#

@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?

proven lily
#

@native tide custom help channel please haha

native tide
#

Aaaa lmao alright šŸ˜‚

proven lily
#

šŸ˜‚

dapper tusk
#

@native tideplease do not continue asking about this, it is against our rules

proven lily
#

Looks like you wanna bypass caorcha yea it is

#

Cpatcha holy

#

CAPTCHA

native tide
#

Sike 😩

proven lily
#

Yea first it's not really possible and second yea

#

Unless you have specifically trained AI good luck šŸ˜‚

native tide
#

šŸ˜‚

proven lily
#

Discord did that for a reason šŸ˜‰

#

Can't have people like you making a bunch of accounts that way šŸ˜‚

late gale
native tide
native tide
proven lily
#

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

native tide
#

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

proven lily
#

I-

#

Sounds a bit sterotypixal šŸ˜‚

native tide
proven lily
#

Lol

proven lily
#

I can create a script to. Do it itself

#

OH MY GOD so many pings šŸ˜”

proven lily
late gale
proven lily
#

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

late gale
#

idk it passed it so robots won

#

lmao

proven lily
#

šŸ˜‚

native tide
proven lily
#

I'm < all

late gale
#

hahaha

proven lily
#

There we go

native tide
#

HAHA

proven lily
#

šŸ˜‚

#

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

native tide
proven lily
#

Wdym

#

I don't like to put myself above others

native tide
native tide
simple sentinel
#

Hi, automating captcha's is very much against Terms of Service. We're going to stop discussing how to bypass them.

proven lily
native tide
#

True!

proven lily
#

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

proven lily
native tide
proven lily
#

Why's that haha

#

Never seen anyone honored to give a compliment

#

But that's very kind of you lol

late gale
#

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 ?

dense slate
#

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.

late gale
#

yea I prefer next anyways so integration doesnt affect anything right ?

dense slate
#

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.

late gale
#

what i meant is does it affect performance or any features of next like fast reloading , SEO , anything ?

plain zealot
#

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?

late gale
#

try to add something in js like console.log("BlahBlah")

#

on click

#

so u can see it on console

dense slate
#

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.

dense slate
#

If anything, Next/React improves performance of a DJango backend.

#

I use Next and it's lightning fast.

late gale
#

Yea same , I love it

dense slate
#

Especially with apollo client and utilizing cache.

#

Are you using REST or GQL?

late gale
#

Im beginner with it but I adore it

late gale
dense slate
#

Nice

late gale
#

Django REST