|
The March Hare posted:Erghhh, can you paste the response from echo $PATH because I have no idea what is going on. code:
http://pastebin.com/DkWrGNuw
|
# ? Oct 19, 2013 03:25 |
|
|
# ? May 15, 2024 03:57 |
|
Pollyanna posted:
Ah, you used macports. FWIW you should use homebrew instead. I have no idea what you did specifically but if you try removing the /Library/Frameworks/Python.framework/Versions/2.7/bin line from your $PATH variable, you should revert to using the osx system-wide installation which shouldn't be broken, unless you did something really really awful. Also, remove the line in your .bash_profile that adds that directory to the path, or it will keep adding it every time you reboot/restart terminal. The March Hare fucked around with this message at 03:44 on Oct 19, 2013 |
# ? Oct 19, 2013 03:40 |
|
Thankfully, I haven't done anything really really awful (yet). I gave up and reinstalled 2.7.5 using the .mkpg. Now it works! And all my installed modules are still around. I still don't know what happened or why, but I think I'm gonna avoid using virtualenv for now. Thanks for the help. When you mentioned stuff about paths I started thinking "maybe the installation I'm using got hosed", rooted around in the system files and that helped me figure it out. So I'm also probably going to uninstall MacPorts, since I don't even remember what it was for.
|
# ? Oct 19, 2013 03:47 |
|
Pollyanna posted:Thankfully, I haven't done anything really really awful (yet). Macports is a package manager, it helps you install things like git easily. But it is a bit worse than homebrew in my (and most people's) opinions, so you should use homebrew. You should also not give up on virtualenv as it is one of the most important habits to get into early, as it prevents you from really spectacularly loving things up and generally makes it much easier to work going into the future. You won't see much tangible benefit in this moment, but you will down the line. It is worth spending however long reading and rereading virtualenv documentation/tutorials or whatever to understand it.
|
# ? Oct 19, 2013 03:52 |
|
Hey dudes, thanks for the help with Getting Started With Django. I took your try it on Ubuntu and skip Vagrant advice; it's working, and I'm learning. One of the reasons it was so confusing, is that initially it's not so much a Django tutorial as a complex web development tutorial. GSWD introduces several big concepts together, and for someone new, the distinctions aren't obvious: -Virtualization -Heroku / web-app servers -Unix command line -Postgresql and databases -Django/Python -Git and versioning After understanding this breakdown and looking up basic tutorials for each, it's starting to click. Dominoes fucked around with this message at 22:11 on Oct 20, 2013 |
# ? Oct 20, 2013 22:08 |
|
Pollyanna posted:Thankfully, I haven't done anything really really awful (yet). Did you try exiting your terminal and reopening it? Serious question, the venv should have been tied to your terminal and shouldn't exist in a new terminal instance, despite the missing environment folder. Also, definitely grab a developer next time you start a project and have them walk you through venv, because it's incredibly easy to use and a lot of devs can't imagine developing without it. It'll be like three minutes of their time, and if they're not a lovely person, they'll be happy to show you how friggin awesome it makes starting new projects or dealing with more than one project. Mainly because having a clean environment lets you play with a ton of really well developed toys without fear of breaking anything you can't easily remove from your system. fletcher posted:If I leave a field blank, I get a nice little This field is required. error message. If I put whitespace in there, it gets around the standard validation and does not throw that same error message. Edit: I also confused model validation with form validation. The post below me explains it in better detail \/\/ Pythagoras a trois fucked around with this message at 19:24 on Oct 21, 2013 |
# ? Oct 21, 2013 15:06 |
|
fletcher posted:If I leave a field blank, I get a nice little This field is required. error message. If I put whitespace in there, it gets around the standard validation and does not throw that same error message. The check for required fields being empty is done by the individual form fields. Form field cleaning is the first step of form cleaning, which happens before model cleaning, so by the time you're stripping the whitespace off, the check has already happened and succeeded. You could simply check after you've stripped the field, and raise a ValidationError if it's blank, but I think the expected way to do something like this is with validators. You would write a function that raises ValidationError with the "required" message if it's given a string of only whitespace, and then pass it to the field constructor for awesome_field.
|
# ? Oct 21, 2013 17:07 |
Pumpkin Pirate posted:The check for required fields being empty is done by the individual form fields. Form field cleaning is the first step of form cleaning, which happens before model cleaning, so by the time you're stripping the whitespace off, the check has already happened and succeeded. Thanks for the input guys. I suppose I'll go with the validator. It really seems like this should be the default behavior in Django though. I mean who would actually want to store whitespace as a value for a required field? Also, is there some convention for where the code for custom validators should live?
|
|
# ? Oct 21, 2013 19:35 |
|
fletcher posted:Thanks for the input guys. I suppose I'll go with the validator. It really seems like this should be the default behavior in Django though. I mean who would actually want to store whitespace as a value for a required field? Now the answer I was trying to give is correct! The long answer is to read through this surprisingly well documented aspect of django: https://docs.djangoproject.com/en/dev/ref/forms/validation/ The short answer is to modify your forms (preferably for this sort of thing you'd be using modelforms) and copy/paste/adjust to taste: code:
|
# ? Oct 21, 2013 21:19 |
Hmmm I'm not actually using any ModelForms, since all my froms post to Django REST Framework endpoints. That's why I was trying to do it at the model level.
|
|
# ? Oct 21, 2013 21:37 |
|
This just popped up on HN, I skimmed it and it looks like a pretty good resource for newcomers. http://www.tangowithdjango.com/book/
|
# ? Oct 22, 2013 14:16 |
|
The March Hare posted:This just popped up on HN, I skimmed it and it looks like a pretty good resource for newcomers.
|
# ? Oct 22, 2013 15:21 |
|
I almost posted this in the general programming thread, but I think I'll ask here first... People will be able to get API keys from the web site I'm working on so that I can monitor/throttle/revoke the REST API usage. I'm also wanting to use the API in my AngularJS frontend. The issue is that anyone with half a brain can get the key I use for the frontend from the page source. My current thoughts on making this harder for them is figuring out how to use REST Framework to assign temporary API keys to each site visitor using Django's anonymous user sessions (or the user session if it's a logged-in user). That way, someone can't just rip the API key out of the page source and go on their merry way. Useful idea or just wasting my time? Any other thoughts?
|
# ? Oct 22, 2013 21:14 |
|
Cheekio posted:Did you try exiting your terminal and reopening it? Serious question, the venv should have been tied to your terminal and shouldn't exist in a new terminal instance, despite the missing environment folder. Yep, I did. I closed the Terminal window, exited Terminal entirely, checked my PYTHONPATH, none of it worked. Bizarre, but that's what happened. And yeah, I'll try out venv again, but this time I'll read the documentation first...
|
# ? Oct 22, 2013 21:42 |
|
Thermopyle posted:I almost posted this in the general programming thread, but I think I'll ask here first... Tie the API keys to a domain? They might get yours, but it only works coming from your domain (I know that's not super-secure, but giving each user a temporary API key is probably gonna drive you nuts).
|
# ? Oct 22, 2013 21:57 |
|
MonkeyMaker posted:Tie the API keys to a domain? They might get yours, but it only works coming from your domain (I know that's not super-secure, but giving each user a temporary API key is probably gonna drive you nuts). That's actually a pretty good idea. None of this is really super-secure, but it seems like it's worth putting at least some effort in to it. If I start getting a big enough mismatch between site visits and API hits, I can always move on to figuring out how to do temporary API keys or something.
|
# ? Oct 22, 2013 22:32 |
|
I implemented simple domain checking for token users. You can see the code here. Specify a list of usernames who should be validated against domain names in settings.FRONTEND_USERS and a list of valid domains in settings.FRONTEND_DOMAINS. Use DomainAndTokenAuthentication in place of TokenAuthentication in your Django Rest Framework configuration.
|
# ? Oct 23, 2013 22:01 |
|
Thermopyle posted:I implemented simple domain checking for token users. You can see the code here. So you'll have to change your settings and restart your Python process every time you modify the list of approved users or domains...
|
# ? Oct 23, 2013 22:38 |
|
MonkeyMaker posted:So you'll have to change your settings and restart your Python process every time you modify the list of approved users or domains... Yeah, I'm not concerned about that as I don't foresee that being something that happens more than once or twice. Domain checking isn't something that will be done for regular not-my-web-client API users.
|
# ? Oct 23, 2013 22:55 |
|
The March Hare posted:This just popped up on HN, I skimmed it and it looks like a pretty good resource for newcomers.
|
# ? Oct 24, 2013 12:22 |
|
Dominoes posted:I'm working through this ATM - it's excellent. Detailed, acts as a tutorial while explaining everything, organized structure. Glad to hear that it is actually helpful. How would the thread feel about collaborating on a new OP? The web design & development thread recently spent a while hacking out a new one on a google doc, and the current Django thread OP is pretty out of date. Plus there have been many excellent resources cropping up in the past few months, so I feel we could improve upon it quite a bit.
|
# ? Oct 24, 2013 14:52 |
|
The March Hare posted:Glad to hear that it is actually helpful. How would the thread feel about collaborating on a new OP? The web design & development thread recently spent a while hacking out a new one on a google doc, and the current Django thread OP is pretty out of date. Plus there have been many excellent resources cropping up in the past few months, so I feel we could improve upon it quite a bit. This sounds like a good idea. The web thread ended up with a pretty good OP.
|
# ? Oct 24, 2013 16:39 |
|
A new OP would be great - I remember getting confused by that tutorial a while back (I think it's outdated now?). I'd help if I could but I don't really know anything about Django. I've got a new pet project - it's a proofreading site where students will fill in a form, upload an essay, and then login to keep track of its status. I'm ok with front-end website design, and I've been managing my own VPS for a while, but so far the bit in the middle (basically anything involving databases) has been locked in a box called "WordPress". I spent some time with Django a while ago, but I've forgotten most of it. I think I used GSWD, but I didn't really have a specific project in mind so I never got beyond "make a blog". With that in mind I am trying to decide between: GSWD http://www.tangowithdjango.com/book/ (based on Dominoes' endorsement above) "Test-driven web development with Python" (posted a few pages ago - does anyone have an opinion?) It's the "test-driven" stuff that is giving me pause. How big a deal is it really? Is it a case of "harder to learn but better in the long run"? Is it worth learning that way right from the beginning? I wanna do things right but I also don't wanna go overboard for my first project. Opinions welcome.
|
# ? Oct 24, 2013 17:48 |
|
A little help / advice is needed here. I am getting back into web development since before the days of nice frameworks and decided to learn Python and use Django to get my web app going. My app has quite a few e-commerce features, but the cart/ordering/shipping/tracking aspect of my app is maybe 20% of the code, the rest is based on custom business logic. My question is this: I've done some research on Django packages like Oscar, Satchmo, Django-shop etc. heavyweight to lightweight packages. But since I have quite a bit of design that goes beyond simple cart/ordering logic: Does it make sense to learn how to integrate a new package into my design vs. roll my own? I’ve done shopping cart/etc before, but I would like to shave time off the development if I can. But I am still learning all the ins and outs of Django, the ORM etc. I don’t want to spend 2 weeks learning how to integrate a Django package when I could just spend 2 weeks rolling my own. But maybe I’m mistaking how much work it will take to roll my own cart/ordering/tracking logic. I have done it before in Java/jsp completely by hand, it was somewhat onerous but I am now running with the assumption that Django will allievate some of the pain I used to go through with all the BS CRUDS, home-made MVC logic I had to do back in 2001. Thanks!
|
# ? Oct 24, 2013 18:08 |
|
fuf posted:
Welcome to dissent on this one but my feeling on TDD is this. Its an excellent tool of you already have a firm idea of what you'll be testing. If you don't know how to build it, which beginners don't, you'll stumble trying figure out what your API is for testing. Figuring out requirements when your not 100% on how to get to them or test them. I think instead try to write tests as you go so you're sure you're writing testable code, and then see whether you can start to predict what the tests will be before you build them. That said, once you do get used to it, it is an EXCELLENT way to add features, as you can verify during every step of your coding not only the new feature but also that you didn't break any old features assuming good test coverage, which is kind of key.
|
# ? Oct 24, 2013 21:37 |
|
Maluco Marinero posted:Welcome to dissent on this one but my feeling on TDD is this. Its an excellent tool of you already have a firm idea of what you'll be testing. If you don't know how to build it, which beginners don't, you'll stumble trying figure out what your API is for testing. Figuring out requirements when your not 100% on how to get to them or test them. Yeah, this is all good advice. I think that if you keep testing in mind while your beginning on a project, at some point in large enough projects it becomes natural to write tests in tandem with the actual code. And then even further into the project as things start fleshing out it almost becomes natural to write the tests before you implement the code. edit: Here's another site on doing TDD with Django: http://www.tdd-django-tutorial.com/
|
# ? Oct 24, 2013 23:15 |
|
We just talked about TDD on today's recording of the podcast. The general consensus was that TDD is a lot easier on existing code bases, where you know how things are generally going to look, than it is on brand new code where you're kind of making it up as you go along. Also that it's a skill that requires practice, so if you think you want to do it, be prepared to be slow and grumpy until you get good at doing it.
|
# ? Oct 25, 2013 00:27 |
|
Thermopyle posted:
FYI, that site is / was the precursor to the 'Test Driven Web Development with Python' site / book a few poss up.
|
# ? Oct 25, 2013 05:02 |
|
So what's the deal with deploying Django? That link is a couple years old, so have things gotten any better? What's my best bet for deploying it if I'm just trying to see my work finally get on the web? I have deployed Django on Heroku before (with some significant pains), is that my best bet?
|
# ? Oct 25, 2013 15:34 |
|
Pollyanna posted:So what's the deal with deploying Django? That link is a couple years old, so have things gotten any better? What's my best bet for deploying it if I'm just trying to see my work finally get on the web? I have deployed Django on Heroku before (with some significant pains), is that my best bet? For something simple? Install gunicorn and run your django site via the wsgi file that was generated when you started your project. Then proxy the address it's running on through nginx or apache or whatever. I'm about to head into work so I can't post specifics but googling around for those terms should get you going pretty easy.
|
# ? Oct 25, 2013 15:44 |
|
Lumpy posted:FYI, that site is / was the precursor to the 'Test Driven Web Development with Python' site / book a few poss up. Forgive me, I'm a moron. Pollyanna posted:So what's the deal with deploying Django? That link is a couple years old, so have things gotten any better? What's my best bet for deploying it if I'm just trying to see my work finally get on the web? I have deployed Django on Heroku before (with some significant pains), is that my best bet? Deploying on Heroku is super, super, super easy. Try asking about whatever issues you are having with that. At what point in the Heroku/Django docs did you get messed up? The only way I can see someone having issues is if they weren't already using best-practices tools like virtualenv, pip, and git. If you're not using those your issues go beyond deployment.
|
# ? Oct 25, 2013 16:53 |
|
Thermopyle posted:Forgive me, I'm a moron. I am using venv, pip and git. Here's where I get stuck. quote:
I followed those instructions, did the rest, and then when I input "heroku open", well... This happens. code:
If it helps, here's my database settings: Python code:
|
# ? Oct 25, 2013 17:07 |
|
So you won't have settings like that for Heroku. Use dj-database-url.
|
# ? Oct 25, 2013 17:10 |
|
code:
You can poke around your database with heroku pg:psql, and \d in psql will show you your tables An example of a database with a table to compare against yours: code:
|
# ? Oct 25, 2013 17:17 |
|
Pollyanna posted:stuff You say you get messed up on the settings part of the heroku instructions, but then say when you enter 'heroku open' it messes up. Have you done the steps in between those two things? Obviously, you've pushed to heroku at some point, but have you made changes to your code and then not pushed them to heroku? Also, it looks like you missed the step where you run heroku run python manage.py syncdb.
|
# ? Oct 25, 2013 17:18 |
|
Okay, so...MonkeyMaker posted:So you won't have settings like that for Heroku. Use dj-database-url. Right, yeah. What basically happens is that the information in the stuff Heroku wants me to paste in settings.py overwrites the settings I had already made, which is clunky but works fine. That's where dj_database_url comes in, and it's what Heroku uses to refer to a database on their end. Thermopyle posted:You say you get messed up on the settings part of the heroku instructions, but then say when you enter 'heroku open' it messes up. Well, I did go check out my web page right after it asks me to "heroku open", so maybe I jumped the gun? The steps in between are creating and pushing a git. If I hadn't done that, it wouldn't be on the server at all. (Right?) Okay, I disabled the Heroku settings, committed and pushed, re-enabled them, committed and pushed, so that's the changes to the code thing down. Everything should be synced up on git. Next is syncing the DB...which works. Let's see what tables are there. Pardot posted:You can poke around your database with heroku pg:psql, and \d in psql will show you your tables Alright, here's what I get when I run heroku pg:psql \d: code:
http://retrocombine.herokuapp.com/stem/ YAY IT'S UP- Oh. Okay, the database didn't actually migrate. The entries and stuff I had are gone! If I add new ones again... http://retrocombine.herokuapp.com/stem/ Okay, it's up! Looks like it's working now. I guess the database was the issue, and I was getting errors because the tables were empty. The only problem I have is that none of my local stuff transferred over. That's fixable with stuff like blog posts, but more complicated things might not be so easy to restore. Why didn't my local database come over? edit: Oh, also, I can't test locally or anything. It gives me a database error. I thought you could work both online and offline? Pollyanna fucked around with this message at 18:26 on Oct 25, 2013 |
# ? Oct 25, 2013 18:20 |
|
Your data didn't migrate because you didn't do anything that would make that happen. You transferred over the structure of your database, which is found (loosely) in your models.py, but you didn't actually move data over. e; You can google around for ways to move the data inside of your local app to a remote deployment, there are a bunch of ways to do it and how you go about it will depend on a few factors, like if you used postgresql in your local testing &c. The March Hare fucked around with this message at 18:31 on Oct 25, 2013 |
# ? Oct 25, 2013 18:29 |
|
And the reason the Heroku instructions don't say anything about transferring local data to the remote server is that you're not really supposed to be putting anything you want in production on you dev database.
|
# ? Oct 25, 2013 18:38 |
|
Thermopyle posted:This sounds like a good idea. The web thread ended up with a pretty good OP. OK, took some initiative to write part of this out. I'm not a Django pro (faaar from it) but I think I'm decent enough at making posts & I want/need feedback and additional info for this thing so here goes~. https://docs.google.com/document/d/1jNYFVwEwAPBkk7X1calp28hZv5nlPEqQwPWUafmNcTw/edit?usp=sharing Please correct me if I'm wrong and leave feedback on what to expand on in this thing. The organization is not set in stone, this is meant to be a really communal effort so if some of the more experienced Django devs in here can do some effortposting to flesh this thing out, that would be great. Additionally, if you know of any good learning resources, or you are learning right now and you have feedback about any of the beginner links or anything, that advice is welcome and very helpful as well. The doc is open for in-doc discussions via comments, but I'm going to do the editing just as a measure of moderation to keep this thing from getting out of hand. I think we should be OK to discuss changes in-thread too, but if it gets lengthy I have plat and can be contacted at marchharesa@gmail.com too.
|
# ? Oct 25, 2013 20:53 |
|
|
# ? May 15, 2024 03:57 |
Anybody using AngularJS with your Django application? How's that working out?
|
|
# ? Oct 28, 2013 23:48 |