I am going to use both Saleor and Wagtail in the same project.
Saleor will take care of all shop related functionalities and Wagtail will be the CMS for everything else (it is a lot of content).
What I need as advice is to how can I run both applications from the same server?
E.g. wagtail will serve urls like www.example.com/about-us etc. and Saleor will serve www.example.com/shop
I understand that this will happen in urls.py but, what confuses me is when I run ./manage.py runserver at the Saleor end how is this going to start the wagtail server.
So basically how can I start both apps with one single management command and share the resource? (it is still a localhost project)
I will be thankful if somebody can show me some web resources about the topic if my approach is correct or can point in a better direction.
Related
This is a bit embarassing, but I'm a Django noob and I couldn't find a simple solution to this:
I have written a Django app in a local VM that I now want to deploy to a "production" server. App works like a charm locally.
Now my IT colleague has set up the server with Django and that also works fine. I can open it via the Web and I get the usual "Congratulations on your first Django-powered page". I can also log into the admin interface. The project has been created.
This is a very low-key mini project and I'm not too familiar with git, so we've decided to just push files via FTP. (And I want to stick with that if at all possible.) So I uploaded the app folder into the project folder and also adjusted the project's settings.py and urls.py.
However, nothing seems to be happening on the server's end. The welcome page is the same, the app does not show up in the admin interface and the URLs won't be resolved as hoped.
Any suggestions what I should have done / done differently?
You need to restart apache or whatever is running your django project. Your changes to py files are cached when you first load your server config (settings).
Any suggestions what I should have done / done differently?
You should be using git/jenkins/deployment techniques, I know you said you've decided not to use it but you're going to be missing out on important things like being able to keep track of changes and unit testing
I transferred my Django project from a Ubuntu server that is currently serving the website. I'm trying to run this project on a localhost MacOSX environment for testing purposes. The command I'm familiar with for Django projects is:
python manage.py runserver
After which when I input 127.0.0.1:8000 into a browser, the project displays.
But my Ubuntu server is not currently running a script in that form, rather in the form of
python manage.py celeryd
My knowledge of how celery interfaces with Django is somewhat limited so this question may be very basic, but I can't find the URL to display the project.
On my Mac server, when I run:
python manage.py celeryd
the script does not error out on me--instead, it appears to be working by displaying this:
However, I don't know how to access the project. When I put 127.0.0.1 in the browser (and many other possible variations using different ports), I get Page Not Found.
Any help is greatly appreciated.
First you need to define 'core' template tag in one of your apps templatetags library say custom_tags.py. Make sure that this app is added to INSTALLED_APPS in settings. Then in your html template add
{% load custom_tags %}
It will fix the error you are getting. For more details please read docs.
You seem confused about what celery is. It is not a webserver, and it won't serve pages for you. It is an offline task manager, useful for performing complex or long running jobs that aren't appropriate to do in the context of a web request.
You'll need an actual web server alongside celery to serve your site itself.
I'm currently learning Django and getting a decent grasp of it. I know you can start the server with python manage.py runserver. But then there is also heroku ps:scale web=1 followed by heroku open to open the web page at the subdomain you chose on the host herokuapp.com. What is the point of using heroku vs just runserver? When it comes time to deploy to production is that what heroku is used for as I read it was for deployment? What is exactly is heroku used for and what are the reasons? When creating a professional django web site/application is heroku required or just very useful? If so why? I don't really understand the reason for using heroku. And I'm curious what the best practices are for django and whether they include using or not using heroku.
Aside from the heroku question, what are the best practices for django as far as setting a domain name and such (other than the herokuapp.com subdomain name) and also as far as what other components/software solutions are worth using with django?
One of the things I'm working on is an FTP portal on the website that people can login to and upload files. Does django have plugins/python modules for such a thing or must it be done custom? Which brings me to my final question, What kind of addons/modules does django offer to avoid reinventing the wheel when implementing a django website/app's certain features?
The tutorial I'm following: http://tutorial.djangogirls.org/en/django_orm/README.html
has helped me get a grasp on django, but I'm curious about the more advanced parts of it. Such as custom modules, custom styling, custom scripts (whether they are js or strictly python).
If someone could point me in the right direction or offer any suggestions it would be much appreciated. The tutorial has me using the modules: dj-database-url, whitenoise, gunicorn, python-dateutil, psycopg2 , requests. I know what some of them do, but what is the purpose of psycopg2, whitenoise, dateutil, and dj-database,url? Are there any other modules worth using?
Sorry for the wall of questions, but I'm trying to understand django as best I can so that I can do a correct assessment when putting together a django project.
Thanks in advance.
EDIT, final questions:
1) Also when i used heroku they gave me a subdomain at herokuapps.com Can I set my own URL and still use heroku?
2) And last but not least, heroku makes you register and gives you a subdomain on herokuapp.com Is there a way to use heroku with your own domain rather than the one they give you? Is there a specific way to do it?
EDIT 2:
When I do runserver it works fine, but when i run it with heroku ps:scale web=1 and then heroku open it opens but only shows the title at the top of the page, and no content. Not sure exactly why that is. Can someone explain the difference between runserver and heroku ps:scale web=1 followed by heroku open??
python manage.py runserver is only for development. Never use it in production.
Heroku makes it super easy to deploy your Django code. You only need some configs and git push heroku master. But it's not the only way to deploy your code. You can also set up a server with a webserver like Nginx, Gunicorn as WSGI server, and a database of your choice. To set things up, you need to know something about Linux and the command line.
So if you don't know how to set up a server, Heroku can be very useful.
Heroku supports custom domains, and it's easy to set up.
As Mikeec3 mentioned, "Two Scoops of Django" is a very good read.
If you are looking for django packages, www.djangopackages.com is a good place to start.
psycopg2 is for postgresql usage with your app. White noise allows you to serve your staticfiles without nginx if using gunicorn. Requests is an easy to use urllib2 library with pythonic calls to work with apis from other websites.
If you want to do some testing with say facebook logins Heroku is a great place to go to, especially if you need a url outside of localhost.
My suggestion is you read Two scoops of Django http://twoscoopspress.org/products/two-scoops-of-django-1-6
It goes over alot of best practices and serves as a great tutorial after polls. I suggest also incorporating django-bower into your project. Ill list a few great things to add.
Django Bower: https://github.com/nvbn/django-bower - Helps organize static files
Crispy Forms : https://github.com/maraujop/django-crispy-forms - Great form rendering, great with bootstrap
Django Rest Framework: https://github.com/tomchristie/django-rest-framework - REST APIs
These are just to start, there's alot to learn.
I have a Django project with 1 app that is working locally and I am trying to make it work on the server but I imagine I am still missing something...
The steps I have followed are:
1) create a virtualnev
2) Install django and the libraries I need
3) copy my local project to the server, keeping the same directory structure
4) create the file passenger_wsgi.py (python passenger_wsgi.py did not return any error)
After this do I need to do anything like python manage.py runserver? Or with this I should be already able to see the site through mydomain/my project/ my app (when I do ot just get an error 404)?
I have read the django book and followed the tutorial, but this part is not well described anywhere...
Thanks in advance for any help!
Deployment is explained in the documentation.
You need to actually serve your application with some kind of HTTP server and something to run your python code. Some of the possible combinations are:
nginx with uWSGI
Any web server as reverse proxy with gunicorn
Apache with mod_wsgi
Your hosting service may or may not give you the choice or even the possibilty to do this.
There is a list of Django friendly hosters in the Django wiki.
Well firstly you might want to go through the previously asked questions.
When you are deploying using passenger you do not need to run manage.py runserver , etc. The passenger_wsgi file should take care of it.
You might want to check this link out, in the first answer also contains link to Dreamhost which details quite extensively on how to achieve the same.
Visit Deploying Django app using passenger
From my personal experience I found Nginx and uwsgi setup to be much more easier to handle and work and debug in the logs, but this is subjective to your needs and platform you may have.
I am trying to understand Pinax and plan to use it in my next project.
I have started with a pinax basic project, and now I have something to go with runserver.
Now, I understand that I can customize the initial setup that I got from pinax and customize the profiles, themes, etc as per my requirements.
But is that all that pinax provides ?
I am very confused here, like I want to use the pinax phileo app in my project, so how does pinax helps me do that ?
My Effort :
I searched and found that I have to install it with pip install phileo
Then, add it to INSTALLED_APPS and use it as required.
But what did pinax do in this ?
Pinax has phileo featured on its website, but why ? Since I could have used it just like any other app on my non-pinax django project.
So, my question in a nutshell is :
What does pinax provide after a base project and default templates that come with pinax ?
Right, now it feels like pinax just provides a base project with some apps already working with some default templates. [ That's it ? ]
Then, what about other apps featured on pinax's website that do not come with base projects ?
Please, help clear up the confusion !
Update
My question is somewhat - What is the significance of pinax-ecosystem when we already have them listed somewhere like djangopackages.com ?
You seem to be assuming that unless all of Pinax is useful, Pinax as a project isn't useful. It was never the intention that Pinax be a single thing, all of which you use on a given project.
If all you find helpful is the project layout, that's fine. Pinax suggests a standard project layout (which you can use alone with pinax-project-zero).
If all you find helpful is the pinax-project-account (django-user-accounts and a few other things, already integrated with templates following bootstrap class naming) as a starting point for you site, that's great. Pinax is fundamentally about getting you started sooner and pinax-project-account is a suitable starting point for most sites with user accounts.
Once you have a project, you are free to add any Django apps you want. There's nothing that requires you to use Pinax apps. "So", you ask, "why does Pinax even bother having apps?".
Well, because apps aren't isolated. Reusability isn't just at the level of app but also groups of apps. Take, for example, a waiting list app, an invitations app, a referral code app, a points app, a badges app. Sure these can be developed and used independently.
But if they are developed with the same mind set you can make sure the waiting list app and invitations app and referral code app work well with the user account app (and don't duplicate anything). You can make sure the referral code app plays nicely with the points app and the points app plays nicely with the badges app. You can make sure your forum app doesn't try to do something your moderation app already provides. Or that each app isn't trying to solve avatars its own way.
So Pinax isn't trying to be a "directory" of apps. It's a family of apps, themes and starter projects written with each other in mind.
Pinax is just django with a blend of other django plugins. You have to enable them and set them up individually. To use each individual app within pinax, you have to read that specific app's documentation and set it up appropriately (list of apps and repos which likely contain documentation here: http://pinaxproject.com/ecosystem/)
Some people like pinax but I find that its more of a hassel than a solution. In the end pinax doesn't work out of the box. You have to customize everything, but at the same time you position yourself into using a bundle you dont need. I suggest instead starting a project and installing the packages you need individually, and even finding more here: http://djangopackages.com/. Especially, if its a big project because then if you bundle/setup everything on your own you will know the ins and outs of it all.
The problem that pinax solves is that it avoids you hunting around for the best app that does something, as pinax bundles it together for you.
So if you want to get something up and running quickly, pinax makes that easy. For example, it is - by far - the quickest way to get a django project going with twitter bootstrap + other common plugins.
The benefit is simply this - when starting a new site, Pinax gives you a bit of a head start compared to an empty Django project.
Consider this: You're starting a new site that will need user account management (including email confirmation, user profiles, password reset, etc.), and notifications.
With Pinax, you can get this functionality in a few commands:
$ mkvirtualenv mysite
$ pip install pinax
$ pinax-admin setup_project -b basic mysite
$ python manage.py syncdb
$ python manage.py runserver
You now have:
Pretty much all you need for user management
All that stuff you always add to settings.py like PROJECT_ROOT
'About' Urls - (about / terms / privacy / DMCA / What's Next)
Django Debug Toolbar
i18n already set up.
Static files with compression when in production
A default theme (using Bootstrap)
A whole bunch of other stuff
From there, you can add apps and build / customize templates just as you would for any Django project. The difference is that you've just saved yourself a few hours of installing and configuring apps.
Regarding themes, they're trying to promote the idea of a theme as an app containing nothing more than static files. Take a look at the repo for the default theme to see how this works (it's basically just an app with static files and templates).
If you're a hobbyist building a single site which is your own project, don't bother with Pinax.
If you're a developer who is continually building new sites from scratch, Pinax may be your friend.
Pinax 0.7 was bundled with some apps and starter projects like social_projects which could be used for building a site more quickly, but I things changed in pinax 0.9.
I think pinax has reinvented its structure for some reasons (eg,In pinax 0.7 some people were complaining that it was messy to customize starter projects or to use only subset of certain starter projects so could pinax 0.9 provides more flexibility).
Some of the apps included in a pinax website are somehow coupled with each other so that it is easier to deploy them together,sometimes all you have to do is just installing them and the apps will communicate with each other.