• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 23:14
CEST 05:14
KST 12:14
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Team Liquid Map Contest #22 - The Finalists12[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21
Community News
2026 GSL Season 1 Qualifiers11Maestros of the Game 2 announced32026 GSL Tour plans announced10Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid20
StarCraft 2
General
Adeleke University 2026/2027 Admission Form is Out Baze University 2026/2027 Admission Form is Out. C Weekly Cups (April 6-12): herO doubles, "Villains" prevail MaNa leaves Team Liquid Oliveira Would Have Returned If EWC Continued
Tourneys
2026 GSL Season 1 Qualifiers Sparkling Tuna Cup - Weekly Open Tournament Master Swan Open (Global Bronze-Master 2) SEL Doubles (SC Evo Bimonthly) $5,000 WardiTV TLMC tournament - Presented by Monster Energy
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
Pros React To: Tulbo in Ro.16 Group A ASL21 General Discussion BW General Discussion [BSL22] RO32 Group Stage mca64Launcher - New Version with StarCraft: Remast
Tourneys
[ASL21] Ro16 Group B Small VOD Thread 2.0 Korean KCM Race Survival 2026 Season 2 [BSL22] RO32 Group D - Sunday 21:00 CEST
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion Cricket [SPORT]
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Reappraising The Situation T…
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2326 users

The Big Programming Thread - Page 698

Forum Index > General Forum
Post a Reply
Prev 1 696 697 698 699 700 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 04 2016 14:42 GMT
#13941
Whenever you want to use a variable you must declare it in a strongly typed language. This means that if your variable is already in use when you try to declare it you should get a duplicate error. In weakly typed languages, because there's no declaration, you can override the variable without realizing it, which makes it more dangerous.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Ropid
Profile Joined March 2009
Germany3557 Posts
January 04 2016 16:43 GMT
#13942
That's doesn't feel like it's about the types, instead about how the particular language works? Like in the Lisps, the declaration and assignment are two different things. The interpreter/compiler could then use that to give you an error if you try to define a name twice, or give an error when you try to assign something to a name that wasn't defined yet. Or it could not care and make the assignment thingy create a new variable when an old one with the name doesn't exist, and could make a new variable definition overwrite the old one without error.
"My goal is to replace my soul with coffee and become immortal."
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-01-04 18:04:05
January 04 2016 17:28 GMT
#13943
Do any of you use django? I know a bunch of you are web developers. There is something in particular that should be easy that I am just not grasping, but if no one uses django I won't bother.

edit: It seems I will struggle for hours, then come here and make a post about it, and then instantly figure out my problem. Leaving this here though because I am still curious if anyone here uses django.
aksfjh
Profile Joined November 2010
United States4853 Posts
January 04 2016 19:25 GMT
#13944
Working on a problem:

I am tryinh to find a file or collection of files. I am given the fully qualified path as 2 different variables, a file and a path. Each may or may not be a regex pattern, but if it is, it is stated that it is. In looking for this file, I am only allowed to use literal characters (no wildcards, pattern matching, or regex) to query directory contents and file existence.

example sets (in xml):

<sets>
<filepath>
<path regex="false">/world/etc</path>
<file regex="false">settings.conf</file>
</filepath>
<filepath>
<path regex="true">^\/foo(\/bar)?\/(x86|x64)\w*$</path>
<file regex="false">alice.txt</file>
</filepath>
<filepath>
<path regex="false">/foo/bar/world</path>
<file regex="true">bob\..*</file>
</filepath>
<filepath>
<path regex="true">^\/world(\/var|\/opt)?\/(x86|x64)\w*\/.*$</path>
<file regex="true">(slice|segment)_txt\.[a-z]{2,4}</file>
</filepath>
</sets>


Doing the first 3 are easy. You look for the literal file, list out the directories those files are in, and collect all matches to the directory pattern for the results. You do the opposite for the directory, listing all the files in the literal directory and collect all matches to the file pattern for the results.

It's the last one that trips me up. The only solution I can think of is breaking the directory regex into as many explicit directories as possible and crawling through the remaining directories for regex matches to further directories and files, but it seems very, very inelegant (and difficult to implement).
Prillan
Profile Joined August 2011
Sweden350 Posts
January 04 2016 19:26 GMT
#13945
On January 04 2016 23:42 WarSame wrote:
Whenever you want to use a variable you must declare it in a strongly typed language. This means that if your variable is already in use when you try to declare it you should get a duplicate error. In weakly typed languages, because there's no declaration, you can override the variable without realizing it, which makes it more dangerous.

It doesn't have anything to do with "weak" or "strong" types.

Is python a strongly typed language?
x = 1
def f():
print(x)

def g():
print(x)
x = 2

>>> f()
1
>>> g()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in f
UnboundLocalError: local variable 'x' referenced before assignment


Is Haskell a weakly typed language?
f x = let x = 2 in x

