- git workflow
- Django docs
- groupr on the web (if this is ever down when you check it, please let me know)
- Install Python 3 (if you haven't already)! Python 2 won't work with this project.
- Install Django!
- Install MySQL if your machine doesn't already have it!
- Install MySQLClient! (This is a Python 3-compatible python interface that Django will use to mess with the database)
- Clone the repo to your machine!
cd
into the Groupr/groupr directory (the one that containsdb.sql
andmanage.py
)- To build the database on your machine
- start up
mysql
by callingmysql -u root
in the terminal and enter password if necessary - run the command
source build_db.sql;
, which if successful will display all of the tables in the db - use the commany
quit;
to leave themysql
shell
- start up
- If you ever change the database schema
- run the command
mysqldump -u root grouprsp_cs411 > db.sql
- commit changes to the repo
- give everyone a quick heads up
- run the command
- To update database with the new schema once it has been pushed and merged into master
- make sure you're in the same directory as
db.sql
- start up
mysql
again - run the following commands:
use grouprsp_cs411;
source db.sql;
quit;
when you're done
- make sure you're in the same directory as
- To run the server:
- make sure you're in the same directory as
manage.py
- run the command
python3 manage.py
- the webpage should be served at http://127.0.0.1:8000/groupr/ If anything goes at all wrong or any errors get thrown with any of these steps, let me know and I'll work with you to get you set up 👍
- make sure you're in the same directory as
There's a little bit of weird stuff involved in this so I'm more that willing to update the version on the web as soon as I can after you guys let me know that you've pushed a change into master. If that becomes cumbersome or if you guys want to do it yourselves, I'd be more than willing to write it up real fast. Either way is totally alright with me, just let me know if any of you want to deploy on the website.
Everything important is in Groupr/groupr/groupr_app
forms.py
is where all the form-generating classes live. See the Django Form docs for more info (overview is here and the api is here)models.py
has nothing in it because we're working with raw SQL commands. Please ignore this file.queries.py
currently builds and executes basic SQL commands, and should ideally expand to handle all the queries we'd need. Currently, it has:TABLE_FIELDS
- a dictionary representing the attributes on each table in the databaseinsert(table, values)
which takes dictionary ofattribute: value
pairs asvalues
and inserts them into the table represented by the stringtable
- currently does not check if an item is already in the database which is probably why we were getting some of the errors that we were getting in the demo
update(table, fields, conditions)
which takes a dictionary ofattribute: value
pairs asfields
, a stringconditions
representing what comes after theWHERE
in theUPDATE SET WHERE
command, and a stringtable
representing the Table in which the update will occur- if
conditions
is an empty string(''
), then theWHERE
clause is dropped
- if
delete(table, conditions)
which takes a stringtable
representing what table, andconditions
, again a string that will constitute theWHERE
clause- if
conditions
is an empty string(''
), then theWHERE
clause is dropped
- if
select(tables, fields, conditions)
which takes a list of strings representing the tables to put in theFROM
clause astables
, a list of attributes for theSELECT
clause asfields
, andconditions
, again a string that will constitute theWHERE
clause- if
fields
is an empty list ([]
), then theSELECT
clause becomesSELECT *
- if
conditions
is an empty string(''
), then theWHERE
clause is dropped
- if
tests.py
which has some currently broken tests that test query building stuff right now.- if you want to write any tests (you don't have to if you don't want to) check out Django's testing docs
urls.py
contains the project's url patternsviews.py
contains the project's views & class-based views- KNOWN ISSUES
- I should change these so that we're only using one type of view
insert_student
andupdate_student
are SUPER gross looking and long and need to be made way more modular than they are 😩 You can ignore all the other files in this directory.
- KNOWN ISSUES
templates/groupr_app
contains all the templates you're going to need- templates on Django
- form template stuff starts here and continues to the bottom of the page
static/groupr_app/
is where you should store your static files including your css- to include a css file in a template, put this at the top of the template, replacing
style.css
as needed:{% load staticfiles %} <link rel="stylesheet" type="text/css" href="{% static 'groupr_app/style.css' %}" />
static/groupr_app/images/
is where images should be if you need 'em- to include images in templates, be sure to
{% load staticfiles %}
at the top of the file and just set<img src="{% static "groupr_app/images/example.jpg" %}>"
where you need them - to include images in static files like css templates,
url("images/example.jpg")
will work great
- to include images in templates, be sure to
- to include a css file in a template, put this at the top of the template, replacing
If something that I've said above is unclear or something in the code is at all confusing (I'm 99% sure something will be) or something just doesn't work, PLEASE let me know via Facebook and I'll take care of it/explain it as soon as possible.