I am using Django-rest-swagger Package for documenting my API but I want to show only some URLs to document I have several apps in my project - some answers are USE Exclude but latest version it is not working -
I am using djangorestframework==3.5.1 and Django-rest-swagger==2.1.0 and Django-rest-framework for API.
I even tried render-schema and get_swagger_view(title='API Documentation', patterns=urlpatterns1).
but it's not working.
help me to find a solution.
Set exclude_from_schema = True in your View/Viewset or add it to the decorator (if you use them). This will exclude the view from swagger docs.
django-rest-swagger has changed a lot, in earlier versions there were settings for exclutish urls by name or namespace. Currently you need to exclude the View from the schema drf is generating, it's documented here http://www.django-rest-framework.org/api-guide/views/#api_view.
Related
I'm writing API in DRF and had need to add nested routes.
Since drf-extensions are specified in official documentation I tend to use this package and it seemed to be working, but the documentation generated by Django Rest Framework doesn't include nested Viewset(route).
The documentation is generated using include_docs_urls from rest_framework.documentation
I would really like to have my nested endpoint described in generated documentation.
Is it possible?
djangorestframework==3.9.0
drf-extensions==0.5.0
Python2.7
Let me preface this by saying I'm VERY new to Django and am also having a hard time with some of the documentation. I know that this question has surely been asked and answered a thousand times, but I can't seem to phrase my query properly.
I'm making a project that uses django-registration-redux, and I wanted to customize the template and the forms to accept additional user information. First, I noticed that my changes to the template files weren't having any effect , then I realized that it was using the template files from my Python install location instead of my actual project. I fixed this by setting the templates folder setting, but I also need to modify the registration-redux forms, and can't figure out how to override the default forms with local forms in my application.
You need not change the template settings for your existing project, but you have to make sure you have included 'registration' in the list of your INSTALLED_APPS. In the documentation its mentioned that
You can extend and customize the included templates as needed
Though its not very clear here, django registration redux is built on top of the in built django registration module. What you need to do is build your own custom registration form which is already explained in this answer.
In your case the template that you need to modify/extend is registration/registration_form.html.
Other useful resources that can help you:
http://www.tangowithdjango.com/book17/chapters/login_redux.html
https://www.youtube.com/watch?v=qkFWkOw-ByU
I just started learning django. I was a rails developer before that. I was wondering if there is anything similar to resource in rails in django? Or do I have to make different urls and corresponding views for those urls? Thanks in advance!
django-smarter provides a similar pattern.
You are asking about RESTful APIs to the django models if I understand correctly. Django does not do it for you natively (as jpic said) but there are some packages you can install to do that:
django-smarter (as jpic said)
tastypie
django rest framework
See https://www.djangopackages.com/grids/g/rest/ for a list of APIs that can be added in to django. I see django-smarter isn't on that list. Maybe someone should add it.
Where can I find an open source pluggable blog app for Django?
It should support:
RSS/Atom
Comments
the built-in Django authentication system
Markdown (optional)
Akismet or other spam protection (optional)
Plus, I'd like to have to ability to embed the blog front page into another page, maybe in another app.
I'd like it to be as simple as possible - no unneccsary features, and 2-3 apps max.
Thanks.
Check out django packages' grid for blog applications.
I would find find one that looks close to what you are looking for and edit it to fit your needs. That's the great thing about django, the ability to customize.
I've used Django Basic Blog as the base, and customized it to suit my needs, it is part of Django Basic Apps
django-zinnia-blog has RSS feeds, traceback/pingback and comments via django-comments. You can use signals to have your comments checked via akismet. To support markdown you can use a template filter.
Eleven django blog engines you should know
I am currently making the switch from Django to Turbogears 2.1 and am running into some problems that I could not find the answers to in the Turbogears docs. If tg developers read this, let me tell you that one of the best features Django has over TG is its documentation!
1) How do I access the request (user?) object within a mako template in order to check if the user is authenticated? For instance
if (request.user.is_authenticated)
'logout link'
else
'login link'
2) A related quesiton (as the user object is exposed in Django to templates via context processors). Is there a way to add data to the request context? For instance, in my Django app I add a cached dictionary of notifications for the user if the user is logged in via a definition in a context_processors.py file and then include that def in the TEMPLATE_CONTEXT_PROCESSORS tuple in the settings file.
3) This may warrant its own question, but I thought I'd throw it in in case anyone has a quick suggestion. I'm using Netbeans as my IDE and it offers no code coloring or tools for mako files. However, trying to rename the templates with a .html extension throws a mako error. Is there any way around this or am I stuck with plain text and the .mak extension?
Thanks very much
I've moved from Turbogears 1.0 to Django. Might not be able to answer all of these, but I believe in general TG2 tries to keep things fairly similar to TG1. Hopefully pointing out how it works in TG 1, might help...
1) In Turbogears 1.0 you would use tg.identity.anonymous to see if the user was logged in or not. A quick look at the docs, shows it's most likely still the same.
2) Turbogears called this sort of thing stdvars - see here for details for TG 1 http://docs.turbogears.org/1.0/stdvars
3) Sorry don't know, but I presume you can probably just tell Netbeans to consider .mak as another extension for html files (so it uses html syntax highlighting).