> f 1
2
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 04 2016 20:21 GMT
#13946
You're correct. Was the term I'm looking for "Explicitly declared"?
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Manit0u
Profile Blog Joined August 2004
Poland17724 Posts
Last Edited: 2016-01-04 20:48:16
January 04 2016 20:47 GMT
#13947
On January 05 2016 02:28 travis wrote:
Do any of you use django? I know a bunch of you are web developers. There is something in particular that should be easy that I am just not grasping, but if no one uses django I won't bother.

edit: It seems I will struggle for hours, then come here and make a post about it, and then instantly figure out my problem. Leaving this here though because I am still curious if anyone here uses django.


I'm not using Django but I have some vague knowledge about it.

Is your problem Django-specific or webdev-specific? (or something else entirely)
Time is precious. Waste it wisely.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
January 04 2016 21:06 GMT
#13948
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-01-04 21:51:44
January 04 2016 21:50 GMT
#13949
I am just learning it and it's honestly just so confusing to wrap my head around.

Is this understanding correct

templates - your html files or whatever, but can contain variables/django code to be loaded into the browser
views - the actual code that is ran
forms - html forms to be used/reused?
models - (this is the confusing part to me... it's how you save/load data from the database??? but are they also forms??)

I've got it running, created a template that loads a form which is a textarea and a submit button. then my view takes the cleaned_data, which I seem to be able to print out - but I don't understand how to save this to my database. I understand that model forms have a .save() method but what if I don't want to use a model form? I want to use my own creation.

So I don't understand how to take that data and save it to a model. I actually don't even really understand what a model form is - is it just a pre-created form that has a model to go with it already?

So in short, how do I use my form/model to save my information to the database? All I want to do is save a string to my database.
Manit0u
Profile Blog Joined August 2004
Poland17724 Posts
Last Edited: 2016-01-04 22:17:05
January 04 2016 22:11 GMT
#13950
Model is the code representation of your database (simplifying it a bit here but in the beginning that's all you need to know). So, if for example you have a "messages" table with fields like "id", "message", "created_at", "updated_at" your model will look more or less like that:


from django.db import models

class Message(models.Model)
message = charField(max_length=255)
created_at = dateTimeField(auto_now_add=True)
updated_at = dateTimeField(auto_now=True)


Now, this model will automatically create the database table for you in the database when you migrate (or however else you set schema in Django, I don't remember).

On to the forms!


from django.forms import ModelForm
from myapp.models import Message

class MessageForm(ModelForm)
class Meta:
model = Message
exclude = [ 'created_at', 'updated_at' ]


Now, you can render this form by passing it to the view:


form = MessageForm()


If you want to edit the message instead of creating a new one:


message = Message.objects.get(pk=1)
form = MessageForm(instance=message)


Tada! You have just generated a form with text which was saved to the database previously. Also, whenever you first create a message it gets timestamped, the same's true for each edit.

So, in short:

Your model maps the database. You can build forms based on your model and those forms are submitted to the database. For edition you fetch data from the database (via model) and feed it into the form being generated so that respective fields are auto-filled with data from the database.

There you have it all, better explained too: https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/

You really need to read up on MVC architecture...
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 04 2016 22:39 GMT
#13951
okay, I had a link to that documentation but I lost it lol, thank you. I keep looking at less useful/outdated resources.

I think part of what confuses me with django is just that there is so much stuff... and there seems to be a million ways to do what ends up essentially being the same thing.

So if I want to make a form that is based on a model then I need to make it as a ModelForm and describe what it does with the meta class. But there is a meta class for both the models and for the model form?

Also I noticed examples with more than one model. I find that kind of strange. When you migrate in django is that essentially django "reorganizing" your database file to work with your models? (I am completely guessing here, how databases work is a mystery to me)


Anyways, I will read up now, I promise
Manit0u
Profile Blog Joined August 2004
Poland17724 Posts
Last Edited: 2016-01-05 00:03:11
January 04 2016 23:55 GMT
#13952
Required reading before you ask any more questions:

http://www.sitepoint.com/web-site-basics-beginners/

https://developer.mozilla.org/en-US/docs/Web/Guide/Introduction_to_Web_development

http://coding-geek.com/how-databases-work/

http://code.tutsplus.com/tutorials/mvc-for-noobs--net-10488

https://developer.chrome.com/apps/app_frameworks (it's about JS but general concepts stay the same)

Edit:
Also, if you really want to learn Django properly, please get this book: http://shop.oreilly.com/product/0636920029533.do

It's amazing.

Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 05 2016 04:00 GMT
#13953
manitou i know you said no new questions yet (i bought the book btw lol)

but I just wanted to get your example working and actually save something to a database

django was giving me some problems, i deleted my migrations folder, i did make migrations over again, and then did migrate
things seemed to go fine

my page loads
but then when I try to use my form and submit the information to be saved into the database I get:

"OperationalError at /home/
no such table: projectApp_message"

to try to put it into the database I am using form.save()
Manit0u
Profile Blog Joined August 2004
Poland17724 Posts
Last Edited: 2016-01-05 05:20:31
January 05 2016 05:17 GMT
#13954
Are you using MySQL or SQLite database? (My bet would be SQLite since that's Django default)

Have you read this yet? https://docs.djangoproject.com/en/1.9/intro/tutorial02/

Also, I haven't done a lot in Django yet so I'm not really that proficient at identifying problems at a glance and knowing the solutions to them. From your error it seems that for some reason migrate didn't create appropriate tables in your database. The only way to know for sure would be checking your database to see if everything is there and it's named correctly (for sqlite you could use something like that: http://sqlitebrowser.org/).
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-01-05 05:50:54
January 05 2016 05:33 GMT
#13955
Ah, alright. yeah I am using sqlite, and I did read through that.

I was hoping the problem would be some obvious step I missed, but I am suspecting that isn't the case and there is something else going on. So it's okay, I am going to choose not to worry about it. Going to finish dive into python and then I am starting that test driven development book. I glanced at it and it looks pretty fun.

edit: just out of curiosity I did look at my database.. it had old tables in it. I deleted it, and made a new database file. Then it worked. So, while I don't understand why I had to remake it, it worked. so yay !
Manit0u
Profile Blog Joined August 2004
Poland17724 Posts
January 05 2016 06:13 GMT
#13956
Probably because you've deleted your migrations files. Django didn't know how your db looked like before so it couldn't update it with recent changes.
Time is precious. Waste it wisely.
Manit0u
Profile Blog Joined August 2004
Poland17724 Posts
January 05 2016 18:24 GMT
#13957

$response = json_decode(json_encode($this->curl->response), true);


Why?! T_T
Time is precious. Waste it wisely.
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
January 05 2016 18:30 GMT
#13958
That is pretty hilarious
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
January 05 2016 20:19 GMT
#13959
On January 06 2016 03:24 Manit0u wrote:

$response = json_decode(json_encode($this->curl->response), true);


Why?! T_T


It's actually not too uncommon. It's a quick way to turn an object tree into an array. It's not exceptionally fast and it really should be in some properly named function somewhere, but the code in itself isn't bad.
aksfjh
Profile Joined November 2010
United States4853 Posts
January 06 2016 01:29 GMT
#13960
On January 06 2016 05:19 Morfildur wrote:
Show nested quote +
On January 06 2016 03:24 Manit0u wrote:

$response = json_decode(json_encode($this->curl->response), true);


Why?! T_T


It's actually not too uncommon. It's a quick way to turn an object tree into an array. It's not exceptionally fast and it really should be in some properly named function somewhere, but the code in itself isn't bad.

Depends on your definition of "bad." It works, but I know some devs that would skewer you for that.
Prev 1 696 697 698 699 700 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
uThermal 2v2 Circuit S2 Mar
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 184
ProTech140
ROOTCatZ 73
StarCraft: Brood War
GuemChi 6265
NaDa 45
SilentControl 19
ivOry 13
Dota 2
NeuroSwarm107
Super Smash Bros
hungrybox491
Other Games
summit1g13178
tarik_tv3770
C9.Mang0587
JimRising 472
Artosis401
ViBE150
Trikslyr144
Maynarde122
Livibee38
kaitlyn36
Organizations
Other Games
BasetradeTV299
Counter-Strike
PGL80
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Berry_CruncH242
• EnkiAlexander 35
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt330
Upcoming Events
Escore
6h 46m
WardiTV Map Contest Tou…
7h 46m
OSC
11h 46m
Big Brain Bouts
12h 46m
MaNa vs goblin
Scarlett vs Spirit
Serral vs herO
Korean StarCraft League
23h 46m
CranKy Ducklings
1d 6h
WardiTV Map Contest Tou…
1d 7h
IPSL
1d 12h
WolFix vs nOmaD
dxtr13 vs Razz
BSL
1d 15h
UltrA vs KwarK
Gosudark vs cavapoo
dxtr13 vs HBO
Doodle vs Razz
CranKy Ducklings
1d 20h
[ Show More ]
Sparkling Tuna Cup
2 days
WardiTV Map Contest Tou…
2 days
Ladder Legends
2 days
BSL
2 days
StRyKeR vs rasowy
Artosis vs Aether
JDConan vs OyAji
Hawk vs izu
IPSL
2 days
JDConan vs TBD
Aegong vs rasowy
Replay Cast
3 days
Wardi Open
3 days
Afreeca Starleague
3 days
Bisu vs Ample
Jaedong vs Flash
Monday Night Weeklies
3 days
RSL Revival
3 days
Afreeca Starleague
4 days
Barracks vs Leta
Royal vs Light
WardiTV Map Contest Tou…
4 days
RSL Revival
5 days
Replay Cast
5 days
The PondCast
6 days
WardiTV Map Contest Tou…
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-04-15
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Escore Tournament S2: W3
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W4
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.