100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
DJANGO EXAM; QUESTIONS AND ANSWERS $13.49   Add to cart

Exam (elaborations)

DJANGO EXAM; QUESTIONS AND ANSWERS

 6 views  0 purchase
  • Course
  • DJANGO
  • Institution
  • DJANGO

DJANGO EXAM; QUESTIONS AND ANSWERS...

Preview 3 out of 17  pages

  • July 26, 2024
  • 17
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
  • DJANGO
  • DJANGO
avatar-seller
luzlinkuz
DJANGO EXAM; QUESTIONS AND ANSWERS How to check version - ANSWER python -m django --version Setting Up a Virtual Environment - ANSWER python virtualenv your_project_name activate virtual environment - ANSWER ./scripts/activate.bat ./scripts/activate How to create a project - ANSWER django-admin start project my project site How to start development server - ANSWER python manage.py run server How to change server IP/Port - ANSWER python manage.py run server 0:8080 settings=mysite.setting How to create a "blog" application - ANSWER python manage.py start app blog In which .py file do you define the data model? - ANSWER open the models.py and define the data schema How to import the Model? - ANSWER django.db.models.Model Write database model for "Post" with "title" field - ANSWER class Post(models. Model): title = models.CharField(max_length=250) In settings.py which setting tells Django that applications are active f or this site - ANSWER INSTALLED_APPS How to add "blog" application to INSTALLED_APPS - ANS WER INSTALLED_APPS = [ 'blog.apps.BlogConfig', ] The BlogConfig class is your application configuration. How to create an initial migration for your database "blog" site - ANSWER python manage.py make migrations blog Which command takes the migration name and returns their SQL without execut ing - ANSWER python manage.py sqlmigrate blog 0001 After "python manage.py make migrations" which command should you run for changes to apply? - ANSWER python manage.py migrate To invoke the Python shell - ANSWER python manage.py shell Creating a Superuser syntax - ANSWER python manage.py createsuperuser In Metadata, Sort result by "publish" field in descending order - ANSW ER class Meta: ordering = '-publish' Add database "Students" model to administration site. - ANSWER fro m .models import Students admin.site.register(Students) Replace admin.site.register() with decorator function? - ANSWER @admin.register() write class with decorator and customize the administration side. Database is "Post" and field to display is 'title' and 'status' - ANSWER @admin.register(Post) class PostAdmin(admin.ModelAdmin): list_display = ('title', 'status') Which attribute allows you to set the field for your model to display on the administration object list page. - ANSWER list_display = () Which attribute display filter options on the administration page for fi lter the result. - ANSWER list_filter =() Attribute for Search Field on Administration page. - ANSWER search_fields = () Which attribute prepopulates the 'slug' filed with the input of 'ti tle' on the Administration page. - ANSWER prepopulate_fields = {'slug': ('title',)} Attribute for raw id - ANSWER raw_id_fields = ('author') Attribute for date hierarchy on Administration page - ANSWER date_hierarchy =() admin.ModelAdmin order class - ANSWER ordering =() How to create the record and write it into the database with single operation, u se grno(1), first_name(Munawar) field. - ANSWER Students.objects.create(grno=1, first_name='Munawar') Write QuerySet for "all_student=" to returns all objects from Students list. - ANSWER all_posts = Post.objects.all() How to filter a QuerySet on "Post" database to return record on field 'publish_ year' field for the year '2020' - ANSWER Post.objects.filter(publish__year=2020) How to use order by in QuerySet on "Post" object field should be 'title' - ANSWER Post.objects.order_by('title') how to delete record from the 'Post' database if record id is '1' - ANSWER any_variable = Post.objects.get(id=1) any_variable .delete() define default manager name? - ANSWER objects = models.Manager() Create model manager class "Students" where their 'status' is 'active' - ANSWER class StudentsManager(models.Manager):

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller luzlinkuz. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67866 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.49
  • (0)
  Add to cart