it is my first time at deploying django code, I need some elaboration, on the part with the secret key. Where should I put the code that reads the text file?
[coda] has quit
madboxs joined the channel
orf_
sorry littlebit, I don't understand your question. You usually put your secret key inside your `settings.py` file
`SECRET_KEY = 'something'`
ironfroggy joined the channel
that goes inside your django application directory, alongside the `wsgi.py` file by default.
it's annoying because I often find myself re-writing the same nginx config file
littlebit
ok
orf_
having to search for the same resources, the only thing that changes is the hostname usually. Check out that `nginx-generator` repo
littlebit
orf_: again thank you for the links
pupil joined the channel
pupil has quit
bbear
hey, django really kicks ass
ModelForms kicks ass as well
I have some questions though about organizing your code
Basically, you can organize your views as you want it, that is to say you could create a folder views/ and put modules into it if your code grows larger, isn't it ?
roomcayz has quit
pupil joined the channel
Donitzo joined the channel
kanja has quit
doismellburning
this is correct and not uncommon
Troy1 joined the channel
space-wizard joined the channel
madboxs joined the channel
littlebit
orf_: one more question, according to your first link I can install gunicorn via pip. Is there a difference if I install it via apt-get install ?
orf_
yes, it will be outdated
and wont work inside a virtualenv (which you should be using)
but either way works I guess
littlebit
orf_:
orf_: ok
Donitzo has quit
KedroBoss joined the channel
kanja joined the channel
Donitzo joined the channel
bbear
why is it advised to yuse a virtual env to run django app ?
doismellburning
bbear: OS package ecosystems / packagers tend to have different use-cases/targets than software developers
bbear: so "the version of django that ships with your system" is probably one picked and supported by your OS
for all Django things that come with your OS
bbear: this will probably be different to "the version of Django you want to develop software against"
bbear: so you use a virtualenv to set up a "local environment" and you fetch whatever version you like as a python package with pip from PyPI
bbear
that's amazing it took me only 2 days to have a running blog (though very rudimentary) with django.
I plan to use debian jessie to run my code. Any advice on how to regularly update that thing using a git hook ?
hpanago has quit
doismellburning
bbear: "update" in what sense?
zamro joined the channel
MattHardcastle joined the channel
eperzhand has quit
skali joined the channel
bbear
I just git push and the deployed code is update on the fly.
well actually it's a bad idea
OR is it ?
admin sys stuff use to give me headaches.
zamro has quit
Donitzo has quit
doismellburning
bbear: so
KedroBoss has quit
bbear: I need to head shortly, and I'm conscious of "here's some advice, bye" as well as "here's a suggestion to fundamentally rethink what you're doing, bye" *but* consider using someone else's PaaS rather than building your own?
(e.g. Heroku)
skali has quit
bbear
yes
I considered
don't worry
thanks
doismellburning
ok, then git as a deployment method isn't great, but it's not a bad idea in-and-of itself
personally I'd use GitHub post-receive hooks to hit something that does a git-pull, YMMV
littlebit
orf_: I copied my django-cms envivroment along with all django-cms files to my test server, starting my virtenv didn't work so I removed the env folder and recreated the virtualenv and did a pip install -r requirements.txt and I got this: http://dpaste.com/1G5EXN3
ironfroggy has quit
doismellburning
yeah, virtualenvs aren't portable (without faff)
littlebit
'faff'??
doismellburning
well
sorry, let me rephrase
ironfroggy joined the channel
virtualenvs aren't portable, except in certain cases, and even then it's tedious
littlebit
doismellburning: ok, how would you do this?
ironfroggy joined the channel
or how is this done?
b0nn
I've got something weird happening. I have from django.views import View but my editor (Eclipse) is saying that VIews is an Unresolved Import. I've restarted Eclipse a couple of times, but it's still failing (and the fail is stopping the build) any ideas?
cybo_
you wouldn't. they're supposed to be recreatable
doismellburning
littlebit: so there's "how I'd do it in a personal setup where I needed to solve this problem immediately" (I'd rebuild the virtualenv on deploy, which is icky)
littlebit: there's "how I'd do it in a personal setup where I had more time" (I'd use Docker) and "what I'd generally do" (I'd use someone else's PaaS)
orf_
you're confusing things doismellburning
littlebit: you don't move virtualenvs. You just do `pip install -r requirements.txt` inside a new one
and then thats it. There is no need to move or copy them
and you don't want to anyway, if you copy one from Windows or Mac to Linux then the dependencies might be different and not work
littlebit
orf_: ok, what do you mean with "inside a new one"?
workbean joined the channel
orf_: what I just did is: pip install -r ./modern_business/requirements.txt
b0nn
littlebit: how much do you know about virtual environments?
doismellburning
yeah, fair, sorry
littlebit
b0nn: virtualenvs are sandboxes where you install your libraries, being totally independent from the libraries that are installed on the system.
I needed to change from: from django.views import View to: from django.views.generic import View.
I'm not sure why the example I am following is wrong :\
Nizumzen joined the channel
Bajax joined the channel
username_ joined the channel
username_ has quit
rocketsnail has left the channel
rocketsnail joined the channel
rocketsnail
Hello, I have a Report model defined (https://dpaste.de/aegN). My report can be targeted at a ForumPost object or a BlogPost object. How would I do this following DRY principle?
b0nn
rocketsnail: why not look at it from the other direction
that is, have a reference from the Post to the report
rocketsnail
b0nn only because if a user makes a post it might not need to be reported to moderators
so there might not be any reports for a BlogPost or ForumPost
b0nn
oh I see
So you want a report, and that report is linked to a Post
mojtaba has quit
There's no reason you can't have two keys one to a BlogPost and one to a ForumPost, then make sure only one can be populated,
ironfroggy joined the channel
But one _must be populated
and check in the save that that rule is satisfied
Another option might be to have both Blog and Forum posts be sub classes of.. myPost
and have a link to myPost in your report
danifus has quit
but you'd have to make sure the myPost always linked to a post