I'm trying to build a niche social network like Instagram as a Python/Django application.
So the things I need, regarding architecture, are (I guess):
REST API (e.g. api.mystagram.com).
Public website (www.mystagram.com or mystagram.com).
URL shortener (e.g. mystagr.am).
Android app
iPhone app
Windows Phone app
...
Before this I only built simple to some less-simple websites, but never extremely complex with own custom APIs or so. I have never build my own REST API before (I have used other REST APIs though) or even built an Android/iPhone app and distributed it in the Play Store/App Store (I have made some typical hello world examples though).
So, the most important thing to me seems to create a kick-ass REST API first and proceed from there. I am blocked however by a few questions.
How should I organize the projects for the public website and REST API? Should these be separate Django projects or should I create only one Django project and add both the public website and REST API as an internal Django module?
Should the public website also make use of the REST API? Or is it better to just use the plain Django models for this?
Thanks in advance for any help! If somebody knows some great presentations or so on this topic (architecture), always welcome!
Kind regards,
Kristof
Django REST Framework
https://github.com/tomchristie/django-rest-framework
Very well maintained, great documentation, easy to use.
I think Tastypie will do what you want. And its simple and easy. Check this out - http://django-tastypie.readthedocs.org/en/latest/!
To Answer your first question, It would be good practice to put public web site and REST APIs into one django project. Now days every web application contains public web site as well as rest apis for mobile app. So it would be easier to maintain both website and rest apis if they both in one application. Below is Django REST Framework link.
https://github.com/tomchristie/django-rest-framework
For second question, Yes you can use rest apis in website also. But in general you don't need to do it. In most of the cases django model works for you.
Related
I'm now writing my engineering thesis about REST and REST APIs, mostly focusing on Django REST framework as it was the framework we used in our engineering project. I just finished writing about the guidelines for API to be RESTful stated by Roy Fielding and I wanted to start section with implementations of REST architecture in Django REST Framework, but then I realized I don't really know why this framework is RESTful. I know what main paradigms are for API to be RESTful, but I don't know what specific parts of framwork inplements for example that our service is stateless or layered. Maybe someone can pinpoint what parts of django rest framework corresponds to specified guidelines for service to be RESTful ? If It's wrong site to ask this type of question then I'm sorry, but any help would be greatly appreciated.
Let's go through the points that make API a RESTful one
1. Client-server architecture
The very essence of the fact that you are developing a backend server, which is not part of your application UI is the point of this client-server architecture.
Every app you develop with Django Rest Framework (from now on DRF) is a backend API, which is separated from the client.
2. Statelessness
I cannot pin point the exact code line that shows why DRF is statelessness but its somewhere deep between Django and the WSGI/ASGI interface.
Somewhere in there you have some kind of code like this:
while True:
request = io.listen_for_request()
response = handle_request(request)
return response
This "very pseudo" code is stateless! why? because we don't save or rely on any information between requests
3. Cacheability
This one is fairly simple, Django and DRF support caching link
4. Layered system
This concept is kinda hard to correlate directly to DRF or Django. This is mainly done through the HTTP protocol.
5. Code on demand (optional)
Servers can temporarily extend or customize the functionality of a client by transferring executable code: for example, compiled components such as Java applets, or client-side scripts such as JavaScript.
Basically Django Templates. It allows you to send forms and pages as part of your endpoints.
6. Uniform Interface
Last but not least, the famous uniform interface. DRF helps you build your REST API interface by creating endpoints with the help of Generic views. Those generic views help you create a full CRUD (create, read...) endpoint on a Django model with little to no effort. The created endpoint follows the Rest API interface of url structure for a resource.
I want to create a desktop application written in python and using polymer as the front-end. To access the user interface, we use web browser such as chrome, mozilla, and safari. I did a lot of research in how to do this. The only reference I have is home Assistant, but I'm still don't quite understand about the architecture and the approach. Anyone have another solution or approach in how to do this?
python ships with a basic http server, however according to the docs it's not made for production use. But it's probably good enough for your use case (single user). On top of this you can implement a basic REST-Api and serve your frontend (.js/.html) as static content.
Or use a framework like django https://www.djangoproject.com/
I have backend of web app by django, include registrations/user profile,
the ability to add photo(video) file and view them, and list of places with the ability to book them.
Now I need to add the ability to work with a mobile application written in ReactJS.
The problem is that before that I did not work with mobile applications and I do not know what strategy to choose, but the frontend developer did not work with the backend. Can I pass django variables directly to the ReactJS code? Do I need additional technologies or frameworks? I would be grateful if someone shared their experience and described how to do it (preferably the least simple way)
You have to build a REST API. In your case, the best solution would be creating the API with Django REST Framework.
It is a very powerful framework for building APIs. They provide some nice tutorials to get started with it.
After that, you can create the frontend app with React by using API calls.
I've developed a couple of apps in Django and need to develop a moderately complex new app now. I've heard about AngularJS and I'm considering to use it in my new web app.
From research I have done so far, it seems like the main benefit of using Angular compared to plain Django is a better user experience. Are there any other major benefits that I need to take into account?
I would imagine the disadvantage of this is increased development time. Assuming I get past the Angular learning curve, how much longer will it take to develop the app in Django + Angular than purely in Django? (For instance 150% longer)
One last question is about using Django as the API framework. Effectively, I'm not using all of Django's features, but only a subset. Given this, is Django a good framework to create the API in? What are other alternatives should I consider?
Currently using a similar architecture for an app.
Backend is in Django and I'm using Django Rest Framework (DRF) to create REST resources. It's a highly powerful and customisable REST framework to create API resources.
From my understanding and experience, DRF works very well with any abstracted front end. So you can use the same APIs for any client be it browser or mobile apps. You can also serve the front end content in the same context as the Django backend or even separated. DRF has authentication methods for both types.
Resources: http://www.django-rest-framework.org/
As for learning curve, AngularJS isn't that difficult if you have basic understanding of the concepts of MV* as well as JavaScript. I won't be able to give you an exact time estimate but for me both methods would have lasted as long as each other.
I need to build a web site with the following features:
1) user forum where we expect light daily traffic
2) database backend for users to create profiles, where they can log in
and upload media (pictures)
3) users can uses their profile to buy content from an online inventory
4) create web pages, shopping carts etc for online inventory
5) secure online credit card processing
I am very familiar with python but not with python web frameworks. I do know
some SQL. How do I get started developing something like this? Is Django
a good alternative?
Not programming related per se: Where do you recommend I get web hosting with a domain
name for an application like this?
Django was made for this kind of thing. Check it out.
As far as hosting, djangofriendly.com is a great resource. I have used WebFaction before and I am absolutely in love with how easy it is to get Django going with them and with their excellent customer service. Very top notch for reasonable prices if you are going the shared hosting route.
If you are looking to speed up some of the tasks described, you should check out Pinax and Django Pluggables. Thanks to the way Django applications are setup it is trivially easy to plug an application into your project.
You can try Pylons lightweight web framework.
Your requirements make pinax sound like a library you might want to look into if you go the django route.
Google App Engine will provide hosting for free as well as Django and a db..